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 |
| 11 #include "cc/base/histograms.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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 | 143 |
| 143 *record_rects = vertical_clustering; | 144 *record_rects = vertical_clustering; |
| 144 } | 145 } |
| 145 | 146 |
| 146 #ifdef NDEBUG | 147 #ifdef NDEBUG |
| 147 const bool kDefaultClearCanvasSetting = false; | 148 const bool kDefaultClearCanvasSetting = false; |
| 148 #else | 149 #else |
| 149 const bool kDefaultClearCanvasSetting = true; | 150 const bool kDefaultClearCanvasSetting = true; |
| 150 #endif | 151 #endif |
| 151 | 152 |
| 153 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( | |
| 154 ScopedPicturePileUpdateTimer, | |
| 155 "Renderer4.PicturePileRecordUs", | |
| 156 "Renderer4.PicturePileRecordedAreaPerMs"); | |
| 157 | |
| 152 } // namespace | 158 } // namespace |
| 153 | 159 |
| 154 namespace cc { | 160 namespace cc { |
| 155 | 161 |
| 156 PicturePile::PicturePile(float min_contents_scale, | 162 PicturePile::PicturePile(float min_contents_scale, |
| 157 const gfx::Size& tile_grid_size) | 163 const gfx::Size& tile_grid_size) |
| 158 : min_contents_scale_(0), | 164 : min_contents_scale_(0), |
| 159 slow_down_raster_scale_factor_for_debug_(0), | 165 slow_down_raster_scale_factor_for_debug_(0), |
| 160 gather_pixel_refs_(false), | 166 gather_pixel_refs_(false), |
| 161 has_any_recordings_(false), | 167 has_any_recordings_(false), |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 174 PicturePile::~PicturePile() { | 180 PicturePile::~PicturePile() { |
| 175 } | 181 } |
| 176 | 182 |
| 177 bool PicturePile::UpdateAndExpandInvalidation( | 183 bool PicturePile::UpdateAndExpandInvalidation( |
| 178 ContentLayerClient* painter, | 184 ContentLayerClient* painter, |
| 179 Region* invalidation, | 185 Region* invalidation, |
| 180 const gfx::Size& layer_size, | 186 const gfx::Size& layer_size, |
| 181 const gfx::Rect& visible_layer_rect, | 187 const gfx::Rect& visible_layer_rect, |
| 182 int frame_number, | 188 int frame_number, |
| 183 RecordingSource::RecordingMode recording_mode) { | 189 RecordingSource::RecordingMode recording_mode) { |
| 190 ScopedPicturePileUpdateTimer timer; | |
| 191 | |
| 184 gfx::Rect interest_rect = visible_layer_rect; | 192 gfx::Rect interest_rect = visible_layer_rect; |
| 185 interest_rect.Inset(-pixel_record_distance_, -pixel_record_distance_); | 193 interest_rect.Inset(-pixel_record_distance_, -pixel_record_distance_); |
| 186 recorded_viewport_ = interest_rect; | 194 recorded_viewport_ = interest_rect; |
| 187 recorded_viewport_.Intersect(gfx::Rect(layer_size)); | 195 recorded_viewport_.Intersect(gfx::Rect(layer_size)); |
| 188 | 196 |
| 189 bool updated = ApplyInvalidationAndResize(interest_rect, invalidation, | 197 bool updated = ApplyInvalidationAndResize(interest_rect, invalidation, |
| 190 layer_size, frame_number); | 198 layer_size, frame_number); |
| 199 | |
| 200 // Count the area that is being invalidated. | |
| 201 for (Region::Iterator it(*invalidation); it.has_rect(); it.next()) | |
|
enne (OOO)
2015/04/13 21:52:27
You need to intersect these invalidations with the
jbroman
2015/04/14 16:02:17
Which rect is the right one to intersect with? I s
enne (OOO)
2015/04/14 16:55:19
Oops, sorry forgot to address this comment. You s
| |
| 202 timer.AddArea(it.rect().size().GetArea()); | |
| 203 | |
| 191 std::vector<gfx::Rect> invalid_tiles; | 204 std::vector<gfx::Rect> invalid_tiles; |
| 192 GetInvalidTileRects(interest_rect, &invalid_tiles); | 205 GetInvalidTileRects(interest_rect, &invalid_tiles); |
| 193 std::vector<gfx::Rect> record_rects; | 206 std::vector<gfx::Rect> record_rects; |
| 194 ClusterTiles(invalid_tiles, &record_rects); | 207 ClusterTiles(invalid_tiles, &record_rects); |
| 195 | 208 |
| 196 if (record_rects.empty()) | 209 if (record_rects.empty()) |
| 197 return updated; | 210 return updated; |
| 198 | 211 |
| 199 CreatePictures(painter, recording_mode, record_rects); | 212 CreatePictures(painter, recording_mode, record_rects); |
| 200 | 213 |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 675 | 688 |
| 676 void PicturePile::SetBufferPixels(int new_buffer_pixels) { | 689 void PicturePile::SetBufferPixels(int new_buffer_pixels) { |
| 677 if (new_buffer_pixels == buffer_pixels()) | 690 if (new_buffer_pixels == buffer_pixels()) |
| 678 return; | 691 return; |
| 679 | 692 |
| 680 Clear(); | 693 Clear(); |
| 681 tiling_.SetBorderTexels(new_buffer_pixels); | 694 tiling_.SetBorderTexels(new_buffer_pixels); |
| 682 } | 695 } |
| 683 | 696 |
| 684 } // namespace cc | 697 } // namespace cc |
| OLD | NEW |