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

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

Issue 952893003: Update from https://crrev.com/317530 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix gn for nacl Created 5 years, 10 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/display_list_recording_source.h ('k') | cc/resources/drawing_display_item.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/display_list_recording_source.h" 5 #include "cc/resources/display_list_recording_source.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "cc/base/region.h" 9 #include "cc/base/region.h"
10 #include "cc/layers/content_layer_client.h" 10 #include "cc/layers/content_layer_client.h"
(...skipping 10 matching lines...) Expand all
21 // 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
22 // operations. 22 // operations.
23 const int kOpCountThatIsOkToAnalyze = 10; 23 const int kOpCountThatIsOkToAnalyze = 10;
24 24
25 } // namespace 25 } // namespace
26 26
27 namespace cc { 27 namespace cc {
28 28
29 DisplayListRecordingSource::DisplayListRecordingSource() 29 DisplayListRecordingSource::DisplayListRecordingSource()
30 : slow_down_raster_scale_factor_for_debug_(0), 30 : slow_down_raster_scale_factor_for_debug_(0),
31 can_use_lcd_text_(true),
32 requires_clear_(false), 31 requires_clear_(false),
33 is_solid_color_(false), 32 is_solid_color_(false),
34 solid_color_(SK_ColorTRANSPARENT), 33 solid_color_(SK_ColorTRANSPARENT),
35 background_color_(SK_ColorTRANSPARENT), 34 background_color_(SK_ColorTRANSPARENT),
36 pixel_record_distance_(kPixelDistanceToRecord), 35 pixel_record_distance_(kPixelDistanceToRecord),
37 is_suitable_for_gpu_rasterization_(true) { 36 is_suitable_for_gpu_rasterization_(true) {
38 } 37 }
39 38
40 DisplayListRecordingSource::~DisplayListRecordingSource() { 39 DisplayListRecordingSource::~DisplayListRecordingSource() {
41 } 40 }
42 41
43 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( 42 bool DisplayListRecordingSource::UpdateAndExpandInvalidation(
44 ContentLayerClient* painter, 43 ContentLayerClient* painter,
45 Region* invalidation, 44 Region* invalidation,
46 bool can_use_lcd_text,
47 const gfx::Size& layer_size, 45 const gfx::Size& layer_size,
48 const gfx::Rect& visible_layer_rect, 46 const gfx::Rect& visible_layer_rect,
49 int frame_number, 47 int frame_number,
50 RecordingMode recording_mode) { 48 RecordingMode recording_mode) {
51 bool updated = false; 49 bool updated = false;
52 50
53 if (size_ != layer_size) { 51 if (size_ != layer_size) {
54 size_ = layer_size; 52 size_ = layer_size;
55 updated = true; 53 updated = true;
56 } 54 }
57 55
58 if (can_use_lcd_text_ != can_use_lcd_text) {
59 can_use_lcd_text_ = can_use_lcd_text;
60 invalidation->Union(gfx::Rect(GetSize()));
61 updated = true;
62 }
63
64 gfx::Rect old_recorded_viewport = recorded_viewport_; 56 gfx::Rect old_recorded_viewport = recorded_viewport_;
65 recorded_viewport_ = visible_layer_rect; 57 recorded_viewport_ = visible_layer_rect;
66 recorded_viewport_.Inset(-pixel_record_distance_, -pixel_record_distance_); 58 recorded_viewport_.Inset(-pixel_record_distance_, -pixel_record_distance_);
67 recorded_viewport_.Intersect(gfx::Rect(GetSize())); 59 recorded_viewport_.Intersect(gfx::Rect(GetSize()));
68 60
69 if (recorded_viewport_ != old_recorded_viewport) { 61 if (recorded_viewport_ != old_recorded_viewport) {
70 // Invalidate newly-exposed and no-longer-exposed areas. 62 // Invalidate newly-exposed and no-longer-exposed areas.
71 Region newly_exposed_region(recorded_viewport_); 63 Region newly_exposed_region(recorded_viewport_);
72 newly_exposed_region.Subtract(old_recorded_viewport); 64 newly_exposed_region.Subtract(old_recorded_viewport);
73 invalidation->Union(newly_exposed_region); 65 invalidation->Union(newly_exposed_region);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 137 }
146 138
147 void DisplayListRecordingSource::SetUnsuitableForGpuRasterizationForTesting() { 139 void DisplayListRecordingSource::SetUnsuitableForGpuRasterizationForTesting() {
148 is_suitable_for_gpu_rasterization_ = false; 140 is_suitable_for_gpu_rasterization_ = false;
149 } 141 }
150 142
151 bool DisplayListRecordingSource::IsSuitableForGpuRasterization() const { 143 bool DisplayListRecordingSource::IsSuitableForGpuRasterization() const {
152 return is_suitable_for_gpu_rasterization_; 144 return is_suitable_for_gpu_rasterization_;
153 } 145 }
154 146
155 scoped_refptr<RasterSource> DisplayListRecordingSource::CreateRasterSource() 147 scoped_refptr<RasterSource> DisplayListRecordingSource::CreateRasterSource(
156 const { 148 bool can_use_lcd_text) const {
157 return scoped_refptr<RasterSource>( 149 return scoped_refptr<RasterSource>(
158 DisplayListRasterSource::CreateFromDisplayListRecordingSource(this)); 150 DisplayListRasterSource::CreateFromDisplayListRecordingSource(
151 this, can_use_lcd_text));
159 } 152 }
160 153
161 gfx::Size DisplayListRecordingSource::GetTileGridSizeForTesting() const { 154 gfx::Size DisplayListRecordingSource::GetTileGridSizeForTesting() const {
162 return gfx::Size(); 155 return gfx::Size();
163 } 156 }
164 157
165 void DisplayListRecordingSource::DetermineIfSolidColor() { 158 void DisplayListRecordingSource::DetermineIfSolidColor() {
166 DCHECK(display_list_.get()); 159 DCHECK(display_list_.get());
167 is_solid_color_ = false; 160 is_solid_color_ = false;
168 solid_color_ = SK_ColorTRANSPARENT; 161 solid_color_ = SK_ColorTRANSPARENT;
169 162
170 if (display_list_->ApproximateOpCount() > kOpCountThatIsOkToAnalyze) 163 if (display_list_->ApproximateOpCount() > kOpCountThatIsOkToAnalyze)
171 return; 164 return;
172 165
173 gfx::Size layer_size = GetSize(); 166 gfx::Size layer_size = GetSize();
174 skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height()); 167 skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height());
175 display_list_->Raster(&canvas, nullptr, 1.f); 168 display_list_->Raster(&canvas, nullptr, 1.f);
176 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); 169 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_);
177 } 170 }
178 171
179 void DisplayListRecordingSource::Clear() { 172 void DisplayListRecordingSource::Clear() {
180 recorded_viewport_ = gfx::Rect(); 173 recorded_viewport_ = gfx::Rect();
181 display_list_ = NULL; 174 display_list_ = NULL;
182 is_solid_color_ = false; 175 is_solid_color_ = false;
183 } 176 }
184 177
185 } // namespace cc 178 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/display_list_recording_source.h ('k') | cc/resources/drawing_display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698