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 | 6 |
7 #include "cc/picture_pile.h" | 7 #include "cc/picture_pile.h" |
8 #include "cc/picture_pile_impl.h" | 8 #include "cc/picture_pile_impl.h" |
9 #include "cc/region.h" | 9 #include "cc/region.h" |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 namespace cc { | 24 namespace cc { |
25 | 25 |
26 PicturePile::PicturePile() { | 26 PicturePile::PicturePile() { |
27 } | 27 } |
28 | 28 |
29 PicturePile::~PicturePile() { | 29 PicturePile::~PicturePile() { |
30 } | 30 } |
31 | 31 |
32 void PicturePile::Update( | 32 void PicturePile::Update( |
33 ContentLayerClient* painter, | 33 ContentLayerClient* painter, |
| 34 SkColor background_color, |
34 const Region& invalidation, | 35 const Region& invalidation, |
35 gfx::Rect visible_layer_rect, | 36 gfx::Rect visible_layer_rect, |
36 RenderingStats* stats) { | 37 RenderingStats* stats) { |
| 38 background_color_ = background_color; |
| 39 |
37 gfx::Rect interest_rect = visible_layer_rect; | 40 gfx::Rect interest_rect = visible_layer_rect; |
38 interest_rect.Inset( | 41 interest_rect.Inset( |
39 -kPixelDistanceToRecord, | 42 -kPixelDistanceToRecord, |
40 -kPixelDistanceToRecord, | 43 -kPixelDistanceToRecord, |
41 -kPixelDistanceToRecord, | 44 -kPixelDistanceToRecord, |
42 -kPixelDistanceToRecord); | 45 -kPixelDistanceToRecord); |
43 for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { | 46 for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { |
44 // Inflate all recordings from invalidations with a margin so that when | 47 // Inflate all recordings from invalidations with a margin so that when |
45 // scaled down to at least min_contents_scale, any final pixel touched by an | 48 // scaled down to at least min_contents_scale, any final pixel touched by an |
46 // invalidation can be fully rasterized by this picture. | 49 // invalidation can be fully rasterized by this picture. |
(...skipping 28 matching lines...) Expand all Loading... |
75 if (!pic_list.empty()) | 78 if (!pic_list.empty()) |
76 InvalidateRect(pic_list, tile_invalidation); | 79 InvalidateRect(pic_list, tile_invalidation); |
77 } | 80 } |
78 } | 81 } |
79 | 82 |
80 // Walk through all pictures in the rect of interest and record. | 83 // Walk through all pictures in the rect of interest and record. |
81 for (TilingData::Iterator iter(&tiling_, interest_rect); iter; ++iter) { | 84 for (TilingData::Iterator iter(&tiling_, interest_rect); iter; ++iter) { |
82 // Create a picture in this list if it doesn't exist. | 85 // Create a picture in this list if it doesn't exist. |
83 PictureList& pic_list = picture_list_map_[iter.index()]; | 86 PictureList& pic_list = picture_list_map_[iter.index()]; |
84 if (pic_list.empty()) { | 87 if (pic_list.empty()) { |
85 gfx::Rect tile = | 88 // Inflate the base picture with a margin, similar to invalidations, so |
86 tiling_.TileBoundsWithBorder(iter.index_x(), iter.index_y()); | 89 // that when scaled down to at least min_contents_scale, the enclosed |
| 90 // rect still includes content all the way to the edge of the layer. |
| 91 gfx::Rect tile = tiling_.TileBounds(iter.index_x(), iter.index_y()); |
| 92 tile.Inset( |
| 93 -buffer_pixels(), |
| 94 -buffer_pixels(), |
| 95 -buffer_pixels(), |
| 96 -buffer_pixels()); |
87 scoped_refptr<Picture> base_picture = Picture::Create(tile); | 97 scoped_refptr<Picture> base_picture = Picture::Create(tile); |
88 pic_list.push_back(base_picture); | 98 pic_list.push_back(base_picture); |
89 } | 99 } |
90 | 100 |
91 for (PictureList::iterator pic = pic_list.begin(); | 101 for (PictureList::iterator pic = pic_list.begin(); |
92 pic != pic_list.end(); ++pic) { | 102 pic != pic_list.end(); ++pic) { |
93 if (!(*pic)->HasRecording()) | 103 if (!(*pic)->HasRecording()) |
94 (*pic)->Record(painter, stats, tile_grid_info_); | 104 (*pic)->Record(painter, stats, tile_grid_info_); |
95 } | 105 } |
96 } | 106 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 155 |
146 | 156 |
147 void PicturePile::PushPropertiesTo(PicturePileImpl* other) { | 157 void PicturePile::PushPropertiesTo(PicturePileImpl* other) { |
148 // TODO(enne): Don't clear clones or push anything if nothing has changed | 158 // TODO(enne): Don't clear clones or push anything if nothing has changed |
149 // on this layer this frame. | 159 // on this layer this frame. |
150 PicturePileBase::PushPropertiesTo(other); | 160 PicturePileBase::PushPropertiesTo(other); |
151 other->clones_.clear(); | 161 other->clones_.clear(); |
152 } | 162 } |
153 | 163 |
154 } // namespace cc | 164 } // namespace cc |
OLD | NEW |