| 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 "cc/base/histograms.h" | |
| 12 #include "cc/base/region.h" | 11 #include "cc/base/region.h" |
| 13 #include "cc/resources/picture_pile_impl.h" | 12 #include "cc/resources/picture_pile_impl.h" |
| 14 #include "skia/ext/analysis_canvas.h" | 13 #include "skia/ext/analysis_canvas.h" |
| 15 | 14 |
| 16 namespace { | 15 namespace { |
| 17 // Layout pixel buffer around the visible layer rect to record. Any base | 16 // Layout pixel buffer around the visible layer rect to record. Any base |
| 18 // picture that intersects the visible layer rect expanded by this distance | 17 // picture that intersects the visible layer rect expanded by this distance |
| 19 // will be recorded. | 18 // will be recorded. |
| 20 const int kPixelDistanceToRecord = 8000; | 19 const int kPixelDistanceToRecord = 8000; |
| 21 // We don't perform solid color analysis on images that have more than 10 skia | 20 // We don't perform solid color analysis on images that have more than 10 skia |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 142 |
| 144 *record_rects = vertical_clustering; | 143 *record_rects = vertical_clustering; |
| 145 } | 144 } |
| 146 | 145 |
| 147 #ifdef NDEBUG | 146 #ifdef NDEBUG |
| 148 const bool kDefaultClearCanvasSetting = false; | 147 const bool kDefaultClearCanvasSetting = false; |
| 149 #else | 148 #else |
| 150 const bool kDefaultClearCanvasSetting = true; | 149 const bool kDefaultClearCanvasSetting = true; |
| 151 #endif | 150 #endif |
| 152 | 151 |
| 153 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( | |
| 154 ScopedPicturePileUpdateTimer, | |
| 155 "Compositing.PicturePile.UpdateUs", | |
| 156 "Compositing.PicturePile.UpdateInvalidatedAreaPerMs"); | |
| 157 | |
| 158 } // namespace | 152 } // namespace |
| 159 | 153 |
| 160 namespace cc { | 154 namespace cc { |
| 161 | 155 |
| 162 PicturePile::PicturePile(float min_contents_scale, | 156 PicturePile::PicturePile(float min_contents_scale, |
| 163 const gfx::Size& tile_grid_size) | 157 const gfx::Size& tile_grid_size) |
| 164 : min_contents_scale_(0), | 158 : min_contents_scale_(0), |
| 165 slow_down_raster_scale_factor_for_debug_(0), | 159 slow_down_raster_scale_factor_for_debug_(0), |
| 166 gather_pixel_refs_(false), | 160 gather_pixel_refs_(false), |
| 167 has_any_recordings_(false), | 161 has_any_recordings_(false), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 180 PicturePile::~PicturePile() { | 174 PicturePile::~PicturePile() { |
| 181 } | 175 } |
| 182 | 176 |
| 183 bool PicturePile::UpdateAndExpandInvalidation( | 177 bool PicturePile::UpdateAndExpandInvalidation( |
| 184 ContentLayerClient* painter, | 178 ContentLayerClient* painter, |
| 185 Region* invalidation, | 179 Region* invalidation, |
| 186 const gfx::Size& layer_size, | 180 const gfx::Size& layer_size, |
| 187 const gfx::Rect& visible_layer_rect, | 181 const gfx::Rect& visible_layer_rect, |
| 188 int frame_number, | 182 int frame_number, |
| 189 RecordingSource::RecordingMode recording_mode) { | 183 RecordingSource::RecordingMode recording_mode) { |
| 190 ScopedPicturePileUpdateTimer timer; | |
| 191 | |
| 192 gfx::Rect interest_rect = visible_layer_rect; | 184 gfx::Rect interest_rect = visible_layer_rect; |
| 193 interest_rect.Inset(-pixel_record_distance_, -pixel_record_distance_); | 185 interest_rect.Inset(-pixel_record_distance_, -pixel_record_distance_); |
| 194 recorded_viewport_ = interest_rect; | 186 recorded_viewport_ = interest_rect; |
| 195 recorded_viewport_.Intersect(gfx::Rect(layer_size)); | 187 recorded_viewport_.Intersect(gfx::Rect(layer_size)); |
| 196 | 188 |
| 197 bool updated = ApplyInvalidationAndResize(interest_rect, invalidation, | 189 bool updated = ApplyInvalidationAndResize(interest_rect, invalidation, |
| 198 layer_size, frame_number); | 190 layer_size, frame_number); |
| 199 | |
| 200 // Count the area that is being invalidated. | |
| 201 Region recorded_invalidation(*invalidation); | |
| 202 recorded_invalidation.Intersect(recorded_viewport_); | |
| 203 for (Region::Iterator it(recorded_invalidation); it.has_rect(); it.next()) | |
| 204 timer.AddArea(it.rect().size().GetArea()); | |
| 205 | |
| 206 std::vector<gfx::Rect> invalid_tiles; | 191 std::vector<gfx::Rect> invalid_tiles; |
| 207 GetInvalidTileRects(interest_rect, &invalid_tiles); | 192 GetInvalidTileRects(interest_rect, &invalid_tiles); |
| 208 std::vector<gfx::Rect> record_rects; | 193 std::vector<gfx::Rect> record_rects; |
| 209 ClusterTiles(invalid_tiles, &record_rects); | 194 ClusterTiles(invalid_tiles, &record_rects); |
| 210 | 195 |
| 211 if (record_rects.empty()) | 196 if (record_rects.empty()) |
| 212 return updated; | 197 return updated; |
| 213 | 198 |
| 214 CreatePictures(painter, recording_mode, record_rects); | 199 CreatePictures(painter, recording_mode, record_rects); |
| 215 | 200 |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 | 675 |
| 691 void PicturePile::SetBufferPixels(int new_buffer_pixels) { | 676 void PicturePile::SetBufferPixels(int new_buffer_pixels) { |
| 692 if (new_buffer_pixels == buffer_pixels()) | 677 if (new_buffer_pixels == buffer_pixels()) |
| 693 return; | 678 return; |
| 694 | 679 |
| 695 Clear(); | 680 Clear(); |
| 696 tiling_.SetBorderTexels(new_buffer_pixels); | 681 tiling_.SetBorderTexels(new_buffer_pixels); |
| 697 } | 682 } |
| 698 | 683 |
| 699 } // namespace cc | 684 } // namespace cc |
| OLD | NEW |