Bug 1396489 - Part 2. Make gfxContext::GetClipExtents can return clipped rect in either user space or device space.
MozReview-Commit-ID: 8orKmq1vz8K
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -590,27 +590,29 @@ gfxContext::PopClip()
{
MOZ_ASSERT(CurrentState().pushedClips.Length() > 0);
CurrentState().pushedClips.RemoveElementAt(CurrentState().pushedClips.Length() - 1);
mDT->PopClip();
}
gfxRect
-gfxContext::GetClipExtents() const
+gfxContext::GetClipExtents(ClipExtentsSpace aSpace) const
{
Rect rect = GetAzureDeviceSpaceClipBounds();
if (rect.width == 0 || rect.height == 0) {
return gfxRect(0, 0, 0, 0);
}
- Matrix mat = mTransform;
- mat.Invert();
- rect = mat.TransformBounds(rect);
+ if (aSpace == eUserSpace) {
+ Matrix mat = mTransform;
+ mat.Invert();
+ rect = mat.TransformBounds(rect);
+ }
return ThebesRect(rect);
}
bool
gfxContext::ExportClip(ClipExporter& aExporter)
{
for (unsigned int i = 0; i < mStateStack.Length(); i++) {
--- a/gfx/thebes/gfxContext.h
+++ b/gfx/thebes/gfxContext.h
@@ -372,21 +372,26 @@ public:
* Any current path will be destroyed by these functions!
*/
void Clip(const Rect& rect);
void Clip(const gfxRect& rect); // will clip to a rect
void Clip(Path* aPath);
void PopClip();
+ enum ClipExtentsSpace {
+ eUserSpace = 0,
+ eDeviceSpace = 1,
+ };
+
/**
- * This will return the current bounds of the clip region in user
- * space.
+ * According to aSpace, this function will return the current bounds of
+ * the clip region in user space or device space.
*/
- gfxRect GetClipExtents() const;
+ gfxRect GetClipExtents(ClipExtentsSpace aSpace = eUserSpace) const;
/**
* Returns true if the given rectangle is fully contained in the current clip.
* This is conservative; it may return false even when the given rectangle is
* fully contained by the current clip.
*/
bool ClipContainsRect(const gfxRect& aRect);