OLD | NEW |
---|---|
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 gfx::Rect canvas_rect, | 73 gfx::Rect canvas_rect, |
74 float contents_scale, | 74 float contents_scale, |
75 RenderingStatsInstrumentation* rendering_stats_instrumentation) { | 75 RenderingStatsInstrumentation* rendering_stats_instrumentation) { |
76 RasterCommon(canvas, | 76 RasterCommon(canvas, |
77 NULL, | 77 NULL, |
78 canvas_rect, | 78 canvas_rect, |
79 contents_scale, | 79 contents_scale, |
80 rendering_stats_instrumentation); | 80 rendering_stats_instrumentation); |
81 } | 81 } |
82 | 82 |
83 void PicturePileImpl::RasterForAnalysis( | |
84 skia::AnalysisCanvas* canvas, | |
85 gfx::Rect canvas_rect, | |
86 float contents_scale) { | |
87 RasterCommon(canvas, canvas, canvas_rect, contents_scale, NULL); | |
88 } | |
89 | |
90 void PicturePileImpl::RasterToBitmap( | 83 void PicturePileImpl::RasterToBitmap( |
91 SkCanvas* canvas, | 84 SkCanvas* canvas, |
92 gfx::Rect canvas_rect, | 85 gfx::Rect canvas_rect, |
93 float contents_scale, | 86 float contents_scale, |
94 RenderingStatsInstrumentation* rendering_stats_instrumentation) { | 87 RenderingStatsInstrumentation* rendering_stats_instrumentation) { |
95 if (clear_canvas_with_debug_color_) { | 88 if (clear_canvas_with_debug_color_) { |
96 // Any non-painted areas will be left in this color. | 89 // Any non-painted areas will be left in this color. |
97 canvas->clear(DebugColors::NonPaintedFillColor()); | 90 canvas->clear(DebugColors::NonPaintedFillColor()); |
98 } | 91 } |
99 | 92 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 continue; | 187 continue; |
195 } | 188 } |
196 | 189 |
197 Region& region = it->second; | 190 Region& region = it->second; |
198 region.Subtract(content_clip); | 191 region.Subtract(content_clip); |
199 } | 192 } |
200 } | 193 } |
201 | 194 |
202 void PicturePileImpl::RasterCommon( | 195 void PicturePileImpl::RasterCommon( |
203 SkCanvas* canvas, | 196 SkCanvas* canvas, |
204 SkDrawPictureCallback* callback, | 197 SkDrawPictureCallback* callback, |
reveman
2013/11/07 15:36:31
|callback| doesn't seem to be used anymore. Should
enne (OOO)
2013/11/07 22:13:50
Done.
| |
205 gfx::Rect canvas_rect, | 198 gfx::Rect canvas_rect, |
206 float contents_scale, | 199 float contents_scale, |
207 RenderingStatsInstrumentation* rendering_stats_instrumentation) { | 200 RenderingStatsInstrumentation* rendering_stats_instrumentation) { |
208 DCHECK(contents_scale >= min_contents_scale_); | 201 DCHECK(contents_scale >= min_contents_scale_); |
209 | 202 |
210 canvas->translate(-canvas_rect.x(), -canvas_rect.y()); | 203 canvas->translate(-canvas_rect.x(), -canvas_rect.y()); |
211 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(), | 204 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(), |
212 contents_scale); | 205 contents_scale); |
213 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size)); | 206 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size)); |
214 gfx::Rect content_rect = total_content_rect; | 207 gfx::Rect content_rect = total_content_rect; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
290 layer_rect.width(), | 283 layer_rect.width(), |
291 layer_rect.height(), | 284 layer_rect.height(), |
292 SkPicture::kUsePathBoundsForClip_RecordingFlag); | 285 SkPicture::kUsePathBoundsForClip_RecordingFlag); |
293 | 286 |
294 RasterToBitmap(canvas, layer_rect, 1.0, NULL); | 287 RasterToBitmap(canvas, layer_rect, 1.0, NULL); |
295 picture->endRecording(); | 288 picture->endRecording(); |
296 | 289 |
297 return picture; | 290 return picture; |
298 } | 291 } |
299 | 292 |
300 void PicturePileImpl::AnalyzeInRect(gfx::Rect content_rect, | |
301 float contents_scale, | |
302 PicturePileImpl::Analysis* analysis) { | |
303 DCHECK(analysis); | |
304 TRACE_EVENT0("cc", "PicturePileImpl::AnalyzeInRect"); | |
305 | |
306 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( | |
307 content_rect, 1.0f / contents_scale); | |
308 | |
309 layer_rect.Intersect(gfx::Rect(tiling_.total_size())); | |
310 | |
311 SkBitmap empty_bitmap; | |
312 empty_bitmap.setConfig(SkBitmap::kNo_Config, | |
313 layer_rect.width(), | |
314 layer_rect.height()); | |
315 skia::AnalysisDevice device(empty_bitmap); | |
316 skia::AnalysisCanvas canvas(&device); | |
317 | |
318 RasterForAnalysis(&canvas, layer_rect, 1.0f); | |
319 | |
320 analysis->is_solid_color = canvas.GetColorIfSolid(&analysis->solid_color); | |
321 analysis->has_text = canvas.HasText(); | |
322 } | |
323 | |
324 PicturePileImpl::Analysis::Analysis() | 293 PicturePileImpl::Analysis::Analysis() |
325 : is_solid_color(false), | 294 : is_solid_color(false), |
326 has_text(false) { | 295 has_text(false) { |
327 } | 296 } |
328 | 297 |
329 PicturePileImpl::Analysis::~Analysis() { | 298 PicturePileImpl::Analysis::~Analysis() { |
330 } | 299 } |
331 | 300 |
332 PicturePileImpl::PixelRefIterator::PixelRefIterator( | 301 PicturePileImpl::PixelRefIterator::PixelRefIterator( |
333 gfx::Rect content_rect, | 302 gfx::Rect content_rect, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 if (!picture || (processed_pictures_.count(picture) != 0)) | 338 if (!picture || (processed_pictures_.count(picture) != 0)) |
370 continue; | 339 continue; |
371 | 340 |
372 processed_pictures_.insert(picture); | 341 processed_pictures_.insert(picture); |
373 pixel_ref_iterator_ = Picture::PixelRefIterator(layer_rect_, picture); | 342 pixel_ref_iterator_ = Picture::PixelRefIterator(layer_rect_, picture); |
374 if (pixel_ref_iterator_) | 343 if (pixel_ref_iterator_) |
375 break; | 344 break; |
376 } | 345 } |
377 } | 346 } |
378 | 347 |
348 gfx::Rect PicturePileImpl::AnalysisRectForRaster(gfx::Rect content_rect, | |
349 float contents_scale) const { | |
350 // Bound the analysis rect to just the pile content. | |
351 gfx::Rect content_bounds( | |
352 gfx::ScaleToEnclosingRect(gfx::Rect(size()), contents_scale)); | |
353 gfx::Rect analysis_rect(content_rect); | |
354 analysis_rect.Intersect(content_bounds); | |
355 // Move to canvas space. | |
356 analysis_rect.set_origin(gfx::Point()); | |
357 | |
358 return analysis_rect; | |
359 } | |
360 | |
379 void PicturePileImpl::DidBeginTracing() { | 361 void PicturePileImpl::DidBeginTracing() { |
380 gfx::Rect layer_rect(tiling_.total_size()); | 362 gfx::Rect layer_rect(tiling_.total_size()); |
381 std::set<void*> processed_pictures; | 363 std::set<void*> processed_pictures; |
382 for (PictureMap::iterator it = picture_map_.begin(); | 364 for (PictureMap::iterator it = picture_map_.begin(); |
383 it != picture_map_.end(); | 365 it != picture_map_.end(); |
384 ++it) { | 366 ++it) { |
385 Picture* picture = it->second.picture.get(); | 367 Picture* picture = it->second.picture.get(); |
386 if (picture && (processed_pictures.count(picture) == 0)) { | 368 if (picture && (processed_pictures.count(picture) == 0)) { |
387 picture->EmitTraceSnapshot(); | 369 picture->EmitTraceSnapshot(); |
388 processed_pictures.insert(picture); | 370 processed_pictures.insert(picture); |
389 } | 371 } |
390 } | 372 } |
391 } | 373 } |
392 | 374 |
393 } // namespace cc | 375 } // namespace cc |
OLD | NEW |