OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 hide_layer_and_subtree_(false), | 54 hide_layer_and_subtree_(false), |
55 masks_to_bounds_(false), | 55 masks_to_bounds_(false), |
56 contents_opaque_(false), | 56 contents_opaque_(false), |
57 double_sided_(true), | 57 double_sided_(true), |
58 should_flatten_transform_(true), | 58 should_flatten_transform_(true), |
59 use_parent_backface_visibility_(false), | 59 use_parent_backface_visibility_(false), |
60 draw_checkerboard_for_missing_tiles_(false), | 60 draw_checkerboard_for_missing_tiles_(false), |
61 force_render_surface_(false), | 61 force_render_surface_(false), |
62 is_3d_sorted_(false), | 62 is_3d_sorted_(false), |
63 transform_is_invertible_(true), | 63 transform_is_invertible_(true), |
64 anchor_point_(0.5f, 0.5f), | |
65 background_color_(0), | 64 background_color_(0), |
66 opacity_(1.f), | 65 opacity_(1.f), |
67 blend_mode_(SkXfermode::kSrcOver_Mode), | 66 blend_mode_(SkXfermode::kSrcOver_Mode), |
68 anchor_point_z_(0.f), | |
69 scroll_parent_(NULL), | 67 scroll_parent_(NULL), |
70 clip_parent_(NULL), | 68 clip_parent_(NULL), |
71 replica_layer_(NULL), | 69 replica_layer_(NULL), |
72 raster_scale_(0.f), | 70 raster_scale_(0.f), |
73 client_(NULL) { | 71 client_(NULL) { |
74 if (layer_id_ == INT_MAX) { | 72 if (layer_id_ == INT_MAX) { |
75 s_next_layer_id = 1; | 73 s_next_layer_id = 1; |
76 } | 74 } |
77 | 75 |
78 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); | 76 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 362 |
365 void Layer::RequestCopyOfOutput( | 363 void Layer::RequestCopyOfOutput( |
366 scoped_ptr<CopyOutputRequest> request) { | 364 scoped_ptr<CopyOutputRequest> request) { |
367 DCHECK(IsPropertyChangeAllowed()); | 365 DCHECK(IsPropertyChangeAllowed()); |
368 if (request->IsEmpty()) | 366 if (request->IsEmpty()) |
369 return; | 367 return; |
370 copy_requests_.push_back(request.Pass()); | 368 copy_requests_.push_back(request.Pass()); |
371 SetNeedsCommit(); | 369 SetNeedsCommit(); |
372 } | 370 } |
373 | 371 |
374 void Layer::SetAnchorPoint(const gfx::PointF& anchor_point) { | |
375 DCHECK(IsPropertyChangeAllowed()); | |
376 if (anchor_point_ == anchor_point) | |
377 return; | |
378 anchor_point_ = anchor_point; | |
379 SetNeedsCommit(); | |
380 } | |
381 | |
382 void Layer::SetAnchorPointZ(float anchor_point_z) { | |
383 DCHECK(IsPropertyChangeAllowed()); | |
384 if (anchor_point_z_ == anchor_point_z) | |
385 return; | |
386 anchor_point_z_ = anchor_point_z; | |
387 SetNeedsCommit(); | |
388 } | |
389 | |
390 void Layer::SetBackgroundColor(SkColor background_color) { | 372 void Layer::SetBackgroundColor(SkColor background_color) { |
391 DCHECK(IsPropertyChangeAllowed()); | 373 DCHECK(IsPropertyChangeAllowed()); |
392 if (background_color_ == background_color) | 374 if (background_color_ == background_color) |
393 return; | 375 return; |
394 background_color_ = background_color; | 376 background_color_ = background_color; |
395 SetNeedsCommit(); | 377 SetNeedsCommit(); |
396 } | 378 } |
397 | 379 |
398 SkColor Layer::SafeOpaqueBackgroundColor() const { | 380 SkColor Layer::SafeOpaqueBackgroundColor() const { |
399 SkColor color = background_color(); | 381 SkColor color = background_color(); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 | 573 |
592 void Layer::SetTransform(const gfx::Transform& transform) { | 574 void Layer::SetTransform(const gfx::Transform& transform) { |
593 DCHECK(IsPropertyChangeAllowed()); | 575 DCHECK(IsPropertyChangeAllowed()); |
594 if (transform_ == transform) | 576 if (transform_ == transform) |
595 return; | 577 return; |
596 transform_ = transform; | 578 transform_ = transform; |
597 transform_is_invertible_ = transform.IsInvertible(); | 579 transform_is_invertible_ = transform.IsInvertible(); |
598 SetNeedsCommit(); | 580 SetNeedsCommit(); |
599 } | 581 } |
600 | 582 |
| 583 void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) { |
| 584 DCHECK(IsPropertyChangeAllowed()); |
| 585 if (transform_origin_ == transform_origin) |
| 586 return; |
| 587 transform_origin_ = transform_origin; |
| 588 SetNeedsCommit(); |
| 589 } |
| 590 |
601 bool Layer::TransformIsAnimating() const { | 591 bool Layer::TransformIsAnimating() const { |
602 return layer_animation_controller_->IsAnimatingProperty(Animation::Transform); | 592 return layer_animation_controller_->IsAnimatingProperty(Animation::Transform); |
603 } | 593 } |
604 | 594 |
605 void Layer::SetScrollParent(Layer* parent) { | 595 void Layer::SetScrollParent(Layer* parent) { |
606 DCHECK(IsPropertyChangeAllowed()); | 596 DCHECK(IsPropertyChangeAllowed()); |
607 if (scroll_parent_ == parent) | 597 if (scroll_parent_ == parent) |
608 return; | 598 return; |
609 | 599 |
610 if (scroll_parent_) | 600 if (scroll_parent_) |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 } | 849 } |
860 | 850 |
861 void Layer::PushPropertiesTo(LayerImpl* layer) { | 851 void Layer::PushPropertiesTo(LayerImpl* layer) { |
862 DCHECK(layer_tree_host_); | 852 DCHECK(layer_tree_host_); |
863 | 853 |
864 // If we did not SavePaintProperties() for the layer this frame, then push the | 854 // If we did not SavePaintProperties() for the layer this frame, then push the |
865 // real property values, not the paint property values. | 855 // real property values, not the paint property values. |
866 bool use_paint_properties = paint_properties_.source_frame_number == | 856 bool use_paint_properties = paint_properties_.source_frame_number == |
867 layer_tree_host_->source_frame_number(); | 857 layer_tree_host_->source_frame_number(); |
868 | 858 |
869 layer->SetAnchorPoint(anchor_point_); | 859 layer->SetTransformOrigin(transform_origin_); |
870 layer->SetAnchorPointZ(anchor_point_z_); | |
871 layer->SetBackgroundColor(background_color_); | 860 layer->SetBackgroundColor(background_color_); |
872 layer->SetBounds(use_paint_properties ? paint_properties_.bounds | 861 layer->SetBounds(use_paint_properties ? paint_properties_.bounds |
873 : bounds_); | 862 : bounds_); |
874 layer->SetContentBounds(content_bounds()); | 863 layer->SetContentBounds(content_bounds()); |
875 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); | 864 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); |
876 | 865 |
877 bool is_tracing; | 866 bool is_tracing; |
878 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 867 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
879 &is_tracing); | 868 &is_tracing); |
880 if (is_tracing) | 869 if (is_tracing) |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 if (clip_parent_) | 1182 if (clip_parent_) |
1194 clip_parent_->RemoveClipChild(this); | 1183 clip_parent_->RemoveClipChild(this); |
1195 | 1184 |
1196 clip_parent_ = NULL; | 1185 clip_parent_ = NULL; |
1197 } | 1186 } |
1198 | 1187 |
1199 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1188 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
1200 benchmark->RunOnLayer(this); | 1189 benchmark->RunOnLayer(this); |
1201 } | 1190 } |
1202 } // namespace cc | 1191 } // namespace cc |
OLD | NEW |