Fixing clip region test in deferred canvas, used to determine whether a draw operation occludes the entire canvas.

BUG=http://code.google.com/p/chromium/issues/detail?id=164580
TEST=unit test DeferredCanvas/TestDeferredCanvasFreshFrame
Review URL: https://codereview.appspot.com/6934045

git-svn-id: http://skia.googlecode.com/svn/trunk@6780 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
junov@chromium.org 2012-12-13 16:30:39 +00:00
parent 9973a8a396
commit 8f0ca06ef4
2 changed files with 14 additions and 19 deletions

View File

@ -684,25 +684,8 @@ bool SkDeferredCanvas::isFullFrame(const SkRect* rect,
}
}
switch (canvas->getClipType()) {
case SkCanvas::kRect_ClipType :
{
SkIRect bounds;
canvas->getClipDeviceBounds(&bounds);
if (bounds.fLeft > 0 || bounds.fTop > 0 ||
bounds.fRight < canvasSize.fWidth ||
bounds.fBottom < canvasSize.fHeight)
return false;
}
break;
case SkCanvas::kComplex_ClipType :
return false; // conservative
case SkCanvas::kEmpty_ClipType:
default:
break;
};
return true;
return this->getClipStack()->quickContains(SkRect::MakeXYWH(0, 0,
SkIntToScalar(canvasSize.fWidth), SkIntToScalar(canvasSize.fHeight)));
}
int SkDeferredCanvas::save(SaveFlags flags) {

View File

@ -166,6 +166,18 @@ static void TestDeferredCanvasFreshFrame(skiatest::Reporter* reporter) {
canvas.restore();
REPORTER_ASSERT(reporter, !canvas.isFreshFrame());
}
{
canvas.save(SkCanvas::kMatrixClip_SaveFlag);
SkPaint paint;
paint.setStyle( SkPaint::kFill_Style );
paint.setAlpha( 255 );
SkPath path;
path.addCircle(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(2));
canvas.clipPath(path, SkRegion::kIntersect_Op, false);
canvas.drawRect(fullRect, paint);
canvas.restore();
REPORTER_ASSERT(reporter, !canvas.isFreshFrame());
}
// Verify that stroked rect does not trigger a fresh frame
{