Bug 1497294 - P1. Remove duplicated method. r=nical
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 09 Oct 2018 13:07:58 +0000
changeset 499194 a6481e1de633ece58bf7ad14bdd9b1159c2d2eca
parent 499193 e0a6c4e8624c4e565341b5d77181a7bfa4a42609
child 499195 da3c96e21a15be08c937560c203b7abd2125ea1e
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1497294
milestone64.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 1497294 - P1. Remove duplicated method. r=nical Additionally, add info for the following type: R8G8B8 B8G8R8 R8G8 HSV Lab DEPTH Differential Revision: https://phabricator.services.mozilla.com/D8065
dom/canvas/CanvasRenderingContext2D.cpp
gfx/2d/Tools.h
gfx/2d/Types.h
gfx/webrender_bindings/WebRenderTypes.h
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -248,17 +248,17 @@ bool
 CanvasRenderingContext2D::PatternIsOpaque(CanvasRenderingContext2D::Style aStyle) const
 {
   const ContextState& state = CurrentState();
   if (state.globalAlpha < 1.0) {
     return false;
   }
 
   if (state.patternStyles[aStyle] && state.patternStyles[aStyle]->mSurface) {
-    return IsOpaqueFormat(state.patternStyles[aStyle]->mSurface->GetFormat());
+    return IsOpaque(state.patternStyles[aStyle]->mSurface->GetFormat());
   }
 
   // TODO: for gradient patterns we could check that all stops are opaque
   // colors.
 
   if (!state.gradientStyles[aStyle]) {
     // it's a color pattern.
     return Color::FromABGR(state.colorStyles[aStyle]).a >= 1.0;
--- a/gfx/2d/Tools.h
+++ b/gfx/2d/Tools.h
@@ -189,32 +189,16 @@ RescalingFactorForColorDepth(ColorDepth 
     case ColorDepth::COLOR_16:
       break;
     case ColorDepth::UNKNOWN:
       MOZ_ASSERT_UNREACHABLE("invalid color depth value");
   }
   return factor;
 }
 
-static inline bool
-IsOpaqueFormat(SurfaceFormat aFormat) {
-  switch (aFormat) {
-    case SurfaceFormat::B8G8R8X8:
-    case SurfaceFormat::R8G8B8X8:
-    case SurfaceFormat::X8R8G8B8:
-    case SurfaceFormat::YUV:
-    case SurfaceFormat::NV12:
-    case SurfaceFormat::YUV422:
-    case SurfaceFormat::R5G6B5_UINT16:
-      return true;
-    default:
-      return false;
-  }
-}
-
 template<typename T, int alignment = 16>
 struct AlignedArray
 {
   typedef T value_type;
 
   AlignedArray()
     : mPtr(nullptr)
     , mStorage(nullptr)
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -87,17 +87,24 @@ enum class SurfaceFormat : int8_t {
 #endif
 };
 
 inline bool IsOpaque(SurfaceFormat aFormat)
 {
   switch (aFormat) {
   case SurfaceFormat::B8G8R8X8:
   case SurfaceFormat::R8G8B8X8:
+  case SurfaceFormat::X8R8G8B8:
   case SurfaceFormat::R5G6B5_UINT16:
+  case SurfaceFormat::R8G8B8:
+  case SurfaceFormat::B8G8R8:
+  case SurfaceFormat::R8G8:
+  case SurfaceFormat::HSV:
+  case SurfaceFormat::Lab:
+  case SurfaceFormat::Depth:
   case SurfaceFormat::YUV:
   case SurfaceFormat::NV12:
   case SurfaceFormat::YUV422:
     return true;
   default:
     return false;
   }
 }
--- a/gfx/webrender_bindings/WebRenderTypes.h
+++ b/gfx/webrender_bindings/WebRenderTypes.h
@@ -110,28 +110,28 @@ struct ImageDescriptor: public wr::WrIma
   }
 
   ImageDescriptor(const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat)
   {
     format = wr::SurfaceFormatToImageFormat(aFormat).value();
     width = aSize.width;
     height = aSize.height;
     stride = 0;
-    opacity = gfx::IsOpaqueFormat(aFormat) ? OpacityType::Opaque
-                                           : OpacityType::HasAlphaChannel;
+    opacity = gfx::IsOpaque(aFormat) ? OpacityType::Opaque
+                                     : OpacityType::HasAlphaChannel;
   }
 
   ImageDescriptor(const gfx::IntSize& aSize, uint32_t aByteStride, gfx::SurfaceFormat aFormat)
   {
     format = wr::SurfaceFormatToImageFormat(aFormat).value();
     width = aSize.width;
     height = aSize.height;
     stride = aByteStride;
-    opacity = gfx::IsOpaqueFormat(aFormat) ? OpacityType::Opaque
-                                           : OpacityType::HasAlphaChannel;
+    opacity = gfx::IsOpaque(aFormat) ? OpacityType::Opaque
+                                     : OpacityType::HasAlphaChannel;
   }
 
   ImageDescriptor(const gfx::IntSize& aSize,
                   uint32_t aByteStride,
                   gfx::SurfaceFormat aFormat,
                   OpacityType aOpacity)
   {
     format = wr::SurfaceFormatToImageFormat(aFormat).value();