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/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 "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
11 #include "third_party/skia/include/core/SkSize.h" | 11 #include "third_party/skia/include/core/SkSize.h" |
12 #include "ui/gfx/rect_conversions.h" | 12 #include "ui/gfx/rect_conversions.h" |
| 13 #include "ui/gfx/size_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 } |
20 | 21 |
21 PicturePileImpl::PicturePileImpl() | 22 PicturePileImpl::PicturePileImpl() |
22 : slow_down_raster_scale_factor_for_debug_(0) { | 23 : slow_down_raster_scale_factor_for_debug_(0) { |
(...skipping 30 matching lines...) Expand all Loading... |
53 } | 54 } |
54 clone->min_contents_scale_ = min_contents_scale_; | 55 clone->min_contents_scale_ = min_contents_scale_; |
55 clone->set_slow_down_raster_scale_factor( | 56 clone->set_slow_down_raster_scale_factor( |
56 slow_down_raster_scale_factor_for_debug_); | 57 slow_down_raster_scale_factor_for_debug_); |
57 | 58 |
58 return clone; | 59 return clone; |
59 } | 60 } |
60 | 61 |
61 void PicturePileImpl::Raster( | 62 void PicturePileImpl::Raster( |
62 SkCanvas* canvas, | 63 SkCanvas* canvas, |
63 gfx::Rect content_rect, | 64 gfx::Rect canvas_rect, |
64 float contents_scale, | 65 float contents_scale, |
65 int64* total_pixels_rasterized) { | 66 int64* total_pixels_rasterized) { |
66 | 67 |
67 DCHECK(contents_scale >= min_contents_scale_); | 68 DCHECK(contents_scale >= min_contents_scale_); |
68 | 69 |
69 #ifndef NDEBUG | 70 #ifndef NDEBUG |
70 // Any non-painted areas will be left in this color. | 71 // Any non-painted areas will be left in this color. |
71 canvas->clear(DebugColors::NonPaintedFillColor()); | 72 canvas->clear(DebugColors::NonPaintedFillColor()); |
72 #endif // NDEBUG | 73 #endif // NDEBUG |
73 | 74 |
74 canvas->save(); | 75 canvas->save(); |
75 canvas->translate(-content_rect.x(), -content_rect.y()); | 76 canvas->translate(-canvas_rect.x(), -canvas_rect.y()); |
76 canvas->clipRect(gfx::RectToSkRect(content_rect)); | |
77 | 77 |
| 78 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(), |
| 79 contents_scale); |
| 80 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size)); |
| 81 gfx::Rect content_rect = total_content_rect; |
| 82 content_rect.Intersect(canvas_rect); |
| 83 |
| 84 // Clear one texel inside the right/bottom edge of the content rect, |
| 85 // as it may only be partially covered by the picture playback. |
| 86 // Also clear one texel outside the right/bottom edge of the content rect, |
| 87 // as it may get blended in by linear filtering when zoomed in. |
| 88 gfx::Rect deflated_content_rect = total_content_rect; |
| 89 deflated_content_rect.Inset(0, 0, 1, 1); |
| 90 |
| 91 gfx::Rect canvas_outside_content_rect = canvas_rect; |
| 92 canvas_outside_content_rect.Subtract(deflated_content_rect); |
| 93 |
| 94 if (!canvas_outside_content_rect.IsEmpty()) { |
| 95 gfx::Rect inflated_content_rect = total_content_rect; |
| 96 inflated_content_rect.Inset(0, 0, -1, -1); |
| 97 canvas->clipRect(gfx::RectToSkRect(inflated_content_rect), |
| 98 SkRegion::kReplace_Op); |
| 99 canvas->clipRect(gfx::RectToSkRect(deflated_content_rect), |
| 100 SkRegion::kDifference_Op); |
| 101 canvas->drawColor(background_color_, SkXfermode::kSrc_Mode); |
| 102 } |
| 103 |
| 104 // Rasterize the collection of relevant picture piles. |
78 gfx::Rect layer_rect = gfx::ToEnclosingRect( | 105 gfx::Rect layer_rect = gfx::ToEnclosingRect( |
79 gfx::ScaleRect(content_rect, 1.f / contents_scale)); | 106 gfx::ScaleRect(content_rect, 1.f / contents_scale)); |
80 | 107 |
| 108 canvas->clipRect(gfx::RectToSkRect(content_rect), |
| 109 SkRegion::kReplace_Op); |
81 Region unclipped(content_rect); | 110 Region unclipped(content_rect); |
82 for (TilingData::Iterator tile_iter(&tiling_, layer_rect); | 111 for (TilingData::Iterator tile_iter(&tiling_, layer_rect); |
83 tile_iter; ++tile_iter) { | 112 tile_iter; ++tile_iter) { |
84 PictureListMap::iterator map_iter = | 113 PictureListMap::iterator map_iter = |
85 picture_list_map_.find(tile_iter.index()); | 114 picture_list_map_.find(tile_iter.index()); |
86 if (map_iter == picture_list_map_.end()) | 115 if (map_iter == picture_list_map_.end()) |
87 continue; | 116 continue; |
88 PictureList& pic_list= map_iter->second; | 117 PictureList& pic_list= map_iter->second; |
89 if (pic_list.empty()) | 118 if (pic_list.empty()) |
90 continue; | 119 continue; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 if (!(*i)->LayerRect().Intersects(layer_rect) || !(*i)->HasRecording()) | 235 if (!(*i)->LayerRect().Intersects(layer_rect) || !(*i)->HasRecording()) |
207 continue; | 236 continue; |
208 if (!(*i)->IsCheapInRect(layer_rect)) | 237 if (!(*i)->IsCheapInRect(layer_rect)) |
209 return false; | 238 return false; |
210 } | 239 } |
211 } | 240 } |
212 return true; | 241 return true; |
213 } | 242 } |
214 | 243 |
215 } // namespace cc | 244 } // namespace cc |
OLD | NEW |