| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 | 64 |
| 65 PicturePileImpl* PicturePileImpl::GetCloneForDrawingOnThread( | 65 PicturePileImpl* PicturePileImpl::GetCloneForDrawingOnThread( |
| 66 unsigned thread_index) const { | 66 unsigned thread_index) const { |
| 67 CHECK_GT(clones_for_drawing_.clones_.size(), thread_index); | 67 CHECK_GT(clones_for_drawing_.clones_.size(), thread_index); |
| 68 return clones_for_drawing_.clones_[thread_index].get(); | 68 return clones_for_drawing_.clones_[thread_index].get(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void PicturePileImpl::RasterDirect( | 71 void PicturePileImpl::RasterDirect( |
| 72 SkCanvas* canvas, | 72 SkCanvas* canvas, |
| 73 gfx::Rect canvas_rect, | 73 const 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 false); | 81 false); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void PicturePileImpl::RasterForAnalysis( | 84 void PicturePileImpl::RasterForAnalysis( |
| 85 skia::AnalysisCanvas* canvas, | 85 skia::AnalysisCanvas* canvas, |
| 86 gfx::Rect canvas_rect, | 86 const gfx::Rect& canvas_rect, |
| 87 float contents_scale, | 87 float contents_scale, |
| 88 RenderingStatsInstrumentation* stats_instrumentation) { | 88 RenderingStatsInstrumentation* stats_instrumentation) { |
| 89 RasterCommon( | 89 RasterCommon( |
| 90 canvas, canvas, canvas_rect, contents_scale, stats_instrumentation, true); | 90 canvas, canvas, canvas_rect, contents_scale, stats_instrumentation, true); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void PicturePileImpl::RasterToBitmap( | 93 void PicturePileImpl::RasterToBitmap( |
| 94 SkCanvas* canvas, | 94 SkCanvas* canvas, |
| 95 gfx::Rect canvas_rect, | 95 const gfx::Rect& canvas_rect, |
| 96 float contents_scale, | 96 float contents_scale, |
| 97 RenderingStatsInstrumentation* rendering_stats_instrumentation) { | 97 RenderingStatsInstrumentation* rendering_stats_instrumentation) { |
| 98 if (clear_canvas_with_debug_color_) { | 98 if (clear_canvas_with_debug_color_) { |
| 99 // Any non-painted areas will be left in this color. | 99 // Any non-painted areas will be left in this color. |
| 100 canvas->clear(DebugColors::NonPaintedFillColor()); | 100 canvas->clear(DebugColors::NonPaintedFillColor()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // If this picture has opaque contents, it is guaranteeing that it will | 103 // If this picture has opaque contents, it is guaranteeing that it will |
| 104 // draw an opaque rect the size of the layer. If it is not, then we must | 104 // draw an opaque rect the size of the layer. If it is not, then we must |
| 105 // clear this canvas ourselves. | 105 // clear this canvas ourselves. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 138 } |
| 139 | 139 |
| 140 RasterCommon(canvas, | 140 RasterCommon(canvas, |
| 141 NULL, | 141 NULL, |
| 142 canvas_rect, | 142 canvas_rect, |
| 143 contents_scale, | 143 contents_scale, |
| 144 rendering_stats_instrumentation, | 144 rendering_stats_instrumentation, |
| 145 false); | 145 false); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void PicturePileImpl::CoalesceRasters(gfx::Rect canvas_rect, | 148 void PicturePileImpl::CoalesceRasters(const gfx::Rect& canvas_rect, |
| 149 gfx::Rect content_rect, | 149 const gfx::Rect& content_rect, |
| 150 float contents_scale, | 150 float contents_scale, |
| 151 PictureRegionMap* results) { | 151 PictureRegionMap* results) { |
| 152 DCHECK(results); | 152 DCHECK(results); |
| 153 // Rasterize the collection of relevant picture piles. | 153 // Rasterize the collection of relevant picture piles. |
| 154 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( | 154 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( |
| 155 content_rect, 1.f / contents_scale); | 155 content_rect, 1.f / contents_scale); |
| 156 | 156 |
| 157 // Coalesce rasters of the same picture into different rects: | 157 // Coalesce rasters of the same picture into different rects: |
| 158 // - Compute the clip of each of the pile chunks, | 158 // - Compute the clip of each of the pile chunks, |
| 159 // - Subtract it from the canvas rect to get difference region | 159 // - Subtract it from the canvas rect to get difference region |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 } | 200 } |
| 201 | 201 |
| 202 Region& region = it->second; | 202 Region& region = it->second; |
| 203 region.Subtract(content_clip); | 203 region.Subtract(content_clip); |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| 207 void PicturePileImpl::RasterCommon( | 207 void PicturePileImpl::RasterCommon( |
| 208 SkCanvas* canvas, | 208 SkCanvas* canvas, |
| 209 SkDrawPictureCallback* callback, | 209 SkDrawPictureCallback* callback, |
| 210 gfx::Rect canvas_rect, | 210 const gfx::Rect& canvas_rect, |
| 211 float contents_scale, | 211 float contents_scale, |
| 212 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 212 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 213 bool is_analysis) { | 213 bool is_analysis) { |
| 214 DCHECK(contents_scale >= min_contents_scale_); | 214 DCHECK(contents_scale >= min_contents_scale_); |
| 215 | 215 |
| 216 canvas->translate(-canvas_rect.x(), -canvas_rect.y()); | 216 canvas->translate(-canvas_rect.x(), -canvas_rect.y()); |
| 217 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(), | 217 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(), |
| 218 contents_scale); | 218 contents_scale); |
| 219 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size)); | 219 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size)); |
| 220 gfx::Rect content_rect = total_content_rect; | 220 gfx::Rect content_rect = total_content_rect; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 layer_rect.height(), | 302 layer_rect.height(), |
| 303 SkPicture::kUsePathBoundsForClip_RecordingFlag); | 303 SkPicture::kUsePathBoundsForClip_RecordingFlag); |
| 304 | 304 |
| 305 RasterToBitmap(canvas, layer_rect, 1.0, NULL); | 305 RasterToBitmap(canvas, layer_rect, 1.0, NULL); |
| 306 picture->endRecording(); | 306 picture->endRecording(); |
| 307 | 307 |
| 308 return picture; | 308 return picture; |
| 309 } | 309 } |
| 310 | 310 |
| 311 void PicturePileImpl::AnalyzeInRect( | 311 void PicturePileImpl::AnalyzeInRect( |
| 312 gfx::Rect content_rect, | 312 const gfx::Rect& content_rect, |
| 313 float contents_scale, | 313 float contents_scale, |
| 314 PicturePileImpl::Analysis* analysis) { | 314 PicturePileImpl::Analysis* analysis) { |
| 315 AnalyzeInRect(content_rect, contents_scale, analysis, NULL); | 315 AnalyzeInRect(content_rect, contents_scale, analysis, NULL); |
| 316 } | 316 } |
| 317 | 317 |
| 318 void PicturePileImpl::AnalyzeInRect( | 318 void PicturePileImpl::AnalyzeInRect( |
| 319 gfx::Rect content_rect, | 319 const gfx::Rect& content_rect, |
| 320 float contents_scale, | 320 float contents_scale, |
| 321 PicturePileImpl::Analysis* analysis, | 321 PicturePileImpl::Analysis* analysis, |
| 322 RenderingStatsInstrumentation* stats_instrumentation) { | 322 RenderingStatsInstrumentation* stats_instrumentation) { |
| 323 DCHECK(analysis); | 323 DCHECK(analysis); |
| 324 TRACE_EVENT0("cc", "PicturePileImpl::AnalyzeInRect"); | 324 TRACE_EVENT0("cc", "PicturePileImpl::AnalyzeInRect"); |
| 325 | 325 |
| 326 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( | 326 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( |
| 327 content_rect, 1.0f / contents_scale); | 327 content_rect, 1.0f / contents_scale); |
| 328 | 328 |
| 329 layer_rect.Intersect(gfx::Rect(tiling_.total_size())); | 329 layer_rect.Intersect(gfx::Rect(tiling_.total_size())); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 343 | 343 |
| 344 PicturePileImpl::Analysis::Analysis() | 344 PicturePileImpl::Analysis::Analysis() |
| 345 : is_solid_color(false), | 345 : is_solid_color(false), |
| 346 has_text(false) { | 346 has_text(false) { |
| 347 } | 347 } |
| 348 | 348 |
| 349 PicturePileImpl::Analysis::~Analysis() { | 349 PicturePileImpl::Analysis::~Analysis() { |
| 350 } | 350 } |
| 351 | 351 |
| 352 PicturePileImpl::PixelRefIterator::PixelRefIterator( | 352 PicturePileImpl::PixelRefIterator::PixelRefIterator( |
| 353 gfx::Rect content_rect, | 353 const gfx::Rect& content_rect, |
| 354 float contents_scale, | 354 float contents_scale, |
| 355 const PicturePileImpl* picture_pile) | 355 const PicturePileImpl* picture_pile) |
| 356 : picture_pile_(picture_pile), | 356 : picture_pile_(picture_pile), |
| 357 layer_rect_(gfx::ScaleToEnclosingRect( | 357 layer_rect_(gfx::ScaleToEnclosingRect( |
| 358 content_rect, 1.f / contents_scale)), | 358 content_rect, 1.f / contents_scale)), |
| 359 tile_iterator_(&picture_pile_->tiling_, layer_rect_) { | 359 tile_iterator_(&picture_pile_->tiling_, layer_rect_) { |
| 360 // Early out if there isn't a single tile. | 360 // Early out if there isn't a single tile. |
| 361 if (!tile_iterator_) | 361 if (!tile_iterator_) |
| 362 return; | 362 return; |
| 363 | 363 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 ++it) { | 405 ++it) { |
| 406 Picture* picture = it->second.GetPicture(); | 406 Picture* picture = it->second.GetPicture(); |
| 407 if (picture && (processed_pictures.count(picture) == 0)) { | 407 if (picture && (processed_pictures.count(picture) == 0)) { |
| 408 picture->EmitTraceSnapshot(); | 408 picture->EmitTraceSnapshot(); |
| 409 processed_pictures.insert(picture); | 409 processed_pictures.insert(picture); |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 } | 412 } |
| 413 | 413 |
| 414 } // namespace cc | 414 } // namespace cc |
| OLD | NEW |