Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: cc/resources/picture_pile.cc

Issue 1028333002: Chromium -> Mojo roll. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/picture_pile.h ('k') | cc/resources/picture_pile_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/region.h" 11 #include "cc/base/region.h"
12 #include "cc/resources/picture_pile_impl.h" 12 #include "cc/resources/picture_pile_impl.h"
13 #include "cc/resources/tile_task_worker_pool.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
22 // operations. 21 // operations.
23 const int kOpCountThatIsOkToAnalyze = 10; 22 const int kOpCountThatIsOkToAnalyze = 10;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 #endif 158 #endif
160 159
161 } // namespace 160 } // namespace
162 161
163 namespace cc { 162 namespace cc {
164 163
165 PicturePile::PicturePile(float min_contents_scale, 164 PicturePile::PicturePile(float min_contents_scale,
166 const gfx::Size& tile_grid_size) 165 const gfx::Size& tile_grid_size)
167 : min_contents_scale_(0), 166 : min_contents_scale_(0),
168 slow_down_raster_scale_factor_for_debug_(0), 167 slow_down_raster_scale_factor_for_debug_(0),
168 gather_pixel_refs_(false),
169 has_any_recordings_(false), 169 has_any_recordings_(false),
170 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), 170 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting),
171 requires_clear_(true), 171 requires_clear_(true),
172 is_solid_color_(false), 172 is_solid_color_(false),
173 solid_color_(SK_ColorTRANSPARENT), 173 solid_color_(SK_ColorTRANSPARENT),
174 background_color_(SK_ColorTRANSPARENT), 174 background_color_(SK_ColorTRANSPARENT),
175 pixel_record_distance_(kPixelDistanceToRecord), 175 pixel_record_distance_(kPixelDistanceToRecord),
176 is_suitable_for_gpu_rasterization_(true) { 176 is_suitable_for_gpu_rasterization_(true) {
177 tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize)); 177 tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize));
178 SetMinContentsScale(min_contents_scale); 178 SetMinContentsScale(min_contents_scale);
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 532
533 void PicturePile::CreatePictures(ContentLayerClient* painter, 533 void PicturePile::CreatePictures(ContentLayerClient* painter,
534 RecordingSource::RecordingMode recording_mode, 534 RecordingSource::RecordingMode recording_mode,
535 const std::vector<gfx::Rect>& record_rects) { 535 const std::vector<gfx::Rect>& record_rects) {
536 for (const auto& record_rect : record_rects) { 536 for (const auto& record_rect : record_rects) {
537 gfx::Rect padded_record_rect = PadRect(record_rect); 537 gfx::Rect padded_record_rect = PadRect(record_rect);
538 538
539 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); 539 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_);
540 scoped_refptr<Picture> picture; 540 scoped_refptr<Picture> picture;
541 541
542 // Note: Currently, gathering of pixel refs when using a single
543 // raster thread doesn't provide any benefit. This might change
544 // in the future but we avoid it for now to reduce the cost of
545 // Picture::Create.
546 bool gather_pixel_refs = TileTaskWorkerPool::GetNumWorkerThreads() > 1;
547
548 for (int i = 0; i < repeat_count; i++) { 542 for (int i = 0; i < repeat_count; i++) {
549 picture = Picture::Create(padded_record_rect, painter, tile_grid_size_, 543 picture = Picture::Create(padded_record_rect, painter, tile_grid_size_,
550 gather_pixel_refs, recording_mode); 544 gather_pixel_refs_, recording_mode);
551 // Note the '&&' with previous is-suitable state. 545 // Note the '&&' with previous is-suitable state.
552 // This means that once a picture-pile becomes unsuitable for gpu 546 // This means that once a picture-pile becomes unsuitable for gpu
553 // rasterization due to some content, it will continue to be unsuitable 547 // rasterization due to some content, it will continue to be unsuitable
554 // even if that content is replaced by gpu-friendly content. 548 // even if that content is replaced by gpu-friendly content.
555 // This is an optimization to avoid iterating though all pictures in 549 // This is an optimization to avoid iterating though all pictures in
556 // the pile after each invalidation. 550 // the pile after each invalidation.
557 if (is_suitable_for_gpu_rasterization_) { 551 if (is_suitable_for_gpu_rasterization_) {
558 const char* reason = nullptr; 552 const char* reason = nullptr;
559 is_suitable_for_gpu_rasterization_ &= 553 is_suitable_for_gpu_rasterization_ &=
560 picture->IsSuitableForGpuRasterization(&reason); 554 picture->IsSuitableForGpuRasterization(&reason);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 int buffer_pixels = static_cast<int>(ceil(1 / min_contents_scale) - 1); 610 int buffer_pixels = static_cast<int>(ceil(1 / min_contents_scale) - 1);
617 buffer_pixels = std::max(0, buffer_pixels); 611 buffer_pixels = std::max(0, buffer_pixels);
618 SetBufferPixels(buffer_pixels); 612 SetBufferPixels(buffer_pixels);
619 min_contents_scale_ = min_contents_scale; 613 min_contents_scale_ = min_contents_scale;
620 } 614 }
621 615
622 void PicturePile::SetSlowdownRasterScaleFactor(int factor) { 616 void PicturePile::SetSlowdownRasterScaleFactor(int factor) {
623 slow_down_raster_scale_factor_for_debug_ = factor; 617 slow_down_raster_scale_factor_for_debug_ = factor;
624 } 618 }
625 619
620 void PicturePile::SetGatherPixelRefs(bool gather_pixel_refs) {
621 gather_pixel_refs_ = gather_pixel_refs;
622 }
623
626 void PicturePile::SetBackgroundColor(SkColor background_color) { 624 void PicturePile::SetBackgroundColor(SkColor background_color) {
627 background_color_ = background_color; 625 background_color_ = background_color;
628 } 626 }
629 627
630 void PicturePile::SetRequiresClear(bool requires_clear) { 628 void PicturePile::SetRequiresClear(bool requires_clear) {
631 requires_clear_ = requires_clear; 629 requires_clear_ = requires_clear;
632 } 630 }
633 631
634 bool PicturePile::IsSuitableForGpuRasterization() const { 632 bool PicturePile::IsSuitableForGpuRasterization() const {
635 return is_suitable_for_gpu_rasterization_; 633 return is_suitable_for_gpu_rasterization_;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 const Picture* PicturePile::PictureInfo::GetPicture() const { 770 const Picture* PicturePile::PictureInfo::GetPicture() const {
773 return picture_.get(); 771 return picture_.get();
774 } 772 }
775 773
776 float PicturePile::PictureInfo::GetInvalidationFrequency() const { 774 float PicturePile::PictureInfo::GetInvalidationFrequency() const {
777 return invalidation_history_.count() / 775 return invalidation_history_.count() /
778 static_cast<float>(INVALIDATION_FRAMES_TRACKED); 776 static_cast<float>(INVALIDATION_FRAMES_TRACKED);
779 } 777 }
780 778
781 } // namespace cc 779 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_pile.h ('k') | cc/resources/picture_pile_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698