Bug 959124 - Implement RemoteBitmapImage::GetAsSourceSurface. r=nical
authorAli Akhtarzada <ali@comoyo.com>
Fri, 17 Jan 2014 11:22:44 -0500
changeset 163977 3eb0b43bae64aab7a57a58c5f4612652a6d4d535
parent 163976 8c9e9d8c4c758156ae52609c25ed8090687db4a8
child 163978 899e651efa23c289c73b1eee5d8c7080d4f171ba
push id38603
push userryanvm@gmail.com
push dateFri, 17 Jan 2014 16:23:14 +0000
treeherdermozilla-inbound@899e651efa23 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs959124
milestone29.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 959124 - Implement RemoteBitmapImage::GetAsSourceSurface. r=nical Just added a subclass specific implementation of GetAsSourceSurface.
gfx/layers/ImageContainer.cpp
gfx/layers/ImageContainer.h
--- a/gfx/layers/ImageContainer.cpp
+++ b/gfx/layers/ImageContainer.cpp
@@ -670,10 +670,27 @@ RemoteBitmapImage::DeprecatedGetAsSurfac
     memcpy(newSurf->Data() + newSurf->Stride() * y,
            mData + mStride * y,
            mSize.width * 4);
   }
 
   return newSurf.forget();
 }
 
+TemporaryRef<gfx::SourceSurface>
+RemoteBitmapImage::GetAsSourceSurface()
+{
+  gfx::SurfaceFormat fmt = mFormat == RemoteImageData::BGRX32
+                         ? gfx::SurfaceFormat::B8G8R8X8
+                         : gfx::SurfaceFormat::B8G8R8A8;
+  RefPtr<gfx::DataSourceSurface> newSurf = gfx::Factory::CreateDataSourceSurface(mSize, fmt);
+
+  for (int y = 0; y < mSize.height; y++) {
+    memcpy(newSurf->GetData() + newSurf->Stride() * y,
+           mData + mStride * y,
+           mSize.width * 4);
+  }
+
+  return newSurf;
+}
+
 } // namespace
 } // namespace
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -968,16 +968,17 @@ private:
   nsCountedRef<nsMainThreadSourceSurfaceRef> mSourceSurface;
 };
 
 class RemoteBitmapImage : public Image {
 public:
   RemoteBitmapImage() : Image(nullptr, REMOTE_IMAGE_BITMAP) {}
 
   already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
+  TemporaryRef<gfx::SourceSurface> GetAsSourceSurface();
 
   gfx::IntSize GetSize() { return mSize; }
 
   unsigned char *mData;
   int mStride;
   gfx::IntSize mSize;
   RemoteImageData::Format mFormat;
 };