| 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 |
| 11 #include "base/numerics/safe_math.h" |
| 11 #include "cc/base/region.h" | 12 #include "cc/base/region.h" |
| 12 #include "cc/resources/picture_pile_impl.h" | 13 #include "cc/resources/picture_pile_impl.h" |
| 13 #include "skia/ext/analysis_canvas.h" | 14 #include "skia/ext/analysis_canvas.h" |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 // Layout pixel buffer around the visible layer rect to record. Any base | 17 // Layout pixel buffer around the visible layer rect to record. Any base |
| 17 // picture that intersects the visible layer rect expanded by this distance | 18 // picture that intersects the visible layer rect expanded by this distance |
| 18 // will be recorded. | 19 // will be recorded. |
| 19 const int kPixelDistanceToRecord = 8000; | 20 const int kPixelDistanceToRecord = 8000; |
| 20 // We don't perform solid color analysis on images that have more than 10 skia | 21 // We don't perform solid color analysis on images that have more than 10 skia |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 174 |
| 174 PicturePile::~PicturePile() { | 175 PicturePile::~PicturePile() { |
| 175 } | 176 } |
| 176 | 177 |
| 177 bool PicturePile::UpdateAndExpandInvalidation( | 178 bool PicturePile::UpdateAndExpandInvalidation( |
| 178 ContentLayerClient* painter, | 179 ContentLayerClient* painter, |
| 179 Region* invalidation, | 180 Region* invalidation, |
| 180 const gfx::Size& layer_size, | 181 const gfx::Size& layer_size, |
| 181 const gfx::Rect& visible_layer_rect, | 182 const gfx::Rect& visible_layer_rect, |
| 182 int frame_number, | 183 int frame_number, |
| 183 RecordingSource::RecordingMode recording_mode) { | 184 RecordingSource::RecordingMode recording_mode, |
| 185 int* recorded_area) { |
| 184 gfx::Rect interest_rect = visible_layer_rect; | 186 gfx::Rect interest_rect = visible_layer_rect; |
| 185 interest_rect.Inset(-pixel_record_distance_, -pixel_record_distance_); | 187 interest_rect.Inset(-pixel_record_distance_, -pixel_record_distance_); |
| 186 recorded_viewport_ = interest_rect; | 188 recorded_viewport_ = interest_rect; |
| 187 recorded_viewport_.Intersect(gfx::Rect(layer_size)); | 189 recorded_viewport_.Intersect(gfx::Rect(layer_size)); |
| 188 | 190 |
| 189 bool updated = ApplyInvalidationAndResize(interest_rect, invalidation, | 191 bool updated = ApplyInvalidationAndResize(interest_rect, invalidation, |
| 190 layer_size, frame_number); | 192 layer_size, frame_number); |
| 191 std::vector<gfx::Rect> invalid_tiles; | 193 std::vector<gfx::Rect> invalid_tiles; |
| 192 GetInvalidTileRects(interest_rect, invalidation, visible_layer_rect, | 194 GetInvalidTileRects(interest_rect, invalidation, visible_layer_rect, |
| 193 frame_number, &invalid_tiles); | 195 frame_number, &invalid_tiles); |
| 194 std::vector<gfx::Rect> record_rects; | 196 std::vector<gfx::Rect> record_rects; |
| 195 ClusterTiles(invalid_tiles, &record_rects); | 197 ClusterTiles(invalid_tiles, &record_rects); |
| 196 | 198 |
| 199 if (recorded_area) { |
| 200 base::CheckedNumeric<int> area = 0; |
| 201 for (const auto& record_rect : record_rects) |
| 202 area += record_rect.size().GetArea(); |
| 203 *recorded_area = area.ValueOrDefault(std::numeric_limits<int>::max()); |
| 204 } |
| 205 |
| 197 if (record_rects.empty()) | 206 if (record_rects.empty()) |
| 198 return updated; | 207 return updated; |
| 199 | 208 |
| 200 CreatePictures(painter, recording_mode, record_rects); | 209 CreatePictures(painter, recording_mode, record_rects); |
| 201 | 210 |
| 202 DetermineIfSolidColor(); | 211 DetermineIfSolidColor(); |
| 203 | 212 |
| 204 has_any_recordings_ = true; | 213 has_any_recordings_ = true; |
| 205 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); | 214 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); |
| 206 return true; | 215 return true; |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 | 688 |
| 680 void PicturePile::SetBufferPixels(int new_buffer_pixels) { | 689 void PicturePile::SetBufferPixels(int new_buffer_pixels) { |
| 681 if (new_buffer_pixels == buffer_pixels()) | 690 if (new_buffer_pixels == buffer_pixels()) |
| 682 return; | 691 return; |
| 683 | 692 |
| 684 Clear(); | 693 Clear(); |
| 685 tiling_.SetBorderTexels(new_buffer_pixels); | 694 tiling_.SetBorderTexels(new_buffer_pixels); |
| 686 } | 695 } |
| 687 | 696 |
| 688 } // namespace cc | 697 } // namespace cc |
| OLD | NEW |