Chromium Code Reviews| 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 "cc/resources/picture_pile.h" | 5 #include "cc/resources/picture_pile.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 | 139 |
| 140 } // namespace | 140 } // namespace |
| 141 | 141 |
| 142 namespace cc { | 142 namespace cc { |
| 143 | 143 |
| 144 PicturePile::PicturePile() : is_suitable_for_gpu_rasterization_(true) {} | 144 PicturePile::PicturePile() : is_suitable_for_gpu_rasterization_(true) {} |
| 145 | 145 |
| 146 PicturePile::~PicturePile() { | 146 PicturePile::~PicturePile() { |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool PicturePile::Update(ContentLayerClient* painter, | 149 bool PicturePile::UpdateAndExpandInvalidation( |
| 150 SkColor background_color, | 150 ContentLayerClient* painter, |
| 151 bool contents_opaque, | 151 Region* invalidation, |
| 152 bool contents_fill_bounds_completely, | 152 SkColor background_color, |
| 153 const Region& invalidation, | 153 bool contents_opaque, |
| 154 const gfx::Rect& visible_layer_rect, | 154 bool contents_fill_bounds_completely, |
| 155 int frame_number, | 155 const gfx::Rect& visible_layer_rect, |
| 156 Picture::RecordingMode recording_mode, | 156 int frame_number, |
| 157 RenderingStatsInstrumentation* stats_instrumentation) { | 157 Picture::RecordingMode recording_mode, |
| 158 RenderingStatsInstrumentation* stats_instrumentation) { | |
| 158 background_color_ = background_color; | 159 background_color_ = background_color; |
| 159 contents_opaque_ = contents_opaque; | 160 contents_opaque_ = contents_opaque; |
| 160 contents_fill_bounds_completely_ = contents_fill_bounds_completely; | 161 contents_fill_bounds_completely_ = contents_fill_bounds_completely; |
| 161 | 162 |
| 162 gfx::Rect interest_rect = visible_layer_rect; | 163 gfx::Rect interest_rect = visible_layer_rect; |
| 163 interest_rect.Inset( | 164 interest_rect.Inset( |
| 164 -kPixelDistanceToRecord, | 165 -kPixelDistanceToRecord, |
| 165 -kPixelDistanceToRecord, | 166 -kPixelDistanceToRecord, |
| 166 -kPixelDistanceToRecord, | 167 -kPixelDistanceToRecord, |
| 167 -kPixelDistanceToRecord); | 168 -kPixelDistanceToRecord); |
| 168 recorded_viewport_ = interest_rect; | 169 recorded_viewport_ = interest_rect; |
| 169 recorded_viewport_.Intersect(tiling_rect()); | 170 recorded_viewport_.Intersect(tiling_rect()); |
| 170 | 171 |
| 172 Region invalidation_expanded_to_recording_tiles; | |
| 173 | |
| 171 bool invalidated = false; | 174 bool invalidated = false; |
| 172 for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { | 175 for (Region::Iterator i(*invalidation); i.has_rect(); i.next()) { |
| 173 gfx::Rect invalidation = i.rect(); | 176 gfx::Rect invalid_rect = i.rect(); |
| 174 // Split this inflated invalidation across tile boundaries and apply it | 177 // Split this inflated invalidation across tile boundaries and apply it |
| 175 // to all tiles that it touches. | 178 // to all tiles that it touches. |
| 176 bool include_borders = true; | 179 bool include_borders = true; |
| 177 for (TilingData::Iterator iter(&tiling_, invalidation, include_borders); | 180 for (TilingData::Iterator iter(&tiling_, invalid_rect, include_borders); |
| 178 iter; | 181 iter; |
| 179 ++iter) { | 182 ++iter) { |
| 180 const PictureMapKey& key = iter.index(); | 183 const PictureMapKey& key = iter.index(); |
| 181 | 184 |
| 182 PictureMap::iterator picture_it = picture_map_.find(key); | 185 PictureMap::iterator picture_it = picture_map_.find(key); |
| 183 if (picture_it == picture_map_.end()) | 186 if (picture_it == picture_map_.end()) |
| 184 continue; | 187 continue; |
| 185 | 188 |
| 186 // Inform the grid cell that it has been invalidated in this frame. | 189 // Inform the grid cell that it has been invalidated in this frame. |
| 187 invalidated = picture_it->second.Invalidate(frame_number) || invalidated; | 190 invalidated = picture_it->second.Invalidate(frame_number) || invalidated; |
| 188 } | 191 } |
| 192 | |
| 193 int left_tile = tiling_.FirstBorderTileXIndexFromSrcCoord(invalid_rect.x()); | |
| 194 int top_tile = tiling_.FirstBorderTileYIndexFromSrcCoord(invalid_rect.y()); | |
| 195 int right_tile = | |
| 196 tiling_.LastBorderTileXIndexFromSrcCoord(invalid_rect.right() - 1); | |
| 197 int bottom_tile = | |
| 198 tiling_.LastBorderTileYIndexFromSrcCoord(invalid_rect.bottom() - 1); | |
| 199 gfx::Rect invalid_rect_filling_tiles = | |
| 200 gfx::UnionRects(tiling_.TileBoundsWithBorder(left_tile, top_tile), | |
|
enne (OOO)
2014/06/13 22:26:42
I think invalidation_expanded_to_recording_tiles.U
enne (OOO)
2014/06/13 22:34:13
Actually, more importantly, you should only inflat
| |
| 201 tiling_.TileBoundsWithBorder(right_tile, bottom_tile)); | |
| 202 invalidation_expanded_to_recording_tiles.Union(invalid_rect_filling_tiles); | |
| 189 } | 203 } |
| 190 | 204 |
| 205 // Return the expanded invalidation. | |
| 206 invalidation_expanded_to_recording_tiles.Swap(invalidation); | |
| 207 | |
| 191 // Make a list of all invalid tiles; we will attempt to | 208 // Make a list of all invalid tiles; we will attempt to |
| 192 // cluster these into multiple invalidation regions. | 209 // cluster these into multiple invalidation regions. |
| 193 std::vector<gfx::Rect> invalid_tiles; | 210 std::vector<gfx::Rect> invalid_tiles; |
| 194 bool include_borders = true; | 211 bool include_borders = true; |
| 195 for (TilingData::Iterator it(&tiling_, interest_rect, include_borders); it; | 212 for (TilingData::Iterator it(&tiling_, interest_rect, include_borders); it; |
| 196 ++it) { | 213 ++it) { |
| 197 const PictureMapKey& key = it.index(); | 214 const PictureMapKey& key = it.index(); |
| 198 PictureInfo& info = picture_map_[key]; | 215 PictureInfo& info = picture_map_[key]; |
| 199 | 216 |
| 200 gfx::Rect rect = PaddedRect(key); | 217 gfx::Rect rect = PaddedRect(key); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 } | 294 } |
| 278 DCHECK(found_tile_for_recorded_picture); | 295 DCHECK(found_tile_for_recorded_picture); |
| 279 } | 296 } |
| 280 | 297 |
| 281 has_any_recordings_ = true; | 298 has_any_recordings_ = true; |
| 282 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); | 299 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); |
| 283 return true; | 300 return true; |
| 284 } | 301 } |
| 285 | 302 |
| 286 } // namespace cc | 303 } // namespace cc |
| OLD | NEW |