Bug 1155495 - Part 2: Remove unnecessary class inheritance and casting. r=nical, r=sotaro
authorJeremy Chen <jeremychen@mozilla.com>
Wed, 20 May 2015 01:43:00 -0400
changeset 265215 a8d45d284f81abf5040551c689478bf01ff4235a
parent 265214 b8e8e84f21e13eb6e4734a22bf2597cfa7fa7fac
child 265216 fbe9d8ab5fca99b00403996d5dab529b959adb7d
push id8157
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:36:23 +0000
treeherdermozilla-aurora@d480e05bd276 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical, sotaro
bugs1155495
milestone41.0a1
Bug 1155495 - Part 2: Remove unnecessary class inheritance and casting. r=nical, r=sotaro
gfx/layers/composite/TextureHost.h
gfx/layers/ipc/CompositableTransactionParent.cpp
gfx/layers/opengl/GrallocTextureHost.h
widget/gonk/HwcComposer2D.cpp
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -493,21 +493,16 @@ public:
 
   /**
    * Indicates whether the TextureHost implementation is backed by an
    * in-memory buffer. The consequence of this is that locking the
    * TextureHost does not contend with locking the texture on the client side.
    */
   virtual bool HasInternalBuffer() const { return false; }
 
-  /**
-   * Cast to a TextureHost for each backend.
-   */
-  virtual TextureHostOGL* AsHostOGL() { return nullptr; }
-
   void AddCompositableRef() { ++mCompositableCount; }
 
   void ReleaseCompositableRef()
   {
     --mCompositableCount;
     MOZ_ASSERT(mCompositableCount >= 0);
     if (mCompositableCount == 0) {
       UnbindTextureSource();
--- a/gfx/layers/ipc/CompositableTransactionParent.cpp
+++ b/gfx/layers/ipc/CompositableTransactionParent.cpp
@@ -174,20 +174,17 @@ CompositableParentManager::ReceiveCompos
 
       MOZ_ASSERT(tex.get());
       compositable->UseTextureHost(tex);
 
       MaybeFence maybeFence = op.fence();
       if (maybeFence.type() == MaybeFence::TFenceHandle) {
         FenceHandle fence = maybeFence.get_FenceHandle();
         if (fence.IsValid() && tex) {
-          TextureHostOGL* hostOGL = tex->AsHostOGL();
-          if (hostOGL) {
-            hostOGL->SetAcquireFence(fence);
-          }
+          tex->SetAcquireFenceHandle(fence);
         }
       }
 
       if (IsAsync() && compositable->GetLayer()) {
         ScheduleComposition(op);
         // Async layer updates don't trigger invalidation, manually tell the layer
         // that its content have changed.
         compositable->GetLayer()->SetInvalidRectToVisibleRegion();
--- a/gfx/layers/opengl/GrallocTextureHost.h
+++ b/gfx/layers/opengl/GrallocTextureHost.h
@@ -11,17 +11,16 @@
 #include "mozilla/layers/TextureHostOGL.h"
 #include "mozilla/layers/ShadowLayerUtilsGralloc.h"
 #include <ui/GraphicBuffer.h>
 
 namespace mozilla {
 namespace layers {
 
 class GrallocTextureHostOGL : public TextureHost
-                            , public TextureHostOGL
 {
   friend class GrallocBufferActor;
 public:
   GrallocTextureHostOGL(TextureFlags aFlags,
                         const NewSurfaceDescriptorGralloc& aDescriptor);
 
   virtual ~GrallocTextureHostOGL();
 
@@ -46,23 +45,16 @@ public:
   virtual LayerRenderState GetRenderState() override;
 
   virtual void PrepareTextureSource(CompositableTextureSourceRef& aTextureSource) override;
 
   virtual bool BindTextureSource(CompositableTextureSourceRef& aTextureSource) override;
 
   virtual void UnbindTextureSource() override;
 
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-  virtual TextureHostOGL* AsHostOGL() override
-  {
-    return this;
-  }
-#endif
-
   virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() override;
 
   virtual void WaitAcquireFenceHandleSyncComplete() override;
 
   bool IsValid() const;
 
   virtual const char* Name() override { return "GrallocTextureHostOGL"; }
 
--- a/widget/gonk/HwcComposer2D.cpp
+++ b/widget/gonk/HwcComposer2D.cpp
@@ -853,21 +853,17 @@ HwcComposer2D::Commit()
         if (mHwcLayerMap.IsEmpty() ||
             (mList->hwLayers[j].compositionType == HWC_FRAMEBUFFER)) {
             continue;
         }
         LayerRenderState state = mHwcLayerMap[j]->GetLayer()->GetRenderState();
         if (!state.mTexture) {
             continue;
         }
-        TextureHostOGL* texture = state.mTexture->AsHostOGL();
-        if (!texture) {
-            continue;
-        }
-        FenceHandle fence = texture->GetAndResetAcquireFence();
+        FenceHandle fence = state.mTexture->GetAndResetAcquireFenceHandle();
         if (fence.IsValid()) {
             nsRefPtr<FenceHandle::FdObj> fdObj = fence.GetAndResetFdObj();
             mList->hwLayers[j].acquireFenceFd = fdObj->GetAndResetFd();
         }
     }
 
     int err = mHwc->set(mHwc, HWC_NUM_DISPLAY_TYPES, displays);
 
@@ -879,21 +875,17 @@ HwcComposer2D::Commit()
             mList->hwLayers[j].releaseFenceFd = -1;
             nsRefPtr<FenceHandle::FdObj> fdObj = new FenceHandle::FdObj(fd);
             FenceHandle fence(fdObj);
 
             LayerRenderState state = mHwcLayerMap[j]->GetLayer()->GetRenderState();
             if (!state.mTexture) {
                 continue;
             }
-            TextureHostOGL* texture = state.mTexture->AsHostOGL();
-            if (!texture) {
-                continue;
-            }
-            texture->SetReleaseFence(fence);
+            state.mTexture->SetReleaseFenceHandle(fence);
         }
     }
 
     if (mList->retireFenceFd >= 0) {
         mPrevRetireFence = FenceHandle(new FenceHandle::FdObj(mList->retireFenceFd));
     }
 
     mPrepared = false;