| 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 "base/debug/trace_event.h" | 5 #include "base/debug/trace_event.h" |
| 6 #include "cc/picture_pile_impl.h" | 6 #include "cc/picture_pile_impl.h" |
| 7 #include "cc/region.h" | 7 #include "cc/region.h" |
| 8 #include "cc/rendering_stats.h" | 8 #include "cc/rendering_stats.h" |
| 9 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
| 10 #include "third_party/skia/include/core/SkSize.h" | 10 #include "third_party/skia/include/core/SkSize.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 | 59 |
| 60 void PicturePileImpl::Raster( | 60 void PicturePileImpl::Raster( |
| 61 SkCanvas* canvas, | 61 SkCanvas* canvas, |
| 62 gfx::Rect content_rect, | 62 gfx::Rect content_rect, |
| 63 float contents_scale, | 63 float contents_scale, |
| 64 RenderingStats* stats) { | 64 RenderingStats* stats) { |
| 65 | 65 |
| 66 DCHECK(contents_scale >= min_contents_scale_); | 66 DCHECK(contents_scale >= min_contents_scale_); |
| 67 | 67 |
| 68 base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); | 68 base::TimeTicks rasterize_begin_time; |
| 69 if (stats) |
| 70 rasterize_begin_time = base::TimeTicks::Now(); |
| 69 | 71 |
| 70 canvas->save(); | 72 canvas->save(); |
| 71 canvas->translate(-content_rect.x(), -content_rect.y()); | 73 canvas->translate(-content_rect.x(), -content_rect.y()); |
| 72 canvas->clipRect(gfx::RectToSkRect(content_rect)); | 74 canvas->clipRect(gfx::RectToSkRect(content_rect)); |
| 73 | 75 |
| 74 gfx::Rect layer_rect = gfx::ToEnclosingRect( | 76 gfx::Rect layer_rect = gfx::ToEnclosingRect( |
| 75 gfx::ScaleRect(content_rect, 1.f / contents_scale)); | 77 gfx::ScaleRect(content_rect, 1.f / contents_scale)); |
| 76 | 78 |
| 77 Region unclipped(content_rect); | 79 Region unclipped(content_rect); |
| 78 for (TilingData::Iterator tile_iter(&tiling_, layer_rect); | 80 for (TilingData::Iterator tile_iter(&tiling_, layer_rect); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 105 } else { | 107 } else { |
| 106 (*i)->Raster(canvas, content_clip, contents_scale); | 108 (*i)->Raster(canvas, content_clip, contents_scale); |
| 107 } | 109 } |
| 108 | 110 |
| 109 // Don't allow pictures underneath to draw where this picture did. | 111 // Don't allow pictures underneath to draw where this picture did. |
| 110 canvas->clipRect( | 112 canvas->clipRect( |
| 111 gfx::RectToSkRect(content_clip), | 113 gfx::RectToSkRect(content_clip), |
| 112 SkRegion::kDifference_Op); | 114 SkRegion::kDifference_Op); |
| 113 unclipped.Subtract(content_clip); | 115 unclipped.Subtract(content_clip); |
| 114 | 116 |
| 115 stats->totalPixelsRasterized += | 117 if (stats) |
| 116 content_clip.width() * content_clip.height(); | 118 stats->totalPixelsRasterized += |
| 119 content_clip.width() * content_clip.height(); |
| 117 } | 120 } |
| 118 } | 121 } |
| 119 canvas->restore(); | 122 canvas->restore(); |
| 120 | 123 |
| 121 stats->totalRasterizeTime += base::TimeTicks::Now() - rasterizeBeginTime; | 124 if (stats) |
| 125 stats->totalRasterizeTime += base::TimeTicks::Now() - rasterize_begin_time; |
| 122 } | 126 } |
| 123 | 127 |
| 124 void PicturePileImpl::GatherPixelRefs( | 128 void PicturePileImpl::GatherPixelRefs( |
| 125 gfx::Rect content_rect, | 129 gfx::Rect content_rect, |
| 126 float contents_scale, | 130 float contents_scale, |
| 127 std::list<skia::LazyPixelRef*>& pixel_refs) { | 131 std::list<skia::LazyPixelRef*>& pixel_refs) { |
| 128 std::list<skia::LazyPixelRef*> result; | 132 std::list<skia::LazyPixelRef*> result; |
| 129 | 133 |
| 130 gfx::Rect layer_rect = gfx::ToEnclosingRect( | 134 gfx::Rect layer_rect = gfx::ToEnclosingRect( |
| 131 gfx::ScaleRect(content_rect, 1.f / contents_scale)); | 135 gfx::ScaleRect(content_rect, 1.f / contents_scale)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 SkPicture::kUsePathBoundsForClip_RecordingFlag); | 169 SkPicture::kUsePathBoundsForClip_RecordingFlag); |
| 166 | 170 |
| 167 RenderingStats stats; | 171 RenderingStats stats; |
| 168 Raster(canvas, layer_rect, 1.0, &stats); | 172 Raster(canvas, layer_rect, 1.0, &stats); |
| 169 picture->endRecording(); | 173 picture->endRecording(); |
| 170 | 174 |
| 171 return picture; | 175 return picture; |
| 172 } | 176 } |
| 173 | 177 |
| 174 } // namespace cc | 178 } // namespace cc |
| OLD | NEW |