Bug 960254 - Part 2: Update some callers that write to DataSourceSurface. r=jrmuizel
authorBas Schouten <bschouten@mozilla.com>
Thu, 16 Jan 2014 13:17:23 +0100
changeset 163790 3ae8e5f144f160596797bd1dccecba9871587c03
parent 163789 b61f6abbd13d93896e72edbb87ffde26c034d06b
child 163791 bbad01205856e33a3271f74980200b7b841095a4
push id26011
push userryanvm@gmail.com
push dateThu, 16 Jan 2014 20:06:29 +0000
treeherdermozilla-central@bcbe93f41547 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs960254
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 960254 - Part 2: Update some callers that write to DataSourceSurface. r=jrmuizel
gfx/gl/SharedSurfaceEGL.cpp
gfx/gl/SharedSurfaceGL.cpp
gfx/layers/YCbCrImageDataSerializer.cpp
gfx/layers/opengl/CompositorOGL.cpp
--- a/gfx/gl/SharedSurfaceEGL.cpp
+++ b/gfx/gl/SharedSurfaceEGL.cpp
@@ -171,23 +171,26 @@ SharedSurface_EGLImage::Fence()
 
         if (!mPixels) {
             SurfaceFormat format =
                   HasAlpha() ? SurfaceFormat::B8G8R8A8
                              : SurfaceFormat::B8G8R8X8;
             mPixels = Factory::CreateDataSourceSurface(Size(), format);
         }
 
+        DataSourceSurface::MappedSurface map;
+        mPixels->Map(DataSourceSurface::MapType::WRITE, &map);
+
         nsRefPtr<gfxImageSurface> wrappedData =
-            new gfxImageSurface(mPixels->GetData(),
+            new gfxImageSurface(map.mData,
                                 ThebesIntSize(mPixels->GetSize()),
-                                mPixels->Stride(),
+                                map.mStride,
                                 SurfaceFormatToImageFormat(mPixels->GetFormat()));
         ReadScreenIntoImageSurface(mGL, wrappedData);
-        mPixels->MarkDirty();
+        mPixels->Unmap();
         return;
     }
     MOZ_ASSERT(mPipeActive);
     MOZ_ASSERT(mCurConsGL);
 
     if (mEGL->IsExtensionSupported(GLLibraryEGL::KHR_fence_sync) &&
         mGL->IsExtensionSupported(GLContext::OES_EGL_sync))
     {
--- a/gfx/gl/SharedSurfaceGL.cpp
+++ b/gfx/gl/SharedSurfaceGL.cpp
@@ -299,23 +299,26 @@ SharedSurface_Basic::~SharedSurface_Basi
 }
 
 void
 SharedSurface_Basic::Fence()
 {
     MOZ_ASSERT(mData->GetSize() == mGL->OffscreenSize());
 
     mGL->MakeCurrent();
+
+    DataSourceSurface::MappedSurface map;
+    mData->Map(DataSourceSurface::MapType::WRITE, &map);
     nsRefPtr<gfxImageSurface> wrappedData =
-      new gfxImageSurface(mData->GetData(),
+      new gfxImageSurface(map.mData,
                           ThebesIntSize(mData->GetSize()),
-                          mData->Stride(),
+                          map.mStride,
                           SurfaceFormatToImageFormat(mData->GetFormat()));
     ReadScreenIntoImageSurface(mGL, wrappedData);
-    mData->MarkDirty();
+    mData->Unmap();
 }
 
 
 
 SharedSurface_GLTexture*
 SharedSurface_GLTexture::Create(GLContext* prodGL,
                                 GLContext* consGL,
                                 const GLFormats& formats,
--- a/gfx/layers/YCbCrImageDataSerializer.cpp
+++ b/gfx/layers/YCbCrImageDataSerializer.cpp
@@ -10,16 +10,19 @@
 #include "mozilla/gfx/BaseSize.h"       // for BaseSize
 #include "mozilla/gfx/Types.h"
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "yuv_convert.h"                // for ConvertYCbCrToRGB32, etc
 
 #define MOZ_ALIGN_WORD(x) (((x) + 3) & ~3)
 
 namespace mozilla {
+
+using namespace gfx;
+
 namespace layers {
 
 // The Data is layed out as follows:
 //
 //  +-----------------+   -++ --+ --+ <-- Beginning of the buffer
 //  | YCbCrBufferInfo |     |   |   |
 //  +-----------------+   --+   |   |
 //  |      data       |         |   | YCbCrBufferInfo->[mY/mCb/mCr]Offset
@@ -241,28 +244,31 @@ YCbCrImageDataSerializer::CopyData(const
       CopyLineWithSkip(aCrData + i * aCbCrStride,
                        GetCrData() + i * GetCbCrStride(),
                        aCbCrSize.width, aCbCrSkip);
     }
   }
   return true;
 }
 
-TemporaryRef<gfx::DataSourceSurface>
+TemporaryRef<DataSourceSurface>
 YCbCrImageDataDeserializer::ToDataSourceSurface()
 {
-  RefPtr<gfx::DataSourceSurface> result =
-    gfx::Factory::CreateDataSourceSurface(GetYSize(), gfx::SurfaceFormat::R8G8B8X8);
+  RefPtr<DataSourceSurface> result =
+    Factory::CreateDataSourceSurface(GetYSize(), gfx::SurfaceFormat::R8G8B8X8);
+
+  DataSourceSurface::MappedSurface map;
+  result->Map(DataSourceSurface::MapType::WRITE, &map);
 
   gfx::ConvertYCbCrToRGB32(GetYData(), GetCbData(), GetCrData(),
-                           result->GetData(),
+                           map.mData,
                            0, 0, //pic x and y
                            GetYSize().width, GetYSize().height,
                            GetYStride(), GetCbCrStride(),
-                           result->Stride(),
+                           map.mStride,
                            gfx::YV12);
-  result->MarkDirty();
+  result->Unmap();
   return result.forget();
 }
 
 
 } // namespace
 } // namespace
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -1482,24 +1482,27 @@ CompositorOGL::CopyToTarget(DrawTarget *
   if (!mGLContext->IsGLES2()) {
     // GLES2 promises that binding to any custom FBO will attach
     // to GL_COLOR_ATTACHMENT0 attachment point.
     mGLContext->fReadBuffer(LOCAL_GL_BACK);
   }
 
   RefPtr<DataSourceSurface> source =
         Factory::CreateDataSourceSurface(rect.Size(), gfx::SurfaceFormat::B8G8R8A8);
+
+  DataSourceSurface::MappedSurface map;
+  source->Map(DataSourceSurface::MapType::WRITE, &map);
   // XXX we should do this properly one day without using the gfxImageSurface
   nsRefPtr<gfxImageSurface> surf =
-    new gfxImageSurface(source->GetData(),
+    new gfxImageSurface(map.mData,
                         gfxIntSize(width, height),
-                        source->Stride(),
+                        map.mStride,
                         gfxImageFormatARGB32);
   ReadPixelsIntoImageSurface(mGLContext, surf);
-  source->MarkDirty();
+  source->Unmap();
 
   // Map from GL space to Cairo space and reverse the world transform.
   Matrix glToCairoTransform = ToMatrix(aTransform);
   glToCairoTransform.Invert();
   glToCairoTransform.Scale(1.0, -1.0);
   glToCairoTransform.Translate(0.0, -height);
 
   Matrix oldMatrix = aTarget->GetTransform();