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 an inflated content rect, to ensure that we always sample | 99 // Clear one texel inside the right/bottom edge of the content rect, |
100 // a correct pixel. | 100 // as it may only be partially covered by the picture playback. |
101 gfx::Rect inflated_content_rect = total_content_rect; | 101 // Also clear one texel outside the right/bottom edge of the content rect, |
102 inflated_content_rect.Inset(0, 0, -1, -1); | 102 // as it may get blended in by linear filtering when zoomed in. |
| 103 gfx::Rect deflated_content_rect = total_content_rect; |
| 104 deflated_content_rect.Inset(0, 0, 1, 1); |
103 | 105 |
104 SkPaint background_paint; | 106 gfx::Rect canvas_outside_content_rect = canvas_rect; |
105 background_paint.setColor(background_color_); | 107 canvas_outside_content_rect.Subtract(deflated_content_rect); |
106 background_paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 108 |
107 canvas->drawRect(RectToSkRect(inflated_content_rect), background_paint); | 109 if (!canvas_outside_content_rect.IsEmpty()) { |
| 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 } |
108 | 118 |
109 // Rasterize the collection of relevant picture piles. | 119 // Rasterize the collection of relevant picture piles. |
110 gfx::Rect layer_rect = gfx::ToEnclosingRect( | 120 gfx::Rect layer_rect = gfx::ToEnclosingRect( |
111 gfx::ScaleRect(content_rect, 1.f / contents_scale)); | 121 gfx::ScaleRect(content_rect, 1.f / contents_scale)); |
112 | 122 |
113 canvas->clipRect(gfx::RectToSkRect(content_rect), | 123 canvas->clipRect(gfx::RectToSkRect(content_rect), |
114 SkRegion::kReplace_Op); | 124 SkRegion::kReplace_Op); |
115 Region unclipped(content_rect); | 125 Region unclipped(content_rect); |
116 | 126 |
117 if (raster_stats) { | 127 if (raster_stats) { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 layer_rect_, | 328 layer_rect_, |
319 *picture_list_iterator_); | 329 *picture_list_iterator_); |
320 if (pixel_ref_iterator_) | 330 if (pixel_ref_iterator_) |
321 return; | 331 return; |
322 } | 332 } |
323 ++tile_iterator_; | 333 ++tile_iterator_; |
324 } while (AdvanceToTileWithPictures()); | 334 } while (AdvanceToTileWithPictures()); |
325 } | 335 } |
326 | 336 |
327 } // namespace cc | 337 } // namespace cc |
OLD | NEW |