Support Canvas Clip on Blit Framebuffer
The previous fix to blit framebuffer didn't take cases where
the canvas had a clip applied into account. Fix and update
the unit test to add this case.
Bug: 658277
Change-Id: If3a9d2c8ddf955164cf529c9d6036618f957e426
Reviewed-on: https://skia-review.googlesource.com/11300
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index af17e5b..8ef09a4 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -1746,15 +1746,15 @@
}
}
- SkIRect copyRect;
- clip.getConservativeBounds(rt->width(), rt->height(), ©Rect);
+ SkIRect copyRect = SkIRect::MakeWH(rt->width(), rt->height());
- SkIRect drawIBounds;
SkIRect clippedRect;
+ clip.getConservativeBounds(rt->width(), rt->height(), &clippedRect);
+ SkIRect drawIBounds;
opBounds.roundOut(&drawIBounds);
// Cover up for any precision issues by outsetting the op bounds a pixel in each direction.
drawIBounds.outset(1, 1);
- if (!clippedRect.intersect(copyRect, drawIBounds)) {
+ if (!clippedRect.intersect(drawIBounds)) {
#ifdef SK_DEBUG
GrCapsDebugf(this->caps(), "Missed an early reject. "
"Bailing on draw from setupDstTexture.\n");
diff --git a/tests/BlendTest.cpp b/tests/BlendTest.cpp
index 2a96f86..193c37d 100644
--- a/tests/BlendTest.cpp
+++ b/tests/BlendTest.cpp
@@ -123,19 +123,22 @@
SkIPoint inPoint;
} allRectsAndPoints[3] = {
{SkRect::MakeXYWH(0, 0, 5, 5), SkIPoint::Make(7, 7), SkIPoint::Make(2, 2)},
- {SkRect::MakeXYWH(2, 2, 5, 5), SkIPoint::Make(0, 0), SkIPoint::Make(4, 4)},
+ {SkRect::MakeXYWH(2, 2, 5, 5), SkIPoint::Make(1, 1), SkIPoint::Make(4, 4)},
{SkRect::MakeXYWH(5, 5, 5, 5), SkIPoint::Make(2, 2), SkIPoint::Make(7, 7)},
};
struct TestCase {
RectAndSamplePoint rectAndPoints;
+ SkRect clip;
int sampleCnt;
};
std::vector<TestCase> testCases;
for (int sampleCnt : {0, 4}) {
for (auto rectAndPoints : allRectsAndPoints) {
- testCases.push_back({rectAndPoints, sampleCnt});
+ for (auto clip : {SkRect::MakeXYWH(0, 0, 10, 10), SkRect::MakeXYWH(1, 1, 8, 8)}) {
+ testCases.push_back({rectAndPoints, clip, sampleCnt});
+ }
}
}
@@ -159,6 +162,7 @@
// Fill our canvas with 0xFFFF80
SkCanvas* canvas = surface->getCanvas();
+ canvas->clipRect(testCase.clip, false);
SkPaint black_paint;
black_paint.setColor(SkColorSetRGB(0xFF, 0xFF, 0x80));
canvas->drawRect(SkRect::MakeXYWH(0, 0, kWidth, kHeight), black_paint);