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

Commit 261725fd authored by Chris Craik's avatar Chris Craik
Browse files

Fix matrix mapping of negative rects

bug:27381362

Also rejects ops with empty clip at record time, and short circuits clip
intersection, when one is empty.

Change-Id: I842612da14ad8fd9f1ba5e9e4fd027ba4e08d365
parent eefb17ac
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -242,6 +242,7 @@ LOCAL_SRC_FILES += \
    tests/unit/GpuMemoryTrackerTests.cpp \
    tests/unit/LayerUpdateQueueTests.cpp \
    tests/unit/LinearAllocatorTests.cpp \
    tests/unit/MatrixTests.cpp \
    tests/unit/OffscreenBufferPoolTests.cpp \
    tests/unit/SkiaBehaviorTests.cpp \
    tests/unit/StringUtilsTests.cpp \
+6 −0
Original line number Diff line number Diff line
@@ -404,11 +404,17 @@ static bool cannotFitInRectangleList(const ClipArea& clipArea, const ClipBase* s
    return currentRectCount + recordedRectCount > RectangleList::kMaxTransformedRectangles;
}

static const ClipRect sEmptyClipRect(Rect(0, 0));

const ClipBase* ClipArea::serializeIntersectedClip(LinearAllocator& allocator,
        const ClipBase* recordedClip, const Matrix4& recordedClipTransform) {

    // if no recordedClip passed, just serialize current state
    if (!recordedClip) return serializeClip(allocator);

    // if either is empty, clip is empty
    if (CC_UNLIKELY(recordedClip->rect.isEmpty())|| mClipRect.isEmpty()) return &sEmptyClipRect;

    if (!mLastResolutionResult
            || recordedClip != mLastResolutionClip
            || recordedClipTransform != mLastResolutionTransform) {
+1 −1
Original line number Diff line number Diff line
@@ -438,7 +438,7 @@ void Matrix4::mapPoint(float& x, float& y) const {
}

void Matrix4::mapRect(Rect& r) const {
    if (isIdentity()) return;
    if (isIdentity() || r.isEmpty()) return;

    if (isSimple()) {
        MUL_ADD_STORE(r.left, data[kScaleX], data[kTranslateX]);
+8 −1
Original line number Diff line number Diff line
@@ -594,7 +594,14 @@ void RecordingCanvas::callDrawGLFunction(Functor* functor) {
}

size_t RecordingCanvas::addOp(RecordedOp* op) {
    // TODO: validate if "addDrawOp" quickrejection logic is useful before adding
    // skip op with empty clip
    if (op->localClip && op->localClip->rect.isEmpty()) {
        // NOTE: this rejection happens after op construction/content ref-ing, so content ref'd
        // and held by renderthread isn't affected by clip rejection.
        // Could rewind alloc here if desired, but callers would have to not touch op afterwards.
        return -1;
    }

    int insertIndex = mDisplayList->ops.size();
    mDisplayList->ops.push_back(op);
    if (mDeferredBarrierType != DeferredBarrierType::None) {
+1 −0
Original line number Diff line number Diff line
@@ -228,6 +228,7 @@ TEST(ClipArea, serializeIntersectedClip) {

        ClipRegion recordedClip;
        recordedClip.region.setPath(ovalPath, SkRegion(SkIRect::MakeWH(200, 200)));
        recordedClip.rect = Rect(200, 200);

        Matrix4 translate10x20;
        translate10x20.loadTranslate(10, 20, 0);
Loading