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>
This commit is contained in:
Eric Karl 2017-04-04 13:42:10 -07:00 committed by Skia Commit-Bot
parent fc0e96e35f
commit 72e551e637
2 changed files with 10 additions and 6 deletions

View File

@ -1746,15 +1746,15 @@ void GrRenderTargetContext::setupDstTexture(GrRenderTarget* rt, const GrClip& cl
}
}
SkIRect copyRect;
clip.getConservativeBounds(rt->width(), rt->height(), &copyRect);
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");

View File

@ -123,19 +123,22 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ES2BlendWithNoTexture, reporter, ctxInfo)
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 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ES2BlendWithNoTexture, reporter, ctxInfo)
// 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);