Bug 973892 - Part 1) Choose the backend in ImageDataSerializer::GetAsDrawTarget. r=mattwoodrow
☠☠ backed out by 995cfd42e045 ☠ ☠
authorNicolas Silva <nical@mozilla.com>
Wed, 19 Feb 2014 18:17:40 +0100
changeset 169894 6364146ddb194ab29bf85da34684d790bb033f52
parent 169893 7ddabb9fd909859bff762ebd6aaf489850f48a69
child 169895 2784838dbc94b2a2155bab798888e89353cdcd42
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersmattwoodrow
bugs973892
milestone30.0a1
Bug 973892 - Part 1) Choose the backend in ImageDataSerializer::GetAsDrawTarget. r=mattwoodrow
gfx/layers/ImageDataSerializer.cpp
gfx/layers/ImageDataSerializer.h
gfx/layers/client/TextureClient.cpp
gfx/thebes/gfxPlatform.h
--- a/gfx/layers/ImageDataSerializer.cpp
+++ b/gfx/layers/ImageDataSerializer.cpp
@@ -123,23 +123,22 @@ ImageDataSerializerBase::GetAsThebesSurf
   IntSize size = GetSize();
   return new gfxImageSurface(GetData(),
                              gfxIntSize(size.width, size.height),
                              GetStride(),
                              SurfaceFormatToImageFormat(GetFormat()));
 }
 
 TemporaryRef<DrawTarget>
-ImageDataSerializerBase::GetAsDrawTarget()
+ImageDataSerializerBase::GetAsDrawTarget(gfx::BackendType aBackend)
 {
   MOZ_ASSERT(IsValid());
-  return gfxPlatform::GetPlatform()->CreateDrawTargetForData(GetData(),
-                                                             GetSize(),
-                                                             GetStride(),
-                                                             GetFormat());
+  return gfx::Factory::CreateDrawTargetForData(aBackend,
+                                               GetData(), GetSize(),
+                                               GetStride(), GetFormat());
 }
 
 TemporaryRef<gfx::DataSourceSurface>
 ImageDataSerializerBase::GetAsSurface()
 {
   MOZ_ASSERT(IsValid());
   return Factory::CreateWrappingDataSourceSurface(GetData(),
                                                   GetStride(),
--- a/gfx/layers/ImageDataSerializer.h
+++ b/gfx/layers/ImageDataSerializer.h
@@ -32,17 +32,17 @@ public:
   bool IsValid() const;
 
   uint8_t* GetData();
   uint32_t GetStride() const;
   gfx::IntSize GetSize() const;
   gfx::SurfaceFormat GetFormat() const;
   TemporaryRef<gfx::DataSourceSurface> GetAsSurface();
   TemporaryRef<gfxImageSurface> GetAsThebesSurface();
-  TemporaryRef<gfx::DrawTarget> GetAsDrawTarget();
+  TemporaryRef<gfx::DrawTarget> GetAsDrawTarget(gfx::BackendType aBackend);
 
 protected:
 
   ImageDataSerializerBase(uint8_t* aData)
   : mData(aData) {}
   uint8_t* mData;
 };
 
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -533,17 +533,17 @@ BufferTextureClient::GetAsDrawTarget()
   }
 
   ImageDataSerializer serializer(GetBuffer());
   if (!serializer.IsValid()) {
     return nullptr;
   }
 
   MOZ_ASSERT(mUsingFallbackDrawTarget == false);
-  mDrawTarget = serializer.GetAsDrawTarget();
+  mDrawTarget = serializer.GetAsDrawTarget(gfxPlatform::GetPlatform()->GetContentBackend());
   if (mDrawTarget) {
     return mDrawTarget;
   }
 
   // fallback path, probably because the Moz2D backend can't create a
   // DrawTarget around raw memory. This is going to be slow :(
   mDrawTarget = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
     serializer.GetSize(), serializer.GetFormat());
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -288,16 +288,20 @@ public:
 
     void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) {
       aObj.DefineProperty("AzureCanvasBackend", GetBackendName(mPreferredCanvasBackend));
       aObj.DefineProperty("AzureSkiaAccelerated", UseAcceleratedSkiaCanvas());
       aObj.DefineProperty("AzureFallbackCanvasBackend", GetBackendName(mFallbackCanvasBackend));
       aObj.DefineProperty("AzureContentBackend", GetBackendName(mContentBackend));
     }
 
+    mozilla::gfx::BackendType GetContentBackend() {
+      return mContentBackend;
+    }
+
     mozilla::gfx::BackendType GetPreferredCanvasBackend() {
       return mPreferredCanvasBackend;
     }
 
     /*
      * Font bits
      */
 
@@ -677,20 +681,16 @@ protected:
      */
     static mozilla::gfx::BackendType GetBackendPref(const char* aBackendPrefName,
                                                     uint32_t &aBackendBitmask);
     /**
      * Decode the backend enumberation from a string.
      */
     static mozilla::gfx::BackendType BackendTypeForName(const nsCString& aName);
 
-    mozilla::gfx::BackendType GetContentBackend() {
-      return mContentBackend;
-    }
-
     static mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
       GetScaledFontForFontWithCairoSkia(mozilla::gfx::DrawTarget* aTarget, gfxFont* aFont);
 
     int8_t  mAllowDownloadableFonts;
     int8_t  mGraphiteShapingEnabled;
     int8_t  mOpenTypeSVGEnabled;
 
     int8_t  mBidiNumeralOption;