OLD | NEW |
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/playback/display_list_recording_source.h" | 5 #include "cc/playback/display_list_recording_source.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/numerics/safe_math.h" | 11 #include "base/numerics/safe_math.h" |
12 #include "cc/base/histograms.h" | 12 #include "cc/base/histograms.h" |
13 #include "cc/base/region.h" | 13 #include "cc/base/region.h" |
14 #include "cc/layers/content_layer_client.h" | 14 #include "cc/layers/content_layer_client.h" |
15 #include "cc/playback/display_item_list.h" | 15 #include "cc/playback/display_item_list.h" |
16 #include "cc/playback/display_list_raster_source.h" | 16 #include "cc/playback/raster_source.h" |
17 #include "cc/proto/display_list_recording_source.pb.h" | 17 #include "cc/proto/display_list_recording_source.pb.h" |
18 #include "cc/proto/gfx_conversions.h" | 18 #include "cc/proto/gfx_conversions.h" |
19 #include "skia/ext/analysis_canvas.h" | 19 #include "skia/ext/analysis_canvas.h" |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 #ifdef NDEBUG | 23 #ifdef NDEBUG |
24 const bool kDefaultClearCanvasSetting = false; | 24 const bool kDefaultClearCanvasSetting = false; |
25 #else | 25 #else |
26 const bool kDefaultClearCanvasSetting = true; | 26 const bool kDefaultClearCanvasSetting = true; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 225 } |
226 | 226 |
227 bool DisplayListRecordingSource::IsSuitableForGpuRasterization() const { | 227 bool DisplayListRecordingSource::IsSuitableForGpuRasterization() const { |
228 // The display list needs to be created (see: UpdateAndExpandInvalidation) | 228 // The display list needs to be created (see: UpdateAndExpandInvalidation) |
229 // before checking for suitability. There are cases where an update will not | 229 // before checking for suitability. There are cases where an update will not |
230 // create a display list (e.g., if the size is empty). We return true in these | 230 // create a display list (e.g., if the size is empty). We return true in these |
231 // cases because the gpu suitability bit sticks false. | 231 // cases because the gpu suitability bit sticks false. |
232 return !display_list_ || display_list_->IsSuitableForGpuRasterization(); | 232 return !display_list_ || display_list_->IsSuitableForGpuRasterization(); |
233 } | 233 } |
234 | 234 |
235 scoped_refptr<DisplayListRasterSource> | 235 scoped_refptr<RasterSource> DisplayListRecordingSource::CreateRasterSource( |
236 DisplayListRecordingSource::CreateRasterSource(bool can_use_lcd_text) const { | 236 bool can_use_lcd_text) const { |
237 return scoped_refptr<DisplayListRasterSource>( | 237 return scoped_refptr<RasterSource>( |
238 DisplayListRasterSource::CreateFromDisplayListRecordingSource( | 238 RasterSource::CreateFromDisplayListRecordingSource(this, |
239 this, can_use_lcd_text)); | 239 can_use_lcd_text)); |
240 } | 240 } |
241 | 241 |
242 void DisplayListRecordingSource::DetermineIfSolidColor() { | 242 void DisplayListRecordingSource::DetermineIfSolidColor() { |
243 DCHECK(display_list_); | 243 DCHECK(display_list_); |
244 is_solid_color_ = false; | 244 is_solid_color_ = false; |
245 solid_color_ = SK_ColorTRANSPARENT; | 245 solid_color_ = SK_ColorTRANSPARENT; |
246 | 246 |
247 if (!display_list_->ShouldBeAnalyzedForSolidColor()) | 247 if (!display_list_->ShouldBeAnalyzedForSolidColor()) |
248 return; | 248 return; |
249 | 249 |
250 gfx::Size layer_size = GetSize(); | 250 gfx::Size layer_size = GetSize(); |
251 skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height()); | 251 skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height()); |
252 display_list_->Raster(&canvas, nullptr, gfx::Rect(), 1.f); | 252 display_list_->Raster(&canvas, nullptr, gfx::Rect(), 1.f); |
253 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); | 253 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); |
254 } | 254 } |
255 | 255 |
256 void DisplayListRecordingSource::Clear() { | 256 void DisplayListRecordingSource::Clear() { |
257 recorded_viewport_ = gfx::Rect(); | 257 recorded_viewport_ = gfx::Rect(); |
258 display_list_ = nullptr; | 258 display_list_ = nullptr; |
259 painter_reported_memory_usage_ = 0; | 259 painter_reported_memory_usage_ = 0; |
260 is_solid_color_ = false; | 260 is_solid_color_ = false; |
261 } | 261 } |
262 | 262 |
263 } // namespace cc | 263 } // namespace cc |
OLD | NEW |