Bug 1200595 - MacIOSurface TextureData implementation. r=mattwoodrow
☠☠ backed out by 027edbd76ba2 ☠ ☠
authorNicolas Silva <nsilva@mozilla.com>
Fri, 20 Nov 2015 14:24:46 +0100
changeset 273544 b555b130d43920794b4bace4b9644decc3daec2b
parent 273543 6819f6d822879048b530f4dd8e937822c8607583
child 273545 09e71ba15ea8cbdb96889b320a5e3e86d8e17490
push id29705
push userkwierso@gmail.com
push dateFri, 20 Nov 2015 22:36:48 +0000
treeherdermozilla-central@e3d9cf3dc326 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1200595
milestone45.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 1200595 - MacIOSurface TextureData implementation. r=mattwoodrow
gfx/layers/MacIOSurfaceImage.cpp
gfx/layers/opengl/MacIOSurfaceTextureClientOGL.cpp
gfx/layers/opengl/MacIOSurfaceTextureClientOGL.h
--- a/gfx/layers/MacIOSurfaceImage.cpp
+++ b/gfx/layers/MacIOSurfaceImage.cpp
@@ -13,19 +13,21 @@
 using namespace mozilla;
 using namespace mozilla::layers;
 using namespace mozilla::gfx;
 
 TextureClient*
 MacIOSurfaceImage::GetTextureClient(CompositableClient* aClient)
 {
   if (!mTextureClient) {
-    mTextureClient = MacIOSurfaceTextureClientOGL::Create(aClient->GetForwarder(),
-                                                          TextureFlags::DEFAULT,
-                                                          mSurface);
+    mTextureClient = TextureClient::CreateWithData(
+      MacIOSurfaceTextureData::Create(mSurface),
+      TextureFlags::DEFAULT,
+      aClient->GetForwarder()
+    );
   }
   return mTextureClient;
 }
 
 already_AddRefed<SourceSurface>
 MacIOSurfaceImage::GetAsSourceSurface()
 {
   RefPtr<DataSourceSurface> dataSurface;
--- a/gfx/layers/opengl/MacIOSurfaceTextureClientOGL.cpp
+++ b/gfx/layers/opengl/MacIOSurfaceTextureClientOGL.cpp
@@ -1,92 +1,69 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MacIOSurfaceTextureClientOGL.h"
-#include "mozilla/gfx/MacIOSurface.h"
+#include "mozilla/gfx/MacIOSurface.h" 
 
 namespace mozilla {
 namespace layers {
 
-MacIOSurfaceTextureClientOGL::MacIOSurfaceTextureClientOGL(ISurfaceAllocator* aAllcator,
-                                                           TextureFlags aFlags)
-  : TextureClient(aAllcator, aFlags)
-  , mIsLocked(false)
+MacIOSurfaceTextureData::MacIOSurfaceTextureData(MacIOSurface* aSurface)
+: mSurface(aSurface)
+{
+  MOZ_ASSERT(mSurface);
+}
+
+MacIOSurfaceTextureData::~MacIOSurfaceTextureData()
 {}
 
-MacIOSurfaceTextureClientOGL::~MacIOSurfaceTextureClientOGL()
+void
+MacIOSurfaceTextureData::FinalizeOnIPDLThread(TextureClient* aWrapper)
 {
-}
-
-void
-MacIOSurfaceTextureClientOGL::FinalizeOnIPDLThread()
-{
-  if (mActor && mSurface) {
-    KeepUntilFullDeallocation(MakeUnique<TKeepAlive<MacIOSurface>>(mSurface));
+  if (mSurface) {
+    aWrapper->KeepUntilFullDeallocation(MakeUnique<TKeepAlive<MacIOSurface>>(mSurface));
   }
 }
 
 // static
-already_AddRefed<MacIOSurfaceTextureClientOGL>
-MacIOSurfaceTextureClientOGL::Create(ISurfaceAllocator* aAllocator,
-                                     TextureFlags aFlags,
-                                     MacIOSurface* aSurface)
+MacIOSurfaceTextureData*
+MacIOSurfaceTextureData::Create(MacIOSurface* aSurface)
 {
-  RefPtr<MacIOSurfaceTextureClientOGL> texture =
-      new MacIOSurfaceTextureClientOGL(aAllocator, aFlags);
-  MOZ_ASSERT(texture->IsValid());
-  MOZ_ASSERT(!texture->IsAllocated());
-  texture->mSurface = aSurface;
-  return texture.forget();
+  MOZ_ASSERT(aSurface);
+  if (!aSurface) {
+    return nullptr;
+  }
+  return new MacIOSurfaceTextureData(aSurface);
 }
 
 bool
-MacIOSurfaceTextureClientOGL::Lock(OpenMode aMode)
-{
-  MOZ_ASSERT(!mIsLocked);
-  mIsLocked = true;
-  return IsValid() && IsAllocated();
-}
-
-void
-MacIOSurfaceTextureClientOGL::Unlock()
+MacIOSurfaceTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
 {
-  MOZ_ASSERT(mIsLocked);
-  mIsLocked = false;
-}
-
-bool
-MacIOSurfaceTextureClientOGL::IsLocked() const
-{
-  return mIsLocked;
-}
-
-bool
-MacIOSurfaceTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
-{
-  MOZ_ASSERT(IsValid());
-  if (!IsAllocated()) {
-    return false;
-  }
   aOutDescriptor = SurfaceDescriptorMacIOSurface(mSurface->GetIOSurfaceID(),
                                                  mSurface->GetContentsScaleFactor(),
                                                  !mSurface->HasAlpha());
   return true;
 }
 
 gfx::IntSize
-MacIOSurfaceTextureClientOGL::GetSize() const
+MacIOSurfaceTextureData::GetSize() const
 {
   return gfx::IntSize(mSurface->GetDevicePixelWidth(), mSurface->GetDevicePixelHeight());
 }
 
+gfx::SurfaceFormat
+MacIOSurfaceTextureData::GetFormat() const
+{
+  return mSurface->GetFormat();
+}
+
 already_AddRefed<gfx::DataSourceSurface>
-MacIOSurfaceTextureClientOGL::GetAsSurface()
+MacIOSurfaceTextureData::GetAsSurface()
 {
   RefPtr<gfx::SourceSurface> surf = mSurface->GetAsSurface();
   return surf->GetDataSurface();
 }
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/opengl/MacIOSurfaceTextureClientOGL.h
+++ b/gfx/layers/opengl/MacIOSurfaceTextureClientOGL.h
@@ -8,55 +8,46 @@
 
 #include "mozilla/layers/TextureClientOGL.h"
 
 class MacIOSurface;
 
 namespace mozilla {
 namespace layers {
 
-class MacIOSurfaceTextureClientOGL : public TextureClient
+class MacIOSurfaceTextureData : public TextureData
 {
 public:
-  explicit MacIOSurfaceTextureClientOGL(ISurfaceAllocator* aAllcator,
-                                        TextureFlags aFlags);
-
-  virtual ~MacIOSurfaceTextureClientOGL();
+  static MacIOSurfaceTextureData* Create(MacIOSurface* aSurface);
 
-  // Creates a TextureClient and init width.
-  static already_AddRefed<MacIOSurfaceTextureClientOGL>
-  Create(ISurfaceAllocator* aAllocator,
-         TextureFlags aFlags,
-         MacIOSurface* aSurface);
-
-  virtual bool Lock(OpenMode aMode) override;
-
-  virtual void Unlock() override;
-
-  virtual bool IsLocked() const override;
-
-  virtual bool IsAllocated() const override { return !!mSurface; }
-
-  virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) override;
+  ~MacIOSurfaceTextureData();
 
   virtual gfx::IntSize GetSize() const override;
 
+  virtual gfx::SurfaceFormat GetFormat() const override;
+
+  virtual bool Lock(OpenMode, FenceHandle*) override { return true; }
+
+  virtual void Unlock() override {}
+
+  virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
+
   virtual bool HasInternalBuffer() const override { return false; }
 
-  virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
+  virtual void Deallocate(ISurfaceAllocator* aAllocator) override { mSurface = nullptr; }
 
-  // This TextureClient should not be used in a context where we use CreateSimilar
-  // (ex. component alpha) because the underlying texture data is always created by
-  // an external producer.
-  virtual already_AddRefed<TextureClient>
-  CreateSimilar(TextureFlags, TextureAllocationFlags) const override { return nullptr; }
+  virtual void Forget(ISurfaceAllocator* aAllocator) override { mSurface = nullptr; }
+
+  // For debugging purposes only.
+  already_AddRefed<gfx::DataSourceSurface> GetAsSurface();
 
 protected:
-  virtual void FinalizeOnIPDLThread() override;
+  explicit MacIOSurfaceTextureData(MacIOSurface* aSurface);
+
+  virtual void FinalizeOnIPDLThread(TextureClient* aWrapper) override;
 
   RefPtr<MacIOSurface> mSurface;
-  bool mIsLocked;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif // MOZILLA_GFX_MACIOSURFACETEXTURECLIENTOGL_H