b=593868; fix OpenGL layers on win32 with d2d content; r=jrmuizel
authorVladimir Vukicevic <vladimir@pobox.com>
Tue, 07 Sep 2010 12:26:43 -0400
changeset 53682 b83ed7cfc199c9d1a0b5aca178354e669bf18f26
parent 53681 f7c46270db80207e3fb8766d8cff49d9fd4d0c95
child 53683 c1346180e12a69fd76ec7c5ea3038c5a3898d751
push idunknown
push userunknown
push dateunknown
reviewersjrmuizel
bugs593868
milestone2.0b6pre
b=593868; fix OpenGL layers on win32 with d2d content; r=jrmuizel
gfx/thebes/GLContextProviderWGL.cpp
--- a/gfx/thebes/GLContextProviderWGL.cpp
+++ b/gfx/thebes/GLContextProviderWGL.cpp
@@ -428,37 +428,51 @@ class TextureImageWGL : public BasicText
                                           const nsIntSize&,
                                           TextureImage::ContentType,
                                           GLContext*);
 
 protected:
     virtual already_AddRefed<gfxASurface>
     CreateUpdateSurface(const gfxIntSize& aSize, ImageFormat aFmt)
     {
+        mUpdateSize = aSize;
+        mUpdateFormat = aFmt;
+
         return gfxPlatform::GetPlatform()->CreateOffscreenSurface(aSize, aFmt);
     }
 
     virtual already_AddRefed<gfxImageSurface>
     GetImageForUpload(gfxASurface* aUpdateSurface)
     {
-        NS_ASSERTION(gfxASurface::SurfaceTypeWin32 == aUpdateSurface->GetType(),
-                     "unexpected surface type");
-        nsRefPtr<gfxImageSurface> uploadImage(
-            static_cast<gfxWindowsSurface*>(aUpdateSurface)->
-            GetImageSurface());
+        nsRefPtr<gfxImageSurface> uploadImage;
+
+        if (aUpdateSurface->GetType() == gfxASurface::SurfaceTypeWin32) {
+            gfxWindowsSurface* ws = static_cast<gfxWindowsSurface*>(aUpdateSurface);
+            uploadImage = ws->GetImageSurface();
+        } else {
+            uploadImage = new gfxImageSurface(mUpdateSize, mUpdateFormat);
+            nsRefPtr<gfxContext> cx(new gfxContext(uploadImage));
+            cx->SetSource(aUpdateSurface);
+            cx->SetOperator(gfxContext::OPERATOR_SOURCE);
+            cx->Paint();
+        }
+
         return uploadImage.forget();
     }
 
 private:
     TextureImageWGL(GLuint aTexture,
                     const nsIntSize& aSize,
                     ContentType aContentType,
                     GLContext* aContext)
         : BasicTextureImage(aTexture, aSize, aContentType, aContext)
     {}
+
+    gfxIntSize mUpdateSize;
+    ImageFormat mUpdateFormat;
 };
 
 already_AddRefed<TextureImage>
 GLContextWGL::CreateBasicTextureImage(GLuint aTexture,
                                       const nsIntSize& aSize,
                                       TextureImage::ContentType aContentType,
                                       GLContext* aContext)
 {