Chromium Code Reviews| Index: cc/trees/layer_tree_host_common.cc |
| diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc |
| index 6123e25e07e41badb14d5e027f491a24b80e1d26..0462b227fcca7a334a1a7d34365f36e452598583 100644 |
| --- a/cc/trees/layer_tree_host_common.cc |
| +++ b/cc/trees/layer_tree_host_common.cc |
| @@ -1115,41 +1115,39 @@ static void CalculateDrawPropertiesInternal( |
| RenderSurfaceType* render_surface = layer->render_surface(); |
| render_surface->ClearLayerLists(); |
| - // The owning layer's draw transform has a scale from content to layer |
| - // space which we do not want; so here we use the combined_transform |
| - // instead of the draw_transform. However, we do need to add a different |
| - // scale factor that accounts for the surface's pixel dimensions. |
| - combined_transform.Scale(1.0 / render_surface_sublayer_scale.x(), |
| - 1.0 / render_surface_sublayer_scale.y()); |
| - render_surface->SetDrawTransform(combined_transform); |
| - |
| - // If this is the root layer, there should be no scale in the surface's draw |
| - // transform. |
| if (IsRootLayer(layer)) { |
| - DCHECK_EQ(render_surface_sublayer_scale.x(), |
|
danakj
2013/06/04 17:26:40
Can these checks stay in the IsRootLayer() block?
danakj
2013/06/04 17:31:30
enne pointed out that webview may want to actually
aelias_OOO_until_Jul13
2013/06/04 17:54:20
Patch Set 1 above applied it directly to root-laye
danakj
2013/06/04 18:02:50
Lost information: I mean that if you set a scale 2
aelias_OOO_until_Jul13
2013/06/04 22:18:27
I changed my mind on this, I believe this use case
|
| - combined_transform_scales.x()); |
| - DCHECK_EQ(render_surface_sublayer_scale.y(), |
| - combined_transform_scales.y()); |
| + // The root layer isn't capable of transforming its render surface since |
|
enne (OOO)
2013/06/04 17:26:03
Hmm. I'm not sure about the "external to the CC i
aelias_OOO_until_Jul13
2013/06/04 17:54:20
Done.
|
| + // it's not created from within this CC instance. So it should just |
| + // forward top-level transforms to the rest of the tree. |
| + sublayer_matrix = combined_transform; |
|
enne (OOO)
2013/06/04 17:26:03
What if the root layer also has a sublayer_matrix
aelias_OOO_until_Jul13
2013/06/04 17:54:20
It should be fine because that will be applied lat
|
| + } else { |
| + // The owning layer's draw transform has a scale from content to layer |
| + // space which we do not want; so here we use the combined_transform |
| + // instead of the draw_transform. However, we do need to add a different |
| + // scale factor that accounts for the surface's pixel dimensions. |
| + combined_transform.Scale(1.0 / render_surface_sublayer_scale.x(), |
| + 1.0 / render_surface_sublayer_scale.y()); |
| + render_surface->SetDrawTransform(combined_transform); |
| + |
| + // The owning layer's transform was re-parented by the surface, so the |
| + // layer's new draw_transform only needs to scale the layer to surface |
| + // space. |
| + layer_draw_properties.target_space_transform.MakeIdentity(); |
| + layer_draw_properties.target_space_transform. |
| + Scale(render_surface_sublayer_scale.x() / layer->contents_scale_x(), |
| + render_surface_sublayer_scale.y() / layer->contents_scale_y()); |
| + |
| + // Inside the surface's subtree, we scale everything to the owning layer's |
| + // scale. The sublayer matrix transforms layer rects into target surface |
| + // content space. Conceptually, all layers in the subtree inherit the |
| + // scale at the point of the render surface in the transform hierarchy, |
| + // but we apply it explicitly to the owning layer and the remainder of the |
| + // subtree independently. |
| + DCHECK(sublayer_matrix.IsIdentity()); |
| + sublayer_matrix.Scale(render_surface_sublayer_scale.x(), |
| + render_surface_sublayer_scale.y()); |
| } |
| - // The owning layer's transform was re-parented by the surface, so the |
| - // layer's new draw_transform only needs to scale the layer to surface |
| - // space. |
| - layer_draw_properties.target_space_transform.MakeIdentity(); |
| - layer_draw_properties.target_space_transform. |
| - Scale(render_surface_sublayer_scale.x() / layer->contents_scale_x(), |
| - render_surface_sublayer_scale.y() / layer->contents_scale_y()); |
| - |
| - // Inside the surface's subtree, we scale everything to the owning layer's |
| - // scale. The sublayer matrix transforms layer rects into target surface |
| - // content space. Conceptually, all layers in the subtree inherit the scale |
| - // at the point of the render surface in the transform hierarchy, but we |
| - // apply it explicitly to the owning layer and the remainder of the subtree |
| - // indenpendently. |
| - DCHECK(sublayer_matrix.IsIdentity()); |
| - sublayer_matrix.Scale(render_surface_sublayer_scale.x(), |
| - render_surface_sublayer_scale.y()); |
| - |
| // The opacity value is moved from the layer to its surface, so that the |
| // entire subtree properly inherits opacity. |
| render_surface->SetDrawOpacity(accumulated_draw_opacity); |
| @@ -1337,6 +1335,7 @@ static void CalculateDrawPropertiesInternal( |
| LayerType* child = |
| LayerTreeHostCommon::get_child_as_raw_ptr(layer->children(), i); |
| gfx::Rect drawable_content_rect_of_child_subtree; |
| + gfx::Transform identity_matrix; |
| CalculateDrawPropertiesInternal<LayerType, LayerList, RenderSurfaceType>( |
| child, |
| sublayer_matrix, |
| @@ -1526,6 +1525,7 @@ static void CalculateDrawPropertiesInternal( |
| void LayerTreeHostCommon::CalculateDrawProperties( |
| Layer* root_layer, |
| gfx::Size device_viewport_size, |
| + const gfx::Transform& device_transform, |
| float device_scale_factor, |
| float page_scale_factor, |
| Layer* page_scale_application_layer, |
| @@ -1535,8 +1535,8 @@ void LayerTreeHostCommon::CalculateDrawProperties( |
| LayerList* render_surface_layer_list) { |
| gfx::Rect total_drawable_content_rect; |
| gfx::Transform identity_matrix; |
| - gfx::Transform device_scale_transform; |
| - device_scale_transform.Scale(device_scale_factor, device_scale_factor); |
| + gfx::Transform scaled_device_transform = device_transform; |
| + scaled_device_transform.Scale(device_scale_factor, device_scale_factor); |
| LayerList dummy_layer_list; |
| // The root layer's render_surface should receive the device viewport as the |
| @@ -1551,7 +1551,7 @@ void LayerTreeHostCommon::CalculateDrawProperties( |
| PreCalculateMetaInformation<Layer>(root_layer); |
| CalculateDrawPropertiesInternal<Layer, LayerList, RenderSurface>( |
| root_layer, |
| - device_scale_transform, |
| + scaled_device_transform, |
| identity_matrix, |
| identity_matrix, |
| NULL, |
| @@ -1581,6 +1581,7 @@ void LayerTreeHostCommon::CalculateDrawProperties( |
| void LayerTreeHostCommon::CalculateDrawProperties( |
| LayerImpl* root_layer, |
| gfx::Size device_viewport_size, |
| + const gfx::Transform& device_transform, |
| float device_scale_factor, |
| float page_scale_factor, |
| LayerImpl* page_scale_application_layer, |
| @@ -1590,8 +1591,8 @@ void LayerTreeHostCommon::CalculateDrawProperties( |
| LayerImplList* render_surface_layer_list) { |
| gfx::Rect total_drawable_content_rect; |
| gfx::Transform identity_matrix; |
| - gfx::Transform device_scale_transform; |
| - device_scale_transform.Scale(device_scale_factor, device_scale_factor); |
| + gfx::Transform scaled_device_transform = device_transform; |
| + scaled_device_transform.Scale(device_scale_factor, device_scale_factor); |
| LayerImplList dummy_layer_list; |
| LayerSorter layer_sorter; |
| @@ -1609,7 +1610,7 @@ void LayerTreeHostCommon::CalculateDrawProperties( |
| LayerImplList, |
| RenderSurfaceImpl>( |
| root_layer, |
| - device_scale_transform, |
| + scaled_device_transform, |
| identity_matrix, |
| identity_matrix, |
| NULL, |