Bug 576437 - CreateOffscreenSurface should not silently translate ImageFormat24 into ImageFormat16_565. r=joe a=blocking2.0
authorOleg Romashin <romaxa@gmail.com>
Thu, 16 Sep 2010 14:34:53 -0700
changeset 54254 0ca9e1e100fe0e6b0bdc8bb7ea2fe6dfbdc2ae04
parent 54253 a6a168f5fb9074656c120faa68b23326c5fce4fe
child 54255 c204e0000a90cc3ce2d326777f6153bf30ca88fc
push idunknown
push userunknown
push dateunknown
reviewersjoe, blocking2
bugs576437
milestone2.0b7pre
Bug 576437 - CreateOffscreenSurface should not silently translate ImageFormat24 into ImageFormat16_565. r=joe a=blocking2.0
gfx/layers/Layers.cpp
gfx/layers/d3d9/ThebesLayerD3D9.cpp
gfx/tests/gfxFontSelectionTest.cpp
gfx/tests/gfxTextRunPerfTest.cpp
gfx/tests/gfxWordCacheTest.cpp
layout/base/nsPresShell.cpp
widget/src/xpwidgets/PuppetWidget.cpp
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -172,17 +172,18 @@ namespace mozilla {
 namespace layers {
 
 //--------------------------------------------------
 // LayerManager
 already_AddRefed<gfxASurface>
 LayerManager::CreateOptimalSurface(const gfxIntSize &aSize,
                                    gfxASurface::gfxImageFormat aFormat)
 {
-  return gfxPlatform::GetPlatform()->CreateOffscreenSurface(aSize, aFormat);
+  return gfxPlatform::GetPlatform()->
+    CreateOffscreenSurface(aSize, gfxASurface::ContentFromFormat(aFormat));
 }
 
 //--------------------------------------------------
 // Layer
 
 PRBool
 Layer::CanUseOpaqueSurface()
 {
--- a/gfx/layers/d3d9/ThebesLayerD3D9.cpp
+++ b/gfx/layers/d3d9/ThebesLayerD3D9.cpp
@@ -385,17 +385,17 @@ ThebesLayerD3D9::DrawRegion(const nsIntR
   } else {
     // XXX - We may consider retaining a SYSTEMMEM texture texture the size
     // of our DEFAULT texture and then use UpdateTexture and add dirty rects
     // to update in a single call.
     destinationSurface =
     gfxPlatform::GetPlatform()->
       CreateOffscreenSurface(gfxIntSize(bounds.width,
                                         bounds.height),
-                             imageFormat);
+                             gfxASurface::ContentFromFormat(imageFormat));
   }
 
   context = new gfxContext(destinationSurface);
   context->Translate(gfxPoint(-bounds.x, -bounds.y));
   LayerManagerD3D9::CallbackInfo cbInfo = mD3DManager->GetCallbackInfo();
   cbInfo.Callback(this, context, aRegion, nsIntRegion(), cbInfo.CallbackData);
 
   if (CanUseOpaqueSurface()) {
--- a/gfx/tests/gfxFontSelectionTest.cpp
+++ b/gfx/tests/gfxFontSelectionTest.cpp
@@ -225,17 +225,19 @@ nsTArray<TestEntry> testList;
 
 already_AddRefed<gfxContext>
 MakeContext ()
 {
     const int size = 200;
 
     nsRefPtr<gfxASurface> surface;
 
-    surface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(size, size), gfxASurface::ImageFormatRGB24);
+    surface = gfxPlatform::GetPlatform()->
+        CreateOffscreenSurface(gfxIntSize(size, size),
+                               gfxASurface::ContentFromFormat(gfxASurface::ImageFormatRGB24));
     gfxContext *ctx = new gfxContext(surface);
     NS_IF_ADDREF(ctx);
     return ctx;
 }
 
 TestEntry*
 AddTest (const char *utf8FamilyString,
          const gfxFontStyle& fontStyle,
--- a/gfx/tests/gfxTextRunPerfTest.cpp
+++ b/gfx/tests/gfxTextRunPerfTest.cpp
@@ -72,17 +72,19 @@ TestEntry testList[] = {
 
 already_AddRefed<gfxContext>
 MakeContext ()
 {
     const int size = 200;
 
     nsRefPtr<gfxASurface> surface;
 
-    surface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(size, size), gfxASurface::ImageFormatRGB24);
+    surface = gfxPlatform::GetPlatform()->
+        CreateOffscreenSurface(gfxIntSize(size, size),
+                               gfxASurface::ContentFromFormat(gfxASurface::ImageFormatRGB24));
     gfxContext *ctx = new gfxContext(surface);
     NS_IF_ADDREF(ctx);
     return ctx;
 }
 
 nsRefPtr<gfxFontGroup> fontGroup;
 const char* lastFamilies = nsnull;
 
--- a/gfx/tests/gfxWordCacheTest.cpp
+++ b/gfx/tests/gfxWordCacheTest.cpp
@@ -118,17 +118,19 @@ MakeTextRun(const PRUnichar *aText, PRUi
 
 already_AddRefed<gfxContext>
 MakeContext ()
 {
    const int size = 200;
 
    nsRefPtr<gfxASurface> surface;
 
-   surface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(size, size), gfxASurface::ImageFormatRGB24);
+   surface = gfxPlatform::GetPlatform()->
+       CreateOffscreenSurface(gfxIntSize(size, size),
+                              gfxASurface::ContentFromFormat(gfxASurface::ImageFormatRGB24));
    gfxContext *ctx = new gfxContext(surface);
    NS_IF_ADDREF(ctx);
    return ctx;
 }
 
 int
 main (int argc, char **argv) {
 #ifdef MOZ_WIDGET_GTK2
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -8357,17 +8357,17 @@ DumpToPNG(nsIPresShell* shell, nsAString
                          gfxImageSurface::ImageFormatARGB32);
   NS_ENSURE_TRUE(imgSurface, NS_ERROR_OUT_OF_MEMORY);
 
   nsRefPtr<gfxContext> imgContext = new gfxContext(imgSurface);
 
   nsRefPtr<gfxASurface> surface = 
     gfxPlatform::GetPlatform()->
     CreateOffscreenSurface(gfxIntSize(width, height),
-      gfxASurface::ImageFormatARGB32);
+      gfxASurface::ContentFromFormat(gfxASurface::ImageFormatARGB32));
   NS_ENSURE_TRUE(surface, NS_ERROR_OUT_OF_MEMORY);
 
   nsRefPtr<gfxContext> context = new gfxContext(surface);
   NS_ENSURE_TRUE(context, NS_ERROR_OUT_OF_MEMORY);
 
   shell->RenderDocument(r, 0, NS_RGB(255, 255, 0), context);
 
   imgContext->DrawSurface(surface, gfxSize(width, height));
--- a/widget/src/xpwidgets/PuppetWidget.cpp
+++ b/widget/src/xpwidgets/PuppetWidget.cpp
@@ -100,17 +100,17 @@ PuppetWidget::Create(nsIWidget        *a
              aAppShell, aToolkit, aInitData);
 
   mBounds = aRect;
   mEnabled = PR_TRUE;
   mVisible = PR_TRUE;
 
   mSurface = gfxPlatform::GetPlatform()
              ->CreateOffscreenSurface(gfxIntSize(1, 1),
-                                      gfxASurface::ImageFormatARGB32);
+                                      gfxASurface::ContentFromFormat(gfxASurface::ImageFormatARGB32));
 
   PuppetWidget* parent = static_cast<PuppetWidget*>(aParent);
   if (parent) {
     parent->SetChild(this);
     mLayerManager = parent->GetLayerManager();
   }
   else {
     Resize(mBounds.x, mBounds.y, mBounds.width, mBounds.height, PR_FALSE);