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

Side by Side Diff: cc/picture_pile_impl.cc

Issue 12316084: cc: Consolidate the analysis_canvas operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win warning fix Created 7 years, 9 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
« no previous file with comments | « cc/picture_pile_impl.h ('k') | cc/switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/debug/trace_event.h" 5 #include "base/debug/trace_event.h"
6 #include "cc/debug_colors.h" 6 #include "cc/debug_colors.h"
7 #include "cc/picture_pile_impl.h" 7 #include "cc/picture_pile_impl.h"
8 #include "cc/region.h" 8 #include "cc/region.h"
9 #include "cc/rendering_stats.h" 9 #include "cc/rendering_stats.h"
10 #include "skia/ext/analysis_canvas.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkCanvas.h"
11 #include "third_party/skia/include/core/SkSize.h" 12 #include "third_party/skia/include/core/SkSize.h"
12 #include "ui/gfx/rect_conversions.h" 13 #include "ui/gfx/rect_conversions.h"
13 #include "ui/gfx/size_conversions.h" 14 #include "ui/gfx/size_conversions.h"
14 #include "ui/gfx/skia_util.h" 15 #include "ui/gfx/skia_util.h"
15 16
16 namespace cc { 17 namespace cc {
17 18
18 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() { 19 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() {
19 return make_scoped_refptr(new PicturePileImpl()); 20 return make_scoped_refptr(new PicturePileImpl());
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 layer_rect.height(), 206 layer_rect.height(),
206 SkPicture::kUsePathBoundsForClip_RecordingFlag); 207 SkPicture::kUsePathBoundsForClip_RecordingFlag);
207 208
208 int64 total_pixels_rasterized = 0; 209 int64 total_pixels_rasterized = 0;
209 Raster(canvas, layer_rect, 1.0, &total_pixels_rasterized); 210 Raster(canvas, layer_rect, 1.0, &total_pixels_rasterized);
210 picture->endRecording(); 211 picture->endRecording();
211 212
212 return picture; 213 return picture;
213 } 214 }
214 215
215 bool PicturePileImpl::IsCheapInRect( 216 void PicturePileImpl::AnalyzeInRect(const gfx::Rect& content_rect,
216 gfx::Rect content_rect, float contents_scale) const { 217 float contents_scale,
218 PicturePileImpl::Analysis* analysis) {
219 DCHECK(analysis);
220
221 TRACE_EVENT0("cc", "PicturePileImpl::AnalyzeInRect");
222
217 gfx::Rect layer_rect = gfx::ToEnclosingRect( 223 gfx::Rect layer_rect = gfx::ToEnclosingRect(
218 gfx::ScaleRect(content_rect, 1.f / contents_scale)); 224 gfx::ScaleRect(content_rect, 1.f / contents_scale));
219 225
226 SkBitmap emptyBitmap;
227 emptyBitmap.setConfig(SkBitmap::kNo_Config, content_rect.width(),
228 content_rect.height());
229 skia::AnalysisDevice device(emptyBitmap);
230 skia::AnalysisCanvas canvas(&device);
231
232 canvas.translate(-content_rect.x(), -content_rect.y());
233 canvas.clipRect(gfx::RectToSkRect(content_rect));
234
235 // The loop here is similar to the raster loop.
236 Region unclipped(content_rect);
220 for (TilingData::Iterator tile_iter(&tiling_, layer_rect); 237 for (TilingData::Iterator tile_iter(&tiling_, layer_rect);
221 tile_iter; ++tile_iter) { 238 tile_iter; ++tile_iter) {
222 PictureListMap::const_iterator map_iter = 239 PictureListMap::iterator map_iter =
223 picture_list_map_.find(tile_iter.index()); 240 picture_list_map_.find(tile_iter.index());
224 if (map_iter == picture_list_map_.end()) 241 if (map_iter == picture_list_map_.end())
225 continue; 242 continue;
243 PictureList& pic_list = map_iter->second;
244 if (pic_list.empty())
245 continue;
226 246
227 const PictureList& pic_list = map_iter->second; 247 for (PictureList::reverse_iterator i = pic_list.rbegin();
228 for (PictureList::const_iterator i = pic_list.begin(); 248 i != pic_list.rend(); ++i) {
229 i != pic_list.end(); ++i) { 249 gfx::Rect content_clip = gfx::ToEnclosedRect(
230 if (!(*i)->LayerRect().Intersects(layer_rect) || !(*i)->HasRecording()) 250 gfx::ScaleRect((*i)->LayerRect(), contents_scale));
251 DCHECK(!content_clip.IsEmpty());
252 if (!unclipped.Intersects(content_clip))
231 continue; 253 continue;
232 if (!(*i)->IsCheapInRect(layer_rect)) 254
233 return false; 255 (*i)->AnalyzeInRect(&canvas,
256 content_rect,
257 contents_scale);
258
259 canvas.clipRect(
260 gfx::RectToSkRect(content_clip),
261 SkRegion::kDifference_Op);
262 unclipped.Subtract(content_clip);
263
234 } 264 }
235 } 265 }
236 return true; 266
267 analysis->is_transparent = canvas.isTransparent();
268 analysis->is_solid_color = canvas.getColorIfSolid(&analysis->solid_color);
269 analysis->is_cheap_to_raster = canvas.isCheap();
270 }
271
272 PicturePileImpl::Analysis::Analysis() :
273 is_solid_color(false),
274 is_transparent(false),
275 is_cheap_to_raster(false) {
237 } 276 }
238 277
239 } // namespace cc 278 } // namespace cc
OLDNEW
« no previous file with comments | « cc/picture_pile_impl.h ('k') | cc/switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698