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
This commit is contained in:
Kartikaya Gupta 2017-04-27 12:04:12 -04:00
Родитель 6e24ccd51b
Коммит 72484c81d2
2 изменённых файлов: 27 добавлений и 9 удалений

Просмотреть файл

@ -11,6 +11,7 @@
#include "mozilla/layers/WebRenderBridgeChild.h"
#include "mozilla/layers/WebRenderLayerManager.h"
#include "nsThreadUtils.h"
#include "UnitTransforms.h"
namespace mozilla {
@ -144,27 +145,39 @@ WebRenderLayer::GetWrClipRect(gfx::Rect& aRect)
return clip;
}
gfx::Matrix4x4
WebRenderLayer::GetWrBoundTransform()
LayerRect
WebRenderLayer::Bounds()
{
return LayerRect(GetLayer()->GetVisibleRegion().GetBounds());
}
BoundsTransformMatrix
WebRenderLayer::BoundsTransform()
{
gfx::Matrix4x4 transform = GetLayer()->GetTransform();
transform._41 = 0.0f;
transform._42 = 0.0f;
transform._43 = 0.0f;
return transform;
return ViewAs<BoundsTransformMatrix>(transform);
}
gfx::Rect
WebRenderLayer::GetWrRelBounds()
LayerRect
WebRenderLayer::BoundsForStackingContext()
{
gfx::Rect bounds = IntRectToRect(GetLayer()->GetVisibleRegion().GetBounds().ToUnknownRect());
gfx::Matrix4x4 transform = GetWrBoundTransform();
LayerRect bounds = Bounds();
BoundsTransformMatrix transform = BoundsTransform();
if (!transform.IsIdentity()) {
// WR will only apply the 'translate' of the transform, so we need to do the scale/rotation manually.
bounds.MoveTo(transform.TransformPoint(bounds.TopLeft()));
}
return RelativeToParent(bounds);
return bounds;
}
gfx::Rect
WebRenderLayer::GetWrRelBounds()
{
return RelativeToParent(BoundsForStackingContext().ToUnknownRect());
}
Maybe<wr::ImageKey>

Просмотреть файл

@ -17,6 +17,8 @@ class ImageClientSingle;
class WebRenderBridgeChild;
class WebRenderLayerManager;
typedef gfx::Matrix4x4Typed<LayerPixel, LayerPixel> BoundsTransformMatrix;
class WebRenderLayer
{
public:
@ -52,10 +54,13 @@ public:
gfx::Point GetOffsetToParent();
gfx::Rect TransformedVisibleBoundsRelativeToParent();
protected:
LayerRect Bounds();
BoundsTransformMatrix BoundsTransform();
LayerRect BoundsForStackingContext();
gfx::Rect GetWrBoundsRect();
gfx::Rect GetWrRelBounds();
gfx::Rect GetWrClipRect(gfx::Rect& aRect);
gfx::Matrix4x4 GetWrBoundTransform();
void DumpLayerInfo(const char* aLayerType, gfx::Rect& aRect);
Maybe<WrImageMask> BuildWrMaskLayer(bool aUnapplyLayerTransform);
};