Commit 50785d11 authored by vmpstr@chromium.org's avatar vmpstr@chromium.org

Revert "cc: Move canvas clear from picture to picture_pile_impl

This moves a clear per picture into a clear-to-background color
per picture pile. We need this to ensure that a solid color
page in low res is considered solid, since all the draws are
of the same color.

BUG=233622

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=198272
"

TBR=reveman

Review URL: https://chromiumcodereview.appspot.com/14322017

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198826 0039d316-1c4b-4281-b951-d872f2087c98
parent 4e9fe568
...@@ -198,6 +198,16 @@ void Picture::Record(ContentLayerClient* painter, ...@@ -198,6 +198,16 @@ void Picture::Record(ContentLayerClient* painter,
canvas->translate(SkFloatToScalar(-layer_rect_.x()), canvas->translate(SkFloatToScalar(-layer_rect_.x()),
SkFloatToScalar(-layer_rect_.y())); SkFloatToScalar(-layer_rect_.y()));
SkPaint paint;
paint.setAntiAlias(false);
paint.setXfermodeMode(SkXfermode::kClear_Mode);
SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(),
layer_rect_.y(),
layer_rect_.width(),
layer_rect_.height());
canvas->clipRect(layer_skrect);
canvas->drawRect(layer_skrect, paint);
gfx::RectF opaque_layer_rect; gfx::RectF opaque_layer_rect;
base::TimeTicks begin_record_time; base::TimeTicks begin_record_time;
if (stats) if (stats)
......
...@@ -96,15 +96,25 @@ void PicturePileImpl::Raster( ...@@ -96,15 +96,25 @@ void PicturePileImpl::Raster(
gfx::Rect content_rect = total_content_rect; gfx::Rect content_rect = total_content_rect;
content_rect.Intersect(canvas_rect); content_rect.Intersect(canvas_rect);
// Clear an inflated content rect, to ensure that we always sample // Clear one texel inside the right/bottom edge of the content rect,
// a correct pixel. // as it may only be partially covered by the picture playback.
gfx::Rect inflated_content_rect = total_content_rect; // Also clear one texel outside the right/bottom edge of the content rect,
inflated_content_rect.Inset(0, 0, -1, -1); // as it may get blended in by linear filtering when zoomed in.
gfx::Rect deflated_content_rect = total_content_rect;
SkPaint background_paint; deflated_content_rect.Inset(0, 0, 1, 1);
background_paint.setColor(background_color_);
background_paint.setXfermodeMode(SkXfermode::kSrc_Mode); gfx::Rect canvas_outside_content_rect = canvas_rect;
canvas->drawRect(RectToSkRect(inflated_content_rect), background_paint); canvas_outside_content_rect.Subtract(deflated_content_rect);
if (!canvas_outside_content_rect.IsEmpty()) {
gfx::Rect inflated_content_rect = total_content_rect;
inflated_content_rect.Inset(0, 0, -1, -1);
canvas->clipRect(gfx::RectToSkRect(inflated_content_rect),
SkRegion::kReplace_Op);
canvas->clipRect(gfx::RectToSkRect(deflated_content_rect),
SkRegion::kDifference_Op);
canvas->drawColor(background_color_, SkXfermode::kSrc_Mode);
}
// Rasterize the collection of relevant picture piles. // Rasterize the collection of relevant picture piles.
gfx::Rect layer_rect = gfx::ToEnclosingRect( gfx::Rect layer_rect = gfx::ToEnclosingRect(
......
...@@ -122,8 +122,7 @@ void AnalysisDevice::clear(SkColor color) { ...@@ -122,8 +122,7 @@ void AnalysisDevice::clear(SkColor color) {
} }
void AnalysisDevice::drawPaint(const SkDraw&, const SkPaint& paint) { void AnalysisDevice::drawPaint(const SkDraw&, const SkPaint& paint) {
isSolidColor_ = isSolidColor_ = false;
(isSolidColor_ && isSolidColorPaint(paint) && paint.getColor() == color_);
isTransparent_ = false; isTransparent_ = false;
} }
...@@ -168,12 +167,9 @@ void AnalysisDevice::drawRect(const SkDraw& draw, const SkRect& rect, ...@@ -168,12 +167,9 @@ void AnalysisDevice::drawRect(const SkDraw& draw, const SkRect& rect,
// - We're not in "forced not solid" mode // - We're not in "forced not solid" mode
// - Paint is solid color // - Paint is solid color
// - The quad is a full tile quad // - The quad is a full tile quad
// - The exception is if the tile is already solid tile,
// and we're drawing the same solid color paint then
// the tile remains solid.
if (!isForcedNotSolid_ && if (!isForcedNotSolid_ &&
isSolidColorPaint(paint) && isSolidColorPaint(paint) &&
(doesCoverCanvas || (isSolidColor_ && paint.getColor() == color_))) { doesCoverCanvas) {
isSolidColor_ = true; isSolidColor_ = true;
color_ = paint.getColor(); color_ = paint.getColor();
hasText_ = false; hasText_ = false;
......
...@@ -179,17 +179,9 @@ TEST(AnalysisCanvasTest, SimpleDrawRect) { ...@@ -179,17 +179,9 @@ TEST(AnalysisCanvasTest, SimpleDrawRect) {
EXPECT_NE(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor); EXPECT_NE(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor);
EXPECT_EQ(color, outputColor); EXPECT_EQ(color, outputColor);
// Paint with the same color, tile should remain solid.
canvas.rotate(50); canvas.rotate(50);
canvas.drawRect(SkRect::MakeWH(255, 255), paint); canvas.drawRect(SkRect::MakeWH(255, 255), paint);
EXPECT_TRUE(canvas.getColorIfSolid(&outputColor));
EXPECT_EQ(color, outputColor);
color = SkColorSetARGB(255, 12, 23, 34);
paint.setColor(color);
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
canvas.drawRect(SkRect::MakeWH(255, 255), paint);
EXPECT_FALSE(canvas.getColorIfSolid(&outputColor)); EXPECT_FALSE(canvas.getColorIfSolid(&outputColor));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment