summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/resources/picture.cc10
-rw-r--r--cc/resources/picture_pile_impl.cc28
-rw-r--r--skia/ext/analysis_canvas.cc8
-rw-r--r--skia/ext/analysis_canvas_unittest.cc8
4 files changed, 23 insertions, 31 deletions
diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc
index 20b5175..159885d 100644
--- a/cc/resources/picture.cc
+++ b/cc/resources/picture.cc
@@ -198,16 +198,6 @@ void Picture::Record(ContentLayerClient* painter,
canvas->translate(SkFloatToScalar(-layer_rect_.x()),
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;
base::TimeTicks begin_record_time;
if (stats)
diff --git a/cc/resources/picture_pile_impl.cc b/cc/resources/picture_pile_impl.cc
index b9abcac..ac63e4a 100644
--- a/cc/resources/picture_pile_impl.cc
+++ b/cc/resources/picture_pile_impl.cc
@@ -96,25 +96,15 @@ void PicturePileImpl::Raster(
gfx::Rect content_rect = total_content_rect;
content_rect.Intersect(canvas_rect);
- // Clear one texel inside the right/bottom edge of the content rect,
- // as it may only be partially covered by the picture playback.
- // Also clear one texel outside the right/bottom edge of the content rect,
- // as it may get blended in by linear filtering when zoomed in.
- gfx::Rect deflated_content_rect = total_content_rect;
- deflated_content_rect.Inset(0, 0, 1, 1);
-
- gfx::Rect canvas_outside_content_rect = canvas_rect;
- 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);
- }
+ // Clear an inflated content rect, to ensure that we always sample
+ // a correct pixel.
+ gfx::Rect inflated_content_rect = total_content_rect;
+ inflated_content_rect.Inset(0, 0, -1, -1);
+
+ SkPaint background_paint;
+ background_paint.setColor(background_color_);
+ background_paint.setXfermodeMode(SkXfermode::kSrc_Mode);
+ canvas->drawRect(RectToSkRect(inflated_content_rect), background_paint);
// Rasterize the collection of relevant picture piles.
gfx::Rect layer_rect = gfx::ToEnclosingRect(
diff --git a/skia/ext/analysis_canvas.cc b/skia/ext/analysis_canvas.cc
index 321ee2b..196d1d0 100644
--- a/skia/ext/analysis_canvas.cc
+++ b/skia/ext/analysis_canvas.cc
@@ -173,7 +173,8 @@ void AnalysisDevice::clear(SkColor color) {
void AnalysisDevice::drawPaint(const SkDraw&, const SkPaint& paint) {
addBitmapFromPaint(paint);
- isSolidColor_ = false;
+ isSolidColor_ =
+ (isSolidColor_ && isSolidColorPaint(paint) && paint.getColor() == color_);
isTransparent_ = false;
}
@@ -221,9 +222,12 @@ void AnalysisDevice::drawRect(const SkDraw& draw, const SkRect& rect,
// - We're not in "forced not solid" mode
// - Paint is solid color
// - 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_ &&
isSolidColorPaint(paint) &&
- doesCoverCanvas) {
+ (doesCoverCanvas || (isSolidColor_ && paint.getColor() == color_))) {
isSolidColor_ = true;
color_ = paint.getColor();
hasText_ = false;
diff --git a/skia/ext/analysis_canvas_unittest.cc b/skia/ext/analysis_canvas_unittest.cc
index 3cc2553..aa69259 100644
--- a/skia/ext/analysis_canvas_unittest.cc
+++ b/skia/ext/analysis_canvas_unittest.cc
@@ -223,9 +223,17 @@ TEST(AnalysisCanvasTest, SimpleDrawRect) {
EXPECT_NE(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor);
EXPECT_EQ(color, outputColor);
+ // Paint with the same color, tile should remain solid.
canvas.rotate(50);
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));
}