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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 | 89 |
90 canvas->save(); | 90 canvas->save(); |
91 canvas->translate(-canvas_rect.x(), -canvas_rect.y()); | 91 canvas->translate(-canvas_rect.x(), -canvas_rect.y()); |
92 | 92 |
93 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(), | 93 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(), |
94 contents_scale); | 94 contents_scale); |
95 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size)); | 95 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size)); |
96 gfx::Rect content_rect = total_content_rect; | 96 gfx::Rect content_rect = total_content_rect; |
97 content_rect.Intersect(canvas_rect); | 97 content_rect.Intersect(canvas_rect); |
98 | 98 |
99 // Clear one texel inside the right/bottom edge of the content rect, | 99 // Clear an inflated content rect, to ensure that we always sample |
100 // as it may only be partially covered by the picture playback. | 100 // a correct pixel. |
101 // Also clear one texel outside the right/bottom edge of the content rect, | 101 gfx::Rect inflated_content_rect = total_content_rect; |
102 // as it may get blended in by linear filtering when zoomed in. | 102 inflated_content_rect.Inset(0, 0, -1, -1); |
103 gfx::Rect deflated_content_rect = total_content_rect; | |
104 deflated_content_rect.Inset(0, 0, 1, 1); | |
105 | 103 |
106 gfx::Rect canvas_outside_content_rect = canvas_rect; | 104 SkPaint background_paint; |
107 canvas_outside_content_rect.Subtract(deflated_content_rect); | 105 background_paint.setColor(background_color_); |
108 | 106 background_paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
109 if (!canvas_outside_content_rect.IsEmpty()) { | 107 canvas->drawRect(RectToSkRect(inflated_content_rect), background_paint); |
Tom Hudson
2013/04/30 09:43:59
canvas->clear(background_color_) may be more effic
vmpstr
2013/04/30 17:06:23
Fixed.
enne (OOO)
2013/04/30 17:13:53
Sometimes we are only rastering a sub-rectangle of
| |
110 gfx::Rect inflated_content_rect = total_content_rect; | |
111 inflated_content_rect.Inset(0, 0, -1, -1); | |
112 canvas->clipRect(gfx::RectToSkRect(inflated_content_rect), | |
113 SkRegion::kReplace_Op); | |
114 canvas->clipRect(gfx::RectToSkRect(deflated_content_rect), | |
115 SkRegion::kDifference_Op); | |
116 canvas->drawColor(background_color_, SkXfermode::kSrc_Mode); | |
117 } | |
118 | 108 |
119 // Rasterize the collection of relevant picture piles. | 109 // Rasterize the collection of relevant picture piles. |
120 gfx::Rect layer_rect = gfx::ToEnclosingRect( | 110 gfx::Rect layer_rect = gfx::ToEnclosingRect( |
121 gfx::ScaleRect(content_rect, 1.f / contents_scale)); | 111 gfx::ScaleRect(content_rect, 1.f / contents_scale)); |
122 | 112 |
123 canvas->clipRect(gfx::RectToSkRect(content_rect), | 113 canvas->clipRect(gfx::RectToSkRect(content_rect), |
124 SkRegion::kReplace_Op); | 114 SkRegion::kReplace_Op); |
125 Region unclipped(content_rect); | 115 Region unclipped(content_rect); |
126 | 116 |
127 if (raster_stats) { | 117 if (raster_stats) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 layer_rect_, | 321 layer_rect_, |
332 *picture_list_iterator_); | 322 *picture_list_iterator_); |
333 if (pixel_ref_iterator_) | 323 if (pixel_ref_iterator_) |
334 return; | 324 return; |
335 } | 325 } |
336 ++tile_iterator_; | 326 ++tile_iterator_; |
337 } while (AdvanceToTileWithPictures()); | 327 } while (AdvanceToTileWithPictures()); |
338 } | 328 } |
339 | 329 |
340 } // namespace cc | 330 } // namespace cc |
OLD | NEW |