Bug 1120780 - Fallback on lock_ycbcr when ColorConvertor fails, r=sotaro
authorMichael Wu <mwu@mozilla.com>
Fri, 20 Mar 2015 10:25:12 +0800
changeset 263481 8368cc78389e10224b4ac4808be727d842333876
parent 263480 069d3d6722ad90dcd95d0a88837c87cafbb377fe
child 263482 ed6fdb6e238e0a9127bfb575056f2408cb8f95f1
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro
bugs1120780
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1120780 - Fallback on lock_ycbcr when ColorConvertor fails, r=sotaro
gfx/layers/GrallocImages.cpp
--- a/gfx/layers/GrallocImages.cpp
+++ b/gfx/layers/GrallocImages.cpp
@@ -269,20 +269,21 @@ ConvertVendorYUVFormatToRGB565(android::
 
   return rv;
 }
 
 static status_t
 ConvertOmxYUVFormatToRGB565(android::sp<GraphicBuffer>& aBuffer,
                             gfx::DataSourceSurface *aSurface,
                             gfx::DataSourceSurface::MappedSurface *aMappedSurface,
-                            const layers::PlanarYCbCrData& aYcbcrData,
-                            int aOmxFormat)
+                            const layers::PlanarYCbCrData& aYcbcrData)
 {
-  if (!aOmxFormat) {
+  uint32_t omxFormat =
+    GrallocImage::GetOmxFormat(aBuffer->getPixelFormat());
+  if (!omxFormat) {
     NS_WARNING("Unknown color format");
     return BAD_VALUE;
   }
 
   status_t rv;
   uint8_t *buffer;
 
   rv = aBuffer->lock(android::GraphicBuffer::USAGE_SW_READ_OFTEN,
@@ -354,17 +355,17 @@ ConvertOmxYUVFormatToRGB565(android::sp<
     gfx::ConvertYCbCrToRGB(ycbcrData,
                            aSurface->GetFormat(),
                            aSurface->GetSize(),
                            aMappedSurface->mData,
                            aMappedSurface->mStride);
     return OK;
   }
 
-  android::ColorConverter colorConverter((OMX_COLOR_FORMATTYPE)aOmxFormat,
+  android::ColorConverter colorConverter((OMX_COLOR_FORMATTYPE)omxFormat,
                                          OMX_COLOR_Format16bitRGB565);
   if (!colorConverter.isValid()) {
     NS_WARNING("Invalid color conversion");
     return BAD_VALUE;
   }
 
   uint32_t pixelStride = aMappedSurface->mStride/gfx::BytesPerPixel(gfx::SurfaceFormat::R5G6B5);
   rv = colorConverter.convert(buffer, width, height,
@@ -397,35 +398,26 @@ GrallocImage::GetAsSourceSurface()
 
   gfx::DataSourceSurface::MappedSurface mappedSurface;
   if (!surface->Map(gfx::DataSourceSurface::WRITE, &mappedSurface)) {
     NS_WARNING("Could not map DataSourceSurface");
     return nullptr;
   }
 
   int32_t rv;
-  uint32_t omxFormat = 0;
-
-  omxFormat = GrallocImage::GetOmxFormat(graphicBuffer->getPixelFormat());
-  if (!omxFormat) {
-    rv = ConvertVendorYUVFormatToRGB565(graphicBuffer, surface, &mappedSurface);
+  rv = ConvertOmxYUVFormatToRGB565(graphicBuffer, surface, &mappedSurface, mData);
+  if (rv == OK) {
     surface->Unmap();
-
-    if (rv != OK) {
-      NS_WARNING("Unknown color format");
-      return nullptr;
-    }
-
     return surface;
   }
 
-  rv = ConvertOmxYUVFormatToRGB565(graphicBuffer, surface, &mappedSurface, mData, omxFormat);
+  rv = ConvertVendorYUVFormatToRGB565(graphicBuffer, surface, &mappedSurface);
   surface->Unmap();
-
   if (rv != OK) {
+    NS_WARNING("Unknown color format");
     return nullptr;
   }
 
   return surface;
 }
 
 android::sp<android::GraphicBuffer>
 GrallocImage::GetGraphicBuffer() const