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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 PerformClustering(invalid_tiles_horizontal, &horizontal_clustering); | 145 PerformClustering(invalid_tiles_horizontal, &horizontal_clustering); |
146 | 146 |
147 if (vertical_density < horizontal_density) { | 147 if (vertical_density < horizontal_density) { |
148 *record_rects = horizontal_clustering; | 148 *record_rects = horizontal_clustering; |
149 return; | 149 return; |
150 } | 150 } |
151 | 151 |
152 *record_rects = vertical_clustering; | 152 *record_rects = vertical_clustering; |
153 } | 153 } |
154 | 154 |
| 155 #ifdef NDEBUG |
| 156 const bool kDefaultClearCanvasSetting = false; |
| 157 #else |
| 158 const bool kDefaultClearCanvasSetting = true; |
| 159 #endif |
| 160 |
155 } // namespace | 161 } // namespace |
156 | 162 |
157 namespace cc { | 163 namespace cc { |
158 | 164 |
159 PicturePile::PicturePile(float min_contents_scale, | 165 PicturePile::PicturePile(float min_contents_scale, |
160 const gfx::Size& tile_grid_size) | 166 const gfx::Size& tile_grid_size) |
161 : min_contents_scale_(0), | 167 : min_contents_scale_(0), |
162 slow_down_raster_scale_factor_for_debug_(0), | 168 slow_down_raster_scale_factor_for_debug_(0), |
163 can_use_lcd_text_(true), | 169 can_use_lcd_text_(true), |
164 has_any_recordings_(false), | 170 has_any_recordings_(false), |
| 171 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), |
| 172 requires_clear_(true), |
165 is_solid_color_(false), | 173 is_solid_color_(false), |
166 solid_color_(SK_ColorTRANSPARENT), | 174 solid_color_(SK_ColorTRANSPARENT), |
| 175 background_color_(SK_ColorTRANSPARENT), |
167 pixel_record_distance_(kPixelDistanceToRecord), | 176 pixel_record_distance_(kPixelDistanceToRecord), |
168 is_suitable_for_gpu_rasterization_(true) { | 177 is_suitable_for_gpu_rasterization_(true) { |
169 tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize)); | 178 tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize)); |
170 SetMinContentsScale(min_contents_scale); | 179 SetMinContentsScale(min_contents_scale); |
171 SetTileGridSize(tile_grid_size); | 180 SetTileGridSize(tile_grid_size); |
172 } | 181 } |
173 | 182 |
174 PicturePile::~PicturePile() { | 183 PicturePile::~PicturePile() { |
175 } | 184 } |
176 | 185 |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 int buffer_pixels = static_cast<int>(ceil(1 / min_contents_scale) - 1); | 625 int buffer_pixels = static_cast<int>(ceil(1 / min_contents_scale) - 1); |
617 buffer_pixels = std::max(0, buffer_pixels); | 626 buffer_pixels = std::max(0, buffer_pixels); |
618 SetBufferPixels(buffer_pixels); | 627 SetBufferPixels(buffer_pixels); |
619 min_contents_scale_ = min_contents_scale; | 628 min_contents_scale_ = min_contents_scale; |
620 } | 629 } |
621 | 630 |
622 void PicturePile::SetSlowdownRasterScaleFactor(int factor) { | 631 void PicturePile::SetSlowdownRasterScaleFactor(int factor) { |
623 slow_down_raster_scale_factor_for_debug_ = factor; | 632 slow_down_raster_scale_factor_for_debug_ = factor; |
624 } | 633 } |
625 | 634 |
| 635 void PicturePile::SetBackgroundColor(SkColor background_color) { |
| 636 background_color_ = background_color; |
| 637 } |
| 638 |
| 639 void PicturePile::SetRequiresClear(bool requires_clear) { |
| 640 requires_clear_ = requires_clear; |
| 641 } |
| 642 |
626 bool PicturePile::IsSuitableForGpuRasterization() const { | 643 bool PicturePile::IsSuitableForGpuRasterization() const { |
627 return is_suitable_for_gpu_rasterization_; | 644 return is_suitable_for_gpu_rasterization_; |
628 } | 645 } |
629 | 646 |
630 void PicturePile::SetTileGridSize(const gfx::Size& tile_grid_size) { | 647 void PicturePile::SetTileGridSize(const gfx::Size& tile_grid_size) { |
631 DCHECK_GT(tile_grid_size.width(), 0); | 648 DCHECK_GT(tile_grid_size.width(), 0); |
632 DCHECK_GT(tile_grid_size.height(), 0); | 649 DCHECK_GT(tile_grid_size.height(), 0); |
633 | 650 |
634 tile_grid_size_ = tile_grid_size; | 651 tile_grid_size_ = tile_grid_size; |
635 } | 652 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 const Picture* PicturePile::PictureInfo::GetPicture() const { | 776 const Picture* PicturePile::PictureInfo::GetPicture() const { |
760 return picture_.get(); | 777 return picture_.get(); |
761 } | 778 } |
762 | 779 |
763 float PicturePile::PictureInfo::GetInvalidationFrequency() const { | 780 float PicturePile::PictureInfo::GetInvalidationFrequency() const { |
764 return invalidation_history_.count() / | 781 return invalidation_history_.count() / |
765 static_cast<float>(INVALIDATION_FRAMES_TRACKED); | 782 static_cast<float>(INVALIDATION_FRAMES_TRACKED); |
766 } | 783 } |
767 | 784 |
768 } // namespace cc | 785 } // namespace cc |
OLD | NEW |