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

Commit 388e43f4 authored by Chris Craik's avatar Chris Craik Committed by Android (Google) Code Review
Browse files

Merge "Fix drawColor/drawPaint bounds" into nyc-dev

parents a3eccfb8 1713c777
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -241,10 +241,13 @@ void RecordingCanvas::drawColor(int color, SkXfermode::Mode mode) {
}

void RecordingCanvas::drawPaint(const SkPaint& paint) {
    const ClipBase* clip = getRecordedClip();
    // if there's no current clip, draw a big rect and hope we cover the eventual clip bounds
    Rect bounds = clip ? clip->rect : Rect(-10000, -10000, 10000, 10000);
    addOp(alloc().create_trivial<RectOp>(
            mState.getRenderTargetClipBounds(), // OK, since we've not passed transform
            bounds,
            Matrix4::identity(),
            getRecordedClip(),
            clip,
            refPaint(&paint)));
}

+14 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <RecordedOp.h>
#include <RecordingCanvas.h>
#include <tests/common/TestUtils.h>
#include <utils/Color.h>

namespace android {
namespace uirenderer {
@@ -185,6 +186,19 @@ TEST(RecordingCanvas, drawText_forceAlignLeft) {
    ASSERT_EQ(3, count);
}

TEST(RecordingCanvas, drawColor) {
    auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200, [](RecordingCanvas& canvas) {
        canvas.drawColor(Color::Black, SkXfermode::kSrcOver_Mode);
    });

    ASSERT_EQ(1u, dl->getOps().size()) << "Must be exactly one op";
    auto op = *(dl->getOps()[0]);
    EXPECT_EQ(RecordedOpId::RectOp, op.opId);
    EXPECT_EQ(nullptr, op.localClip);
    EXPECT_TRUE(op.unmappedBounds.contains(Rect(-1000, -1000, 1000, 1000)))
            << "no clip, unmappedBounds should resolve to be much larger than DL bounds";
}

TEST(RecordingCanvas, backgroundAndImage) {
    auto dl = TestUtils::createDisplayList<RecordingCanvas>(100, 200, [](RecordingCanvas& canvas) {
        SkBitmap bitmap;