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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <limits> 6 #include <limits>
7 7
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "cc/base/region.h" 9 #include "cc/base/region.h"
10 #include "cc/debug/debug_colors.h" 10 #include "cc/debug/debug_colors.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 unsigned thread_index) const { 72 unsigned thread_index) const {
73 CHECK_GT(clones_for_drawing_.clones_.size(), thread_index); 73 CHECK_GT(clones_for_drawing_.clones_.size(), thread_index);
74 return clones_for_drawing_.clones_[thread_index]; 74 return clones_for_drawing_.clones_[thread_index];
75 } 75 }
76 76
77 void PicturePileImpl::Raster( 77 void PicturePileImpl::Raster(
78 SkCanvas* canvas, 78 SkCanvas* canvas,
79 gfx::Rect canvas_rect, 79 gfx::Rect canvas_rect,
80 float contents_scale, 80 float contents_scale,
81 RasterStats* raster_stats) { 81 RasterStats* raster_stats) {
82
83 DCHECK(contents_scale >= min_contents_scale_); 82 DCHECK(contents_scale >= min_contents_scale_);
84 83
85 canvas->save();
86 canvas->translate(-canvas_rect.x(), -canvas_rect.y()); 84 canvas->translate(-canvas_rect.x(), -canvas_rect.y());
87 85
88 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(), 86 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(),
89 contents_scale); 87 contents_scale);
90 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size)); 88 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size));
91 gfx::Rect content_rect = total_content_rect; 89 gfx::Rect content_rect = total_content_rect;
92 content_rect.Intersect(canvas_rect); 90 content_rect.Intersect(canvas_rect);
93 91
94 // Clear one texel inside the right/bottom edge of the content rect,
95 // as it may only be partially covered by the picture playback.
96 // Also clear one texel outside the right/bottom edge of the content rect,
97 // as it may get blended in by linear filtering when zoomed in.
98 gfx::Rect deflated_content_rect = total_content_rect;
99 deflated_content_rect.Inset(0, 0, 1, 1);
100
101 gfx::Rect canvas_outside_content_rect = canvas_rect;
102 canvas_outside_content_rect.Subtract(deflated_content_rect);
103
104 if (!canvas_outside_content_rect.IsEmpty()) {
105 gfx::Rect inflated_content_rect = total_content_rect;
106 inflated_content_rect.Inset(0, 0, -1, -1);
107 canvas->clipRect(gfx::RectToSkRect(inflated_content_rect),
108 SkRegion::kReplace_Op);
109 canvas->clipRect(gfx::RectToSkRect(deflated_content_rect),
110 SkRegion::kDifference_Op);
111 canvas->drawColor(background_color_, SkXfermode::kSrc_Mode);
112 }
113
114 // Rasterize the collection of relevant picture piles. 92 // Rasterize the collection of relevant picture piles.
115 gfx::Rect layer_rect = gfx::ToEnclosingRect( 93 gfx::Rect layer_rect = gfx::ToEnclosingRect(
116 gfx::ScaleRect(content_rect, 1.f / contents_scale)); 94 gfx::ScaleRect(content_rect, 1.f / contents_scale));
117 95
118 canvas->clipRect(gfx::RectToSkRect(content_rect), 96 canvas->clipRect(gfx::RectToSkRect(content_rect),
119 SkRegion::kReplace_Op); 97 SkRegion::kIntersect_Op);
120 Region unclipped(content_rect); 98 Region unclipped(content_rect);
121 99
122 if (raster_stats) { 100 if (raster_stats) {
123 raster_stats->total_pixels_rasterized = 0; 101 raster_stats->total_pixels_rasterized = 0;
124 raster_stats->total_rasterize_time = base::TimeDelta::FromSeconds(0); 102 raster_stats->total_rasterize_time = base::TimeDelta::FromSeconds(0);
125 raster_stats->best_rasterize_time = base::TimeDelta::FromSeconds(0); 103 raster_stats->best_rasterize_time = base::TimeDelta::FromSeconds(0);
126 } 104 }
127 105
128 for (TilingData::Iterator tile_iter(&tiling_, layer_rect); 106 for (TilingData::Iterator tile_iter(&tiling_, layer_rect);
129 tile_iter; ++tile_iter) { 107 tile_iter; ++tile_iter) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // distinguish between non painted areas and problems with missing 188 // distinguish between non painted areas and problems with missing
211 // pictures. 189 // pictures.
212 SkPaint paint; 190 SkPaint paint;
213 paint.setColor(DebugColors::MissingPictureFillColor()); 191 paint.setColor(DebugColors::MissingPictureFillColor());
214 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 192 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
215 canvas->drawPaint(paint); 193 canvas->drawPaint(paint);
216 #endif // NDEBUG 194 #endif // NDEBUG
217 195
218 // We should always paint some part of |content_rect|. 196 // We should always paint some part of |content_rect|.
219 DCHECK(!unclipped.Contains(content_rect)); 197 DCHECK(!unclipped.Contains(content_rect));
198 }
199
200 void PicturePileImpl::RasterToBitmap(
201 SkCanvas* canvas,
202 gfx::Rect canvas_rect,
203 float contents_scale,
204 RasterStats* raster_stats) {
205
206 canvas->save();
207 canvas->translate(-canvas_rect.x(), -canvas_rect.y());
208
209 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(),
210 contents_scale);
211 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size));
212 gfx::Rect content_rect = total_content_rect;
213 content_rect.Intersect(canvas_rect);
214
215 #ifndef NDEBUG
216 // Any non-painted areas will be left in this color.
217 canvas->clear(DebugColors::NonPaintedFillColor());
218 #endif // NDEBUG
219
220 // 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
221 SkPaint paint;
222 paint.setAntiAlias(false);
223 paint.setXfermodeMode(SkXfermode::kClear_Mode);
224 canvas->drawRect(gfx::RectToSkRect(content_rect), paint);
225
226 // Clear one texel inside the right/bottom edge of the content rect,
227 // as it may only be partially covered by the picture playback.
228 // Also clear one texel outside the right/bottom edge of the content rect,
229 // as it may get blended in by linear filtering when zoomed in.
230 gfx::Rect deflated_content_rect = total_content_rect;
231 deflated_content_rect.Inset(0, 0, 1, 1);
232
233 gfx::Rect canvas_outside_content_rect = canvas_rect;
234 canvas_outside_content_rect.Subtract(deflated_content_rect);
235
236 if (!canvas_outside_content_rect.IsEmpty()) {
237 gfx::Rect inflated_content_rect = total_content_rect;
238 inflated_content_rect.Inset(0, 0, -1, -1);
239 canvas->clipRect(gfx::RectToSkRect(inflated_content_rect),
240 SkRegion::kReplace_Op);
241 canvas->clipRect(gfx::RectToSkRect(deflated_content_rect),
242 SkRegion::kDifference_Op);
243 canvas->drawColor(background_color_, SkXfermode::kSrc_Mode);
244 }
220 245
221 canvas->restore(); 246 canvas->restore();
247
248 Raster(canvas, canvas_rect, contents_scale, raster_stats);
222 } 249 }
223 250
224 skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() { 251 skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() {
225 TRACE_EVENT0("cc", "PicturePileImpl::GetFlattenedPicture"); 252 TRACE_EVENT0("cc", "PicturePileImpl::GetFlattenedPicture");
226 253
227 gfx::Rect layer_rect(tiling_.total_size()); 254 gfx::Rect layer_rect(tiling_.total_size());
228 skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); 255 skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture);
229 if (layer_rect.IsEmpty()) 256 if (layer_rect.IsEmpty())
230 return picture; 257 return picture;
231 258
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 layer_rect_, 352 layer_rect_,
326 *picture_list_iterator_); 353 *picture_list_iterator_);
327 if (pixel_ref_iterator_) 354 if (pixel_ref_iterator_)
328 return; 355 return;
329 } 356 }
330 ++tile_iterator_; 357 ++tile_iterator_;
331 } while (AdvanceToTileWithPictures()); 358 } while (AdvanceToTileWithPictures());
332 } 359 }
333 360
334 } // namespace cc 361 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698