Bug 1396489 - Part 2. Make gfxContext::GetClipExtents can return clipped rect in either user space or device space. draft
authorcku <cku@mozilla.com>
Mon, 04 Sep 2017 12:32:03 +0800
changeset 659013 3839dec3df9ed02a6c42576c1b2d51b3f5c1ee81
parent 659012 0caedc7f54f257bafad4964fd38ca7a432e88e58
child 659014 846e7bede82028a62ea71c13c7d807435815fa7e
child 659026 6cc88899806987bfc3bb73e90aa91b14bfb3c762
push id77980
push userbmo:cku@mozilla.com
push dateTue, 05 Sep 2017 10:11:55 +0000
bugs1396489
milestone57.0a1
Bug 1396489 - Part 2. Make gfxContext::GetClipExtents can return clipped rect in either user space or device space. MozReview-Commit-ID: 8orKmq1vz8K
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxContext.h
--- 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);