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

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: removed unused vars 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
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/skia_util.h" 14 #include "ui/gfx/skia_util.h"
14 15
15 namespace cc { 16 namespace cc {
16 17
17 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() { 18 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() {
18 return make_scoped_refptr(new PicturePileImpl()); 19 return make_scoped_refptr(new PicturePileImpl());
19 } 20 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 layer_rect.height(), 182 layer_rect.height(),
182 SkPicture::kUsePathBoundsForClip_RecordingFlag); 183 SkPicture::kUsePathBoundsForClip_RecordingFlag);
183 184
184 int64 total_pixels_rasterized = 0; 185 int64 total_pixels_rasterized = 0;
185 Raster(canvas, layer_rect, 1.0, &total_pixels_rasterized); 186 Raster(canvas, layer_rect, 1.0, &total_pixels_rasterized);
186 picture->endRecording(); 187 picture->endRecording();
187 188
188 return picture; 189 return picture;
189 } 190 }
190 191
191 bool PicturePileImpl::IsCheapInRect( 192 void PicturePileImpl::AnalyzeInRect(const gfx::Rect& content_rect,
192 gfx::Rect content_rect, float contents_scale) const { 193 float contents_scale,
194 PicturePileImpl::Analysis* analysis) {
195 DCHECK(analysis);
196
197 TRACE_EVENT0("cc", "PicturePileImpl::AnalyzeInRect");
198
193 gfx::Rect layer_rect = gfx::ToEnclosingRect( 199 gfx::Rect layer_rect = gfx::ToEnclosingRect(
194 gfx::ScaleRect(content_rect, 1.f / contents_scale)); 200 gfx::ScaleRect(content_rect, 1.f / contents_scale));
195 201
202 SkBitmap emptyBitmap;
203 emptyBitmap.setConfig(SkBitmap::kNo_Config, content_rect.width(),
204 content_rect.height());
205 skia::AnalysisDevice device(emptyBitmap);
206 skia::AnalysisCanvas canvas(&device);
207
208 canvas.translate(-content_rect.x(), -content_rect.y());
209 canvas.clipRect(gfx::RectToSkRect(content_rect));
210
211 Region unclipped(content_rect);
212 analysis->is_solid_color_ = false;
213 bool determined_if_transparent = false;
214 bool is_transparent_guess = false;
215 bool cheap = true;
196 for (TilingData::Iterator tile_iter(&tiling_, layer_rect); 216 for (TilingData::Iterator tile_iter(&tiling_, layer_rect);
197 tile_iter; ++tile_iter) { 217 tile_iter; ++tile_iter) {
198 PictureListMap::const_iterator map_iter = 218 PictureListMap::iterator map_iter =
199 picture_list_map_.find(tile_iter.index()); 219 picture_list_map_.find(tile_iter.index());
200 if (map_iter == picture_list_map_.end()) 220 if (map_iter == picture_list_map_.end())
201 continue; 221 continue;
222 PictureList& pic_list= map_iter->second;
223 if (pic_list.empty())
224 continue;
202 225
203 const PictureList& pic_list = map_iter->second; 226 for (PictureList::reverse_iterator i = pic_list.rbegin();
204 for (PictureList::const_iterator i = pic_list.begin(); 227 i != pic_list.rend(); ++i) {
205 i != pic_list.end(); ++i) { 228 gfx::Rect content_clip = gfx::ToEnclosedRect(
206 if (!(*i)->LayerRect().Intersects(layer_rect) || !(*i)->HasRecording()) 229 gfx::ScaleRect((*i)->LayerRect(), contents_scale));
230 if (!unclipped.Intersects(content_clip))
207 continue; 231 continue;
208 if (!(*i)->IsCheapInRect(layer_rect)) 232
209 return false; 233 Picture::Analysis picture_analysis;
234 (*i)->AnalyzeInRect(&canvas,
235 content_clip,
236 contents_scale,
237 &picture_analysis);
238
239 // Since the iteration happens bottom-up, take the solid information
240 // from the last picture that is analyzed.
241 analysis->is_solid_color_ = picture_analysis.is_solid_color_;
242 analysis->solid_color_ = picture_analysis.solid_color_;
243
244 // If the current picture is transparent, then the best we can do
245 // is guess that the whole tile will be transparent (since that
246 // might change in later iterations)
247 if (picture_analysis.is_transparent_)
248 is_transparent_guess = true;
249 else {
250 analysis->is_transparent_ = false;
251 determined_if_transparent = true;
252 }
253
254 // Cheap can turn into not cheap, but not cheap
255 // can't be updated to be cheap
256 if (cheap)
257 cheap = picture_analysis.is_cheap_to_raster_;
258
259 // Don't allow pictures underneath to draw where this picture did.
260 canvas.clipRect(
261 gfx::RectToSkRect(content_clip),
262 SkRegion::kDifference_Op);
263 unclipped.Subtract(content_clip);
210 } 264 }
211 } 265 }
212 return true; 266
267 if (!determined_if_transparent)
268 analysis->is_transparent_ = is_transparent_guess;
269 analysis->is_cheap_to_raster_ = cheap;
270 analysis->is_analyzed_ = true;
271 }
272
273 PicturePileImpl::Analysis::Analysis()
274 : is_analyzed_(false) {
213 } 275 }
214 276
215 } // namespace cc 277 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698