Index: cc/layers/layer_impl.cc |
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc |
index 024ba5abca6c9e9645d5b444223f37b2083273c3..499230e46e7a41e51fd6ba387af84baf270866ba 100644 |
--- a/cc/layers/layer_impl.cc |
+++ b/cc/layers/layer_impl.cc |
@@ -22,6 +22,7 @@ |
#include "cc/output/copy_output_request.h" |
#include "cc/quads/debug_border_draw_quad.h" |
#include "cc/quads/render_pass.h" |
+#include "cc/trees/draw_property_utils.h" |
#include "cc/trees/layer_tree_host_common.h" |
#include "cc/trees/layer_tree_impl.h" |
#include "cc/trees/layer_tree_settings.h" |
@@ -306,7 +307,7 @@ void LayerImpl::TakeCopyRequestsAndTransformToTarget( |
gfx::Rect request_in_layer_space = request->area(); |
request_in_layer_space.Intersect(gfx::Rect(bounds())); |
request->set_area(MathUtil::MapEnclosingClippedRect( |
- draw_properties_.target_space_transform, request_in_layer_space)); |
+ DrawTransform(), request_in_layer_space)); |
} |
layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); |
@@ -701,7 +702,7 @@ base::DictionaryValue* LayerImpl::LayerTreeAsJson() const { |
list->AppendDouble(position_.y()); |
result->Set("Position", list); |
- const gfx::Transform& gfx_transform = draw_properties_.target_space_transform; |
+ const gfx::Transform& gfx_transform = DrawTransform(); |
double transform[16]; |
gfx_transform.matrix().asColMajord(transform); |
list = new base::ListValue; |
@@ -1773,18 +1774,34 @@ void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { |
render_surface_.reset(); |
} |
+gfx::Transform LayerImpl::DrawTransform() const { |
+ // Only drawn layers have up-to-date draw properties when property trees are |
+ // enabled. |
+ if (layer_tree_impl()->settings().use_property_trees && |
+ !IsDrawnRenderSurfaceLayerListMember()) { |
+ if (layer_tree_impl()->property_trees()->non_root_surfaces_enabled) { |
+ return DrawTransformFromPropertyTrees( |
+ this, layer_tree_impl()->property_trees()->transform_tree); |
+ } else { |
+ return ScreenSpaceTransformFromPropertyTrees( |
+ this, layer_tree_impl()->property_trees()->transform_tree); |
+ } |
+ } |
+ |
+ return draw_properties().target_space_transform; |
+} |
+ |
Region LayerImpl::GetInvalidationRegion() { |
return Region(update_rect_); |
} |
gfx::Rect LayerImpl::GetEnclosingRectInTargetSpace() const { |
- return MathUtil::MapEnclosingClippedRect( |
- draw_properties_.target_space_transform, gfx::Rect(bounds())); |
+ return MathUtil::MapEnclosingClippedRect(DrawTransform(), |
+ gfx::Rect(bounds())); |
} |
gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const { |
- gfx::Transform scaled_draw_transform = |
- draw_properties_.target_space_transform; |
+ gfx::Transform scaled_draw_transform = DrawTransform(); |
scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale); |
gfx::Size scaled_bounds = gfx::ScaleToCeiledSize(bounds(), scale); |
return MathUtil::MapEnclosingClippedRect(scaled_draw_transform, |
@@ -1804,10 +1821,8 @@ float LayerImpl::GetIdealContentsScale() const { |
return default_scale; |
} |
- // TODO(enne): the transform needs to come from property trees instead of |
- // draw properties. |
gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
- draw_properties().target_space_transform, default_scale); |
+ DrawTransform(), default_scale); |
return std::max(transform_scales.x(), transform_scales.y()); |
} |