Bug 1376855 - Removed unused variables and interfaces. r=kats draft
authorMorris Tseng <mtseng@mozilla.com>
Wed, 28 Jun 2017 13:42:24 -0700
changeset 603975 d653be78c0f7e47b284bb48ed2f36be0139816cd
parent 603974 2cd1deabc0d4b90a51a4566d83bc974527711603
child 636055 887378a9f644e8b1640ce04c475f062dade75368
push id66921
push userbmo:mtseng@mozilla.com
push dateWed, 05 Jul 2017 03:31:35 +0000
reviewerskats
bugs1376855
milestone56.0a1
Bug 1376855 - Removed unused variables and interfaces. r=kats MozReview-Commit-ID: 5rPI7jNI94K
gfx/layers/wr/WebRenderDisplayItemLayer.cpp
gfx/layers/wr/WebRenderDisplayItemLayer.h
layout/painting/nsDisplayList.cpp
layout/painting/nsDisplayList.h
--- a/gfx/layers/wr/WebRenderDisplayItemLayer.cpp
+++ b/gfx/layers/wr/WebRenderDisplayItemLayer.cpp
@@ -7,32 +7,25 @@
 
 #include "LayersLogging.h"
 #include "mozilla/webrender/webrender_ffi.h"
 #include "mozilla/webrender/WebRenderTypes.h"
 #include "mozilla/layers/ScrollingLayersHelper.h"
 #include "mozilla/layers/StackingContextHelper.h"
 #include "mozilla/layers/WebRenderBridgeChild.h"
 #include "nsDisplayList.h"
-#include "mozilla/gfx/DrawEventRecorder.h"
 #include "mozilla/gfx/Matrix.h"
 #include "UnitTransforms.h"
 
 namespace mozilla {
 namespace layers {
 
 WebRenderDisplayItemLayer::~WebRenderDisplayItemLayer()
 {
   MOZ_COUNT_DTOR(WebRenderDisplayItemLayer);
-  if (mKey.isSome()) {
-    WrManager()->AddImageKeyForDiscard(mKey.value());
-  }
-  if (mExternalImageId.isSome()) {
-    WrBridge()->DeallocExternalImageId(mExternalImageId.ref());
-  }
 }
 
 void
 WebRenderDisplayItemLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
                                        const StackingContextHelper& aSc)
 {
   if (mVisibleRegion.IsEmpty()) {
     return;
@@ -41,24 +34,18 @@ WebRenderDisplayItemLayer::RenderLayer(w
   ScrollingLayersHelper scroller(this, aBuilder, aSc);
 
   if (mItem) {
     WrSize contentSize; // this won't actually be used by anything
     wr::DisplayListBuilder builder(WrBridge()->GetPipeline(), contentSize);
     // We might have recycled this layer. Throw away the old commands.
     mParentCommands.Clear();
 
-    // TODO: Remove the old interface once we add support for image type display items.
-    if (mItem->GetType() == nsDisplayItem::TYPE_BACKGROUND ||
-        mItem->GetType() == nsDisplayItem::TYPE_BULLET) {
-      mItem->CreateWebRenderCommand(builder, aSc, mParentCommands, this);
-    } else {
-      mItem->CreateWebRenderCommands(builder, aSc, mParentCommands, WrManager(),
-                                     GetDisplayListBuilder());
-    }
+    mItem->CreateWebRenderCommands(builder, aSc, mParentCommands, WrManager(),
+                                   GetDisplayListBuilder());
     builder.Finalize(contentSize, mBuiltDisplayList);
   } else {
     // else we have an empty transaction and just use the
     // old commands.
     WebRenderLayerManager* manager = WrManager();
     MOZ_ASSERT(manager);
 
     // Since our recording relies on our parent layer's transform and stacking context
@@ -68,95 +55,10 @@ WebRenderDisplayItemLayer::RenderLayer(w
       return;
     }
   }
 
   aBuilder.PushBuiltDisplayList(mBuiltDisplayList);
   WrBridge()->AddWebRenderParentCommands(mParentCommands);
 }
 
-Maybe<wr::ImageKey>
-WebRenderDisplayItemLayer::SendImageContainer(ImageContainer* aContainer,
-                                              nsTArray<layers::WebRenderParentCommand>& aParentCommands)
-{
-  MOZ_ASSERT(aContainer);
-
-  if (mImageContainer != aContainer) {
-    AutoLockImage autoLock(aContainer);
-    Image* image = autoLock.GetImage();
-    if (!image) {
-      return Nothing();
-    }
-
-    if (!mImageClient) {
-      mImageClient = ImageClient::CreateImageClient(CompositableType::IMAGE,
-                                                    WrBridge(),
-                                                    TextureFlags::DEFAULT);
-      if (!mImageClient) {
-        return Nothing();
-      }
-      mImageClient->Connect();
-    }
-
-    if (mExternalImageId.isNothing()) {
-      MOZ_ASSERT(mImageClient);
-      mExternalImageId = Some(WrBridge()->AllocExternalImageIdForCompositable(mImageClient));
-    }
-    MOZ_ASSERT(mExternalImageId.isSome());
-    MOZ_ASSERT(mImageClient->AsImageClientSingle());
-
-    mKey = UpdateImageKey(mImageClient->AsImageClientSingle(),
-                          aContainer,
-                          mKey,
-                          mExternalImageId.ref());
-
-    mImageContainer = aContainer;
-  }
-
-  return mKey;
-}
-
-bool
-WebRenderDisplayItemLayer::PushItemAsBlobImage(wr::DisplayListBuilder& aBuilder,
-                                               const StackingContextHelper& aSc)
-{
-  const int32_t appUnitsPerDevPixel = mItem->Frame()->PresContext()->AppUnitsPerDevPixel();
-
-  bool snap;
-  LayerRect bounds = ViewAs<LayerPixel>(
-      LayoutDeviceRect::FromAppUnits(mItem->GetBounds(mBuilder, &snap), appUnitsPerDevPixel),
-      PixelCastJustification::WebRenderHasUnitResolution);
-  LayerIntSize imageSize = RoundedToInt(bounds.Size());
-  LayerRect imageRect;
-  imageRect.SizeTo(LayerSize(imageSize));
-
-  RefPtr<gfx::DrawEventRecorderMemory> recorder = MakeAndAddRef<gfx::DrawEventRecorderMemory>();
-  RefPtr<gfx::DrawTarget> dummyDt =
-    gfx::Factory::CreateDrawTarget(gfx::BackendType::SKIA, gfx::IntSize(1, 1), gfx::SurfaceFormat::B8G8R8X8);
-  RefPtr<gfx::DrawTarget> dt = gfx::Factory::CreateRecordingDrawTarget(recorder, dummyDt, imageSize.ToUnknownSize());
-  LayerPoint offset = ViewAs<LayerPixel>(
-      LayoutDevicePoint::FromAppUnits(mItem->ToReferenceFrame(), appUnitsPerDevPixel),
-      PixelCastJustification::WebRenderHasUnitResolution);
-
-  {
-    dt->ClearRect(imageRect.ToUnknownRect());
-    RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt, offset.ToUnknownPoint());
-    MOZ_ASSERT(context);
-
-    mItem->Paint(mBuilder, context);
-  }
-
-  wr::ByteBuffer bytes(recorder->mOutputStream.mLength, (uint8_t*)recorder->mOutputStream.mData);
-
-  WrRect dest = aSc.ToRelativeWrRect(imageRect + offset);
-  WrImageKey key = GetImageKey();
-  WrBridge()->SendAddBlobImage(key, imageSize.ToUnknownSize(), imageSize.width * 4, dt->GetFormat(), bytes);
-  WrManager()->AddImageKeyForDiscard(key);
-
-  aBuilder.PushImage(dest,
-                     dest,
-                     wr::ImageRendering::Auto,
-                     key);
-  return true;
-}
-
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/wr/WebRenderDisplayItemLayer.h
+++ b/gfx/layers/wr/WebRenderDisplayItemLayer.h
@@ -21,34 +21,25 @@ class WebRenderDisplayItemLayer : public
                                   public DisplayItemLayer {
 public:
   explicit WebRenderDisplayItemLayer(WebRenderLayerManager* aLayerManager)
     : DisplayItemLayer(aLayerManager, static_cast<WebRenderLayer*>(this))
   {
     MOZ_COUNT_CTOR(WebRenderDisplayItemLayer);
   }
 
-  Maybe<wr::ImageKey> SendImageContainer(ImageContainer* aContainer,
-                                         nsTArray<layers::WebRenderParentCommand>& aParentCommands);
-  bool PushItemAsBlobImage(wr::DisplayListBuilder& aBuilder,
-                           const StackingContextHelper& aSc);
-
 protected:
   virtual ~WebRenderDisplayItemLayer();
 
 public:
   Layer* GetLayer() override { return this; }
   void RenderLayer(wr::DisplayListBuilder& aBuilder,
                    const StackingContextHelper& aHelper) override;
 
 private:
   wr::BuiltDisplayList mBuiltDisplayList;
   nsTArray<WebRenderParentCommand> mParentCommands;
-  RefPtr<ImageClient> mImageClient;
-  RefPtr<ImageContainer> mImageContainer;
-  wr::MaybeExternalImageId mExternalImageId;
-  Maybe<wr::ImageKey> mKey;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif // GFX_WEBRENDERDisplayItemLayer_H
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -3557,41 +3557,16 @@ nsDisplayBackgroundImage::CreateWebRende
   DrawResult result =
     nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayer(params, aBuilder, aSc, aParentCommands, nullptr, aManager, this);
   nsDisplayBackgroundGeometry::UpdateDrawResult(this, result);
 
   return true;
 }
 
 void
-nsDisplayBackgroundImage::CreateWebRenderCommand(wr::DisplayListBuilder& aBuilder,
-                                                 const StackingContextHelper& aSc,
-                                                 nsTArray<WebRenderParentCommand>& aParentCommands,
-                                                 WebRenderDisplayItemLayer* aLayer)
-{
-  nsCSSRendering::PaintBGParams params =
-    nsCSSRendering::PaintBGParams::ForSingleLayer(*StyleFrame()->PresContext(),
-                                                  mVisibleRect, mBackgroundRect,
-                                                  StyleFrame(), mImageFlags, mLayer,
-                                                  CompositionOp::OP_OVER);
-  params.bgClipRect = &mBounds;
-
-  DrawResult result =
-    nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayer(params,
-                                                                 aBuilder,
-                                                                 aSc,
-                                                                 aParentCommands,
-                                                                 aLayer,
-                                                                 aLayer->WrManager(),
-                                                                 this);
-
-  nsDisplayBackgroundGeometry::UpdateDrawResult(this, result);
-}
-
-void
 nsDisplayBackgroundImage::HitTest(nsDisplayListBuilder* aBuilder,
                                   const nsRect& aRect,
                                   HitTestState* aState,
                                   nsTArray<nsIFrame*> *aOutFrames)
 {
   if (RoundedBorderIntersectsRect(mFrame, ToReferenceFrame(), aRect)) {
     aOutFrames->AppendElement(mFrame);
   }
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -1946,27 +1946,17 @@ public:
    * constructed.
    */
   virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
                                              LayerManager* aManager,
                                              const ContainerLayerParameters& aContainerParameters)
   { return nullptr; }
 
   /**
-    * Create the WebRenderCommands required to paint this display item.
-    * The layer this item is in is passed in as rects must be relative
-    * to their parent.
-    */
-   virtual void CreateWebRenderCommand(mozilla::wr::DisplayListBuilder& aBuilder,
-                                       const StackingContextHelper& aSc,
-                                       nsTArray<WebRenderParentCommand>& aParentCommands,
-                                       WebRenderDisplayItemLayer* aLayer) {}
-
-  /**
-    * Alternate function to create the WebRenderCommands without
+    * Function to create the WebRenderCommands without
     * Layer. For layers mode, aManager->IsLayersFreeTransaction()
     * should be false to prevent doing GetLayerState again. For
     * layers-free mode, we should check if the layer state is
     * active first and have an early return if the layer state is
     * not active.
     *
     * @return true if successfully creating webrender commands.
     */
@@ -3124,20 +3114,16 @@ public:
   virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
                                    LayerManager* aManager,
                                    const ContainerLayerParameters& aParameters) override;
 
   virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
                                              LayerManager* aManager,
                                              const ContainerLayerParameters& aContainerParameters) override;
 
-  virtual void CreateWebRenderCommand(mozilla::wr::DisplayListBuilder& aBuilder,
-                                      const StackingContextHelper& aSc,
-                                      nsTArray<WebRenderParentCommand>& aParentCommands,
-                                      WebRenderDisplayItemLayer* aLayer) override;
   virtual bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
                                        const StackingContextHelper& aSc,
                                        nsTArray<WebRenderParentCommand>& aParentCommands,
                                        mozilla::layers::WebRenderLayerManager* aManager,
                                        nsDisplayListBuilder* aDisplayListBuilder) override;
   virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
                        HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) override;
   virtual bool ComputeVisibility(nsDisplayListBuilder* aBuilder,