Bug 1170390 - Use Optimal2DFormatForContent over OptimalFormatForContent to avoid enum conversions. r=jrmuizel
authorLee Salzman <lsalzman@mozilla.com>
Mon, 06 Jul 2015 22:27:19 -0400
changeset 252572 d11f383428198a325fbf41bd7ca92c6a9f504200
parent 252571 dcb8ffba924659d92807683adc0c064a0c55bc70
child 252573 8b5add472b89d0d60e38113e7aa48fc7c0a4b563
push id62183
push userryanvm@gmail.com
push dateMon, 13 Jul 2015 14:36:09 +0000
treeherdermozilla-inbound@bae616b77f82 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1170390
milestone42.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 1170390 - Use Optimal2DFormatForContent over OptimalFormatForContent to avoid enum conversions. r=jrmuizel
gfx/gl/SharedSurfaceGralloc.cpp
gfx/gl/TextureImageEGL.cpp
gfx/layers/client/CanvasClient.cpp
gfx/layers/client/ContentClient.cpp
gfx/layers/client/TiledContentClient.cpp
--- a/gfx/gl/SharedSurfaceGralloc.cpp
+++ b/gfx/gl/SharedSurfaceGralloc.cpp
@@ -14,17 +14,16 @@
 #include "mozilla/layers/GrallocTextureClient.h"
 #include "mozilla/layers/ShadowLayers.h"
 
 #include "ui/GraphicBuffer.h"
 #include "../layers/ipc/ShadowLayers.h"
 #include "ScopedGLHelpers.h"
 
 #include "gfxPlatform.h"
-#include "gfx2DGlue.h"
 #include "gfxPrefs.h"
 
 #define DEBUG_GRALLOC
 #ifdef DEBUG_GRALLOC
 #define DEBUG_PRINT(...) do { printf_stderr(__VA_ARGS__); } while (0)
 #else
 #define DEBUG_PRINT(...) do { } while (0)
 #endif
@@ -59,22 +58,19 @@ SharedSurface_Gralloc::Create(GLContext*
     DEBUG_PRINT("SharedSurface_Gralloc::Create -------\n");
 
     if (!HasExtensions(egl, prodGL))
         return Move(ret);
 
     gfxContentType type = hasAlpha ? gfxContentType::COLOR_ALPHA
                                    : gfxContentType::COLOR;
 
-    auto platform = gfxPlatform::GetPlatform();
-    gfxImageFormat format = platform->OptimalFormatForContent(type);
-
     typedef GrallocTextureClientOGL ptrT;
     RefPtr<ptrT> grallocTC = new ptrT(allocator,
-                                      gfx::ImageFormatToSurfaceFormat(format),
+                                      gfxPlatform::GetPlatform()->Optimal2DFormatForContent(type),
                                       gfx::BackendType::NONE, // we don't need to use it with a DrawTarget
                                       flags);
 
     if (!grallocTC->AllocateForGLRendering(size)) {
         return Move(ret);
     }
 
     sp<GraphicBuffer> buffer = grallocTC->GetGraphicBuffer();
--- a/gfx/gl/TextureImageEGL.cpp
+++ b/gfx/gl/TextureImageEGL.cpp
@@ -3,17 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "TextureImageEGL.h"
 #include "GLLibraryEGL.h"
 #include "GLContext.h"
 #include "GLUploadHelpers.h"
 #include "gfxPlatform.h"
-#include "gfx2DGlue.h"
 #include "mozilla/gfx/Types.h"
 
 namespace mozilla {
 namespace gl {
 
 static GLenum
 GLFormatForImage(gfx::SurfaceFormat aFormat)
 {
@@ -61,18 +60,18 @@ TextureImageEGL::TextureImageEGL(GLuint 
     , mEGLImage(nullptr)
     , mTexture(aTexture)
     , mSurface(nullptr)
     , mConfig(nullptr)
     , mTextureState(aTextureState)
     , mBound(false)
 {
     if (mUpdateFormat == gfx::SurfaceFormat::UNKNOWN) {
-        mUpdateFormat = gfx::ImageFormatToSurfaceFormat(
-                gfxPlatform::GetPlatform()->OptimalFormatForContent(GetContentType()));
+        mUpdateFormat =
+                gfxPlatform::GetPlatform()->Optimal2DFormatForContent(GetContentType());
     }
 
     if (mUpdateFormat == gfx::SurfaceFormat::R5G6B5) {
         mTextureFormat = gfx::SurfaceFormat::R8G8B8X8;
     } else if (mUpdateFormat == gfx::SurfaceFormat::B8G8R8X8) {
         mTextureFormat = gfx::SurfaceFormat::B8G8R8X8;
     } else {
         mTextureFormat = gfx::SurfaceFormat::B8G8R8A8;
--- a/gfx/layers/client/CanvasClient.cpp
+++ b/gfx/layers/client/CanvasClient.cpp
@@ -57,24 +57,23 @@ CanvasClient2D::Update(gfx::IntSize aSiz
   }
 
   bool bufferCreated = false;
   if (!mBuffer) {
     bool isOpaque = (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE);
     gfxContentType contentType = isOpaque
                                                 ? gfxContentType::COLOR
                                                 : gfxContentType::COLOR_ALPHA;
-    gfxImageFormat format
-      = gfxPlatform::GetPlatform()->OptimalFormatForContent(contentType);
+    gfx::SurfaceFormat surfaceFormat
+      = gfxPlatform::GetPlatform()->Optimal2DFormatForContent(contentType);
     TextureFlags flags = TextureFlags::DEFAULT;
     if (mTextureFlags & TextureFlags::ORIGIN_BOTTOM_LEFT) {
       flags |= TextureFlags::ORIGIN_BOTTOM_LEFT;
     }
 
-    gfx::SurfaceFormat surfaceFormat = gfx::ImageFormatToSurfaceFormat(format);
     mBuffer = CreateTextureClientForCanvas(surfaceFormat, aSize, flags, aLayer);
     if (!mBuffer) {
       NS_WARNING("Failed to allocate the TextureClient");
       return;
     }
     MOZ_ASSERT(mBuffer->CanExposeDrawTarget());
 
     bufferCreated = true;
--- a/gfx/layers/client/ContentClient.cpp
+++ b/gfx/layers/client/ContentClient.cpp
@@ -30,17 +30,16 @@
 #include "prenv.h"                      // for PR_GetEnv
 #include "nsLayoutUtils.h"
 #ifdef XP_WIN
 #include "gfxWindowsPlatform.h"
 #endif
 #ifdef MOZ_WIDGET_GTK
 #include "gfxPlatformGtk.h"
 #endif
-#include "gfx2DGlue.h"
 #include "ReadbackLayer.h"
 
 #include <vector>
 
 using namespace std;
 
 namespace mozilla {
 
@@ -125,22 +124,20 @@ ContentClientBasic::ContentClientBasic()
 void
 ContentClientBasic::CreateBuffer(ContentType aType,
                                  const IntRect& aRect,
                                  uint32_t aFlags,
                                  RefPtr<gfx::DrawTarget>* aBlackDT,
                                  RefPtr<gfx::DrawTarget>* aWhiteDT)
 {
   MOZ_ASSERT(!(aFlags & BUFFER_COMPONENT_ALPHA));
-  gfxImageFormat format =
-    gfxPlatform::GetPlatform()->OptimalFormatForContent(aType);
 
   *aBlackDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
     IntSize(aRect.width, aRect.height),
-    ImageFormatToSurfaceFormat(format));
+    gfxPlatform::GetPlatform()->Optimal2DFormatForContent(aType));
 }
 
 void
 ContentClientRemoteBuffer::DestroyBuffers()
 {
   if (!mTextureClient) {
     return;
   }
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -22,17 +22,16 @@
 #include "mozilla/layers/LayerMetricsWrapper.h"
 #include "mozilla/layers/ShadowLayers.h"  // for ShadowLayerForwarder
 #include "TextureClientPool.h"
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsISupportsImpl.h"            // for gfxContext::AddRef, etc
 #include "gfxReusableSharedImageSurfaceWrapper.h"
 #include "nsExpirationTracker.h"        // for nsExpirationTracker
 #include "nsMathUtils.h"               // for NS_lroundf
-#include "gfx2DGlue.h"
 #include "LayersLogging.h"
 #include "UnitTransforms.h"             // for TransformTo
 #include "mozilla/UniquePtr.h"
 
 // This is the minimum area that we deem reasonable to copy from the front buffer to the
 // back buffer on tile updates. If the valid region is smaller than this, we just
 // redraw it and save on the copy (and requisite surface-locking involved).
 #define MINIMUM_TILE_COPY_AREA (1.f/16.f)
@@ -897,25 +896,22 @@ ClientTiledLayerBuffer::PaintThebes(cons
   if (!gfxPrefs::TiledDrawTargetEnabled()) {
     nsRefPtr<gfxContext> ctxt;
 
     const IntRect bounds = aPaintRegion.GetBounds();
     {
       PROFILER_LABEL("ClientTiledLayerBuffer", "PaintThebesSingleBufferAlloc",
         js::ProfileEntry::Category::GRAPHICS);
 
-      gfxImageFormat format =
-        gfxPlatform::GetPlatform()->OptimalFormatForContent(
-          GetContentType());
-
       mSinglePaintDrawTarget =
         gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
           gfx::IntSize(ceilf(bounds.width * mResolution),
                        ceilf(bounds.height * mResolution)),
-          gfx::ImageFormatToSurfaceFormat(format));
+          gfxPlatform::GetPlatform()->Optimal2DFormatForContent(
+            GetContentType()));
 
       if (!mSinglePaintDrawTarget) {
         return;
       }
 
       ctxt = new gfxContext(mSinglePaintDrawTarget);
 
       mSinglePaintBufferOffset = nsIntPoint(bounds.x, bounds.y);