Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7952)

Unified Diff: cc/resources/picture_pile_impl.cc

Issue 13863015: Add flag for drawing layers to screen with Ganesh (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/resources/picture_pile_impl.cc
diff --git a/cc/resources/picture_pile_impl.cc b/cc/resources/picture_pile_impl.cc
index 8f2ef54e3f55738f12575ecc21c23e4f24309ab6..bfbec46a8edd9b823770adbcab9e48dbeb7f9ae9 100644
--- a/cc/resources/picture_pile_impl.cc
+++ b/cc/resources/picture_pile_impl.cc
@@ -79,10 +79,8 @@ void PicturePileImpl::Raster(
gfx::Rect canvas_rect,
float contents_scale,
RasterStats* raster_stats) {
-
DCHECK(contents_scale >= min_contents_scale_);
- canvas->save();
canvas->translate(-canvas_rect.x(), -canvas_rect.y());
gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(),
@@ -91,32 +89,12 @@ 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);
- }
-
// Rasterize the collection of relevant picture piles.
gfx::Rect layer_rect = gfx::ToEnclosingRect(
gfx::ScaleRect(content_rect, 1.f / contents_scale));
canvas->clipRect(gfx::RectToSkRect(content_rect),
- SkRegion::kReplace_Op);
+ SkRegion::kIntersect_Op);
Region unclipped(content_rect);
if (raster_stats) {
@@ -217,8 +195,57 @@ void PicturePileImpl::Raster(
// We should always paint some part of |content_rect|.
DCHECK(!unclipped.Contains(content_rect));
+}
+
+void PicturePileImpl::RasterToBitmap(
+ SkCanvas* canvas,
+ gfx::Rect canvas_rect,
+ float contents_scale,
+ RasterStats* raster_stats) {
+
+ canvas->save();
+ canvas->translate(-canvas_rect.x(), -canvas_rect.y());
+
+ gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(),
+ contents_scale);
+ gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size));
+ gfx::Rect content_rect = total_content_rect;
+ content_rect.Intersect(canvas_rect);
+
+#ifndef NDEBUG
+ // Any non-painted areas will be left in this color.
+ canvas->clear(DebugColors::NonPaintedFillColor());
+#endif // NDEBUG
+
+ // TODO(enne): this needs to be rolled together with the border clear
enne (OOO) 2013/05/13 19:33:10 It is definitely weird to clear to transparent and
+ SkPaint paint;
+ paint.setAntiAlias(false);
+ paint.setXfermodeMode(SkXfermode::kClear_Mode);
+ canvas->drawRect(gfx::RectToSkRect(content_rect), paint);
+
+ // 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);
+ }
canvas->restore();
+
+ Raster(canvas, canvas_rect, contents_scale, raster_stats);
}
skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() {

Powered by Google App Engine
This is Rietveld 408576698