| 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/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" |
| 11 #include "cc/resources/display_item_list.h" | 11 #include "cc/resources/display_item_list.h" |
| 12 #include "cc/resources/display_list_raster_source.h" | 12 #include "cc/resources/display_list_raster_source.h" |
| 13 #include "skia/ext/analysis_canvas.h" | 13 #include "skia/ext/analysis_canvas.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // 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 |
| 18 // picture that intersects the visible layer rect expanded by this distance | 18 // picture that intersects the visible layer rect expanded by this distance |
| 19 // will be recorded. | 19 // will be recorded. |
| 20 const int kPixelDistanceToRecord = 8000; | 20 const int kPixelDistanceToRecord = 8000; |
| 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 const gfx::Size& grid_cell_size) | |
| 31 : slow_down_raster_scale_factor_for_debug_(0), | 30 : slow_down_raster_scale_factor_for_debug_(0), |
| 32 gather_pixel_refs_(false), | 31 gather_pixel_refs_(false), |
| 33 requires_clear_(false), | 32 requires_clear_(false), |
| 34 is_solid_color_(false), | 33 is_solid_color_(false), |
| 35 solid_color_(SK_ColorTRANSPARENT), | 34 solid_color_(SK_ColorTRANSPARENT), |
| 36 background_color_(SK_ColorTRANSPARENT), | 35 background_color_(SK_ColorTRANSPARENT), |
| 37 pixel_record_distance_(kPixelDistanceToRecord), | 36 pixel_record_distance_(kPixelDistanceToRecord), |
| 38 grid_cell_size_(grid_cell_size), | |
| 39 is_suitable_for_gpu_rasterization_(true) { | 37 is_suitable_for_gpu_rasterization_(true) { |
| 40 } | 38 } |
| 41 | 39 |
| 42 DisplayListRecordingSource::~DisplayListRecordingSource() { | 40 DisplayListRecordingSource::~DisplayListRecordingSource() { |
| 43 } | 41 } |
| 44 | 42 |
| 45 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( | 43 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( |
| 46 ContentLayerClient* painter, | 44 ContentLayerClient* painter, |
| 47 Region* invalidation, | 45 Region* invalidation, |
| 48 const gfx::Size& layer_size, | 46 const gfx::Size& layer_size, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 painting_control); | 108 painting_control); |
| 111 } | 109 } |
| 112 display_list_->set_layer_rect(recorded_viewport_); | 110 display_list_->set_layer_rect(recorded_viewport_); |
| 113 is_suitable_for_gpu_rasterization_ = | 111 is_suitable_for_gpu_rasterization_ = |
| 114 display_list_->IsSuitableForGpuRasterization(); | 112 display_list_->IsSuitableForGpuRasterization(); |
| 115 | 113 |
| 116 DetermineIfSolidColor(); | 114 DetermineIfSolidColor(); |
| 117 display_list_->EmitTraceSnapshot(); | 115 display_list_->EmitTraceSnapshot(); |
| 118 | 116 |
| 119 display_list_->CreateAndCacheSkPicture(); | 117 display_list_->CreateAndCacheSkPicture(); |
| 120 if (gather_pixel_refs_) | |
| 121 display_list_->GatherPixelRefs(grid_cell_size_); | |
| 122 | 118 |
| 123 return true; | 119 return true; |
| 124 } | 120 } |
| 125 | 121 |
| 126 void DisplayListRecordingSource::DidMoveToNewCompositor() { | 122 void DisplayListRecordingSource::DidMoveToNewCompositor() { |
| 127 // No invalidation history to worry about here. | 123 // No invalidation history to worry about here. |
| 128 } | 124 } |
| 129 | 125 |
| 130 gfx::Size DisplayListRecordingSource::GetSize() const { | 126 gfx::Size DisplayListRecordingSource::GetSize() const { |
| 131 return size_; | 127 return size_; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); | 181 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); |
| 186 } | 182 } |
| 187 | 183 |
| 188 void DisplayListRecordingSource::Clear() { | 184 void DisplayListRecordingSource::Clear() { |
| 189 recorded_viewport_ = gfx::Rect(); | 185 recorded_viewport_ = gfx::Rect(); |
| 190 display_list_ = NULL; | 186 display_list_ = NULL; |
| 191 is_solid_color_ = false; | 187 is_solid_color_ = false; |
| 192 } | 188 } |
| 193 | 189 |
| 194 } // namespace cc | 190 } // namespace cc |
| OLD | NEW |