summaryrefslogtreecommitdiffstats
path: root/cc/trees
diff options
context:
space:
mode:
authoraelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-06 23:23:32 +0000
committeraelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-06 23:23:32 +0000
commitf224cc9a660a41bf5115fb2db7564cd0c87d68b5 (patch)
tree367cecabdd2f47685b214c92833567a44140ba99 /cc/trees
parent2ed80f0145fc03eb7eac6333b11eb27645bb37ea (diff)
downloadchromium_src-f224cc9a660a41bf5115fb2db7564cd0c87d68b5.zip
chromium_src-f224cc9a660a41bf5115fb2db7564cd0c87d68b5.tar.gz
chromium_src-f224cc9a660a41bf5115fb2db7564cd0c87d68b5.tar.bz2
Implement transform/clip support for Android WebView.
Transforms are applied above the root-layer. I fixed LTHCommon to forward root-layer transforms to sublayers, as the RenderSurface-based logic was previously clearing transforms and copying over only the scale portion. The clip rect is treated as the viewport for the purposes of DrawQuads and Renderer (this is required to avoid awful performance when the WebView is much larger than the screen). Because y-flipping the clip rect depends on knowledge of the true surface size, I also needed to add a new OutputSurface::SurfaceSize() getter and refactored viewport size throughout the Renderers to separate render-pass draw rect, glViewport rect, and surface size. Scale and translate transforms work with this patch, but rotation is still broken. New tests: LayerTreeHostCommonTest.TransformAboveRootLayer, GLRendererTest2.ScissorAndViewportWithinNonreshapableSurface, RendererPixelTest/2* and 3* NOTRY=true BUG=230463 Review URL: https://chromiumcodereview.appspot.com/15579002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204650 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/trees')
-rw-r--r--cc/trees/damage_tracker_unittest.cc1
-rw-r--r--cc/trees/layer_tree_host.cc1
-rw-r--r--cc/trees/layer_tree_host_common.cc113
-rw-r--r--cc/trees/layer_tree_host_common.h2
-rw-r--r--cc/trees/layer_tree_host_common_unittest.cc168
-rw-r--r--cc/trees/layer_tree_host_impl.cc28
-rw-r--r--cc/trees/layer_tree_host_impl.h29
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc4
-rw-r--r--cc/trees/layer_tree_impl.cc3
-rw-r--r--cc/trees/occlusion_tracker_unittest.cc2
10 files changed, 279 insertions, 72 deletions
diff --git a/cc/trees/damage_tracker_unittest.cc b/cc/trees/damage_tracker_unittest.cc
index 724fd37..56bf80b 100644
--- a/cc/trees/damage_tracker_unittest.cc
+++ b/cc/trees/damage_tracker_unittest.cc
@@ -36,6 +36,7 @@ void ExecuteCalculateDrawProperties(
LayerTreeHostCommon::CalculateDrawProperties(root,
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index 4ba7d59..a637f02 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -715,6 +715,7 @@ void LayerTreeHost::UpdateLayers(Layer* root_layer,
LayerTreeHostCommon::CalculateDrawProperties(
root_layer,
device_viewport_size(),
+ gfx::Transform(),
device_scale_factor_,
page_scale_factor_,
root_scroll,
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 6123e25..88609329 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -406,8 +406,7 @@ gfx::Transform ComputeSizeDeltaCompensation(
gfx::Transform target_surface_space_to_container_layer_space;
// Calculate step 1a
- LayerImpl* container_target_surface =
- container ? container->render_target() : 0;
+ LayerImpl* container_target_surface = container->render_target();
for (LayerImpl* current_target_surface = NextTargetSurface(layer);
current_target_surface &&
current_target_surface != container_target_surface;
@@ -418,20 +417,18 @@ gfx::Transform ComputeSizeDeltaCompensation(
current_target_surface->render_surface()->draw_transform());
}
// Calculate step 1b
- if (container) {
- gfx::Transform container_layer_space_to_container_target_surface_space =
- container->draw_transform();
- container_layer_space_to_container_target_surface_space.Scale(
- container->contents_scale_x(), container->contents_scale_y());
-
- gfx::Transform container_target_surface_space_to_container_layer_space;
- if (container_layer_space_to_container_target_surface_space.GetInverse(
- &container_target_surface_space_to_container_layer_space)) {
- // Note: Again, Concat is used to conver the result coordinate space from
- // the container render surface to the container layer.
- target_surface_space_to_container_layer_space.ConcatTransform(
- container_target_surface_space_to_container_layer_space);
- }
+ gfx::Transform container_layer_space_to_container_target_surface_space =
+ container->draw_transform();
+ container_layer_space_to_container_target_surface_space.Scale(
+ container->contents_scale_x(), container->contents_scale_y());
+
+ gfx::Transform container_target_surface_space_to_container_layer_space;
+ if (container_layer_space_to_container_target_surface_space.GetInverse(
+ &container_target_surface_space_to_container_layer_space)) {
+ // Note: Again, Concat is used to conver the result coordinate space from
+ // the container render surface to the container layer.
+ target_surface_space_to_container_layer_space.ConcatTransform(
+ container_target_surface_space_to_container_layer_space);
}
// Apply step 3
@@ -482,8 +479,7 @@ void ApplyPositionAdjustment(
layer->position_constraint().is_fixed_to_right_edge();
bool fixed_to_bottom_edge =
layer->position_constraint().is_fixed_to_bottom_edge();
- gfx::Vector2dF position_offset =
- container ? container->fixed_container_size_delta() : gfx::Vector2dF();
+ gfx::Vector2dF position_offset = container->fixed_container_size_delta();
position_offset.set_x(fixed_to_right_edge ? position_offset.x() : 0);
position_offset.set_y(fixed_to_bottom_edge ? position_offset.y() : 0);
if (position_offset.IsZero())
@@ -1115,41 +1111,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(),
- combined_transform_scales.x());
- DCHECK_EQ(render_surface_sublayer_scale.y(),
- combined_transform_scales.y());
+ // The root layer's render surface size is predetermined and so the root
+ // layer can't directly support non-identity transforms. It should just
+ // forward top-level transforms to the rest of the tree.
+ sublayer_matrix = combined_transform;
+ } 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 +1331,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 +1521,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 +1531,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,10 +1547,10 @@ void LayerTreeHostCommon::CalculateDrawProperties(
PreCalculateMetaInformation<Layer>(root_layer);
CalculateDrawPropertiesInternal<Layer, LayerList, RenderSurface>(
root_layer,
- device_scale_transform,
+ scaled_device_transform,
identity_matrix,
identity_matrix,
- NULL,
+ root_layer,
device_viewport_rect,
device_viewport_rect,
subtree_should_be_clipped,
@@ -1581,6 +1577,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 +1587,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,10 +1606,10 @@ void LayerTreeHostCommon::CalculateDrawProperties(
LayerImplList,
RenderSurfaceImpl>(
root_layer,
- device_scale_transform,
+ scaled_device_transform,
identity_matrix,
identity_matrix,
- NULL,
+ root_layer,
device_viewport_rect,
device_viewport_rect,
subtree_should_be_clipped,
diff --git a/cc/trees/layer_tree_host_common.h b/cc/trees/layer_tree_host_common.h
index 165cd5e..b2b39c4 100644
--- a/cc/trees/layer_tree_host_common.h
+++ b/cc/trees/layer_tree_host_common.h
@@ -29,6 +29,7 @@ class CC_EXPORT LayerTreeHostCommon {
static void 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,
@@ -39,6 +40,7 @@ class CC_EXPORT LayerTreeHostCommon {
static void 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,
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index aa9c7f0..8fa91ce 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -99,6 +99,7 @@ void ExecuteCalculateDrawProperties(Layer* root_layer,
LayerTreeHostCommon::CalculateDrawProperties(
root_layer,
device_viewport_size,
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
page_scale_application_layer,
@@ -126,6 +127,7 @@ void ExecuteCalculateDrawProperties(LayerImpl* root_layer,
LayerTreeHostCommon::CalculateDrawProperties(
root_layer,
device_viewport_size,
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
page_scale_application_layer,
@@ -1484,6 +1486,121 @@ TEST(LayerTreeHostCommonTest, TransformsForDegenerateIntermediateLayer) {
grand_child->draw_transform());
}
+TEST(LayerTreeHostCommonTest, TransformAboveRootLayer) {
+ // Transformations applied at the root of the tree should be forwarded
+ // to child layers instead of applied to the root RenderSurface.
+ const gfx::Transform identity_matrix;
+ scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> child = Layer::Create();
+
+ root->AddChild(child);
+
+ SetLayerPropertiesForTesting(root.get(),
+ identity_matrix,
+ identity_matrix,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(20, 20),
+ false);
+ SetLayerPropertiesForTesting(child.get(),
+ identity_matrix,
+ identity_matrix,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(20, 20),
+ false);
+
+ LayerList render_surface_layer_list;
+ int dummy_max_texture_size = 512;
+
+ gfx::Transform translate;
+ translate.Translate(50, 50);
+ LayerTreeHostCommon::CalculateDrawProperties(root.get(),
+ root->bounds(),
+ translate,
+ 1.f,
+ 1.f,
+ NULL,
+ dummy_max_texture_size,
+ false,
+ true, // can_adjust_raster_scale
+ &render_surface_layer_list);
+ EXPECT_EQ(translate, root->draw_properties().target_space_transform);
+ EXPECT_EQ(translate, child->draw_properties().target_space_transform);
+ EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
+
+ gfx::Transform scale;
+ scale.Scale(2, 2);
+ LayerTreeHostCommon::CalculateDrawProperties(root.get(),
+ root->bounds(),
+ scale,
+ 1.f,
+ 1.f,
+ NULL,
+ dummy_max_texture_size,
+ false,
+ true, // can_adjust_raster_scale
+ &render_surface_layer_list);
+ EXPECT_EQ(scale, root->draw_properties().target_space_transform);
+ EXPECT_EQ(scale, child->draw_properties().target_space_transform);
+ EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
+
+ gfx::Transform rotate;
+ rotate.Rotate(2);
+ LayerTreeHostCommon::CalculateDrawProperties(root.get(),
+ root->bounds(),
+ rotate,
+ 1.f,
+ 1.f,
+ NULL,
+ dummy_max_texture_size,
+ false,
+ true, // can_adjust_raster_scale
+ &render_surface_layer_list);
+ EXPECT_EQ(rotate, root->draw_properties().target_space_transform);
+ EXPECT_EQ(rotate, child->draw_properties().target_space_transform);
+ EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
+
+ gfx::Transform composite;
+ composite.ConcatTransform(translate);
+ composite.ConcatTransform(scale);
+ composite.ConcatTransform(rotate);
+ LayerTreeHostCommon::CalculateDrawProperties(root.get(),
+ root->bounds(),
+ composite,
+ 1.f,
+ 1.f,
+ NULL,
+ dummy_max_texture_size,
+ false,
+ true, // can_adjust_raster_scale
+ &render_surface_layer_list);
+ EXPECT_EQ(composite, root->draw_properties().target_space_transform);
+ EXPECT_EQ(composite, child->draw_properties().target_space_transform);
+ EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
+
+ // Verify that it composes correctly with transforms directly on root layer.
+ root->SetTransform(composite);
+ root->SetSublayerTransform(composite);
+ LayerTreeHostCommon::CalculateDrawProperties(root.get(),
+ root->bounds(),
+ composite,
+ 1.f,
+ 1.f,
+ NULL,
+ dummy_max_texture_size,
+ false,
+ true, // can_adjust_raster_scale
+ &render_surface_layer_list);
+ gfx::Transform compositeSquared = composite;
+ compositeSquared.ConcatTransform(composite);
+ gfx::Transform compositeCubed = compositeSquared;
+ compositeCubed.ConcatTransform(composite);
+ EXPECT_EQ(compositeSquared, root->draw_properties().target_space_transform);
+ EXPECT_EQ(compositeCubed, child->draw_properties().target_space_transform);
+ EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
+}
+
TEST(LayerTreeHostCommonTest,
RenderSurfaceListForRenderSurfaceWithClippedLayer) {
scoped_refptr<Layer> parent = Layer::Create();
@@ -1523,6 +1640,7 @@ TEST(LayerTreeHostCommonTest,
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -1572,6 +1690,7 @@ TEST(LayerTreeHostCommonTest, RenderSurfaceListForTransparentChild) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -1631,6 +1750,7 @@ TEST(LayerTreeHostCommonTest, ForceRenderSurface) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -1648,6 +1768,7 @@ TEST(LayerTreeHostCommonTest, ForceRenderSurface) {
render_surface1->SetForceRenderSurface(false);
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -1749,6 +1870,7 @@ TEST(LayerTreeHostCommonTest, ClipRectCullsRenderSurfaces) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -1830,6 +1952,7 @@ TEST(LayerTreeHostCommonTest, ClipRectCullsSurfaceWithoutVisibleContent) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -1854,6 +1977,7 @@ TEST(LayerTreeHostCommonTest, ClipRectCullsSurfaceWithoutVisibleContent) {
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -1958,6 +2082,7 @@ TEST(LayerTreeHostCommonTest, IsClippedIsSetCorrectly) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -1987,6 +2112,7 @@ TEST(LayerTreeHostCommonTest, IsClippedIsSetCorrectly) {
parent->SetMasksToBounds(true);
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -2015,6 +2141,7 @@ TEST(LayerTreeHostCommonTest, IsClippedIsSetCorrectly) {
child2->SetMasksToBounds(true);
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -2123,6 +2250,7 @@ TEST(LayerTreeHostCommonTest, drawable_content_rectForLayers) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -2268,6 +2396,7 @@ TEST(LayerTreeHostCommonTest, ClipRectIsPropagatedCorrectlyToSurfaces) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -3598,6 +3727,7 @@ TEST(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -3792,6 +3922,7 @@ TEST(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -3932,6 +4063,7 @@ TEST(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -4060,6 +4192,7 @@ TEST(LayerTreeHostCommonTest,
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -4138,6 +4271,7 @@ TEST(LayerTreeHostCommonTest, HitTestingForSingleLayer) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -4214,6 +4348,7 @@ TEST(LayerTreeHostCommonTest, HitTestingForSingleLayerAndHud) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
hud_bounds,
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -4282,6 +4417,7 @@ TEST(LayerTreeHostCommonTest, HitTestingForUninvertibleTransform) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -4359,6 +4495,7 @@ TEST(LayerTreeHostCommonTest, HitTestingForSinglePositionedLayer) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -4425,6 +4562,7 @@ TEST(LayerTreeHostCommonTest, HitTestingForSingleRotatedLayer) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -4504,6 +4642,7 @@ TEST(LayerTreeHostCommonTest, HitTestingForSinglePerspectiveLayer) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -4594,6 +4733,7 @@ TEST(LayerTreeHostCommonTest, HitTestingForSingleLayerWithScaledContents) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -4695,6 +4835,7 @@ TEST(LayerTreeHostCommonTest, HitTestingForSimpleClippedLayer) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -4829,6 +4970,7 @@ TEST(LayerTreeHostCommonTest, HitTestingForMultiClippedRotatedLayer) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -4956,6 +5098,7 @@ TEST(LayerTreeHostCommonTest, HitTestingForNonClippingIntermediateLayer) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -5074,6 +5217,7 @@ TEST(LayerTreeHostCommonTest, HitTestingForMultipleLayers) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -5228,6 +5372,7 @@ TEST(LayerTreeHostCommonTest, HitTestingForMultipleLayerLists) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -5346,6 +5491,7 @@ TEST(LayerTreeHostCommonTest, HitCheckingTouchHandlerRegionsForSingleLayer) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -5444,6 +5590,7 @@ TEST(LayerTreeHostCommonTest,
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -5532,6 +5679,7 @@ TEST(LayerTreeHostCommonTest,
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -5638,6 +5786,7 @@ TEST(LayerTreeHostCommonTest,
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -5751,6 +5900,7 @@ TEST(LayerTreeHostCommonTest,
gfx::ScaleSize(root->bounds(), device_scale_factor * page_scale_factor));
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
scaled_bounds_for_root,
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
root.get(),
@@ -5891,6 +6041,7 @@ TEST(LayerTreeHostCommonTest,
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -6036,6 +6187,7 @@ TEST(LayerTreeHostCommonTest, LayerTransformsInHighDPI) {
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
parent.get(),
@@ -6173,6 +6325,7 @@ TEST(LayerTreeHostCommonTest, SurfaceLayerTransformsInHighDPI) {
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
parent.get(),
@@ -6273,6 +6426,7 @@ TEST(LayerTreeHostCommonTest,
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
parent.get(),
@@ -6412,6 +6566,7 @@ TEST(LayerTreeHostCommonTest, ContentsScale) {
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
parent.get(),
@@ -6454,6 +6609,7 @@ TEST(LayerTreeHostCommonTest, ContentsScale) {
render_surface_layer_list.clear();
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
parent.get(),
@@ -6482,6 +6638,7 @@ TEST(LayerTreeHostCommonTest, ContentsScale) {
render_surface_layer_list.clear();
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
parent.get(),
@@ -6507,6 +6664,7 @@ TEST(LayerTreeHostCommonTest, ContentsScale) {
render_surface_layer_list.clear();
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
parent.get(),
@@ -6595,6 +6753,7 @@ TEST(LayerTreeHostCommonTest,
LayerTreeHostCommon::CalculateDrawProperties(
root.get(),
root->bounds(),
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
parent.get(),
@@ -6678,6 +6837,7 @@ TEST(LayerTreeHostCommonTest, SmallContentsScale) {
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
parent.get(),
@@ -6703,6 +6863,7 @@ TEST(LayerTreeHostCommonTest, SmallContentsScale) {
render_surface_layer_list.clear();
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
parent.get(),
@@ -6824,6 +6985,7 @@ TEST(LayerTreeHostCommonTest, ContentsScaleForSurfaces) {
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
parent.get(),
@@ -7039,6 +7201,7 @@ TEST(LayerTreeHostCommonTest,
LayerTreeHostCommon::CalculateDrawProperties(
root.get(),
root->bounds(),
+ gfx::Transform(),
device_scale_factor,
page_scale_factor,
parent.get(),
@@ -7192,6 +7355,7 @@ TEST(LayerTreeHostCommonTest, ContentsScaleForAnimatingLayer) {
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -7210,6 +7374,7 @@ TEST(LayerTreeHostCommonTest, ContentsScaleForAnimatingLayer) {
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -7280,6 +7445,7 @@ TEST(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) {
float device_scale_factor = 1.5f;
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
device_scale_factor,
1.f,
NULL,
@@ -7417,6 +7583,7 @@ TEST(LayerTreeHostCommonTest,
float device_scale_factor = 1.7f;
LayerTreeHostCommon::CalculateDrawProperties(parent.get(),
parent->bounds(),
+ gfx::Transform(),
device_scale_factor,
1.f,
NULL,
@@ -7571,6 +7738,7 @@ TEST(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) {
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 7d8bf91..5d84fcd 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -165,8 +165,6 @@ LayerTreeHostImpl::LayerTreeHostImpl(
wheel_scrolling_(false),
root_layer_scroll_offset_delegate_(NULL),
settings_(settings),
- overdraw_bottom_height_(0.f),
- device_scale_factor_(1.f),
visible_(true),
managed_memory_policy_(
PrioritizedResourceManager::DefaultMemoryAllocationLimit(),
@@ -182,6 +180,8 @@ LayerTreeHostImpl::LayerTreeHostImpl(
last_sent_memory_visible_bytes_(0),
last_sent_memory_visible_and_nearby_bytes_(0),
last_sent_memory_use_bytes_(0),
+ device_scale_factor_(1.f),
+ overdraw_bottom_height_(0.f),
animation_registrar_(AnimationRegistrar::Create()),
rendering_stats_instrumentation_(rendering_stats_instrumentation) {
DCHECK(proxy_->IsImplThread());
@@ -1040,6 +1040,13 @@ void LayerTreeHostImpl::SetManagedMemoryPolicy(
client_->SetNeedsCommitOnImplThread();
}
+void LayerTreeHostImpl::SetExternalDrawConstraints(
+ const gfx::Transform& transform,
+ gfx::Rect viewport) {
+ external_transform_ = transform;
+ external_viewport_ = viewport;
+}
+
void LayerTreeHostImpl::SetNeedsRedrawRect(gfx::Rect damage_rect) {
client_->SetNeedsRedrawRectOnImplThread(damage_rect);
}
@@ -1221,17 +1228,13 @@ void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) {
output_surface_->SetNeedsBeginFrame(enable);
}
-gfx::Size LayerTreeHostImpl::DeviceViewportSize() const {
- return device_viewport_size();
-}
-
float LayerTreeHostImpl::DeviceScaleFactor() const {
return device_scale_factor_;
}
gfx::SizeF LayerTreeHostImpl::VisibleViewportSize() const {
gfx::SizeF dip_size =
- gfx::ScaleSize(DeviceViewportSize(), 1.f / device_scale_factor());
+ gfx::ScaleSize(device_viewport_size(), 1.f / device_scale_factor());
// The clip layer should be used if non-overlay scrollbars may exist since
// it adjusts for them.
@@ -1553,6 +1556,17 @@ void LayerTreeHostImpl::SetDeviceScaleFactor(float device_scale_factor) {
SetFullRootLayerDamage();
}
+gfx::Rect LayerTreeHostImpl::DeviceViewport() const {
+ if (external_viewport_.IsEmpty())
+ return gfx::Rect(device_viewport_size_);
+
+ return external_viewport_;
+}
+
+const gfx::Transform& LayerTreeHostImpl::DeviceTransform() const {
+ return external_transform_;
+}
+
void LayerTreeHostImpl::UpdateMaxScrollOffset() {
active_tree_->UpdateMaxScrollOffset();
}
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index f65922a..e3671cf 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -176,8 +176,8 @@ class CC_EXPORT LayerTreeHostImpl
gfx::SizeF VisibleViewportSize() const;
// RendererClient implementation
+ virtual gfx::Rect DeviceViewport() const OVERRIDE;
private:
- virtual gfx::Size DeviceViewportSize() const OVERRIDE;
virtual float DeviceScaleFactor() const OVERRIDE;
virtual const LayerTreeSettings& Settings() const OVERRIDE;
public:
@@ -207,6 +207,8 @@ class CC_EXPORT LayerTreeHostImpl
OVERRIDE;
virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck& ack)
OVERRIDE;
+ virtual void SetExternalDrawConstraints(const gfx::Transform& transform,
+ gfx::Rect viewport) OVERRIDE;
// Called from LayerTreeImpl.
void OnCanDrawStateChangedForTree();
@@ -267,6 +269,8 @@ class CC_EXPORT LayerTreeHostImpl
void SetDeviceScaleFactor(float device_scale_factor);
float device_scale_factor() const { return device_scale_factor_; }
+ const gfx::Transform& DeviceTransform() const;
+
scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas();
bool needs_animate_layers() const {
@@ -457,9 +461,6 @@ class CC_EXPORT LayerTreeHostImpl
LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate_;
LayerTreeSettings settings_;
LayerTreeDebugState debug_state_;
- gfx::Size device_viewport_size_;
- float overdraw_bottom_height_;
- float device_scale_factor_;
bool visible_;
ManagedMemoryPolicy managed_memory_policy_;
@@ -493,6 +494,26 @@ class CC_EXPORT LayerTreeHostImpl
size_t last_sent_memory_visible_and_nearby_bytes_;
size_t last_sent_memory_use_bytes_;
+ // Viewport size passed in from the main thread, in physical pixels.
+ gfx::Size device_viewport_size_;
+
+ // Conversion factor from CSS pixels to physical pixels when
+ // pageScaleFactor=1.
+ float device_scale_factor_;
+
+ // Vertical amount of the viewport size that's known to covered by a
+ // browser-side UI element, such as an on-screen-keyboard. This affects
+ // scrollable size since we want to still be able to scroll to the bottom of
+ // the page when the keyboard is up.
+ float overdraw_bottom_height_;
+
+ // Optional top-level constraints that can be set by the OutputSurface. The
+ // external_viewport_'s size takes precedence over device_viewport_size_ for
+ // DrawQuad generation and Renderer; however, device_viewport_size_ is still
+ // used for scrollable size.
+ gfx::Transform external_transform_;
+ gfx::Rect external_viewport_;
+
gfx::Rect viewport_damage_rect_;
base::TimeTicks current_frame_timeticks_;
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index ab97c86..95bc4fe 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -4602,8 +4602,8 @@ class TestRenderer : public GLRenderer, public RendererClient {
}
// RendererClient implementation.
- virtual gfx::Size DeviceViewportSize() const OVERRIDE {
- return viewport_size_;
+ virtual gfx::Rect DeviceViewport() const OVERRIDE {
+ return gfx::Rect(viewport_size_);
}
virtual float DeviceScaleFactor() const OVERRIDE {
return 1.f;
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index 6bc370c..e8ae6f1 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -282,7 +282,8 @@ void LayerTreeImpl::UpdateDrawProperties() {
IsActiveTree());
LayerTreeHostCommon::CalculateDrawProperties(
root_layer(),
- device_viewport_size(),
+ layer_tree_host_impl_->DeviceViewport().size(),
+ layer_tree_host_impl_->DeviceTransform(),
device_scale_factor(),
total_page_scale_factor(),
root_scroll_layer_,
diff --git a/cc/trees/occlusion_tracker_unittest.cc b/cc/trees/occlusion_tracker_unittest.cc
index 09c64ef..7cf6aa7 100644
--- a/cc/trees/occlusion_tracker_unittest.cc
+++ b/cc/trees/occlusion_tracker_unittest.cc
@@ -316,6 +316,7 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test {
LayerTreeHostCommon::CalculateDrawProperties(
root,
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,
@@ -337,6 +338,7 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test {
LayerTreeHostCommon::CalculateDrawProperties(
root,
root->bounds(),
+ gfx::Transform(),
1.f,
1.f,
NULL,