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

Side by Side Diff: cc/layers/picture_layer.cc

Issue 2559413002: [1/5] Pass transformed rasterization policy from Blink (Closed)
Patch Set: rebase Created 3 years, 8 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/layers/picture_layer.h ('k') | cc/layers/picture_layer_impl.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/layers/picture_layer.h" 5 #include "cc/layers/picture_layer.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "cc/layers/content_layer_client.h" 9 #include "cc/layers/content_layer_client.h"
10 #include "cc/layers/picture_layer_impl.h" 10 #include "cc/layers/picture_layer_impl.h"
11 #include "cc/layers/recording_source.h" 11 #include "cc/layers/recording_source.h"
12 #include "cc/paint/paint_record.h" 12 #include "cc/paint/paint_record.h"
13 #include "cc/trees/layer_tree_host.h" 13 #include "cc/trees/layer_tree_host.h"
14 #include "cc/trees/layer_tree_impl.h" 14 #include "cc/trees/layer_tree_impl.h"
15 #include "cc/trees/transform_node.h"
15 #include "ui/gfx/geometry/rect_conversions.h" 16 #include "ui/gfx/geometry/rect_conversions.h"
16 17
17 namespace cc { 18 namespace cc {
18 19
19 PictureLayer::PictureLayerInputs::PictureLayerInputs() = default; 20 PictureLayer::PictureLayerInputs::PictureLayerInputs() = default;
20 21
21 PictureLayer::PictureLayerInputs::~PictureLayerInputs() = default; 22 PictureLayer::PictureLayerInputs::~PictureLayerInputs() = default;
22 23
23 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { 24 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) {
24 return make_scoped_refptr(new PictureLayer(client)); 25 return make_scoped_refptr(new PictureLayer(client));
(...skipping 22 matching lines...) Expand all
47 48
48 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { 49 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) {
49 Layer::PushPropertiesTo(base_layer); 50 Layer::PushPropertiesTo(base_layer);
50 TRACE_EVENT0("cc", "PictureLayer::PushPropertiesTo"); 51 TRACE_EVENT0("cc", "PictureLayer::PushPropertiesTo");
51 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); 52 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer);
52 // TODO(danakj): Make mask_type_ a constructor parameter for PictureLayer. 53 // TODO(danakj): Make mask_type_ a constructor parameter for PictureLayer.
53 DCHECK_EQ(layer_impl->mask_type(), mask_type()); 54 DCHECK_EQ(layer_impl->mask_type(), mask_type());
54 DropRecordingSourceContentIfInvalid(); 55 DropRecordingSourceContentIfInvalid();
55 56
56 layer_impl->SetNearestNeighbor(picture_layer_inputs_.nearest_neighbor); 57 layer_impl->SetNearestNeighbor(picture_layer_inputs_.nearest_neighbor);
58 layer_impl->SetUseTransformedRasterization(
59 ShouldUseTransformedRasterization());
57 60
58 // Preserve lcd text settings from the current raster source. 61 // Preserve lcd text settings from the current raster source.
59 bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText(); 62 bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText();
60 scoped_refptr<RasterSource> raster_source = 63 scoped_refptr<RasterSource> raster_source =
61 recording_source_->CreateRasterSource(can_use_lcd_text); 64 recording_source_->CreateRasterSource(can_use_lcd_text);
62 layer_impl->set_gpu_raster_max_texture_size( 65 layer_impl->set_gpu_raster_max_texture_size(
63 layer_tree_host()->device_viewport_size()); 66 layer_tree_host()->device_viewport_size());
64 layer_impl->UpdateRasterSource(std::move(raster_source), 67 layer_impl->UpdateRasterSource(std::move(raster_source),
65 &last_updated_invalidation_, nullptr); 68 &last_updated_invalidation_, nullptr);
66 DCHECK(last_updated_invalidation_.IsEmpty()); 69 DCHECK(last_updated_invalidation_.IsEmpty());
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 194 }
192 195
193 void PictureLayer::SetNearestNeighbor(bool nearest_neighbor) { 196 void PictureLayer::SetNearestNeighbor(bool nearest_neighbor) {
194 if (picture_layer_inputs_.nearest_neighbor == nearest_neighbor) 197 if (picture_layer_inputs_.nearest_neighbor == nearest_neighbor)
195 return; 198 return;
196 199
197 picture_layer_inputs_.nearest_neighbor = nearest_neighbor; 200 picture_layer_inputs_.nearest_neighbor = nearest_neighbor;
198 SetNeedsCommit(); 201 SetNeedsCommit();
199 } 202 }
200 203
204 void PictureLayer::SetAllowTransformedRasterization(bool allowed) {
205 if (picture_layer_inputs_.allow_transformed_rasterization == allowed)
206 return;
207
208 picture_layer_inputs_.allow_transformed_rasterization = allowed;
209 SetNeedsCommit();
210 }
211
201 bool PictureLayer::HasDrawableContent() const { 212 bool PictureLayer::HasDrawableContent() const {
202 return picture_layer_inputs_.client && Layer::HasDrawableContent(); 213 return picture_layer_inputs_.client && Layer::HasDrawableContent();
203 } 214 }
204 215
205 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { 216 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) {
206 benchmark->RunOnLayer(this); 217 benchmark->RunOnLayer(this);
207 } 218 }
208 219
209 void PictureLayer::DropRecordingSourceContentIfInvalid() { 220 void PictureLayer::DropRecordingSourceContentIfInvalid() {
210 int source_frame_number = layer_tree_host()->SourceFrameNumber(); 221 int source_frame_number = layer_tree_host()->SourceFrameNumber();
(...skipping 15 matching lines...) Expand all
226 // Update may not get called for the layer (if it's not in the viewport 237 // Update may not get called for the layer (if it's not in the viewport
227 // for example), even though it has resized making the recording source no 238 // for example), even though it has resized making the recording source no
228 // longer valid. In this case just destroy the recording source. 239 // longer valid. In this case just destroy the recording source.
229 recording_source_->SetEmptyBounds(); 240 recording_source_->SetEmptyBounds();
230 picture_layer_inputs_.recorded_viewport = gfx::Rect(); 241 picture_layer_inputs_.recorded_viewport = gfx::Rect();
231 picture_layer_inputs_.display_list = nullptr; 242 picture_layer_inputs_.display_list = nullptr;
232 picture_layer_inputs_.painter_reported_memory_usage = 0; 243 picture_layer_inputs_.painter_reported_memory_usage = 0;
233 } 244 }
234 } 245 }
235 246
247 bool PictureLayer::ShouldUseTransformedRasterization() const {
248 if (!picture_layer_inputs_.allow_transformed_rasterization)
249 return false;
250
251 const TransformTree& transform_tree =
252 layer_tree_host()->property_trees()->transform_tree;
253 DCHECK(!transform_tree.needs_update());
254 if (transform_tree.Node(transform_tree_index())
255 ->to_screen_is_potentially_animated)
256 return false;
257
258 const gfx::Transform& to_screen =
259 transform_tree.ToScreen(transform_tree_index());
260 if (!to_screen.IsScaleOrTranslation())
261 return false;
262
263 float origin_x =
264 to_screen.matrix().getFloat(0, 3) + offset_to_transform_parent().x();
265 float origin_y =
266 to_screen.matrix().getFloat(1, 3) + offset_to_transform_parent().y();
267 if (origin_x - floorf(origin_x) == 0.f && origin_y - floorf(origin_y) == 0.f)
268 return false;
269
270 return true;
271 }
272
236 const DisplayItemList* PictureLayer::GetDisplayItemList() { 273 const DisplayItemList* PictureLayer::GetDisplayItemList() {
237 return picture_layer_inputs_.display_list.get(); 274 return picture_layer_inputs_.display_list.get();
238 } 275 }
239 276
240 } // namespace cc 277 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer.h ('k') | cc/layers/picture_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698