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