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" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 updated = true; | 53 updated = true; |
54 } | 54 } |
55 | 55 |
56 if (can_use_lcd_text_ != can_use_lcd_text) { | 56 if (can_use_lcd_text_ != can_use_lcd_text) { |
57 can_use_lcd_text_ = can_use_lcd_text; | 57 can_use_lcd_text_ = can_use_lcd_text; |
58 invalidation->Union(gfx::Rect(GetSize())); | 58 invalidation->Union(gfx::Rect(GetSize())); |
59 updated = true; | 59 updated = true; |
60 } | 60 } |
61 | 61 |
62 gfx::Rect old_recorded_viewport = recorded_viewport_; | 62 gfx::Rect old_recorded_viewport = recorded_viewport_; |
63 recorded_viewport_ = visible_layer_rect; | 63 // TODO(wangxianzhu): Blink slimming paint doesn't support incremental |
64 recorded_viewport_.Inset(-pixel_record_distance_, -pixel_record_distance_); | 64 // painting for now so we must record for the whole layer. Should measure |
65 recorded_viewport_.Intersect(gfx::Rect(GetSize())); | 65 // performance and determine the best choice. Consider display item caching. |
| 66 recorded_viewport_ = gfx::Rect(GetSize()); |
66 | 67 |
67 if (recorded_viewport_ != old_recorded_viewport) { | 68 if (recorded_viewport_ != old_recorded_viewport) { |
68 // Invalidate newly-exposed and no-longer-exposed areas. | 69 // Invalidate newly-exposed and no-longer-exposed areas. |
69 Region newly_exposed_region(recorded_viewport_); | 70 Region newly_exposed_region(recorded_viewport_); |
70 newly_exposed_region.Subtract(old_recorded_viewport); | 71 newly_exposed_region.Subtract(old_recorded_viewport); |
71 invalidation->Union(newly_exposed_region); | 72 invalidation->Union(newly_exposed_region); |
72 | 73 |
73 Region no_longer_exposed_region(old_recorded_viewport); | 74 Region no_longer_exposed_region(old_recorded_viewport); |
74 no_longer_exposed_region.Subtract(recorded_viewport_); | 75 no_longer_exposed_region.Subtract(recorded_viewport_); |
75 invalidation->Union(no_longer_exposed_region); | 76 invalidation->Union(no_longer_exposed_region); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 bool DisplayListRecordingSource::IsSuitableForGpuRasterization() const { | 124 bool DisplayListRecordingSource::IsSuitableForGpuRasterization() const { |
124 return is_suitable_for_gpu_rasterization_; | 125 return is_suitable_for_gpu_rasterization_; |
125 } | 126 } |
126 | 127 |
127 scoped_refptr<RasterSource> DisplayListRecordingSource::CreateRasterSource() | 128 scoped_refptr<RasterSource> DisplayListRecordingSource::CreateRasterSource() |
128 const { | 129 const { |
129 return scoped_refptr<RasterSource>( | 130 return scoped_refptr<RasterSource>( |
130 DisplayListRasterSource::CreateFromDisplayListRecordingSource(this)); | 131 DisplayListRasterSource::CreateFromDisplayListRecordingSource(this)); |
131 } | 132 } |
132 | 133 |
133 SkTileGridFactory::TileGridInfo | 134 gfx::Size DisplayListRecordingSource::GetTileGridSizeForTesting() const { |
134 DisplayListRecordingSource::GetTileGridInfoForTesting() const { | 135 return gfx::Size(); |
135 return SkTileGridFactory::TileGridInfo(); | |
136 } | 136 } |
137 | 137 |
138 void DisplayListRecordingSource::DetermineIfSolidColor() { | 138 void DisplayListRecordingSource::DetermineIfSolidColor() { |
139 DCHECK(display_list_.get()); | 139 DCHECK(display_list_.get()); |
140 is_solid_color_ = false; | 140 is_solid_color_ = false; |
141 solid_color_ = SK_ColorTRANSPARENT; | 141 solid_color_ = SK_ColorTRANSPARENT; |
142 | 142 |
143 if (display_list_->ApproximateOpCount() > kOpCountThatIsOkToAnalyze) | 143 if (display_list_->ApproximateOpCount() > kOpCountThatIsOkToAnalyze) |
144 return; | 144 return; |
145 | 145 |
146 gfx::Size layer_size = GetSize(); | 146 gfx::Size layer_size = GetSize(); |
147 skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height()); | 147 skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height()); |
148 display_list_->Raster(&canvas, nullptr, 1.f); | 148 display_list_->Raster(&canvas, nullptr, 1.f); |
149 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); | 149 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); |
150 } | 150 } |
151 | 151 |
152 void DisplayListRecordingSource::Clear() { | 152 void DisplayListRecordingSource::Clear() { |
153 recorded_viewport_ = gfx::Rect(); | 153 recorded_viewport_ = gfx::Rect(); |
154 display_list_ = NULL; | 154 display_list_ = NULL; |
155 is_solid_color_ = false; | 155 is_solid_color_ = false; |
156 } | 156 } |
157 | 157 |
158 } // namespace cc | 158 } // namespace cc |
OLD | NEW |