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

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

Issue 2559413002: [1/5] Pass transformed rasterization policy from Blink (Closed)
Patch Set: Created 4 years 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
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/blimp/client_picture_cache.h" 9 #include "cc/blimp/client_picture_cache.h"
10 #include "cc/blimp/engine_picture_cache.h" 10 #include "cc/blimp/engine_picture_cache.h"
11 #include "cc/layers/content_layer_client.h" 11 #include "cc/layers/content_layer_client.h"
12 #include "cc/layers/picture_layer_impl.h" 12 #include "cc/layers/picture_layer_impl.h"
13 #include "cc/playback/recording_source.h" 13 #include "cc/playback/recording_source.h"
14 #include "cc/proto/cc_conversions.h" 14 #include "cc/proto/cc_conversions.h"
15 #include "cc/proto/gfx_conversions.h" 15 #include "cc/proto/gfx_conversions.h"
16 #include "cc/proto/layer.pb.h" 16 #include "cc/proto/layer.pb.h"
17 #include "cc/trees/layer_tree_host.h" 17 #include "cc/trees/layer_tree_host.h"
18 #include "cc/trees/layer_tree_impl.h" 18 #include "cc/trees/layer_tree_impl.h"
19 #include "cc/trees/transform_node.h"
19 #include "third_party/skia/include/core/SkPictureRecorder.h" 20 #include "third_party/skia/include/core/SkPictureRecorder.h"
20 #include "ui/gfx/geometry/rect_conversions.h" 21 #include "ui/gfx/geometry/rect_conversions.h"
21 22
22 namespace cc { 23 namespace cc {
23 24
24 PictureLayer::PictureLayerInputs::PictureLayerInputs() = default; 25 PictureLayer::PictureLayerInputs::PictureLayerInputs() = default;
25 26
26 PictureLayer::PictureLayerInputs::~PictureLayerInputs() = default; 27 PictureLayer::PictureLayerInputs::~PictureLayerInputs() = default;
27 28
28 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { 29 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) {
(...skipping 23 matching lines...) Expand all
52 53
53 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { 54 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) {
54 Layer::PushPropertiesTo(base_layer); 55 Layer::PushPropertiesTo(base_layer);
55 TRACE_EVENT0("cc", "PictureLayer::PushPropertiesTo"); 56 TRACE_EVENT0("cc", "PictureLayer::PushPropertiesTo");
56 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); 57 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer);
57 // TODO(danakj): Make is_mask_ a constructor parameter for PictureLayer. 58 // TODO(danakj): Make is_mask_ a constructor parameter for PictureLayer.
58 DCHECK_EQ(layer_impl->is_mask(), is_mask_); 59 DCHECK_EQ(layer_impl->is_mask(), is_mask_);
59 DropRecordingSourceContentIfInvalid(); 60 DropRecordingSourceContentIfInvalid();
60 61
61 layer_impl->SetNearestNeighbor(picture_layer_inputs_.nearest_neighbor); 62 layer_impl->SetNearestNeighbor(picture_layer_inputs_.nearest_neighbor);
63 layer_impl->SetUseTransformedRasterization(UseTransformedRasterization());
62 64
63 // Preserve lcd text settings from the current raster source. 65 // Preserve lcd text settings from the current raster source.
64 bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText(); 66 bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText();
65 scoped_refptr<RasterSource> raster_source = 67 scoped_refptr<RasterSource> raster_source =
66 recording_source_->CreateRasterSource(can_use_lcd_text); 68 recording_source_->CreateRasterSource(can_use_lcd_text);
67 layer_impl->set_gpu_raster_max_texture_size( 69 layer_impl->set_gpu_raster_max_texture_size(
68 GetLayerTree()->device_viewport_size()); 70 GetLayerTree()->device_viewport_size());
69 layer_impl->UpdateRasterSource(raster_source, &last_updated_invalidation_, 71 layer_impl->UpdateRasterSource(raster_source, &last_updated_invalidation_,
70 nullptr); 72 nullptr);
71 DCHECK(last_updated_invalidation_.IsEmpty()); 73 DCHECK(last_updated_invalidation_.IsEmpty());
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 193 }
192 194
193 void PictureLayer::SetNearestNeighbor(bool nearest_neighbor) { 195 void PictureLayer::SetNearestNeighbor(bool nearest_neighbor) {
194 if (picture_layer_inputs_.nearest_neighbor == nearest_neighbor) 196 if (picture_layer_inputs_.nearest_neighbor == nearest_neighbor)
195 return; 197 return;
196 198
197 picture_layer_inputs_.nearest_neighbor = nearest_neighbor; 199 picture_layer_inputs_.nearest_neighbor = nearest_neighbor;
198 SetNeedsCommit(); 200 SetNeedsCommit();
199 } 201 }
200 202
203 void PictureLayer::SetAllowTransformedRasterization(bool allowed) {
204 if (picture_layer_inputs_.allow_transformed_rasterization == allowed)
205 return;
206
207 picture_layer_inputs_.allow_transformed_rasterization = allowed;
208 SetNeedsCommit();
209 }
210
201 bool PictureLayer::HasDrawableContent() const { 211 bool PictureLayer::HasDrawableContent() const {
202 return picture_layer_inputs_.client && Layer::HasDrawableContent(); 212 return picture_layer_inputs_.client && Layer::HasDrawableContent();
203 } 213 }
204 214
205 void PictureLayer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { 215 void PictureLayer::SetTypeForProtoSerialization(proto::LayerNode* proto) const {
206 proto->set_type(proto::LayerNode::PICTURE_LAYER); 216 proto->set_type(proto::LayerNode::PICTURE_LAYER);
207 } 217 }
208 218
209 void PictureLayer::ToLayerPropertiesProto(proto::LayerProperties* proto) { 219 void PictureLayer::ToLayerPropertiesProto(proto::LayerProperties* proto) {
210 DCHECK(GetLayerTree()); 220 DCHECK(GetLayerTree());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // Update may not get called for the layer (if it's not in the viewport 265 // Update may not get called for the layer (if it's not in the viewport
256 // for example), even though it has resized making the recording source no 266 // for example), even though it has resized making the recording source no
257 // longer valid. In this case just destroy the recording source. 267 // longer valid. In this case just destroy the recording source.
258 recording_source_->SetEmptyBounds(); 268 recording_source_->SetEmptyBounds();
259 picture_layer_inputs_.recorded_viewport = gfx::Rect(); 269 picture_layer_inputs_.recorded_viewport = gfx::Rect();
260 picture_layer_inputs_.display_list = nullptr; 270 picture_layer_inputs_.display_list = nullptr;
261 picture_layer_inputs_.painter_reported_memory_usage = 0; 271 picture_layer_inputs_.painter_reported_memory_usage = 0;
262 } 272 }
263 } 273 }
264 274
275 bool PictureLayer::UseTransformedRasterization() const {
276 if (!picture_layer_inputs_.allow_transformed_rasterization)
277 return false;
278
279 const TransformTree &transform_tree = GetLayerTree()->property_trees()->transf orm_tree;
280 DCHECK(!transform_tree.needs_update());
281 if (transform_tree.Node(transform_tree_index())->to_screen_is_potentially_anim ated)
282 return false;
283
284 const gfx::Transform& to_screen = transform_tree.ToScreen(transform_tree_index ());
285 if (!to_screen.IsScaleOrTranslation())
286 return false;
287
288 float origin_x = to_screen.matrix().getFloat(0, 3) + offset_to_transform_paren t().x();
289 float origin_y = to_screen.matrix().getFloat(1, 3) + offset_to_transform_paren t().y();
290 if (origin_x - floorf(origin_x) == 0.f && origin_y - floorf(origin_y) == 0.f)
291 return false;
292
293 return true;
294 }
295
265 const DisplayItemList* PictureLayer::GetDisplayItemList() { 296 const DisplayItemList* PictureLayer::GetDisplayItemList() {
266 return picture_layer_inputs_.display_list.get(); 297 return picture_layer_inputs_.display_list.get();
267 } 298 }
268 299
269 } // namespace cc 300 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698