Bug 959154 - Part 6: Move away from DeprecatedDirectUpdate and remove them. r=nical
☠☠ backed out by 5749f2fc4f47 ☠ ☠
authorAndreas Pehrson <pehrsons@gmail.com>
Thu, 13 Feb 2014 17:27:19 +0100
changeset 169160 6ca9ba706c9441c582cacdd09d00c237b9b6e79e
parent 169159 c6ec9df2d729c17b1a83daae90c7bfa07e5947ce
child 169161 0f9be8d2caaf567398b4054d01b087bf43c45de8
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersnical
bugs959154
milestone30.0a1
Bug 959154 - Part 6: Move away from DeprecatedDirectUpdate and remove them. r=nical
gfx/gl/GLTextureImage.cpp
gfx/gl/GLTextureImage.h
gfx/gl/TextureImageEGL.cpp
gfx/gl/TextureImageEGL.h
gfx/layers/opengl/TextureHostOGL.cpp
--- a/gfx/gl/GLTextureImage.cpp
+++ b/gfx/gl/GLTextureImage.cpp
@@ -85,24 +85,19 @@ bool
 TextureImage::UpdateFromDataSource(gfx::DataSourceSurface *aSurface,
                                    const nsIntRegion* aDestRegion,
                                    const gfx::IntPoint* aSrcPoint)
 {
     nsIntRegion destRegion = aDestRegion ? *aDestRegion
                                          : nsIntRect(0, 0,
                                                      aSurface->GetSize().width,
                                                      aSurface->GetSize().height);
-    nsIntPoint thebesSrcPoint = aSrcPoint ? nsIntPoint(aSrcPoint->x, aSrcPoint->y)
-                                          : nsIntPoint(0, 0);
-    RefPtr<gfxASurface> thebesSurf
-        = new gfxImageSurface(aSurface->GetData(),
-                              ThebesIntSize(aSurface->GetSize()),
-                              aSurface->Stride(),
-                              SurfaceFormatToImageFormat(aSurface->GetFormat()));
-    return DeprecatedDirectUpdate(thebesSurf, destRegion, thebesSrcPoint);
+    gfx::IntPoint srcPoint = aSrcPoint ? *aSrcPoint
+                                       : gfx::IntPoint(0, 0);
+    return DirectUpdate(aSurface, destRegion, srcPoint);
 }
 
 gfx::IntRect TextureImage::GetTileRect() {
     return gfx::IntRect(gfx::IntPoint(0,0), mSize);
 }
 
 gfx::IntRect TextureImage::GetSrcTileRect() {
     return GetTileRect();
@@ -220,30 +215,16 @@ BasicTextureImage::FinishedSurfaceUpdate
 }
 
 void
 BasicTextureImage::FinishedSurfaceUpload()
 {
 }
 
 bool
-BasicTextureImage::DeprecatedDirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion, const nsIntPoint& aFrom /* = nsIntPoint(0, 0) */)
-{
-    nsRefPtr<gfxImageSurface> imageSurf = aSurf->GetAsImageSurface();
-    NS_ASSERTION(imageSurf, "surface is not an image surface");
-
-    RefPtr<gfx::DataSourceSurface> wrappedSurf =
-        gfx::Factory::CreateWrappingDataSourceSurface(imageSurf->Data(),
-                                                      imageSurf->Stride(),
-                                                      gfx::ToIntSize(imageSurf->GetSize()),
-                                                      gfx::ImageFormatToSurfaceFormat(imageSurf->Format()));
-    return DirectUpdate(wrappedSurf, aRegion, gfx::IntPoint(aFrom.x, aFrom.y));
-}
-
-bool
 BasicTextureImage::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom /* = gfx::IntPoint(0, 0) */)
 {
     nsIntRect bounds = aRegion.GetBounds();
     nsIntRegion region;
     if (mTextureState != Valid) {
         bounds = nsIntRect(0, 0, mSize.width, mSize.height);
         region = nsIntRegion(bounds);
     } else {
@@ -369,30 +350,16 @@ TiledTextureImage::TiledTextureImage(GLC
     }
 }
 
 TiledTextureImage::~TiledTextureImage()
 {
 }
 
 bool
-TiledTextureImage::DeprecatedDirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion, const nsIntPoint& aFrom /* = nsIntPoint(0, 0) */)
-{
-    nsRefPtr<gfxImageSurface> imageSurf = aSurf->GetAsImageSurface();
-    NS_ASSERTION(imageSurf, "surface is not an image surface");
-
-    RefPtr<gfx::DataSourceSurface> wrappedSurf =
-        gfx::Factory::CreateWrappingDataSourceSurface(imageSurf->Data(),
-                                                      imageSurf->Stride(),
-                                                      gfx::ToIntSize(imageSurf->GetSize()),
-                                                      gfx::ImageFormatToSurfaceFormat(imageSurf->Format()));
-    return DirectUpdate(wrappedSurf, aRegion, gfx::IntPoint(aFrom.x, aFrom.y));
-}
-
-bool
 TiledTextureImage::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom /* = gfx::IntPoint(0, 0) */)
 {
     if (mSize.width == 0 || mSize.height == 0) {
         return true;
     }
 
     nsIntRegion region;
 
--- a/gfx/gl/GLTextureImage.h
+++ b/gfx/gl/GLTextureImage.h
@@ -171,18 +171,16 @@ public:
      */
     virtual void MarkValid() {}
 
     /**
      * aSurf - the source surface to update from
      * aRegion - the region in this image to update
      * aFrom - offset in the source to update from
      */
-    virtual bool DeprecatedDirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion, const nsIntPoint& aFrom = nsIntPoint(0,0)) = 0;
-    // Moz2D equivalent
     virtual bool DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom = gfx::IntPoint(0,0)) = 0;
     bool UpdateFromDataSource(gfx::DataSourceSurface *aSurf,
                               const nsIntRegion* aDstRegion = nullptr,
                               const gfx::IntPoint* aSrcOffset = nullptr);
 
     virtual void BindTexture(GLenum aTextureUnit) = 0;
 
     /**
@@ -278,17 +276,16 @@ public:
                       TextureImage::Flags aFlags = TextureImage::NoFlags,
                       TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
 
     virtual void BindTexture(GLenum aTextureUnit);
 
     virtual gfxASurface* BeginUpdate(nsIntRegion& aRegion);
     virtual void GetUpdateRegion(nsIntRegion& aForRegion);
     virtual void EndUpdate();
-    virtual bool DeprecatedDirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion, const nsIntPoint& aFrom = nsIntPoint(0,0));
     virtual bool DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom = gfx::IntPoint(0,0));
     virtual GLuint GetTextureID() { return mTexture; }
     // Returns a surface to draw into
     virtual already_AddRefed<gfxASurface>
       GetSurfaceForUpdate(const gfxIntSize& aSize, ImageFormat aFmt);
 
     virtual void MarkValid() { mTextureState = Valid; }
 
@@ -339,17 +336,16 @@ public:
     virtual void BeginTileIteration();
     virtual bool NextTile();
     virtual void SetIterationCallback(TileIterationCallback aCallback,
                                       void* aCallbackData);
     virtual gfx::IntRect GetTileRect();
     virtual GLuint GetTextureID() {
         return mImages[mCurrentImage]->GetTextureID();
     }
-    virtual bool DeprecatedDirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion, const nsIntPoint& aFrom = nsIntPoint(0,0));
     virtual bool DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom = gfx::IntPoint(0,0));
     virtual bool InUpdate() const { return mInUpdate; }
     virtual void BindTexture(GLenum);
 
 protected:
     virtual gfx::IntRect GetSrcTileRect();
 
     unsigned int mCurrentImage;
--- a/gfx/gl/TextureImageEGL.cpp
+++ b/gfx/gl/TextureImageEGL.cpp
@@ -199,30 +199,16 @@ TextureImageEGL::EndUpdate()
     }
 
     mUpdateSurface = nullptr;
     mTextureState = Valid;
     return;         // mTexture is bound
 }
 
 bool
-TextureImageEGL::DeprecatedDirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion, const nsIntPoint& aFrom /* = nsIntPoint(0, 0) */)
-{
-    nsRefPtr<gfxImageSurface> imageSurf = aSurf->GetAsImageSurface();
-    NS_ASSERTION(imageSurf, "surface is not an image surface");
-
-    RefPtr<gfx::DataSourceSurface> wrappedSurf =
-        gfx::Factory::CreateWrappingDataSourceSurface(imageSurf->Data(),
-                                                      imageSurf->Stride(),
-                                                      gfx::ToIntSize(imageSurf->GetSize()),
-                                                      gfx::ImageFormatToSurfaceFormat(imageSurf->Format()));
-    return DirectUpdate(wrappedSurf, aRegion, gfx::IntPoint(aFrom.x, aFrom.y));
-}
-
-bool
 TextureImageEGL::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom /* = gfx::IntPoint(0,0) */)
 {
     nsIntRect bounds = aRegion.GetBounds();
 
     nsIntRegion region;
     if (mTextureState != Valid) {
         bounds = nsIntRect(0, 0, mSize.width, mSize.height);
         region = nsIntRegion(bounds);
--- a/gfx/gl/TextureImageEGL.h
+++ b/gfx/gl/TextureImageEGL.h
@@ -27,18 +27,16 @@ public:
     virtual ~TextureImageEGL();
 
     virtual void GetUpdateRegion(nsIntRegion& aForRegion);
 
     virtual gfxASurface* BeginUpdate(nsIntRegion& aRegion);
 
     virtual void EndUpdate();
 
-    virtual bool DeprecatedDirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion, const nsIntPoint& aFrom /* = nsIntPoint(0, 0) */);
-
     virtual bool DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom = gfx::IntPoint(0,0));
 
     virtual void BindTexture(GLenum aTextureUnit);
 
     virtual GLuint GetTextureID()
     {
         // Ensure the texture is allocated before it is used.
         if (mTextureState == Created) {
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -735,21 +735,28 @@ TextureImageDeprecatedTextureHostOGL::Up
   // XXX this is always just ridiculously slow
   nsIntRegion updateRegion;
 
   if (!aRegion) {
     updateRegion = nsIntRegion(nsIntRect(0, 0, size.width, size.height));
   } else {
     updateRegion = *aRegion;
   }
-  nsIntPoint offset;
+  gfx::IntPoint offset;
   if (aOffset) {
-    offset = *aOffset;
+    offset.x = aOffset->x;
+    offset.y = aOffset->y;
   }
-  mTexture->DeprecatedDirectUpdate(surf.Get(), updateRegion, offset);
+  nsRefPtr<gfxImageSurface> thebesSurf = surf.GetAsImage();
+  RefPtr<DataSourceSurface> sourceSurf =
+    gfx::Factory::CreateWrappingDataSourceSurface(thebesSurf->Data(),
+                                                  thebesSurf->Stride(),
+                                                  ToIntSize(thebesSurf->GetSize()),
+                                                  ImageFormatToSurfaceFormat(thebesSurf->Format()));
+  mTexture->DirectUpdate(sourceSurf, updateRegion, offset);
   mFormat = mTexture->GetTextureFormat();
 
   if (mTexture->InUpdate()) {
     mTexture->EndUpdate();
   }
 }
 
 bool