Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f587bfb authored by Chris Craik's avatar Chris Craik Committed by Android Git Automerger
Browse files

am 4c935068: am 41b43d7c: am 7b0fa466: am 0f724601: Merge "Fix clip area...

am 4c935068: am 41b43d7c: am 7b0fa466: am 0f724601: Merge "Fix clip area behavior for REPLACE op" into mnc-dev

* commit '4c935068':
  Fix clip area behavior for REPLACE op
parents ee924ded 4c935068
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -263,10 +263,11 @@ void ClipArea::enterRectangleMode() {
bool ClipArea::rectangleModeClipRectWithTransform(const Rect& r,
        const mat4* transform, SkRegion::Op op) {

    // TODO: we should be able to handle kReplace_Op efficiently without
    // going through RegionMode and later falling back into RectangleMode.

    if (op != SkRegion::kIntersect_Op) {
    if (op == SkRegion::kReplace_Op && transform->rectToRect()) {
        mClipRect = r;
        transform->mapRect(mClipRect);
        return true;
    } else if (op != SkRegion::kIntersect_Op) {
        enterRegionMode();
        return regionModeClipRectWithTransform(r, transform, op);
    }
+2 −0
Original line number Diff line number Diff line
@@ -153,6 +153,8 @@ private:
    }

    void regionFromPath(const SkPath& path, SkRegion& pathAsRegion) {
        // TODO: this should not mask every path to the viewport - this makes it impossible to use
        // paths to clip to larger areas (which is valid e.g. with SkRegion::kReplace_Op)
        pathAsRegion.setPath(path, createViewportRegion());
    }

+11 −0
Original line number Diff line number Diff line
@@ -112,5 +112,16 @@ TEST(ClipArea, paths) {
    regionBounds.set(skRect);
    EXPECT_EQ(expected, regionBounds);
}

TEST(ClipArea, replaceNegative) {
    ClipArea area(createClipArea());
    area.setClip(0, 0, 100, 100);

    Matrix4 transform;
    transform.loadIdentity();
    Rect expected(-50, -50, 50, 50);
    area.clipRectWithTransform(expected, &transform, SkRegion::kReplace_Op);
    EXPECT_EQ(expected, area.getClipRect());
}
}
}