author Kartikaya Gupta <>
Wed, 26 Apr 2017 16:37:15 -0400
changeset 568966 d8a7f08fe28de3c766ec2dbba74316ce75f82bad
parent 568965 c8996739dbc29d57c4f835e15f9ce9d64fdd7a7c
child 568833 9dcc152b2e5f0a15c30a3c3c94bd84967c6392c0
permissions -rw-r--r--
Bug 1359842 - Do some cleanup of GetWrRelBounds. r?nical This moves the bulk of the meaningful work done by GetWrRelBounds into strongly-typed helper functions. GetWrRelBounds is left as a wrapper so call sites don't need to be updated yet. Note also that the strongly-typed functions do not do any conversions from one reference point from another (e.g. by calling the RelativeToXXX functions). MozReview-Commit-ID: B3nPbOJOf9o

/* -*- Mode: C++; tab-width: 2; 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 */


#include "Layers.h"
#include "mozilla/webrender/WebRenderTypes.h"
#include "mozilla/webrender/WebRenderAPI.h"

namespace mozilla {
namespace layers {

class ImageClientSingle;
class WebRenderBridgeChild;
class WebRenderLayerManager;

typedef gfx::Matrix4x4Typed<LayerPixel, LayerPixel> BoundsTransformMatrix;

class WebRenderLayer
  virtual Layer* GetLayer() = 0;
  virtual void RenderLayer(wr::DisplayListBuilder& aBuilder) = 0;
  virtual Maybe<WrImageMask> RenderMaskLayer(const gfx::Matrix4x4& aTransform)
    return Nothing();

  virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() { return nullptr; }
  static inline WebRenderLayer*
  ToWebRenderLayer(Layer* aLayer)
    return static_cast<WebRenderLayer*>(aLayer->ImplData());

  Maybe<wr::ImageKey> UpdateImageKey(ImageClientSingle* aImageClient,
                                     ImageContainer* aContainer,
                                     Maybe<wr::ImageKey>& aOldKey,
                                     wr::ExternalImageId& aExternalImageId);

  WebRenderLayerManager* WrManager();
  WebRenderBridgeChild* WrBridge();
  WrImageKey GetImageKey();

  gfx::Rect RelativeToVisible(gfx::Rect aRect);
  gfx::Rect RelativeToTransformedVisible(gfx::Rect aRect);
  gfx::Rect ParentStackingContextBounds();
  gfx::Rect RelativeToParent(gfx::Rect aRect);
  gfx::Rect VisibleBoundsRelativeToParent();
  gfx::Point GetOffsetToParent();
  gfx::Rect TransformedVisibleBoundsRelativeToParent();
  LayerRect Bounds();
  BoundsTransformMatrix BoundsTransform();
  LayerRect BoundsForStackingContext();

  gfx::Rect GetWrBoundsRect();
  gfx::Rect GetWrRelBounds();
  gfx::Rect GetWrClipRect(gfx::Rect& aRect);
  void DumpLayerInfo(const char* aLayerType, gfx::Rect& aRect);
  Maybe<WrImageMask> BuildWrMaskLayer(bool aUnapplyLayerTransform);

} // namespace layers
} // namespace mozilla