Backed out 5 changesets (bug 960254, bug 960354)
authorBas Schouten <bschouten@mozilla.com>
Thu, 16 Jan 2014 14:36:53 +0100
changeset 163700 2628e64cf37571a3699985562935c47cf051d9a6
parent 163699 8d3e02a7f23ce58733e4ee20fa64d9c9637835b8
child 163701 b61f6abbd13d93896e72edbb87ffde26c034d06b
push id38545
push userbschouten@mozilla.com
push dateThu, 16 Jan 2014 13:37:18 +0000
treeherdermozilla-inbound@327d381e24c8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs960254, 960354
milestone29.0a1
backs out4441c32c724c6bb40a02312d1eba5295fd2686d4
4aecc5ca2a19bdc70bde8389cf0d13e2f430c24d
9f499e5f7954989f095a949c7bd8d70955501860
fd9b6b044a5ab9e006d1206e7c5622545c938a0c
c1f6fbc397bd67d63ea79df232f31cbe3640f590
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
Backed out 5 changesets (bug 960254, bug 960354) Backed out changeset 4441c32c724c (bug 960254) Backed out changeset 4aecc5ca2a19 (bug 960254) Backed out changeset 9f499e5f7954 (bug 960354) Backed out changeset fd9b6b044a5a (bug 960354) Backed out changeset c1f6fbc397bd (bug 960354)
gfx/2d/2D.h
gfx/2d/DataSourceSurfaceWrapper.h
gfx/2d/SourceSurfaceD2D.cpp
gfx/2d/SourceSurfaceD2D.h
gfx/2d/SourceSurfaceD2D1.cpp
gfx/2d/SourceSurfaceD2D1.h
gfx/2d/SourceSurfaceD2DTarget.cpp
gfx/2d/SourceSurfaceD2DTarget.h
gfx/gl/SharedSurfaceEGL.cpp
gfx/gl/SharedSurfaceGL.cpp
gfx/layers/YCbCrImageDataSerializer.cpp
gfx/layers/opengl/CompositorOGL.cpp
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -18,18 +18,16 @@
 // to be able to hold on to a GLContext.
 #include "mozilla/GenericRefCounted.h"
 
 // This RefPtr class isn't ideal for usage in Azure, as it doesn't allow T**
 // outparams using the &-operator. But it will have to do as there's no easy
 // solution.
 #include "mozilla/RefPtr.h"
 
-#include "mozilla/DebugOnly.h"
-
 #ifdef MOZ_ENABLE_FREETYPE
 #include <string>
 #endif
 
 struct _cairo_surface;
 typedef _cairo_surface cairo_surface_t;
 
 struct _cairo_scaled_font;
@@ -334,67 +332,41 @@ public:
    * DataSourceSurface's data can be accessed directly.
    */
   virtual TemporaryRef<DataSourceSurface> GetDataSurface() = 0;
 };
 
 class DataSourceSurface : public SourceSurface
 {
 public:
-  DataSourceSurface()
-    : mIsMapped(false)
-  {
-  }
-
-  struct MappedSurface {
-    uint8_t *mData;
-    int32_t mStride;
-  };
-
-  enum MapType {
-    READ,
-    WRITE,
-    READ_WRITE
-  };
-
   virtual SurfaceType GetType() const { return SurfaceType::DATA; }
-  /* [DEPRECATED]
+  /*
    * Get the raw bitmap data of the surface.
    * Can return null if there was OOM allocating surface data.
    */
   virtual uint8_t *GetData() = 0;
 
-  /* [DEPRECATED]
+  /*
    * Stride of the surface, distance in bytes between the start of the image
    * data belonging to row y and row y+1. This may be negative.
    * Can return 0 if there was OOM allocating surface data.
    */
   virtual int32_t Stride() = 0;
 
-  virtual bool Map(MapType, MappedSurface *aMappedSurface)
-  {
-    aMappedSurface->mData = GetData();
-    aMappedSurface->mStride = Stride();
-    mIsMapped = true;
-    return true;
-  }
-
-  virtual void Unmap()
-  {
-    MOZ_ASSERT(mIsMapped);
-    mIsMapped = false;
-  }
+  /*
+   * This function is called after modifying the data on the source surface
+   * directly through the data pointer.
+   */
+  virtual void MarkDirty() {}
 
   /*
    * Returns a DataSourceSurface with the same data as this one, but
    * guaranteed to have surface->GetType() == SurfaceType::DATA.
    */
   virtual TemporaryRef<DataSourceSurface> GetDataSurface();
-
-  DebugOnly<bool> mIsMapped;
 };
 
 /* This is an abstract object that accepts path segments. */
 class PathSink : public RefCounted<PathSink>
 {
 public:
   virtual ~PathSink() {}
 
--- a/gfx/2d/DataSourceSurfaceWrapper.h
+++ b/gfx/2d/DataSourceSurfaceWrapper.h
@@ -22,16 +22,17 @@ public:
 
   virtual SurfaceType GetType() const MOZ_OVERRIDE { return SurfaceType::DATA; }
 
   virtual uint8_t *GetData() MOZ_OVERRIDE { return mSurface->GetData(); }
   virtual int32_t Stride() MOZ_OVERRIDE { return mSurface->Stride(); }
   virtual IntSize GetSize() const MOZ_OVERRIDE { return mSurface->GetSize(); }
   virtual SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mSurface->GetFormat(); }
   virtual bool IsValid() const MOZ_OVERRIDE { return mSurface->IsValid(); }
+  virtual void MarkDirty() { mSurface->MarkDirty(); }
 
 private:
   RefPtr<DataSourceSurface> mSurface;
 };
 
 }
 }
 
--- a/gfx/2d/SourceSurfaceD2D.cpp
+++ b/gfx/2d/SourceSurfaceD2D.cpp
@@ -169,17 +169,17 @@ DataSourceSurfaceD2D::DataSourceSurfaceD
 
   renderTarget->BeginDraw();
   renderTarget->DrawBitmap(aSourceSurface->mBitmap,
                            D2D1::RectF(0, 0,
                                        Float(mSize.width),
                                        Float(mSize.height)));
   renderTarget->EndDraw();
 
-  desc.CPUAccessFlags = D3D10_CPU_ACCESS_READ | D3D10_CPU_ACCESS_WRITE;
+  desc.CPUAccessFlags = D3D10_CPU_ACCESS_READ;
   desc.Usage = D3D10_USAGE_STAGING;
   desc.BindFlags = 0;
   hr = aSourceSurface->mDevice->CreateTexture2D(&desc, nullptr, byRef(mTexture));
   if (FAILED(hr)) {
     gfxWarning() << "Failed to create staging texture. Code: " << hr;
     mTexture = nullptr;
     return;
   }
@@ -223,66 +223,19 @@ DataSourceSurfaceD2D::GetSize() const
 }
 
 SurfaceFormat
 DataSourceSurfaceD2D::GetFormat() const
 {
   return mFormat;
 }
 
-bool
-DataSourceSurfaceD2D::Map(MapType aMapType, MappedSurface *aMappedSurface)
-{
-  // DataSourceSurfaces used with the new Map API should not be used with GetData!!
-  MOZ_ASSERT(!mMapped);
-  MOZ_ASSERT(!mIsMapped);
-
-  if (!mTexture) {
-    return false;
-  }
-
-  D3D10_MAP mapType;
-
-  if (aMapType == MapType::READ) {
-    mapType = D3D10_MAP_READ;
-  } else if (aMapType == MapType::WRITE) {
-    mapType = D3D10_MAP_WRITE;
-  } else {
-    mapType = D3D10_MAP_READ_WRITE;
-  }
-
-  D3D10_MAPPED_TEXTURE2D map;
-
-  HRESULT hr = mTexture->Map(0, mapType, 0, &map);
-
-  if (FAILED(hr)) {
-    gfxWarning() << "Texture map failed with code: " << hr;
-    return false;
-  }
-
-  aMappedSurface->mData = (uint8_t*)map.pData;
-  aMappedSurface->mStride = map.RowPitch;
-
-  return true;
-}
-
-void
-DataSourceSurfaceD2D::Unmap()
-{
-  MOZ_ASSERT(mIsMapped);
-
-  mTexture->Unmap(0);
-}
-
 void
 DataSourceSurfaceD2D::EnsureMappedTexture()
 {
-  // Do not use GetData() after having used Map!
-  MOZ_ASSERT(!mIsMapped);
-
   if (mMapped ||
       !mTexture) {
     return;
   }
 
   HRESULT hr = mTexture->Map(0, D3D10_MAP_READ, 0, &mData);
   if (FAILED(hr)) {
     gfxWarning() << "Failed to map texture. Code: " << hr;
--- a/gfx/2d/SourceSurfaceD2D.h
+++ b/gfx/2d/SourceSurfaceD2D.h
@@ -57,18 +57,16 @@ class DataSourceSurfaceD2D : public Data
 public:
   DataSourceSurfaceD2D(SourceSurfaceD2D* aSourceSurface);
   virtual ~DataSourceSurfaceD2D();
 
   virtual unsigned char* GetData();
   virtual int32_t Stride();
   virtual IntSize GetSize() const;
   virtual SurfaceFormat GetFormat() const;
-  virtual bool Map(MapType, MappedSurface *aMappedSurface);
-  virtual void Unmap();
 
   bool IsValid()
   {
     return mTexture;
   }
 
 private:
   void EnsureMappedTexture();
--- a/gfx/2d/SourceSurfaceD2D1.cpp
+++ b/gfx/2d/SourceSurfaceD2D1.cpp
@@ -136,58 +136,27 @@ DataSourceSurfaceD2D1::GetSize() const
 uint8_t*
 DataSourceSurfaceD2D1::GetData()
 {
   EnsureMapped();
 
   return mMap.bits;
 }
 
-bool
-DataSourceSurfaceD2D1::Map(MapType aMapType, MappedSurface *aMappedSurface)
-{
-  // DataSourceSurfaces used with the new Map API should not be used with GetData!!
-  MOZ_ASSERT(!mMapped);
-  MOZ_ASSERT(!mIsMapped);
-
-  D2D1_MAP_OPTIONS options;
-  if (aMapType == MapType::READ) {
-    options = D2D1_MAP_OPTIONS_READ;
-  } else {
-    MOZ_CRASH("No support for Write maps on D2D1 DataSourceSurfaces yet!");
-  }
-
-  D2D1_MAPPED_RECT map;
-  mBitmap->Map(D2D1_MAP_OPTIONS_READ, &map);
-  aMappedSurface->mData = map.bits;
-  aMappedSurface->mStride = map.pitch;
-
-  mIsMapped = true;
-  return true;
-}
-
-void
-DataSourceSurfaceD2D1::Unmap()
-{
-  mBitmap->Unmap();
-}
-
 int32_t
 DataSourceSurfaceD2D1::Stride()
 {
   EnsureMapped();
 
   return mMap.pitch;
 }
 
 void
 DataSourceSurfaceD2D1::EnsureMapped()
 {
-  // Do not use GetData() after having used Map!
-  MOZ_ASSERT(!mIsMapped);
   if (mMapped) {
     return;
   }
   mBitmap->Map(D2D1_MAP_OPTIONS_READ, &mMap);
   mMapped = true;
 }
 
 }
--- a/gfx/2d/SourceSurfaceD2D1.h
+++ b/gfx/2d/SourceSurfaceD2D1.h
@@ -65,18 +65,16 @@ public:
   DataSourceSurfaceD2D1(ID2D1Bitmap1 *aMappableBitmap, SurfaceFormat aFormat);
   ~DataSourceSurfaceD2D1();
 
   virtual SurfaceType GetType() const { return SurfaceType::DATA; }
   virtual IntSize GetSize() const;
   virtual SurfaceFormat GetFormat() const { return mFormat; }
   virtual uint8_t *GetData();
   virtual int32_t Stride();
-  virtual bool Map(MapType, MappedSurface *aMappedSurface);
-  virtual void Unmap();
 
 private:
   friend class SourceSurfaceD2DTarget;
   void EnsureMapped();
 
   mutable RefPtr<ID2D1Bitmap1> mBitmap;
   SurfaceFormat mFormat;
   D2D1_MAPPED_RECT mMap;
--- a/gfx/2d/SourceSurfaceD2DTarget.cpp
+++ b/gfx/2d/SourceSurfaceD2DTarget.cpp
@@ -231,65 +231,19 @@ DataSourceSurfaceD2DTarget::GetData()
 
 int32_t
 DataSourceSurfaceD2DTarget::Stride()
 {
   EnsureMapped();
   return mMap.RowPitch;
 }
 
-bool
-DataSourceSurfaceD2DTarget::Map(MapType aMapType, MappedSurface *aMappedSurface)
-{
-  // DataSourceSurfaces used with the new Map API should not be used with GetData!!
-  MOZ_ASSERT(!mMapped);
-  MOZ_ASSERT(!mIsMapped);
-
-  if (!mTexture) {
-    return false;
-  }
-
-  D3D10_MAP mapType;
-
-  if (aMapType == MapType::READ) {
-    mapType = D3D10_MAP_READ;
-  } else if (aMapType == MapType::WRITE) {
-    mapType = D3D10_MAP_WRITE;
-  } else {
-    mapType = D3D10_MAP_READ_WRITE;
-  }
-
-  D3D10_MAPPED_TEXTURE2D map;
-
-  HRESULT hr = mTexture->Map(0, mapType, 0, &map);
-
-  if (FAILED(hr)) {
-    gfxWarning() << "Texture map failed with code: " << hr;
-    return false;
-  }
-
-  aMappedSurface->mData = (uint8_t*)map.pData;
-  aMappedSurface->mStride = map.RowPitch;
-
-  return true;
-}
-
-void
-DataSourceSurfaceD2DTarget::Unmap()
-{
-  MOZ_ASSERT(mIsMapped);
-
-  mTexture->Unmap(0);
-}
-
 void
 DataSourceSurfaceD2DTarget::EnsureMapped()
 {
-  // Do not use GetData() after having used Map!
-  MOZ_ASSERT(!mIsMapped);
   if (!mMapped) {
     HRESULT hr = mTexture->Map(0, D3D10_MAP_READ, 0, &mMap);
     if (FAILED(hr)) {
       gfxWarning() << "Failed to map texture to memory. Code: " << hr;
       return;
     }
     mMapped = true;
   }
--- a/gfx/2d/SourceSurfaceD2DTarget.h
+++ b/gfx/2d/SourceSurfaceD2DTarget.h
@@ -63,18 +63,16 @@ public:
   DataSourceSurfaceD2DTarget(SurfaceFormat aFormat);
   ~DataSourceSurfaceD2DTarget();
 
   virtual SurfaceType GetType() const { return SurfaceType::DATA; }
   virtual IntSize GetSize() const;
   virtual SurfaceFormat GetFormat() const;
   virtual uint8_t *GetData();
   virtual int32_t Stride();
-  virtual bool Map(MapType, MappedSurface *aMappedSurface);
-  virtual void Unmap();
 
 private:
   friend class SourceSurfaceD2DTarget;
   void EnsureMapped();
 
   mutable RefPtr<ID3D10Texture2D> mTexture;
   SurfaceFormat mFormat;
   D3D10_MAPPED_TEXTURE2D mMap;
--- a/gfx/gl/SharedSurfaceEGL.cpp
+++ b/gfx/gl/SharedSurfaceEGL.cpp
@@ -171,26 +171,23 @@ 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(map.mData,
+            new gfxImageSurface(mPixels->GetData(),
                                 ThebesIntSize(mPixels->GetSize()),
-                                map.mStride,
+                                mPixels->Stride(),
                                 SurfaceFormatToImageFormat(mPixels->GetFormat()));
         ReadScreenIntoImageSurface(mGL, wrappedData);
-        mPixels->Unmap();
+        mPixels->MarkDirty();
         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,26 +299,23 @@ 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(map.mData,
+      new gfxImageSurface(mData->GetData(),
                           ThebesIntSize(mData->GetSize()),
-                          map.mStride,
+                          mData->Stride(),
                           SurfaceFormatToImageFormat(mData->GetFormat()));
     ReadScreenIntoImageSurface(mGL, wrappedData);
-    mData->Unmap();
+    mData->MarkDirty();
 }
 
 
 
 SharedSurface_GLTexture*
 SharedSurface_GLTexture::Create(GLContext* prodGL,
                                 GLContext* consGL,
                                 const GLFormats& formats,
--- a/gfx/layers/YCbCrImageDataSerializer.cpp
+++ b/gfx/layers/YCbCrImageDataSerializer.cpp
@@ -10,19 +10,16 @@
 #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
@@ -244,31 +241,28 @@ YCbCrImageDataSerializer::CopyData(const
       CopyLineWithSkip(aCrData + i * aCbCrStride,
                        GetCrData() + i * GetCbCrStride(),
                        aCbCrSize.width, aCbCrSkip);
     }
   }
   return true;
 }
 
-TemporaryRef<DataSourceSurface>
+TemporaryRef<gfx::DataSourceSurface>
 YCbCrImageDataDeserializer::ToDataSourceSurface()
 {
-  RefPtr<DataSourceSurface> result =
-    Factory::CreateDataSourceSurface(GetYSize(), gfx::SurfaceFormat::R8G8B8X8);
-
-  DataSourceSurface::MappedSurface map;
-  result->Map(DataSourceSurface::MapType::WRITE, &map);
+  RefPtr<gfx::DataSourceSurface> result =
+    gfx::Factory::CreateDataSourceSurface(GetYSize(), gfx::SurfaceFormat::R8G8B8X8);
 
   gfx::ConvertYCbCrToRGB32(GetYData(), GetCbData(), GetCrData(),
-                           map.mData,
+                           result->GetData(),
                            0, 0, //pic x and y
                            GetYSize().width, GetYSize().height,
                            GetYStride(), GetCbCrStride(),
-                           map.mStride,
+                           result->Stride(),
                            gfx::YV12);
-  result->Unmap();
+  result->MarkDirty();
   return result.forget();
 }
 
 
 } // namespace
 } // namespace
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -1482,27 +1482,24 @@ 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(map.mData,
+    new gfxImageSurface(source->GetData(),
                         gfxIntSize(width, height),
-                        map.mStride,
+                        source->Stride(),
                         gfxImageFormatARGB32);
   ReadPixelsIntoImageSurface(mGLContext, surf);
-  source->Unmap();
+  source->MarkDirty();
 
   // 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();