summaryrefslogtreecommitdiff
path: root/chromium/cc/trees
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-08-14 11:38:45 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-08-14 17:16:47 +0000
commit3a97ca8dd9b96b599ae2d33e40df0dd2f7ea5859 (patch)
tree43cc572ba067417c7341db81f71ae7cc6e0fcc3e /chromium/cc/trees
parentf61ab1ac7f855cd281809255c0aedbb1895e1823 (diff)
downloadqtwebengine-chromium-3a97ca8dd9b96b599ae2d33e40df0dd2f7ea5859.tar.gz
BASELINE: Update chromium to 45.0.2454.40
Change-Id: Id2121d9f11a8fc633677236c65a3e41feef589e4 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'chromium/cc/trees')
-rw-r--r--chromium/cc/trees/blocking_task_runner.cc1
-rw-r--r--chromium/cc/trees/damage_tracker.cc6
-rw-r--r--chromium/cc/trees/damage_tracker_unittest.cc32
-rw-r--r--chromium/cc/trees/draw_property_utils.cc60
-rw-r--r--chromium/cc/trees/draw_property_utils.h51
-rw-r--r--chromium/cc/trees/layer_tree_host.cc572
-rw-r--r--chromium/cc/trees/layer_tree_host.h103
-rw-r--r--chromium/cc/trees/layer_tree_host_client.h7
-rw-r--r--chromium/cc/trees/layer_tree_host_common.cc446
-rw-r--r--chromium/cc/trees/layer_tree_host_common.h31
-rw-r--r--chromium/cc/trees/layer_tree_host_common_perftest.cc87
-rw-r--r--chromium/cc/trees/layer_tree_host_common_unittest.cc3350
-rw-r--r--chromium/cc/trees/layer_tree_host_impl.cc831
-rw-r--r--chromium/cc/trees/layer_tree_host_impl.h107
-rw-r--r--chromium/cc/trees/layer_tree_host_impl_unittest.cc998
-rw-r--r--chromium/cc/trees/layer_tree_host_perftest.cc36
-rw-r--r--chromium/cc/trees/layer_tree_host_pixeltest_blending.cc6
-rw-r--r--chromium/cc/trees/layer_tree_host_pixeltest_masks.cc60
-rw-r--r--chromium/cc/trees/layer_tree_host_pixeltest_readback.cc12
-rw-r--r--chromium/cc/trees/layer_tree_host_pixeltest_synchronous.cc8
-rw-r--r--chromium/cc/trees/layer_tree_host_pixeltest_tiles.cc214
-rw-r--r--chromium/cc/trees/layer_tree_host_unittest.cc2004
-rw-r--r--chromium/cc/trees/layer_tree_host_unittest_animation.cc230
-rw-r--r--chromium/cc/trees/layer_tree_host_unittest_animation_timelines.cc923
-rw-r--r--chromium/cc/trees/layer_tree_host_unittest_context.cc448
-rw-r--r--chromium/cc/trees/layer_tree_host_unittest_copyrequest.cc168
-rw-r--r--chromium/cc/trees/layer_tree_host_unittest_damage.cc74
-rw-r--r--chromium/cc/trees/layer_tree_host_unittest_delegated.cc53
-rw-r--r--chromium/cc/trees/layer_tree_host_unittest_no_message_loop.cc248
-rw-r--r--chromium/cc/trees/layer_tree_host_unittest_occlusion.cc32
-rw-r--r--chromium/cc/trees/layer_tree_host_unittest_picture.cc79
-rw-r--r--chromium/cc/trees/layer_tree_host_unittest_proxy.cc16
-rw-r--r--chromium/cc/trees/layer_tree_host_unittest_scroll.cc131
-rw-r--r--chromium/cc/trees/layer_tree_host_unittest_video.cc6
-rw-r--r--chromium/cc/trees/layer_tree_impl.cc349
-rw-r--r--chromium/cc/trees/layer_tree_impl.h46
-rw-r--r--chromium/cc/trees/layer_tree_impl_unittest.cc196
-rw-r--r--chromium/cc/trees/layer_tree_settings.cc28
-rw-r--r--chromium/cc/trees/layer_tree_settings.h17
-rw-r--r--chromium/cc/trees/mutator_host_client.h45
-rw-r--r--chromium/cc/trees/occlusion_tracker.cc196
-rw-r--r--chromium/cc/trees/occlusion_tracker.h24
-rw-r--r--chromium/cc/trees/occlusion_tracker_perftest.cc38
-rw-r--r--chromium/cc/trees/occlusion_tracker_unittest.cc1727
-rw-r--r--chromium/cc/trees/property_tree.cc139
-rw-r--r--chromium/cc/trees/property_tree.h95
-rw-r--r--chromium/cc/trees/property_tree_builder.cc159
-rw-r--r--chromium/cc/trees/property_tree_builder.h4
-rw-r--r--chromium/cc/trees/property_tree_unittest.cc120
-rw-r--r--chromium/cc/trees/proxy.cc1
-rw-r--r--chromium/cc/trees/proxy.h3
-rw-r--r--chromium/cc/trees/proxy_timing_history.cc124
-rw-r--r--chromium/cc/trees/proxy_timing_history.h46
-rw-r--r--chromium/cc/trees/single_thread_proxy.cc201
-rw-r--r--chromium/cc/trees/single_thread_proxy.h18
-rw-r--r--chromium/cc/trees/thread_proxy.cc232
-rw-r--r--chromium/cc/trees/thread_proxy.h44
-rw-r--r--chromium/cc/trees/tree_synchronizer.cc8
-rw-r--r--chromium/cc/trees/tree_synchronizer.h2
-rw-r--r--chromium/cc/trees/tree_synchronizer_unittest.cc143
60 files changed, 6659 insertions, 8776 deletions
diff --git a/chromium/cc/trees/blocking_task_runner.cc b/chromium/cc/trees/blocking_task_runner.cc
index 1111e9bf4b7..b0a935e2529 100644
--- a/chromium/cc/trees/blocking_task_runner.cc
+++ b/chromium/cc/trees/blocking_task_runner.cc
@@ -8,7 +8,6 @@
#include "base/callback.h"
#include "base/logging.h"
-#include "base/message_loop/message_loop_proxy.h"
namespace cc {
diff --git a/chromium/cc/trees/damage_tracker.cc b/chromium/cc/trees/damage_tracker.cc
index 235dfcfd7ef..de11b47c1a9 100644
--- a/chromium/cc/trees/damage_tracker.cc
+++ b/chromium/cc/trees/damage_tracker.cc
@@ -288,6 +288,7 @@ void DamageTracker::ExtendDamageForLayer(LayerImpl* layer,
gfx::RectF damage_rect =
gfx::UnionRects(layer->update_rect(), layer->damage_rect());
+ damage_rect.Intersect(gfx::RectF(layer->bounds()));
if (layer_is_new || layer->LayerPropertyChanged()) {
// If a layer is new or has changed, then its entire layer rect affects the
@@ -300,9 +301,8 @@ void DamageTracker::ExtendDamageForLayer(LayerImpl* layer,
} else if (!damage_rect.IsEmpty()) {
// If the layer properties haven't changed, then the the target surface is
// only affected by the layer's damaged area, which could be empty.
- gfx::Rect damage_content_rect = layer->LayerRectToContentRect(damage_rect);
- gfx::Rect damage_rect_in_target_space = MathUtil::MapEnclosingClippedRect(
- layer->draw_transform(), damage_content_rect);
+ gfx::Rect damage_rect_in_target_space = gfx::ToEnclosingRect(
+ MathUtil::MapClippedRect(layer->draw_transform(), damage_rect));
target_damage_rect->Union(damage_rect_in_target_space);
}
}
diff --git a/chromium/cc/trees/damage_tracker_unittest.cc b/chromium/cc/trees/damage_tracker_unittest.cc
index 2df71ddf2a7..831b1f718ec 100644
--- a/chromium/cc/trees/damage_tracker_unittest.cc
+++ b/chromium/cc/trees/damage_tracker_unittest.cc
@@ -14,6 +14,7 @@
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_host_common.h"
+#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/single_thread_proxy.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/effects/SkBlurImageFilter.h"
@@ -47,6 +48,7 @@ void ClearDamageForAllSurfaces(LayerImpl* layer) {
}
void EmulateDrawingOneFrame(LayerImpl* root) {
+ root->layer_tree_impl()->property_trees()->needs_rebuild = true;
// This emulates only steps that are relevant to testing the damage tracker:
// 1. computing the render passes and layerlists
// 2. updating all damage trackers in the correct order
@@ -58,16 +60,17 @@ void EmulateDrawingOneFrame(LayerImpl* root) {
// Iterate back-to-front, so that damage correctly propagates from descendant
// surfaces to ancestors.
- for (int i = render_surface_layer_list.size() - 1; i >= 0; --i) {
+ size_t render_surface_layer_list_size = render_surface_layer_list.size();
+ for (size_t i = 0; i < render_surface_layer_list_size; ++i) {
+ size_t index = render_surface_layer_list_size - 1 - i;
RenderSurfaceImpl* target_surface =
- render_surface_layer_list[i]->render_surface();
+ render_surface_layer_list[index]->render_surface();
target_surface->damage_tracker()->UpdateDamageTrackingState(
- target_surface->layer_list(),
- target_surface->OwningLayerId(),
+ target_surface->layer_list(), target_surface->OwningLayerId(),
target_surface->SurfacePropertyChangedOnlyFromDescendant(),
target_surface->content_rect(),
- render_surface_layer_list[i]->mask_layer(),
- render_surface_layer_list[i]->filters());
+ render_surface_layer_list[index]->mask_layer(),
+ render_surface_layer_list[index]->filters());
}
root->ResetAllChangeTrackingForSubtree();
@@ -86,14 +89,12 @@ class DamageTrackerTest : public testing::Test {
root->SetPosition(gfx::PointF());
root->SetBounds(gfx::Size(500, 500));
- root->SetContentBounds(gfx::Size(500, 500));
root->SetDrawsContent(true);
root->SetHasRenderSurface(true);
root->render_surface()->SetContentRect(gfx::Rect(0, 0, 500, 500));
child->SetPosition(gfx::PointF(100.f, 100.f));
child->SetBounds(gfx::Size(30, 30));
- child->SetContentBounds(gfx::Size(30, 30));
child->SetDrawsContent(true);
root->AddChild(child.Pass());
@@ -118,14 +119,12 @@ class DamageTrackerTest : public testing::Test {
root->SetPosition(gfx::PointF());
root->SetBounds(gfx::Size(500, 500));
- root->SetContentBounds(gfx::Size(500, 500));
root->SetDrawsContent(true);
root->SetHasRenderSurface(true);
root->render_surface()->SetContentRect(gfx::Rect(0, 0, 500, 500));
child1->SetPosition(gfx::PointF(100.f, 100.f));
child1->SetBounds(gfx::Size(30, 30));
- child1->SetContentBounds(gfx::Size(30, 30));
// With a child that draws_content, opacity will cause the layer to create
// its own RenderSurface. This layer does not draw, but is intended to
// create its own RenderSurface.
@@ -134,17 +133,14 @@ class DamageTrackerTest : public testing::Test {
child2->SetPosition(gfx::PointF(11.f, 11.f));
child2->SetBounds(gfx::Size(18, 18));
- child2->SetContentBounds(gfx::Size(18, 18));
child2->SetDrawsContent(true);
grand_child1->SetPosition(gfx::PointF(200.f, 200.f));
grand_child1->SetBounds(gfx::Size(6, 8));
- grand_child1->SetContentBounds(gfx::Size(6, 8));
grand_child1->SetDrawsContent(true);
grand_child2->SetPosition(gfx::PointF(190.f, 190.f));
grand_child2->SetBounds(gfx::Size(6, 8));
- grand_child2->SetContentBounds(gfx::Size(6, 8));
grand_child2->SetDrawsContent(true);
child1->AddChild(grand_child1.Pass());
@@ -469,7 +465,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForPerspectiveClippedLayer) {
// Set up the child
child->SetPosition(gfx::PointF(0.f, 0.f));
child->SetBounds(gfx::Size(100, 100));
- child->SetContentBounds(gfx::Size(100, 100));
child->SetTransform(transform);
EmulateDrawingOneFrame(root.get());
@@ -707,7 +702,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingLayer) {
LayerImpl::Create(host_impl_.active_tree(), 3);
child2->SetPosition(gfx::PointF(400.f, 380.f));
child2->SetBounds(gfx::Size(6, 8));
- child2->SetContentBounds(gfx::Size(6, 8));
child2->SetDrawsContent(true);
root->AddChild(child2.Pass());
}
@@ -756,7 +750,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForNewUnchangedLayer) {
LayerImpl::Create(host_impl_.active_tree(), 3);
child2->SetPosition(gfx::PointF(400.f, 380.f));
child2->SetBounds(gfx::Size(6, 8));
- child2->SetContentBounds(gfx::Size(6, 8));
child2->SetDrawsContent(true);
child2->ResetAllChangeTrackingForSubtree();
// Sanity check the initial conditions of the test, if these asserts
@@ -789,7 +782,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForMultipleLayers) {
LayerImpl::Create(host_impl_.active_tree(), 3);
child2->SetPosition(gfx::PointF(400.f, 380.f));
child2->SetBounds(gfx::Size(6, 8));
- child2->SetContentBounds(gfx::Size(6, 8));
child2->SetDrawsContent(true);
root->AddChild(child2.Pass());
}
@@ -1039,7 +1031,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForReplica) {
LayerImpl::Create(host_impl_.active_tree(), 6);
grand_child3->SetPosition(gfx::PointF(240.f, 240.f));
grand_child3->SetBounds(gfx::Size(10, 10));
- grand_child3->SetContentBounds(gfx::Size(10, 10));
grand_child3->SetDrawsContent(true);
child1->AddChild(grand_child3.Pass());
}
@@ -1141,7 +1132,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForMask) {
LayerImpl::Create(host_impl_.active_tree(), 3);
mask_layer->SetPosition(child->position());
mask_layer->SetBounds(child->bounds());
- mask_layer->SetContentBounds(child->bounds());
child->SetMaskLayer(mask_layer.Pass());
child->SetHasRenderSurface(true);
}
@@ -1154,7 +1144,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForMask) {
LayerImpl::Create(host_impl_.active_tree(), 4);
grand_child->SetPosition(gfx::PointF(2.f, 2.f));
grand_child->SetBounds(gfx::Size(2, 2));
- grand_child->SetContentBounds(gfx::Size(2, 2));
grand_child->SetDrawsContent(true);
child->AddChild(grand_child.Pass());
}
@@ -1243,7 +1232,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForReplicaMask) {
LayerImpl::Create(host_impl_.active_tree(), 7);
replica_mask_layer->SetPosition(gfx::PointF());
replica_mask_layer->SetBounds(grand_child1->bounds());
- replica_mask_layer->SetContentBounds(grand_child1->bounds());
grand_child1_replica->SetMaskLayer(replica_mask_layer.Pass());
}
LayerImpl* replica_mask_layer = grand_child1_replica->mask_layer();
@@ -1322,7 +1310,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForReplicaMaskWithTransformOrigin) {
replica_mask_layer->SetPosition(gfx::PointF());
// Note: this is not the transform origin being tested.
replica_mask_layer->SetBounds(grand_child1->bounds());
- replica_mask_layer->SetContentBounds(grand_child1->bounds());
grand_child1_replica->SetMaskLayer(replica_mask_layer.Pass());
}
LayerImpl* replica_mask_layer = grand_child1_replica->mask_layer();
@@ -1456,7 +1443,6 @@ TEST_F(DamageTrackerTest, HugeDamageRect) {
// but has a huge negative position.
child->SetPosition(gfx::PointF());
child->SetBounds(gfx::Size(kBigNumber + i, kBigNumber + i));
- child->SetContentBounds(gfx::Size(kBigNumber + i, kBigNumber + i));
child->SetTransform(transform);
EmulateDrawingOneFrame(root.get());
diff --git a/chromium/cc/trees/draw_property_utils.cc b/chromium/cc/trees/draw_property_utils.cc
index b1b4de1dd74..9f63421ed94 100644
--- a/chromium/cc/trees/draw_property_utils.cc
+++ b/chromium/cc/trees/draw_property_utils.cc
@@ -270,7 +270,7 @@ static bool LayerShouldBeSkipped(LayerType* layer,
// Some additional conditions need to be computed at a later point after the
// recursion is finished.
// - the intersection of render_surface content and layer clip_rect is empty
- // - the visible_content_rect is empty
+ // - the visible_layer_rect is empty
//
// Note, if the layer should not have been drawn due to being fully
// transparent, we would have skipped the entire subtree and never made it
@@ -430,6 +430,14 @@ void ComputeTransforms(TransformTree* transform_tree) {
transform_tree->set_needs_update(false);
}
+void ComputeOpacities(OpacityTree* opacity_tree) {
+ if (!opacity_tree->needs_update())
+ return;
+ for (int i = 1; i < static_cast<int>(opacity_tree->size()); ++i)
+ opacity_tree->UpdateOpacities(i);
+ opacity_tree->set_needs_update(false);
+}
+
template <typename LayerType>
void ComputeVisibleRectsUsingPropertyTreesInternal(
LayerType* root_layer,
@@ -439,6 +447,7 @@ void ComputeVisibleRectsUsingPropertyTreesInternal(
property_trees->clip_tree.set_needs_update(true);
ComputeTransforms(&property_trees->transform_tree);
ComputeClips(&property_trees->clip_tree, property_trees->transform_tree);
+ ComputeOpacities(&property_trees->opacity_tree);
const bool subtree_is_visible_from_ancestor = true;
std::vector<LayerType*> visible_layer_list;
@@ -453,6 +462,8 @@ void ComputeVisibleRectsUsingPropertyTreesInternal(
void BuildPropertyTreesAndComputeVisibleRects(
Layer* root_layer,
const Layer* page_scale_layer,
+ const Layer* inner_viewport_scroll_layer,
+ const Layer* outer_viewport_scroll_layer,
float page_scale_factor,
float device_scale_factor,
const gfx::Rect& viewport,
@@ -460,7 +471,8 @@ void BuildPropertyTreesAndComputeVisibleRects(
PropertyTrees* property_trees,
LayerList* update_layer_list) {
PropertyTreeBuilder::BuildPropertyTrees(
- root_layer, page_scale_layer, page_scale_factor, device_scale_factor,
+ root_layer, page_scale_layer, inner_viewport_scroll_layer,
+ outer_viewport_scroll_layer, page_scale_factor, device_scale_factor,
viewport, device_transform, property_trees);
ComputeVisibleRectsUsingPropertyTrees(root_layer, property_trees,
update_layer_list);
@@ -469,6 +481,8 @@ void BuildPropertyTreesAndComputeVisibleRects(
void BuildPropertyTreesAndComputeVisibleRects(
LayerImpl* root_layer,
const LayerImpl* page_scale_layer,
+ const LayerImpl* inner_viewport_scroll_layer,
+ const LayerImpl* outer_viewport_scroll_layer,
float page_scale_factor,
float device_scale_factor,
const gfx::Rect& viewport,
@@ -476,7 +490,8 @@ void BuildPropertyTreesAndComputeVisibleRects(
PropertyTrees* property_trees,
LayerImplList* update_layer_list) {
PropertyTreeBuilder::BuildPropertyTrees(
- root_layer, page_scale_layer, page_scale_factor, device_scale_factor,
+ root_layer, page_scale_layer, inner_viewport_scroll_layer,
+ outer_viewport_scroll_layer, page_scale_factor, device_scale_factor,
viewport, device_transform, property_trees);
ComputeVisibleRectsUsingPropertyTrees(root_layer, property_trees,
update_layer_list);
@@ -501,10 +516,6 @@ gfx::Transform DrawTransformFromPropertyTreesInternal(
const LayerType* layer,
const TransformTree& tree) {
const TransformNode* node = tree.Node(layer->transform_tree_index());
- // TODO(vollick): ultimately we'll need to find this information (whether or
- // not we establish a render surface) somewhere other than the layer.
- const TransformNode* target_node =
- layer->render_surface() ? node : tree.Node(node->data.content_target_id);
gfx::Transform xform;
const bool owns_non_root_surface = layer->parent() && layer->render_surface();
@@ -518,8 +529,7 @@ gfx::Transform DrawTransformFromPropertyTreesInternal(
layer->offset_to_transform_parent().y());
} else {
// Surfaces need to apply their sublayer scale.
- xform.Scale(target_node->data.sublayer_scale.x(),
- target_node->data.sublayer_scale.y());
+ xform.Scale(node->data.sublayer_scale.x(), node->data.sublayer_scale.y());
}
return xform;
}
@@ -576,7 +586,7 @@ float DrawOpacityFromPropertyTreesInternal(LayerType layer,
float draw_opacity = 1.f;
while (node != target_node) {
- draw_opacity *= node->data;
+ draw_opacity *= node->data.opacity;
node = tree.parent(node);
}
return draw_opacity;
@@ -592,4 +602,34 @@ float DrawOpacityFromPropertyTrees(const LayerImpl* layer,
return DrawOpacityFromPropertyTreesInternal(layer, tree);
}
+bool CanUseLcdTextFromPropertyTrees(const LayerImpl* layer,
+ bool layers_always_allowed_lcd_text,
+ bool can_use_lcd_text,
+ PropertyTrees* property_trees) {
+ if (layers_always_allowed_lcd_text)
+ return true;
+ if (!can_use_lcd_text)
+ return false;
+ if (!layer->contents_opaque())
+ return false;
+ DCHECK(!property_trees->transform_tree.needs_update());
+ DCHECK(!property_trees->opacity_tree.needs_update());
+
+ const OpacityNode* opacity_node =
+ property_trees->opacity_tree.Node(layer->opacity_tree_index());
+ if (opacity_node->data.screen_space_opacity != 1.f)
+ return false;
+ const TransformNode* transform_node =
+ property_trees->transform_tree.Node(layer->transform_tree_index());
+ if (!transform_node->data.node_and_ancestors_have_only_integer_translation)
+ return false;
+ if (static_cast<int>(layer->offset_to_transform_parent().x()) !=
+ layer->offset_to_transform_parent().x())
+ return false;
+ if (static_cast<int>(layer->offset_to_transform_parent().y()) !=
+ layer->offset_to_transform_parent().y())
+ return false;
+ return true;
+}
+
} // namespace cc
diff --git a/chromium/cc/trees/draw_property_utils.h b/chromium/cc/trees/draw_property_utils.h
index 893645d7dd9..952bef1a691 100644
--- a/chromium/cc/trees/draw_property_utils.h
+++ b/chromium/cc/trees/draw_property_utils.h
@@ -33,28 +33,35 @@ ComputeClips(ClipTree* clip_tree, const TransformTree& transform_tree);
// tree. This must be done prior to calling |ComputeClips|.
void CC_EXPORT ComputeTransforms(TransformTree* transform_tree);
+// Computes screen space opacity for every node in the opacity tree.
+void CC_EXPORT ComputeOpacities(OpacityTree* opacity_tree);
+
// Computes the visible content rect for every layer under |root_layer|. The
// visible content rect is the clipped content space rect that will be used for
// recording.
-void CC_EXPORT
-BuildPropertyTreesAndComputeVisibleRects(Layer* root_layer,
- const Layer* page_scale_layer,
- float page_scale_factor,
- float device_scale_factor,
- const gfx::Rect& viewport,
- const gfx::Transform& device_transform,
- PropertyTrees* property_trees,
- LayerList* update_layer_list);
-
-void CC_EXPORT
-BuildPropertyTreesAndComputeVisibleRects(LayerImpl* root_layer,
- const LayerImpl* page_scale_layer,
- float page_scale_factor,
- float device_scale_factor,
- const gfx::Rect& viewport,
- const gfx::Transform& device_transform,
- PropertyTrees* property_trees,
- LayerImplList* update_layer_list);
+void CC_EXPORT BuildPropertyTreesAndComputeVisibleRects(
+ Layer* root_layer,
+ const Layer* page_scale_layer,
+ const Layer* inner_viewport_scroll_layer,
+ const Layer* outer_viewport_scroll_layer,
+ float page_scale_factor,
+ float device_scale_factor,
+ const gfx::Rect& viewport,
+ const gfx::Transform& device_transform,
+ PropertyTrees* property_trees,
+ LayerList* update_layer_list);
+
+void CC_EXPORT BuildPropertyTreesAndComputeVisibleRects(
+ LayerImpl* root_layer,
+ const LayerImpl* page_scale_layer,
+ const LayerImpl* inner_viewport_scroll_layer,
+ const LayerImpl* outer_viewport_scroll_layer,
+ float page_scale_factor,
+ float device_scale_factor,
+ const gfx::Rect& viewport,
+ const gfx::Transform& device_transform,
+ PropertyTrees* property_trees,
+ LayerImplList* update_layer_list);
void CC_EXPORT
ComputeVisibleRectsUsingPropertyTrees(Layer* root_layer,
@@ -87,6 +94,12 @@ DrawOpacityFromPropertyTrees(const Layer* layer, const OpacityTree& tree);
float CC_EXPORT
DrawOpacityFromPropertyTrees(const LayerImpl* layer, const OpacityTree& tree);
+bool CC_EXPORT
+CanUseLcdTextFromPropertyTrees(const LayerImpl* layer,
+ bool layers_always_allowed_lcd_text,
+ bool can_use_lcd_text,
+ PropertyTrees* property_trees);
+
} // namespace cc
#endif // CC_TREES_DRAW_PROPERTY_UTILS_H_
diff --git a/chromium/cc/trees/layer_tree_host.cc b/chromium/cc/trees/layer_tree_host.cc
index 6c4696ee10b..a348301ba49 100644
--- a/chromium/cc/trees/layer_tree_host.cc
+++ b/chromium/cc/trees/layer_tree_host.cc
@@ -20,6 +20,7 @@
#include "base/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/trace_event_argument.h"
+#include "cc/animation/animation_host.h"
#include "cc/animation/animation_registrar.h"
#include "cc/animation/layer_animation_controller.h"
#include "cc/base/math_util.h"
@@ -35,7 +36,6 @@
#include "cc/layers/layer_iterator.h"
#include "cc/layers/painted_scrollbar_layer.h"
#include "cc/layers/render_surface.h"
-#include "cc/resources/prioritized_resource_manager.h"
#include "cc/resources/ui_resource_request.h"
#include "cc/scheduler/begin_frame_source.h"
#include "cc/trees/draw_property_utils.h"
@@ -43,7 +43,6 @@
#include "cc/trees/layer_tree_host_common.h"
#include "cc/trees/layer_tree_host_impl.h"
#include "cc/trees/layer_tree_impl.h"
-#include "cc/trees/occlusion_tracker.h"
#include "cc/trees/single_thread_proxy.h"
#include "cc/trees/thread_proxy.h"
#include "cc/trees/tree_synchronizer.h"
@@ -94,6 +93,7 @@ LayerTreeHost::LayerTreeHost(InitParams* params)
needs_meta_info_recomputation_(true),
client_(params->client),
source_frame_number_(0),
+ meta_information_sequence_number_(1),
rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()),
output_surface_lost_(true),
settings_(*params->settings),
@@ -111,7 +111,6 @@ LayerTreeHost::LayerTreeHost(InitParams* params)
gpu_rasterization_histogram_recorded_(false),
background_color_(SK_ColorWHITE),
has_transparent_background_(false),
- partial_texture_update_requests_(0),
did_complete_scale_animation_(false),
in_paint_layer_contents_(false),
id_(s_layer_tree_host_sequence_number.GetNext() + 1),
@@ -121,8 +120,17 @@ LayerTreeHost::LayerTreeHost(InitParams* params)
task_graph_runner_(params->task_graph_runner),
surface_id_namespace_(0u),
next_surface_sequence_(1u) {
- if (settings_.accelerated_animation_enabled)
- animation_registrar_ = AnimationRegistrar::Create();
+ DCHECK(task_graph_runner_);
+
+ if (settings_.accelerated_animation_enabled) {
+ if (settings_.use_compositor_animation_timelines) {
+ animation_host_ = AnimationHost::Create(ThreadInstance::MAIN);
+ animation_host_->SetMutatorHostClient(this);
+ } else {
+ animation_registrar_ = AnimationRegistrar::Create();
+ }
+ }
+
rendering_stats_instrumentation_->set_record_rendering_stats(
debug_state_.RecordRenderingStats());
}
@@ -158,14 +166,21 @@ void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) {
proxy_ = proxy.Pass();
proxy_->Start();
if (settings_.accelerated_animation_enabled) {
- animation_registrar_->set_supports_scroll_animations(
- proxy_->SupportsImplScrolling());
+ if (animation_host_)
+ animation_host_->SetSupportsScrollAnimations(
+ proxy_->SupportsImplScrolling());
+ else
+ animation_registrar_->set_supports_scroll_animations(
+ proxy_->SupportsImplScrolling());
}
}
LayerTreeHost::~LayerTreeHost() {
TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost");
+ if (animation_host_)
+ animation_host_->SetMutatorHostClient(nullptr);
+
if (root_layer_.get())
root_layer_->SetLayerTreeHost(NULL);
@@ -193,13 +208,6 @@ void LayerTreeHost::SetLayerTreeHostClientReady() {
proxy_->SetLayerTreeHostClientReady();
}
-void LayerTreeHost::DeleteContentsTexturesOnImplThread(
- ResourceProvider* resource_provider) {
- DCHECK(proxy_->IsImplThread());
- if (contents_texture_manager_)
- contents_texture_manager_->ClearAllMemory(resource_provider);
-}
-
void LayerTreeHost::WillBeginMainFrame() {
devtools_instrumentation::WillBeginMainThreadFrame(id(),
source_frame_number());
@@ -241,32 +249,6 @@ void LayerTreeHost::BeginCommitOnImplThread(LayerTreeHostImpl* host_impl) {
void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
DCHECK(proxy_->IsImplThread());
- // If there are linked evicted backings, these backings' resources may be put
- // into the impl tree, so we can't draw yet. Determine this before clearing
- // all evicted backings.
- bool new_impl_tree_has_no_evicted_resources = false;
- if (contents_texture_manager_) {
- new_impl_tree_has_no_evicted_resources =
- !contents_texture_manager_->LinkedEvictedBackingsExist();
-
- // If the memory limit has been increased since this now-finishing
- // commit began, and the extra now-available memory would have been used,
- // then request another commit.
- if (contents_texture_manager_->MaxMemoryLimitBytes() <
- host_impl->memory_allocation_limit_bytes() &&
- contents_texture_manager_->MaxMemoryLimitBytes() <
- contents_texture_manager_->MaxMemoryNeededBytes()) {
- host_impl->SetNeedsCommit();
- }
-
- host_impl->set_max_memory_needed_bytes(
- contents_texture_manager_->MaxMemoryNeededBytes());
-
- contents_texture_manager_->UpdateBackingsState(
- host_impl->resource_provider());
- contents_texture_manager_->ReduceMemory(host_impl->resource_provider());
- }
-
bool is_new_trace;
TRACE_EVENT_IS_NEW_TRACE(&is_new_trace);
if (is_new_trace &&
@@ -317,6 +299,8 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
sync_tree->RegisterSelection(selection_);
+ // Setting property trees must happen before pushing the page scale.
+ sync_tree->SetPropertyTrees(property_trees_);
sync_tree->PushPageScaleFromMainThread(
page_scale_factor_, min_page_scale_factor_, max_page_scale_factor_);
sync_tree->elastic_overscroll()->PushFromMainThread(elastic_overscroll_);
@@ -350,30 +334,38 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
DCHECK(!sync_tree->ViewportSizeInvalid());
- if (new_impl_tree_has_no_evicted_resources) {
- if (sync_tree->ContentsTexturesPurged())
- sync_tree->ResetContentsTexturesPurged();
- }
-
sync_tree->set_has_ever_been_drawn(false);
- sync_tree->SetPropertyTrees(property_trees_);
{
TRACE_EVENT0("cc", "LayerTreeHost::PushProperties");
TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer());
+
+ if (animation_host_) {
+ DCHECK(host_impl->animation_host());
+ animation_host_->PushPropertiesTo(host_impl->animation_host());
+ }
}
+ // This must happen after synchronizing property trees and after push
+ // properties, which updates property tree indices.
+ sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread();
+
micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl);
}
void LayerTreeHost::WillCommit() {
+ OnCommitForSwapPromises();
client_->WillCommit();
}
void LayerTreeHost::UpdateHudLayer() {
if (debug_state_.ShowHudInfo()) {
- if (!hud_layer_.get())
- hud_layer_ = HeadsUpDisplayLayer::Create();
+ if (!hud_layer_.get()) {
+ LayerSettings hud_layer_settings;
+ hud_layer_settings.use_compositor_animation_timelines =
+ settings_.use_compositor_animation_timelines;
+ hud_layer_ = HeadsUpDisplayLayer::Create(hud_layer_settings);
+ }
if (root_layer_.get() && !hud_layer_->parent())
root_layer_->AddChild(hud_layer_);
@@ -406,19 +398,10 @@ void LayerTreeHost::RequestNewOutputSurface() {
void LayerTreeHost::DidInitializeOutputSurface() {
output_surface_lost_ = false;
-
- if (!contents_texture_manager_ && !settings_.impl_side_painting) {
- contents_texture_manager_ =
- PrioritizedResourceManager::Create(proxy_.get());
- surface_memory_placeholder_ =
- contents_texture_manager_->CreateTexture(gfx::Size(), RGBA_8888);
- }
-
if (root_layer()) {
LayerTreeHostCommon::CallFunctionForSubtree(
root_layer(), [](Layer* layer) { layer->OnOutputSurfaceCreated(); });
}
-
client_->DidInitializeOutputSurface();
}
@@ -493,12 +476,6 @@ void LayerTreeHost::SetNeedsUpdateLayers() {
}
void LayerTreeHost::SetNeedsCommit() {
- if (!prepaint_callback_.IsCancelled()) {
- TRACE_EVENT_INSTANT0("cc",
- "LayerTreeHost::SetNeedsCommit::cancel prepaint",
- TRACE_EVENT_SCOPE_THREAD);
- prepaint_callback_.Cancel();
- }
proxy_->SetNeedsCommit();
NotifySwapPromiseMonitorsOfSetNeedsCommit();
}
@@ -543,7 +520,10 @@ void LayerTreeHost::SetNextCommitForcesRedraw() {
void LayerTreeHost::SetAnimationEvents(
scoped_ptr<AnimationEventsVector> events) {
DCHECK(proxy_->IsMainThread());
- animation_registrar_->SetAnimationEvents(events.Pass());
+ if (animation_host_)
+ animation_host_->SetAnimationEvents(events.Pass());
+ else
+ animation_registrar_->SetAnimationEvents(events.Pass());
}
void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) {
@@ -679,6 +659,16 @@ void LayerTreeHost::NotifyInputThrottledUntilCommit() {
proxy_->NotifyInputThrottledUntilCommit();
}
+void LayerTreeHost::LayoutAndUpdateLayers() {
+ DCHECK(!proxy_->HasImplThread());
+ // This function is only valid when not using the scheduler.
+ DCHECK(!settings_.single_thread_proxy_scheduler);
+ SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get());
+
+ SetLayerTreeHostClientReady();
+ proxy->LayoutAndUpdateLayers();
+}
+
void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) {
DCHECK(!proxy_->HasImplThread());
// This function is only valid when not using the scheduler.
@@ -689,18 +679,13 @@ void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) {
proxy->CompositeImmediately(frame_begin_time);
}
-bool LayerTreeHost::UpdateLayers(ResourceUpdateQueue* queue) {
+bool LayerTreeHost::UpdateLayers() {
DCHECK(!output_surface_lost_);
-
if (!root_layer())
return false;
-
DCHECK(!root_layer()->parent());
-
- bool result = UpdateLayers(root_layer(), queue);
-
+ bool result = DoUpdateLayers(root_layer());
micro_benchmark_controller_.DidUpdateLayers();
-
return result || next_commit_forces_redraw_;
}
@@ -725,8 +710,7 @@ static Layer* FindFirstScrollableLayer(Layer* layer) {
}
void LayerTreeHost::RecordGpuRasterizationHistogram() {
- // Gpu rasterization is only supported when impl-side painting is enabled.
- if (gpu_rasterization_histogram_recorded_ || !settings_.impl_side_painting)
+ if (gpu_rasterization_histogram_recorded_)
return;
// Record how widely gpu rasterization is enabled.
@@ -753,10 +737,9 @@ bool LayerTreeHost::UsingSharedMemoryResources() {
return GetRendererCapabilities().using_shared_memory_resources;
}
-bool LayerTreeHost::UpdateLayers(Layer* root_layer,
- ResourceUpdateQueue* queue) {
- TRACE_EVENT1("cc", "LayerTreeHost::UpdateLayers",
- "source_frame_number", source_frame_number());
+bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) {
+ TRACE_EVENT1("cc", "LayerTreeHost::DoUpdateLayers", "source_frame_number",
+ source_frame_number());
RenderSurfaceLayerList render_surface_layer_list;
@@ -781,6 +764,7 @@ bool LayerTreeHost::UpdateLayers(Layer* root_layer,
LayerTreeHostCommon::CalcDrawPropsMainInputs inputs(
root_layer, device_viewport_size(), gfx::Transform(),
device_scale_factor_, page_scale_factor_, page_scale_layer,
+ inner_viewport_scroll_layer_.get(), outer_viewport_scroll_layer_.get(),
elastic_overscroll_, overscroll_elasticity_layer_.get(),
GetRendererCapabilities().max_texture_size, settings_.can_use_lcd_text,
settings_.layers_always_allowed_lcd_text, can_render_to_separate_surface,
@@ -788,79 +772,43 @@ bool LayerTreeHost::UpdateLayers(Layer* root_layer,
settings_.verify_property_trees, &render_surface_layer_list,
render_surface_layer_list_id, &property_trees_);
- // This is a temporary state of affairs until impl-side painting is shipped
- // everywhere and main thread property trees can be used in all cases.
- // This code here implies that even if verify property trees is on,
- // no verification will occur and only property trees will be used on the
- // main thread.
- if (using_only_property_trees()) {
- TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::CalcDrawProps");
-
- LayerTreeHostCommon::PreCalculateMetaInformation(root_layer);
-
- bool preserves_2d_axis_alignment = false;
- gfx::Transform identity_transform;
- LayerList update_layer_list;
-
- LayerTreeHostCommon::UpdateRenderSurfaces(
- root_layer, can_render_to_separate_surface, identity_transform,
- preserves_2d_axis_alignment);
- {
- TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
- "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees");
- BuildPropertyTreesAndComputeVisibleRects(
- root_layer, page_scale_layer, page_scale_factor_,
- device_scale_factor_, gfx::Rect(device_viewport_size_),
- identity_transform, &property_trees_, &update_layer_list);
- }
+ TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::CalcDrawProps");
- for (const auto& layer : update_layer_list)
- layer->SavePaintProperties();
-
- base::AutoReset<bool> painting(&in_paint_layer_contents_, true);
- bool did_paint_content = false;
- for (const auto& layer : update_layer_list) {
- // TODO(enne): temporarily clobber draw properties visible rect.
- layer->draw_properties().visible_content_rect =
- layer->visible_rect_from_property_trees();
- did_paint_content |= layer->Update(queue, nullptr);
- content_is_suitable_for_gpu_rasterization_ &=
- layer->IsSuitableForGpuRasterization();
- }
- return did_paint_content;
- }
+ LayerTreeHostCommon::PreCalculateMetaInformation(root_layer);
+
+ bool preserves_2d_axis_alignment = false;
+ gfx::Transform identity_transform;
+ LayerList update_layer_list;
+ LayerTreeHostCommon::UpdateRenderSurfaces(
+ root_layer, can_render_to_separate_surface, identity_transform,
+ preserves_2d_axis_alignment);
{
- TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::CalcDrawProps");
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
+ TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
+ "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees");
+ BuildPropertyTreesAndComputeVisibleRects(
+ root_layer, page_scale_layer, inner_viewport_scroll_layer_.get(),
+ outer_viewport_scroll_layer_.get(), page_scale_factor_,
+ device_scale_factor_, gfx::Rect(device_viewport_size_),
+ identity_transform, &property_trees_, &update_layer_list);
}
- // Reset partial texture update requests.
- partial_texture_update_requests_ = 0;
+ for (const auto& layer : update_layer_list)
+ layer->SavePaintProperties();
+ base::AutoReset<bool> painting(&in_paint_layer_contents_, true);
bool did_paint_content = false;
- bool need_more_updates = false;
- PaintLayerContents(render_surface_layer_list, queue, &did_paint_content,
- &need_more_updates);
- if (need_more_updates) {
- TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::posting prepaint task");
- prepaint_callback_.Reset(base::Bind(&LayerTreeHost::TriggerPrepaint,
- base::Unretained(this)));
- static base::TimeDelta prepaint_delay =
- base::TimeDelta::FromMilliseconds(100);
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, prepaint_callback_.callback(), prepaint_delay);
+ for (const auto& layer : update_layer_list) {
+ // TODO(enne): temporarily clobber draw properties visible rect.
+ layer->draw_properties().visible_layer_rect =
+ layer->visible_rect_from_property_trees();
+ did_paint_content |= layer->Update();
+ content_is_suitable_for_gpu_rasterization_ &=
+ layer->IsSuitableForGpuRasterization();
}
-
return did_paint_content;
}
-void LayerTreeHost::TriggerPrepaint() {
- prepaint_callback_.Cancel();
- TRACE_EVENT0("cc", "LayerTreeHost::TriggerPrepaint");
- SetNeedsCommit();
-}
-
void LayerTreeHost::ReduceMemoryUsage() {
if (!root_layer())
return;
@@ -869,154 +817,6 @@ void LayerTreeHost::ReduceMemoryUsage() {
root_layer(), [](Layer* layer) { layer->ReduceMemoryUsage(); });
}
-void LayerTreeHost::SetPrioritiesForSurfaces(size_t surface_memory_bytes) {
- DCHECK(surface_memory_placeholder_);
-
- // Surfaces have a place holder for their memory since they are managed
- // independantly but should still be tracked and reduce other memory usage.
- surface_memory_placeholder_->SetTextureManager(
- contents_texture_manager_.get());
- surface_memory_placeholder_->set_request_priority(
- PriorityCalculator::RenderSurfacePriority());
- surface_memory_placeholder_->SetToSelfManagedMemoryPlaceholder(
- surface_memory_bytes);
-}
-
-void LayerTreeHost::SetPrioritiesForLayers(
- const RenderSurfaceLayerList& update_list) {
- PriorityCalculator calculator;
- typedef LayerIterator<Layer> LayerIteratorType;
- LayerIteratorType end = LayerIteratorType::End(&update_list);
- for (LayerIteratorType it = LayerIteratorType::Begin(&update_list);
- it != end;
- ++it) {
- if (it.represents_itself()) {
- it->SetTexturePriorities(calculator);
- } else if (it.represents_target_render_surface()) {
- if (it->mask_layer())
- it->mask_layer()->SetTexturePriorities(calculator);
- if (it->replica_layer() && it->replica_layer()->mask_layer())
- it->replica_layer()->mask_layer()->SetTexturePriorities(calculator);
- }
- }
-}
-
-void LayerTreeHost::PrioritizeTextures(
- const RenderSurfaceLayerList& render_surface_layer_list) {
- if (!contents_texture_manager_)
- return;
-
- contents_texture_manager_->ClearPriorities();
-
- size_t memory_for_render_surfaces_metric =
- CalculateMemoryForRenderSurfaces(render_surface_layer_list);
-
- SetPrioritiesForLayers(render_surface_layer_list);
- SetPrioritiesForSurfaces(memory_for_render_surfaces_metric);
-
- contents_texture_manager_->PrioritizeTextures();
-}
-
-size_t LayerTreeHost::CalculateMemoryForRenderSurfaces(
- const RenderSurfaceLayerList& update_list) {
- size_t readback_bytes = 0;
- size_t contents_texture_bytes = 0;
-
- // Start iteration at 1 to skip the root surface as it does not have a texture
- // cost.
- for (size_t i = 1; i < update_list.size(); ++i) {
- Layer* render_surface_layer = update_list.at(i);
- RenderSurface* render_surface = render_surface_layer->render_surface();
-
- size_t bytes =
- Resource::MemorySizeBytes(render_surface->content_rect().size(),
- RGBA_8888);
- contents_texture_bytes += bytes;
-
- if (render_surface_layer->background_filters().IsEmpty() &&
- render_surface_layer->uses_default_blend_mode())
- continue;
-
- if (!readback_bytes) {
- readback_bytes = Resource::MemorySizeBytes(device_viewport_size_,
- RGBA_8888);
- }
- }
- return readback_bytes + contents_texture_bytes;
-}
-
-void LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer,
- ResourceUpdateQueue* queue,
- bool* did_paint_content,
- bool* need_more_updates) {
- // Note: Masks and replicas only exist for layers that own render surfaces. If
- // we reach this point in code, we already know that at least something will
- // be drawn into this render surface, so the mask and replica should be
- // painted.
-
- Layer* mask_layer = render_surface_layer->mask_layer();
- if (mask_layer) {
- *did_paint_content |= mask_layer->Update(queue, NULL);
- *need_more_updates |= mask_layer->NeedMoreUpdates();
- }
-
- Layer* replica_mask_layer =
- render_surface_layer->replica_layer() ?
- render_surface_layer->replica_layer()->mask_layer() : NULL;
- if (replica_mask_layer) {
- *did_paint_content |= replica_mask_layer->Update(queue, NULL);
- *need_more_updates |= replica_mask_layer->NeedMoreUpdates();
- }
-}
-
-void LayerTreeHost::PaintLayerContents(
- const RenderSurfaceLayerList& render_surface_layer_list,
- ResourceUpdateQueue* queue,
- bool* did_paint_content,
- bool* need_more_updates) {
- OcclusionTracker<Layer> occlusion_tracker(
- root_layer_->render_surface()->content_rect());
- occlusion_tracker.set_minimum_tracking_size(
- settings_.minimum_occlusion_tracking_size);
-
- PrioritizeTextures(render_surface_layer_list);
-
- in_paint_layer_contents_ = true;
-
- // Iterates front-to-back to allow for testing occlusion and performing
- // culling during the tree walk.
- typedef LayerIterator<Layer> LayerIteratorType;
- LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list);
- for (LayerIteratorType it =
- LayerIteratorType::Begin(&render_surface_layer_list);
- it != end;
- ++it) {
- occlusion_tracker.EnterLayer(it);
-
- if (it.represents_target_render_surface()) {
- PaintMasksForRenderSurface(
- *it, queue, did_paint_content, need_more_updates);
- } else if (it.represents_itself()) {
- DCHECK(!it->paint_properties().bounds.IsEmpty());
- *did_paint_content |= it->Update(queue, &occlusion_tracker);
- *need_more_updates |= it->NeedMoreUpdates();
- // Note the '&&' with previous is-suitable state.
- // This means that once the layer-tree becomes unsuitable for gpu
- // rasterization due to some content, it will continue to be unsuitable
- // even if that content is replaced by gpu-friendly content.
- // This is to avoid switching back-and-forth between gpu and sw
- // rasterization which may be both bad for performance and visually
- // jarring.
- content_is_suitable_for_gpu_rasterization_ &=
- it->IsSuitableForGpuRasterization();
- }
-
- occlusion_tracker.LeaveLayer(it);
- }
-
- in_paint_layer_contents_ = false;
-}
-
void LayerTreeHost::ApplyScrollAndScale(ScrollAndScaleSet* info) {
ScopedPtrVector<SwapPromise>::iterator it = info->swap_promises.begin();
for (; it != info->swap_promises.end(); ++it) {
@@ -1071,22 +871,12 @@ void LayerTreeHost::ApplyScrollAndScale(ScrollAndScaleSet* info) {
ApplyPageScaleDeltaFromImplSide(info->page_scale_delta);
elastic_overscroll_ += info->elastic_overscroll_delta;
- if (!settings_.use_pinch_virtual_viewport) {
- // TODO(miletus): Make sure either this code path is totally gone,
- // or revisit the flooring here if the old pinch viewport code path
- // is causing problems with fractional scroll offset.
- client_->ApplyViewportDeltas(
- gfx::ToFlooredVector2d(inner_viewport_scroll_delta +
- outer_viewport_scroll_delta),
- info->page_scale_delta, info->top_controls_delta);
- } else {
- // TODO(ccameron): pass the elastic overscroll here so that input events
- // may be translated appropriately.
- client_->ApplyViewportDeltas(
- inner_viewport_scroll_delta, outer_viewport_scroll_delta,
- info->elastic_overscroll_delta, info->page_scale_delta,
- info->top_controls_delta);
- }
+ // TODO(ccameron): pass the elastic overscroll here so that input events
+ // may be translated appropriately.
+ client_->ApplyViewportDeltas(
+ inner_viewport_scroll_delta, outer_viewport_scroll_delta,
+ info->elastic_overscroll_delta, info->page_scale_delta,
+ info->top_controls_delta);
}
}
@@ -1114,31 +904,6 @@ void LayerTreeHost::RateLimit() {
client_->RateLimitSharedMainThreadContext();
}
-bool LayerTreeHost::AlwaysUsePartialTextureUpdates() {
- if (!proxy_->GetRendererCapabilities().allow_partial_texture_updates)
- return false;
- return !proxy_->HasImplThread();
-}
-
-size_t LayerTreeHost::MaxPartialTextureUpdates() const {
- size_t max_partial_texture_updates = 0;
- if (proxy_->GetRendererCapabilities().allow_partial_texture_updates &&
- !settings_.impl_side_painting) {
- max_partial_texture_updates =
- std::min(settings_.max_partial_texture_updates,
- proxy_->MaxPartialTextureUpdates());
- }
- return max_partial_texture_updates;
-}
-
-bool LayerTreeHost::RequestPartialTextureUpdate() {
- if (partial_texture_update_requests_ >= MaxPartialTextureUpdates())
- return false;
-
- partial_texture_update_requests_++;
- return true;
-}
-
void LayerTreeHost::SetDeviceScaleFactor(float device_scale_factor) {
if (device_scale_factor == device_scale_factor_)
return;
@@ -1166,11 +931,16 @@ void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) {
return;
AnimationEventsVector events;
- if (animation_registrar_->AnimateLayers(monotonic_time)) {
- animation_registrar_->UpdateAnimationState(true, &events);
- if (!events.empty())
- property_trees_.needs_rebuild = true;
+ if (animation_host_) {
+ if (animation_host_->AnimateLayers(monotonic_time))
+ animation_host_->UpdateAnimationState(true, &events);
+ } else {
+ if (animation_registrar_->AnimateLayers(monotonic_time))
+ animation_registrar_->UpdateAnimationState(true, &events);
}
+
+ if (!events.empty())
+ property_trees_.needs_rebuild = true;
}
UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) {
@@ -1284,6 +1054,11 @@ void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) {
swap_promise_list_.clear();
}
+void LayerTreeHost::OnCommitForSwapPromises() {
+ for (auto* swap_promise : swap_promise_list_)
+ swap_promise->OnCommit();
+}
+
void LayerTreeHost::set_surface_id_namespace(uint32_t id_namespace) {
surface_id_namespace_ = id_namespace;
}
@@ -1307,4 +1082,137 @@ void LayerTreeHost::SetAuthoritativeVSyncInterval(
proxy_->SetAuthoritativeVSyncInterval(interval);
}
+void LayerTreeHost::RecordFrameTimingEvents(
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
+ scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
+ client_->RecordFrameTimingEvents(composite_events.Pass(),
+ main_frame_events.Pass());
+}
+
+Layer* LayerTreeHost::LayerById(int id) const {
+ LayerIdMap::const_iterator iter = layer_id_map_.find(id);
+ return iter != layer_id_map_.end() ? iter->second : NULL;
+}
+
+void LayerTreeHost::RegisterLayer(Layer* layer) {
+ DCHECK(!LayerById(layer->id()));
+ DCHECK(!in_paint_layer_contents_);
+ layer_id_map_[layer->id()] = layer;
+ if (animation_host_)
+ animation_host_->RegisterLayer(layer->id(), LayerTreeType::ACTIVE);
+}
+
+void LayerTreeHost::UnregisterLayer(Layer* layer) {
+ DCHECK(LayerById(layer->id()));
+ DCHECK(!in_paint_layer_contents_);
+ if (animation_host_)
+ animation_host_->UnregisterLayer(layer->id(), LayerTreeType::ACTIVE);
+ layer_id_map_.erase(layer->id());
+}
+
+bool LayerTreeHost::IsLayerInTree(int layer_id, LayerTreeType tree_type) const {
+ return tree_type == LayerTreeType::ACTIVE;
+}
+
+void LayerTreeHost::SetMutatorsNeedCommit() {
+ SetNeedsCommit();
+}
+
+void LayerTreeHost::SetLayerFilterMutated(int layer_id,
+ LayerTreeType tree_type,
+ const FilterOperations& filters) {
+ LayerAnimationValueObserver* layer = LayerById(layer_id);
+ DCHECK(layer);
+ layer->OnFilterAnimated(filters);
+}
+
+void LayerTreeHost::SetLayerOpacityMutated(int layer_id,
+ LayerTreeType tree_type,
+ float opacity) {
+ LayerAnimationValueObserver* layer = LayerById(layer_id);
+ DCHECK(layer);
+ layer->OnOpacityAnimated(opacity);
+}
+
+void LayerTreeHost::SetLayerTransformMutated(int layer_id,
+ LayerTreeType tree_type,
+ const gfx::Transform& transform) {
+ LayerAnimationValueObserver* layer = LayerById(layer_id);
+ DCHECK(layer);
+ layer->OnTransformAnimated(transform);
+}
+
+void LayerTreeHost::SetLayerScrollOffsetMutated(
+ int layer_id,
+ LayerTreeType tree_type,
+ const gfx::ScrollOffset& scroll_offset) {
+ LayerAnimationValueObserver* layer = LayerById(layer_id);
+ DCHECK(layer);
+ layer->OnScrollOffsetAnimated(scroll_offset);
+}
+
+gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation(
+ int layer_id) const {
+ LayerAnimationValueProvider* layer = LayerById(layer_id);
+ DCHECK(layer);
+ return layer->ScrollOffsetForAnimation();
+}
+
+bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted(
+ const Layer* layer) const {
+ return animation_host_
+ ? animation_host_->ScrollOffsetAnimationWasInterrupted(layer->id())
+ : false;
+}
+
+bool LayerTreeHost::IsAnimatingFilterProperty(const Layer* layer) const {
+ return animation_host_
+ ? animation_host_->IsAnimatingFilterProperty(layer->id())
+ : false;
+}
+
+bool LayerTreeHost::IsAnimatingOpacityProperty(const Layer* layer) const {
+ return animation_host_
+ ? animation_host_->IsAnimatingOpacityProperty(layer->id())
+ : false;
+}
+
+bool LayerTreeHost::IsAnimatingTransformProperty(const Layer* layer) const {
+ return animation_host_
+ ? animation_host_->IsAnimatingTransformProperty(layer->id())
+ : false;
+}
+
+bool LayerTreeHost::HasPotentiallyRunningOpacityAnimation(
+ const Layer* layer) const {
+ return animation_host_
+ ? animation_host_->HasPotentiallyRunningOpacityAnimation(
+ layer->id())
+ : false;
+}
+
+bool LayerTreeHost::HasPotentiallyRunningTransformAnimation(
+ const Layer* layer) const {
+ return animation_host_
+ ? animation_host_->HasPotentiallyRunningTransformAnimation(
+ layer->id())
+ : false;
+}
+
+bool LayerTreeHost::AnimationsPreserveAxisAlignment(const Layer* layer) const {
+ return animation_host_
+ ? animation_host_->AnimationsPreserveAxisAlignment(layer->id())
+ : true;
+}
+
+bool LayerTreeHost::HasAnyAnimation(const Layer* layer) const {
+ return animation_host_ ? animation_host_->HasAnyAnimation(layer->id())
+ : false;
+}
+
+bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const {
+ return animation_host_ ? animation_host_->HasActiveAnimation(layer->id())
+ : false;
+}
+
} // namespace cc
diff --git a/chromium/cc/trees/layer_tree_host.h b/chromium/cc/trees/layer_tree_host.h
index cf47facddd4..4f38352f9c6 100644
--- a/chromium/cc/trees/layer_tree_host.h
+++ b/chromium/cc/trees/layer_tree_host.h
@@ -21,6 +21,7 @@
#include "cc/animation/animation_events.h"
#include "cc/base/cc_export.h"
#include "cc/base/scoped_ptr_vector.h"
+#include "cc/debug/frame_timing_tracker.h"
#include "cc/debug/micro_benchmark.h"
#include "cc/debug/micro_benchmark_controller.h"
#include "cc/input/input_handler.h"
@@ -37,6 +38,7 @@
#include "cc/trees/layer_tree_host_client.h"
#include "cc/trees/layer_tree_host_common.h"
#include "cc/trees/layer_tree_settings.h"
+#include "cc/trees/mutator_host_client.h"
#include "cc/trees/proxy.h"
#include "cc/trees/swap_promise_monitor.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -48,14 +50,13 @@ class GpuMemoryBufferManager;
namespace cc {
class AnimationRegistrar;
+class AnimationHost;
class BeginFrameSource;
class HeadsUpDisplayLayer;
class Layer;
class LayerTreeHostImpl;
class LayerTreeHostImplClient;
class LayerTreeHostSingleThreadClient;
-class PrioritizedResource;
-class PrioritizedResourceManager;
class PropertyTrees;
class Region;
class RenderingStatsInstrumentation;
@@ -69,7 +70,7 @@ struct PendingPageScaleAnimation;
struct RenderingStats;
struct ScrollAndScaleSet;
-class CC_EXPORT LayerTreeHost {
+class CC_EXPORT LayerTreeHost : public MutatorHostClient {
public:
// TODO(sad): InitParams should be a movable type so that it can be
// std::move()d to the Create* functions.
@@ -120,8 +121,7 @@ class CC_EXPORT LayerTreeHost {
bool output_surface_lost() const { return output_surface_lost_; }
void DidCommitAndDrawFrame() { client_->DidCommitAndDrawFrame(); }
void DidCompleteSwapBuffers() { client_->DidCompleteSwapBuffers(); }
- void DeleteContentsTexturesOnImplThread(ResourceProvider* resource_provider);
- bool UpdateLayers(ResourceUpdateQueue* queue);
+ bool UpdateLayers();
// Called when the compositor completed page scale animation.
void DidCompletePageScaleAnimation();
@@ -133,6 +133,7 @@ class CC_EXPORT LayerTreeHost {
void NotifyInputThrottledUntilCommit();
+ void LayoutAndUpdateLayers();
void Composite(base::TimeTicks frame_begin_time);
void FinishAllRendering();
@@ -141,6 +142,14 @@ class CC_EXPORT LayerTreeHost {
int source_frame_number() const { return source_frame_number_; }
+ int meta_information_sequence_number() {
+ return meta_information_sequence_number_;
+ }
+
+ void IncrementMetaInformationSequenceNumber() {
+ meta_information_sequence_number_++;
+ }
+
void SetNeedsDisplayOnAllLayers();
void CollectRenderingStats(RenderingStats* stats) const;
@@ -218,10 +227,6 @@ class CC_EXPORT LayerTreeHost {
has_transparent_background_ = transparent;
}
- PrioritizedResourceManager* contents_texture_manager() const {
- return contents_texture_manager_.get();
- }
-
void SetVisible(bool visible);
bool visible() const { return visible_; }
@@ -241,10 +246,6 @@ class CC_EXPORT LayerTreeHost {
void RateLimit();
- bool AlwaysUsePartialTextureUpdates();
- size_t MaxPartialTextureUpdates() const;
- bool RequestPartialTextureUpdate();
-
void SetDeviceScaleFactor(float device_scale_factor);
float device_scale_factor() const { return device_scale_factor_; }
@@ -255,10 +256,10 @@ class CC_EXPORT LayerTreeHost {
HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); }
Proxy* proxy() const { return proxy_.get(); }
-
AnimationRegistrar* animation_registrar() const {
return animation_registrar_.get();
}
+ AnimationHost* animation_host() const { return animation_host_.get(); }
bool in_paint_layer_contents() const { return in_paint_layer_contents_; }
@@ -315,11 +316,41 @@ class CC_EXPORT LayerTreeHost {
return needs_meta_info_recomputation_;
}
- // If this is true, only property trees will be used for main thread CDP.
- // CDP will not be run, and verify_property_trees will be ignored.
- bool using_only_property_trees() const {
- return settings().impl_side_painting;
- }
+ void RecordFrameTimingEvents(
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
+ scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events);
+
+ Layer* LayerById(int id) const;
+ void RegisterLayer(Layer* layer);
+ void UnregisterLayer(Layer* layer);
+ // LayerTreeMutatorsClient implementation.
+ bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override;
+ void SetMutatorsNeedCommit() override;
+ void SetLayerFilterMutated(int layer_id,
+ LayerTreeType tree_type,
+ const FilterOperations& filters) override;
+ void SetLayerOpacityMutated(int layer_id,
+ LayerTreeType tree_type,
+ float opacity) override;
+ void SetLayerTransformMutated(int layer_id,
+ LayerTreeType tree_type,
+ const gfx::Transform& transform) override;
+ void SetLayerScrollOffsetMutated(
+ int layer_id,
+ LayerTreeType tree_type,
+ const gfx::ScrollOffset& scroll_offset) override;
+ void ScrollOffsetAnimationFinished() override {}
+ gfx::ScrollOffset GetScrollOffsetForAnimation(int layer_id) const override;
+
+ bool ScrollOffsetAnimationWasInterrupted(const Layer* layer) const;
+ bool IsAnimatingFilterProperty(const Layer* layer) const;
+ bool IsAnimatingOpacityProperty(const Layer* layer) const;
+ bool IsAnimatingTransformProperty(const Layer* layer) const;
+ bool HasPotentiallyRunningOpacityAnimation(const Layer* layer) const;
+ bool HasPotentiallyRunningTransformAnimation(const Layer* layer) const;
+ bool AnimationsPreserveAxisAlignment(const Layer* layer) const;
+ bool HasAnyAnimation(const Layer* layer) const;
+ bool HasActiveAnimation(const Layer* layer) const;
protected:
explicit LayerTreeHost(InitParams* params);
@@ -349,31 +380,16 @@ class CC_EXPORT LayerTreeHost {
MicroBenchmarkController micro_benchmark_controller_;
+ void OnCommitForSwapPromises();
+
private:
void InitializeProxy(scoped_ptr<Proxy> proxy);
- void PaintLayerContents(
- const RenderSurfaceLayerList& render_surface_layer_list,
- ResourceUpdateQueue* queue,
- bool* did_paint_content,
- bool* need_more_updates);
- void PaintMasksForRenderSurface(Layer* render_surface_layer,
- ResourceUpdateQueue* queue,
- bool* did_paint_content,
- bool* need_more_updates);
- bool UpdateLayers(Layer* root_layer, ResourceUpdateQueue* queue);
+ bool DoUpdateLayers(Layer* root_layer);
void UpdateHudLayer();
- void TriggerPrepaint();
void ReduceMemoryUsage();
- void PrioritizeTextures(
- const RenderSurfaceLayerList& render_surface_layer_list);
- void SetPrioritiesForSurfaces(size_t surface_memory_bytes);
- void SetPrioritiesForLayers(const RenderSurfaceLayerList& update_list);
- size_t CalculateMemoryForRenderSurfaces(
- const RenderSurfaceLayerList& update_list);
-
bool AnimateLayersRecursive(Layer* current, base::TimeTicks time);
struct UIResourceClientData {
@@ -398,12 +414,11 @@ class CC_EXPORT LayerTreeHost {
bool needs_full_tree_sync_;
bool needs_meta_info_recomputation_;
- base::CancelableClosure prepaint_callback_;
-
LayerTreeHostClient* client_;
scoped_ptr<Proxy> proxy_;
int source_frame_number_;
+ int meta_information_sequence_number_;
scoped_ptr<RenderingStatsInstrumentation> rendering_stats_instrumentation_;
bool output_surface_lost_;
@@ -411,9 +426,6 @@ class CC_EXPORT LayerTreeHost {
scoped_refptr<Layer> root_layer_;
scoped_refptr<HeadsUpDisplayLayer> hud_layer_;
- scoped_ptr<PrioritizedResourceManager> contents_texture_manager_;
- scoped_ptr<PrioritizedResource> surface_memory_placeholder_;
-
base::WeakPtr<InputHandler> input_handler_weak_ptr_;
base::WeakPtr<TopControlsManager> top_controls_manager_weak_ptr_;
@@ -441,10 +453,8 @@ class CC_EXPORT LayerTreeHost {
SkColor background_color_;
bool has_transparent_background_;
- typedef ScopedPtrVector<PrioritizedResource> TextureList;
- size_t partial_texture_update_requests_;
-
scoped_ptr<AnimationRegistrar> animation_registrar_;
+ scoped_ptr<AnimationHost> animation_host_;
scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation_;
@@ -473,6 +483,9 @@ class CC_EXPORT LayerTreeHost {
PropertyTrees property_trees_;
+ typedef base::hash_map<int, Layer*> LayerIdMap;
+ LayerIdMap layer_id_map_;
+
uint32_t surface_id_namespace_;
uint32_t next_surface_sequence_;
diff --git a/chromium/cc/trees/layer_tree_host_client.h b/chromium/cc/trees/layer_tree_host_client.h
index 6b305326ff9..56a128f4bad 100644
--- a/chromium/cc/trees/layer_tree_host_client.h
+++ b/chromium/cc/trees/layer_tree_host_client.h
@@ -8,6 +8,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
+#include "cc/debug/frame_timing_tracker.h"
namespace gfx {
class Vector2d;
@@ -35,9 +36,6 @@ class LayerTreeHostClient {
const gfx::Vector2dF& elastic_overscroll_delta,
float page_scale,
float top_controls_delta) = 0;
- virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
- float page_scale,
- float top_controls_delta) = 0;
// Request an OutputSurface from the client. When the client has one it should
// call LayerTreeHost::SetOutputSurface. This will result in either
// DidFailToInitializeOutputSurface or DidInitializeOutputSurface being
@@ -49,6 +47,9 @@ class LayerTreeHostClient {
virtual void DidCommit() = 0;
virtual void DidCommitAndDrawFrame() = 0;
virtual void DidCompleteSwapBuffers() = 0;
+ virtual void RecordFrameTimingEvents(
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
+ scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) = 0;
// Called when page scale animation has completed.
virtual void DidCompletePageScaleAnimation() = 0;
diff --git a/chromium/cc/trees/layer_tree_host_common.cc b/chromium/cc/trees/layer_tree_host_common.cc
index 09882856e55..427a3c825e1 100644
--- a/chromium/cc/trees/layer_tree_host_common.cc
+++ b/chromium/cc/trees/layer_tree_host_common.cc
@@ -302,8 +302,8 @@ void UpdateAccumulatedSurfaceState(
current_target->render_surface()->draw_transform();
// If we have unclipped descendants, the draw transform is a translation.
- DCHECK(current_target->num_unclipped_descendants() == 0 ||
- current_draw_transform.IsIdentityOrTranslation());
+ DCHECK_IMPLIES(current_target->num_unclipped_descendants(),
+ current_draw_transform.IsIdentityOrTranslation());
target_rect = gfx::ToEnclosingRect(
MathUtil::MapClippedRect(current_draw_transform, target_rect));
@@ -370,14 +370,14 @@ static inline bool LayerClipsSubtree(LayerType* layer) {
}
template <typename LayerType>
-static gfx::Rect CalculateVisibleContentRect(
+static gfx::Rect CalculateVisibleLayerRect(
LayerType* layer,
const gfx::Rect& clip_rect_of_target_surface_in_target_space,
const gfx::Rect& layer_rect_in_target_space) {
DCHECK(layer->render_target());
// Nothing is visible if the layer bounds are empty.
- if (!layer->DrawsContent() || layer->content_bounds().IsEmpty() ||
+ if (!layer->DrawsContent() || layer->bounds().IsEmpty() ||
layer->drawable_content_rect().IsEmpty())
return gfx::Rect();
@@ -403,10 +403,8 @@ static gfx::Rect CalculateVisibleContentRect(
return gfx::Rect();
return CalculateVisibleRectWithCachedLayerRect(
- visible_rect_in_target_surface_space,
- gfx::Rect(layer->content_bounds()),
- layer_rect_in_target_space,
- layer->draw_transform());
+ visible_rect_in_target_surface_space, gfx::Rect(layer->bounds()),
+ layer_rect_in_target_space, layer->draw_transform());
}
static inline bool TransformToParentIsKnown(LayerImpl* layer) { return true; }
@@ -434,7 +432,7 @@ static bool LayerShouldBeSkipped(LayerType* layer, bool layer_is_drawn) {
// Some additional conditions need to be computed at a later point after the
// recursion is finished.
// - the intersection of render_surface content and layer clip_rect is empty
- // - the visible_content_rect is empty
+ // - the visible_layer_rect is empty
//
// Note, if the layer should not have been drawn due to being fully
// transparent, we would have skipped the entire subtree and never made it
@@ -712,9 +710,6 @@ gfx::Transform ComputeSizeDeltaCompensation(
// Calculate step 1b
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)) {
@@ -911,106 +906,12 @@ gfx::Transform ComputeScrollCompensationMatrixForChildren(
template <typename LayerType>
static inline void UpdateLayerScaleDrawProperties(
LayerType* layer,
- float ideal_contents_scale,
float maximum_animation_contents_scale,
- float starting_animation_contents_scale,
- float page_scale_factor,
- float device_scale_factor) {
- layer->draw_properties().ideal_contents_scale = ideal_contents_scale;
+ float starting_animation_contents_scale) {
layer->draw_properties().maximum_animation_contents_scale =
maximum_animation_contents_scale;
layer->draw_properties().starting_animation_contents_scale =
starting_animation_contents_scale;
- layer->draw_properties().page_scale_factor = page_scale_factor;
- layer->draw_properties().device_scale_factor = device_scale_factor;
-}
-
-static inline void CalculateContentsScale(LayerImpl* layer,
- float contents_scale) {
- // LayerImpl has all of its content scales and bounds pushed from the Main
- // thread during commit and just uses those values as-is.
-}
-
-static inline void CalculateContentsScale(Layer* layer, float contents_scale) {
- layer->CalculateContentsScale(contents_scale,
- &layer->draw_properties().contents_scale_x,
- &layer->draw_properties().contents_scale_y,
- &layer->draw_properties().content_bounds);
-
- Layer* mask_layer = layer->mask_layer();
- if (mask_layer) {
- mask_layer->CalculateContentsScale(
- contents_scale,
- &mask_layer->draw_properties().contents_scale_x,
- &mask_layer->draw_properties().contents_scale_y,
- &mask_layer->draw_properties().content_bounds);
- }
-
- Layer* replica_mask_layer =
- layer->replica_layer() ? layer->replica_layer()->mask_layer() : NULL;
- if (replica_mask_layer) {
- replica_mask_layer->CalculateContentsScale(
- contents_scale,
- &replica_mask_layer->draw_properties().contents_scale_x,
- &replica_mask_layer->draw_properties().contents_scale_y,
- &replica_mask_layer->draw_properties().content_bounds);
- }
-}
-
-static inline void UpdateLayerContentsScale(
- LayerImpl* layer,
- bool can_adjust_raster_scale,
- float ideal_contents_scale,
- float device_scale_factor,
- float page_scale_factor,
- bool animating_transform_to_screen) {
- CalculateContentsScale(layer, ideal_contents_scale);
-}
-
-static inline void UpdateLayerContentsScale(
- Layer* layer,
- bool can_adjust_raster_scale,
- float ideal_contents_scale,
- float device_scale_factor,
- float page_scale_factor,
- bool animating_transform_to_screen) {
- if (can_adjust_raster_scale) {
- float ideal_raster_scale =
- ideal_contents_scale / (device_scale_factor * page_scale_factor);
-
- bool need_to_set_raster_scale = layer->raster_scale_is_unknown();
-
- // If we've previously saved a raster_scale but the ideal changes, things
- // are unpredictable and we should just use 1.
- if (!need_to_set_raster_scale && layer->raster_scale() != 1.f &&
- ideal_raster_scale != layer->raster_scale()) {
- ideal_raster_scale = 1.f;
- need_to_set_raster_scale = true;
- }
-
- if (need_to_set_raster_scale) {
- bool use_and_save_ideal_scale =
- ideal_raster_scale >= 1.f && !animating_transform_to_screen;
- if (use_and_save_ideal_scale)
- layer->set_raster_scale(ideal_raster_scale);
- }
- }
-
- float raster_scale = 1.f;
- if (!layer->raster_scale_is_unknown())
- raster_scale = layer->raster_scale();
-
- gfx::Size old_content_bounds = layer->content_bounds();
- float old_contents_scale_x = layer->contents_scale_x();
- float old_contents_scale_y = layer->contents_scale_y();
-
- float contents_scale = raster_scale * device_scale_factor * page_scale_factor;
- CalculateContentsScale(layer, contents_scale);
-
- if (layer->content_bounds() != old_content_bounds ||
- layer->contents_scale_x() != old_contents_scale_x ||
- layer->contents_scale_y() != old_contents_scale_y)
- layer->SetNeedsPushProperties();
}
static inline void CalculateAnimationContentsScale(
@@ -1059,8 +960,7 @@ static inline void CalculateAnimationContentsScale(
// scales and translations. We treat all non-translations as potentially
// affecting scale. Animations that include non-translation/scale components
// will cause the computation of MaximumScale below to fail.
- bool layer_is_animating_scale =
- !layer->layer_animation_controller()->HasOnlyTranslationTransforms();
+ bool layer_is_animating_scale = !layer->HasOnlyTranslationTransforms();
if (!layer_is_animating_scale && !ancestor_is_animating_scale) {
*combined_maximum_animation_contents_scale = 0.f;
@@ -1097,13 +997,11 @@ static inline void CalculateAnimationContentsScale(
float layer_maximum_animated_scale = 0.f;
float layer_start_animated_scale = 0.f;
- if (!layer->layer_animation_controller()->MaximumTargetScale(
- &layer_maximum_animated_scale)) {
+ if (!layer->MaximumTargetScale(&layer_maximum_animated_scale)) {
*combined_maximum_animation_contents_scale = 0.f;
return;
}
- if (!layer->layer_animation_controller()->AnimationStartScale(
- &layer_start_animated_scale)) {
+ if (!layer->AnimationStartScale(&layer_start_animated_scale)) {
*combined_starting_animation_contents_scale = 0.f;
return;
}
@@ -1124,8 +1022,8 @@ static inline void MarkLayerWithRenderSurfaceLayerListId(
int current_render_surface_layer_list_id) {
layer->draw_properties().last_drawn_render_surface_layer_list_id =
current_render_surface_layer_list_id;
- layer->draw_properties().layer_or_descendant_is_drawn =
- !!current_render_surface_layer_list_id;
+ layer->set_layer_or_descendant_is_drawn(
+ !!current_render_surface_layer_list_id);
}
template <typename LayerTypePtr>
@@ -1184,7 +1082,7 @@ static inline void RemoveSurfaceForEarlyExit(
}
struct PreCalculateMetaInformationRecursiveData {
- int num_unclipped_descendants;
+ size_t num_unclipped_descendants;
int num_layer_or_descendants_with_copy_request;
int num_layer_or_descendants_with_input_handler;
@@ -1220,30 +1118,15 @@ static void ValidateRenderSurface(LayerImpl* layer) {
static void ValidateRenderSurface(Layer* layer) {
}
-static void ResetDrawProperties(Layer* layer) {
- layer->draw_properties().sorted_for_recursion = false;
- layer->draw_properties().has_child_with_a_scroll_parent = false;
- layer->draw_properties().layer_or_descendant_is_drawn = false;
- layer->draw_properties().visited = false;
- if (!HasInvertibleOrAnimatedTransform(layer)) {
- // Layers with singular transforms should not be drawn, the whole subtree
- // can be skipped.
- return;
- }
-
- for (size_t i = 0; i < layer->children().size(); ++i) {
- Layer* child_layer = layer->child_at(i);
- if (child_layer->scroll_parent())
- layer->draw_properties().has_child_with_a_scroll_parent = true;
- ResetDrawProperties(child_layer);
- }
+static bool IsMetaInformationRecomputationNeeded(Layer* layer) {
+ return layer->layer_tree_host()->needs_meta_info_recomputation();
}
-static void ResetDrawProperties(LayerImpl* layer) {
+static void UpdateMetaInformationSequenceNumber(Layer* root_layer) {
+ root_layer->layer_tree_host()->IncrementMetaInformationSequenceNumber();
}
-static bool IsMetaInformationRecomputationNeeded(Layer* layer) {
- return layer->layer_tree_host()->needs_meta_info_recomputation();
+static void UpdateMetaInformationSequenceNumber(LayerImpl* root_layer) {
}
// Recursively walks the layer tree(if needed) to compute any information
@@ -1252,6 +1135,12 @@ static void PreCalculateMetaInformationInternal(
Layer* layer,
PreCalculateMetaInformationRecursiveData* recursive_data) {
ValidateRenderSurface(layer);
+
+ layer->set_sorted_for_recursion(false);
+ layer->draw_properties().has_child_with_a_scroll_parent = false;
+ layer->set_layer_or_descendant_is_drawn(false);
+ layer->set_visited(false);
+
if (!HasInvertibleOrAnimatedTransform(layer)) {
// Layers with singular transforms should not be drawn, the whole subtree
// can be skipped.
@@ -1266,17 +1155,23 @@ static void PreCalculateMetaInformationInternal(
if (layer->clip_parent())
recursive_data->num_unclipped_descendants++;
+ layer->set_num_children_with_scroll_parent(0);
for (size_t i = 0; i < layer->children().size(); ++i) {
Layer* child_layer = layer->child_at(i);
PreCalculateMetaInformationRecursiveData data_for_child;
PreCalculateMetaInformationInternal(child_layer, &data_for_child);
+ if (child_layer->scroll_parent()) {
+ layer->draw_properties().has_child_with_a_scroll_parent = true;
+ layer->set_num_children_with_scroll_parent(
+ layer->num_children_with_scroll_parent() + 1);
+ }
recursive_data->Merge(data_for_child);
}
if (layer->clip_children()) {
- int num_clip_children = layer->clip_children()->size();
+ size_t num_clip_children = layer->clip_children()->size();
DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children);
recursive_data->num_unclipped_descendants -= num_clip_children;
}
@@ -1308,10 +1203,10 @@ static void PreCalculateMetaInformationInternal(
PreCalculateMetaInformationRecursiveData* recursive_data) {
ValidateRenderSurface(layer);
- layer->draw_properties().sorted_for_recursion = false;
+ layer->set_sorted_for_recursion(false);
layer->draw_properties().has_child_with_a_scroll_parent = false;
- layer->draw_properties().layer_or_descendant_is_drawn = false;
- layer->draw_properties().visited = false;
+ layer->set_layer_or_descendant_is_drawn(false);
+ layer->set_visited(false);
if (!HasInvertibleOrAnimatedTransform(layer)) {
// Layers with singular transforms should not be drawn, the whole subtree
@@ -1334,7 +1229,7 @@ static void PreCalculateMetaInformationInternal(
}
if (layer->clip_children()) {
- int num_clip_children = layer->clip_children()->size();
+ size_t num_clip_children = layer->clip_children()->size();
DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children);
recursive_data->num_unclipped_descendants -= num_clip_children;
}
@@ -1359,12 +1254,25 @@ void LayerTreeHostCommon::PreCalculateMetaInformation(Layer* root_layer) {
PreCalculateMetaInformationInternal(root_layer, &recursive_data);
}
+void LayerTreeHostCommon::PreCalculateMetaInformationForTesting(
+ LayerImpl* root_layer) {
+ PreCalculateMetaInformationRecursiveData recursive_data;
+ PreCalculateMetaInformationInternal(root_layer, &recursive_data);
+}
+
+void LayerTreeHostCommon::PreCalculateMetaInformationForTesting(
+ Layer* root_layer) {
+ UpdateMetaInformationSequenceNumber(root_layer);
+ PreCalculateMetaInformationRecursiveData recursive_data;
+ PreCalculateMetaInformationInternal(root_layer, &recursive_data);
+}
+
template <typename LayerType>
struct SubtreeGlobals {
int max_texture_size;
float device_scale_factor;
float page_scale_factor;
- const LayerType* page_scale_application_layer;
+ const LayerType* page_scale_layer;
gfx::Vector2dF elastic_overscroll;
const LayerType* elastic_overscroll_application_layer;
bool can_adjust_raster_scales;
@@ -1412,7 +1320,7 @@ struct DataForRecursion {
bool ancestor_clips_subtree;
typename LayerType::RenderSurfaceType*
nearest_occlusion_immune_ancestor_surface;
- bool in_subtree_of_page_scale_application_layer;
+ bool in_subtree_of_page_scale_layer;
bool subtree_can_use_lcd_text;
bool subtree_is_visible_from_ancestor;
};
@@ -1460,14 +1368,15 @@ static void AddScrollParentChain(std::vector<LayerType*>* out,
// that we will potentionally add to the list. That is, the child of parent
// containing |layer|.
LayerType* child = GetChildContainingLayer(parent, layer);
- if (child->draw_properties().sorted_for_recursion)
+ if (child->sorted_for_recursion())
return;
if (LayerType* scroll_parent = child->scroll_parent())
AddScrollParentChain(out, parent, scroll_parent);
out->push_back(child);
- child->draw_properties().sorted_for_recursion = true;
+ bool sorted_for_recursion = true;
+ child->set_sorted_for_recursion(sorted_for_recursion);
}
template <typename LayerType>
@@ -1479,7 +1388,7 @@ static bool SortChildrenForRecursion(std::vector<LayerType*>* out,
LayerType* current =
LayerTreeHostCommon::get_layer_as_raw_ptr(parent.children(), i);
- if (current->draw_properties().sorted_for_recursion) {
+ if (current->sorted_for_recursion()) {
order_changed = true;
continue;
}
@@ -1518,14 +1427,6 @@ static LayerImplList* GetLayerListForSorting(LayerImplList* layer_list) {
return layer_list;
}
-static inline gfx::Vector2d BoundsDelta(Layer* layer) {
- return gfx::Vector2d();
-}
-
-static inline gfx::Vector2d BoundsDelta(LayerImpl* layer) {
- return gfx::ToCeiledVector2d(layer->bounds_delta());
-}
-
template <typename LayerType, typename GetIndexAndCountType>
static void SortLayerListContributions(
const LayerType& parent,
@@ -1679,18 +1580,18 @@ static void CalculateDrawPropertiesInternal(
// It makes no sense to have a non-unit page_scale_factor without specifying
// which layer roots the subtree the scale is applied to.
- DCHECK(globals.page_scale_application_layer ||
- (globals.page_scale_factor == 1.f));
+ DCHECK(globals.page_scale_layer || (globals.page_scale_factor == 1.f));
- CHECK(!layer->draw_properties().visited);
- layer->draw_properties().visited = true;
+ CHECK(!layer->visited());
+ bool visited = true;
+ layer->set_visited(visited);
DataForRecursion<LayerType> data_for_children;
typename LayerType::RenderSurfaceType*
nearest_occlusion_immune_ancestor_surface =
data_from_ancestor.nearest_occlusion_immune_ancestor_surface;
- data_for_children.in_subtree_of_page_scale_application_layer =
- data_from_ancestor.in_subtree_of_page_scale_application_layer;
+ data_for_children.in_subtree_of_page_scale_layer =
+ data_from_ancestor.in_subtree_of_page_scale_layer;
data_for_children.subtree_can_use_lcd_text =
data_from_ancestor.subtree_can_use_lcd_text;
@@ -1826,69 +1727,42 @@ static void CalculateDrawPropertiesInternal(
// Compute the 2d scale components of the transform hierarchy up to the target
// surface. From there, we can decide on a contents scale for the layer.
float layer_scale_factors = globals.device_scale_factor;
- if (data_from_ancestor.in_subtree_of_page_scale_application_layer)
+ if (data_from_ancestor.in_subtree_of_page_scale_layer)
layer_scale_factors *= globals.page_scale_factor;
gfx::Vector2dF combined_transform_scales =
MathUtil::ComputeTransform2dScaleComponents(
combined_transform,
layer_scale_factors);
- float ideal_contents_scale =
- globals.can_adjust_raster_scales
- ? std::max(combined_transform_scales.x(),
- combined_transform_scales.y())
- : layer_scale_factors;
- UpdateLayerContentsScale(
- layer,
- globals.can_adjust_raster_scales,
- ideal_contents_scale,
- globals.device_scale_factor,
- data_from_ancestor.in_subtree_of_page_scale_application_layer
- ? globals.page_scale_factor
- : 1.f,
- animating_transform_to_screen);
-
- UpdateLayerScaleDrawProperties(
- layer, ideal_contents_scale, combined_maximum_animation_contents_scale,
- combined_starting_animation_contents_scale,
- data_from_ancestor.in_subtree_of_page_scale_application_layer
- ? globals.page_scale_factor
- : 1.f,
- globals.device_scale_factor);
+ UpdateLayerScaleDrawProperties(layer,
+ combined_maximum_animation_contents_scale,
+ combined_starting_animation_contents_scale);
LayerType* mask_layer = layer->mask_layer();
if (mask_layer) {
- UpdateLayerScaleDrawProperties(
- mask_layer, ideal_contents_scale,
- combined_maximum_animation_contents_scale,
- combined_starting_animation_contents_scale,
- data_from_ancestor.in_subtree_of_page_scale_application_layer
- ? globals.page_scale_factor
- : 1.f,
- globals.device_scale_factor);
+ UpdateLayerScaleDrawProperties(mask_layer,
+ combined_maximum_animation_contents_scale,
+ combined_starting_animation_contents_scale);
}
LayerType* replica_mask_layer =
layer->replica_layer() ? layer->replica_layer()->mask_layer() : NULL;
if (replica_mask_layer) {
- UpdateLayerScaleDrawProperties(
- replica_mask_layer, ideal_contents_scale,
- combined_maximum_animation_contents_scale,
- combined_starting_animation_contents_scale,
- data_from_ancestor.in_subtree_of_page_scale_application_layer
- ? globals.page_scale_factor
- : 1.f,
- globals.device_scale_factor);
+ UpdateLayerScaleDrawProperties(replica_mask_layer,
+ combined_maximum_animation_contents_scale,
+ combined_starting_animation_contents_scale);
+ }
+
+ if (layer == globals.page_scale_layer) {
+ combined_transform.Scale(globals.page_scale_factor,
+ globals.page_scale_factor);
+ data_for_children.in_subtree_of_page_scale_layer = true;
}
// The draw_transform that gets computed below is effectively the layer's
// draw_transform, unless the layer itself creates a render_surface. In that
// case, the render_surface re-parents the transforms.
layer_draw_properties.target_space_transform = combined_transform;
- // M[draw] = M[parent] * LT * S[layer2content]
- layer_draw_properties.target_space_transform.Scale(
- SK_MScalar1 / layer->contents_scale_x(),
- SK_MScalar1 / layer->contents_scale_y());
// The layer's screen_space_transform represents the transform between root
// layer's "screen space" and local content space.
@@ -1963,8 +1837,7 @@ static void CalculateDrawPropertiesInternal(
// space.
layer_draw_properties.target_space_transform.MakeIdentity();
layer_draw_properties.target_space_transform.Scale(
- combined_transform_scales.x() / layer->contents_scale_x(),
- combined_transform_scales.y() / layer->contents_scale_y());
+ combined_transform_scales.x(), combined_transform_scales.y());
// Inside the surface's subtree, we scale everything to the owning layer's
// scale. The sublayer matrix transforms layer rects into target surface
@@ -2016,16 +1889,25 @@ static void CalculateDrawPropertiesInternal(
DrawProperties<LayerType>& mask_layer_draw_properties =
layer->mask_layer()->draw_properties();
mask_layer_draw_properties.render_target = layer;
- mask_layer_draw_properties.visible_content_rect =
- gfx::Rect(layer->content_bounds());
+ mask_layer_draw_properties.visible_layer_rect =
+ gfx::Rect(layer->bounds());
+ // Temporarily copy the draw transform of the mask's owning layer into the
+ // mask layer draw properties. This won't actually get used for drawing
+ // (the render surface uses the mask texture directly), but will get used
+ // to get the correct contents scale.
+ // TODO(enne): do something similar for property trees.
+ mask_layer_draw_properties.target_space_transform =
+ layer_draw_properties.target_space_transform;
}
if (layer->replica_layer() && layer->replica_layer()->mask_layer()) {
DrawProperties<LayerType>& replica_mask_draw_properties =
layer->replica_layer()->mask_layer()->draw_properties();
replica_mask_draw_properties.render_target = layer;
- replica_mask_draw_properties.visible_content_rect =
- gfx::Rect(layer->content_bounds());
+ replica_mask_draw_properties.visible_layer_rect =
+ gfx::Rect(layer->bounds());
+ replica_mask_draw_properties.target_space_transform =
+ layer_draw_properties.target_space_transform;
}
// Ignore occlusion from outside the surface when surface contents need to
@@ -2064,7 +1946,7 @@ static void CalculateDrawPropertiesInternal(
gfx::Rect projected_surface_rect = MathUtil::ProjectEnclosingClippedRect(
inverse_surface_draw_transform, surface_clip_rect_in_target_space);
- if (layer_draw_properties.num_unclipped_descendants > 0) {
+ if (layer_draw_properties.num_unclipped_descendants > 0u) {
// If we have unclipped descendants, we cannot count on the render
// surface's bounds clipping our subtree: the unclipped descendants
// could cause us to expand our bounds. In this case, we must rely on
@@ -2143,22 +2025,10 @@ static void CalculateDrawPropertiesInternal(
layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text;
- gfx::Size content_size_affected_by_delta(layer->content_bounds());
-
- // Non-zero BoundsDelta imply the contents_scale of 1.0
- // because BoundsDela is only set on Android where
- // ContentScalingLayer is never used.
- DCHECK_IMPLIES(!BoundsDelta(layer).IsZero(),
- (layer->contents_scale_x() == 1.0 &&
- layer->contents_scale_y() == 1.0));
-
- // Thus we can omit contents scale in the following calculation.
- gfx::Vector2d bounds_delta = BoundsDelta(layer);
- content_size_affected_by_delta.Enlarge(bounds_delta.x(), bounds_delta.y());
-
+ // The layer bounds() includes the layer's bounds_delta() which we want
+ // for the clip rect.
gfx::Rect rect_in_target_space = MathUtil::MapEnclosingClippedRect(
- layer->draw_transform(),
- gfx::Rect(content_size_affected_by_delta));
+ layer->draw_transform(), gfx::Rect(layer->bounds()));
if (LayerClipsSubtree(layer)) {
layer_or_ancestor_clips_descendants = true;
@@ -2207,12 +2077,6 @@ static void CalculateDrawPropertiesInternal(
size_t layer_list_child_sorting_start_index = descendants.size();
if (!layer->children().empty()) {
- if (layer == globals.page_scale_application_layer) {
- data_for_children.parent_matrix.Scale(
- globals.page_scale_factor,
- globals.page_scale_factor);
- data_for_children.in_subtree_of_page_scale_application_layer = true;
- }
if (layer == globals.elastic_overscroll_application_layer) {
data_for_children.parent_matrix.Translate(
-globals.elastic_overscroll.x(), -globals.elastic_overscroll.y());
@@ -2289,8 +2153,11 @@ static void CalculateDrawPropertiesInternal(
render_surface_layer_list->size() -
child->draw_properties()
.index_of_first_render_surface_layer_list_addition;
- layer_draw_properties.layer_or_descendant_is_drawn |=
- child->draw_properties().layer_or_descendant_is_drawn;
+
+ if (child->layer_or_descendant_is_drawn()) {
+ bool layer_or_descendant_is_drawn = true;
+ layer->set_layer_or_descendant_is_drawn(layer_or_descendant_is_drawn);
+ }
}
// Add the unsorted layer list contributions, if necessary.
@@ -2336,7 +2203,7 @@ static void CalculateDrawPropertiesInternal(
}
// Compute the layer's visible content rect (the rect is in content space).
- layer_draw_properties.visible_content_rect = CalculateVisibleContentRect(
+ layer_draw_properties.visible_layer_rect = CalculateVisibleLayerRect(
layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space);
// Compute the remaining properties for the render surface, if the layer has
@@ -2396,9 +2263,8 @@ static void CalculateDrawPropertiesInternal(
// layer space which we need to undo and replace with a scale from the
// surface's subtree into layer space.
gfx::Transform screen_space_transform = layer->screen_space_transform();
- screen_space_transform.Scale(
- layer->contents_scale_x() / combined_transform_scales.x(),
- layer->contents_scale_y() / combined_transform_scales.y());
+ screen_space_transform.Scale(1.0 / combined_transform_scales.x(),
+ 1.0 / combined_transform_scales.y());
render_surface->SetScreenSpaceTransform(screen_space_transform);
if (layer->replica_layer()) {
@@ -2485,7 +2351,7 @@ static void ProcessCalcDrawPropsInputs(
globals->device_scale_factor =
inputs.device_scale_factor * device_transform_scale;
globals->page_scale_factor = inputs.page_scale_factor;
- globals->page_scale_application_layer = inputs.page_scale_application_layer;
+ globals->page_scale_layer = inputs.page_scale_layer;
globals->elastic_overscroll = inputs.elastic_overscroll;
globals->elastic_overscroll_application_layer =
inputs.elastic_overscroll_application_layer;
@@ -2506,7 +2372,7 @@ static void ProcessCalcDrawPropsInputs(
data_for_recursion->ancestor_is_animating_scale = false;
data_for_recursion->ancestor_clips_subtree = true;
data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL;
- data_for_recursion->in_subtree_of_page_scale_application_layer = false;
+ data_for_recursion->in_subtree_of_page_scale_layer = false;
data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text;
data_for_recursion->subtree_is_visible_from_ancestor = true;
}
@@ -2592,51 +2458,59 @@ static bool ApproximatelyEqual(const gfx::Transform& a,
return true;
}
+void VerifyPropertyTreeValuesForLayer(LayerImpl* current_layer,
+ PropertyTrees* property_trees,
+ bool layers_always_allowed_lcd_text,
+ bool can_use_lcd_text) {
+ const bool visible_rects_match =
+ ApproximatelyEqual(current_layer->visible_layer_rect(),
+ current_layer->visible_rect_from_property_trees());
+ CHECK(visible_rects_match)
+ << "expected: " << current_layer->visible_layer_rect().ToString()
+ << " actual: "
+ << current_layer->visible_rect_from_property_trees().ToString();
+
+ const bool draw_transforms_match =
+ ApproximatelyEqual(current_layer->draw_transform(),
+ DrawTransformFromPropertyTrees(
+ current_layer, property_trees->transform_tree));
+ CHECK(draw_transforms_match)
+ << "expected: " << current_layer->draw_transform().ToString()
+ << " actual: "
+ << DrawTransformFromPropertyTrees(
+ current_layer, property_trees->transform_tree).ToString();
+
+ const bool draw_opacities_match =
+ current_layer->draw_opacity() ==
+ DrawOpacityFromPropertyTrees(current_layer, property_trees->opacity_tree);
+ CHECK(draw_opacities_match)
+ << "expected: " << current_layer->draw_opacity()
+ << " actual: " << DrawOpacityFromPropertyTrees(
+ current_layer, property_trees->opacity_tree);
+ const bool can_use_lcd_text_match =
+ CanUseLcdTextFromPropertyTrees(
+ current_layer, layers_always_allowed_lcd_text, can_use_lcd_text,
+ property_trees) == current_layer->can_use_lcd_text();
+ CHECK(can_use_lcd_text_match);
+}
+
void VerifyPropertyTreeValues(
LayerTreeHostCommon::CalcDrawPropsMainInputs* inputs) {
- LayerIterator<Layer> it, end;
- for (it = LayerIterator<Layer>::Begin(inputs->render_surface_layer_list),
- end = LayerIterator<Layer>::End(inputs->render_surface_layer_list);
- it != end; ++it) {
- Layer* current_layer = *it;
- if (!it.represents_itself() || !current_layer->DrawsContent())
- continue;
-
- const bool visible_rects_match =
- ApproximatelyEqual(current_layer->visible_content_rect(),
- current_layer->visible_rect_from_property_trees());
- CHECK(visible_rects_match)
- << "expected: " << current_layer->visible_content_rect().ToString()
- << " actual: "
- << current_layer->visible_rect_from_property_trees().ToString();
-
- const bool draw_transforms_match = ApproximatelyEqual(
- current_layer->draw_transform(),
- DrawTransformFromPropertyTrees(current_layer,
- inputs->property_trees->transform_tree));
- CHECK(draw_transforms_match)
- << "expected: " << current_layer->draw_transform().ToString()
- << " actual: "
- << DrawTransformFromPropertyTrees(
- current_layer, inputs->property_trees->transform_tree)
- .ToString();
-
- const bool draw_opacities_match =
- current_layer->draw_opacity() ==
- DrawOpacityFromPropertyTrees(current_layer,
- inputs->property_trees->opacity_tree);
- CHECK(draw_opacities_match)
- << "expected: " << current_layer->draw_opacity() << " actual: "
- << DrawOpacityFromPropertyTrees(current_layer,
- inputs->property_trees->opacity_tree);
- }
}
void VerifyPropertyTreeValues(
LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) {
- // TODO(enne): need to synchronize compositor thread changes
- // for animation and scrolling to the property trees before these
- // can be correct.
+ LayerIterator it, end;
+ for (it = LayerIterator::Begin(inputs->render_surface_layer_list),
+ end = LayerIterator::End(inputs->render_surface_layer_list);
+ it != end; ++it) {
+ LayerImpl* current_layer = *it;
+ if (!it.represents_itself() || !current_layer->DrawsContent())
+ continue;
+ VerifyPropertyTreeValuesForLayer(current_layer, inputs->property_trees,
+ inputs->layers_always_allowed_lcd_text,
+ inputs->can_use_lcd_text);
+ }
}
enum PropertyTreeOption {
@@ -2654,6 +2528,7 @@ void CalculateDrawPropertiesAndVerify(LayerTreeHostCommon::CalcDrawPropsInputs<
DataForRecursion<LayerType> data_for_recursion;
ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
+ UpdateMetaInformationSequenceNumber(inputs->root_layer);
PreCalculateMetaInformationRecursiveData recursive_data;
PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data);
@@ -2665,7 +2540,6 @@ void CalculateDrawPropertiesAndVerify(LayerTreeHostCommon::CalcDrawPropsInputs<
TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
"LayerTreeHostCommon::CalculateDrawProperties");
}
- ResetDrawProperties(inputs->root_layer);
std::vector<AccumulatedSurfaceState<LayerType>> accumulated_surface_state;
CalculateDrawPropertiesInternal<LayerType>(
@@ -2696,8 +2570,10 @@ void CalculateDrawPropertiesAndVerify(LayerTreeHostCommon::CalcDrawPropsInputs<
}
BuildPropertyTreesAndComputeVisibleRects(
- inputs->root_layer, inputs->page_scale_application_layer,
- inputs->page_scale_factor, inputs->device_scale_factor,
+ inputs->root_layer, inputs->page_scale_layer,
+ inputs->inner_viewport_scroll_layer,
+ inputs->outer_viewport_scroll_layer, inputs->page_scale_factor,
+ inputs->device_scale_factor,
gfx::Rect(inputs->device_viewport_size), inputs->device_transform,
inputs->property_trees, &update_layer_list);
@@ -2747,14 +2623,12 @@ void LayerTreeHostCommon::CalculateDrawProperties(
CalculateDrawPropertiesAndVerify(inputs, BUILD_PROPERTY_TREES_IF_NEEDED);
}
-PropertyTrees* GetPropertyTrees(Layer* layer,
- PropertyTrees* trees_from_inputs) {
+PropertyTrees* GetPropertyTrees(Layer* layer) {
return layer->layer_tree_host()->property_trees();
}
-PropertyTrees* GetPropertyTrees(LayerImpl* layer,
- PropertyTrees* trees_from_inputs) {
- return trees_from_inputs;
+PropertyTrees* GetPropertyTrees(LayerImpl* layer) {
+ return layer->layer_tree_impl()->property_trees();
}
} // namespace cc
diff --git a/chromium/cc/trees/layer_tree_host_common.h b/chromium/cc/trees/layer_tree_host_common.h
index 7d90445023f..bf62111acbe 100644
--- a/chromium/cc/trees/layer_tree_host_common.h
+++ b/chromium/cc/trees/layer_tree_host_common.h
@@ -39,7 +39,9 @@ class CC_EXPORT LayerTreeHostCommon {
const gfx::Transform& device_transform,
float device_scale_factor,
float page_scale_factor,
- const LayerType* page_scale_application_layer,
+ const LayerType* page_scale_layer,
+ const LayerType* inner_viewport_scroll_layer,
+ const LayerType* outer_viewport_scroll_layer,
const gfx::Vector2dF& elastic_overscroll,
const LayerType* elastic_overscroll_application_layer,
int max_texture_size,
@@ -56,7 +58,9 @@ class CC_EXPORT LayerTreeHostCommon {
device_transform(device_transform),
device_scale_factor(device_scale_factor),
page_scale_factor(page_scale_factor),
- page_scale_application_layer(page_scale_application_layer),
+ page_scale_layer(page_scale_layer),
+ inner_viewport_scroll_layer(inner_viewport_scroll_layer),
+ outer_viewport_scroll_layer(outer_viewport_scroll_layer),
elastic_overscroll(elastic_overscroll),
elastic_overscroll_application_layer(
elastic_overscroll_application_layer),
@@ -76,7 +80,9 @@ class CC_EXPORT LayerTreeHostCommon {
gfx::Transform device_transform;
float device_scale_factor;
float page_scale_factor;
- const LayerType* page_scale_application_layer;
+ const LayerType* page_scale_layer;
+ const LayerType* inner_viewport_scroll_layer;
+ const LayerType* outer_viewport_scroll_layer;
gfx::Vector2dF elastic_overscroll;
const LayerType* elastic_overscroll_application_layer;
int max_texture_size;
@@ -102,9 +108,6 @@ class CC_EXPORT LayerTreeHostCommon {
LayerType* root_layer,
const gfx::Size& device_viewport_size,
RenderSurfaceLayerListType* render_surface_layer_list);
-
- private:
- PropertyTrees temporary_property_trees;
};
typedef CalcDrawPropsInputs<Layer, RenderSurfaceLayerList>
@@ -121,6 +124,8 @@ class CC_EXPORT LayerTreeHostCommon {
bool* animation_preserves_axis_alignment);
static void CalculateDrawProperties(CalcDrawPropsMainInputs* inputs);
static void PreCalculateMetaInformation(Layer* root_layer);
+ static void PreCalculateMetaInformationForTesting(LayerImpl* root_layer);
+ static void PreCalculateMetaInformationForTesting(Layer* root_layer);
typedef CalcDrawPropsInputs<LayerImpl, LayerImplList> CalcDrawPropsImplInputs;
typedef CalcDrawPropsInputsForTesting<LayerImpl, LayerImplList>
@@ -235,10 +240,8 @@ void LayerTreeHostCommon::CallFunctionForSubtree(LayerType* layer,
}
}
-CC_EXPORT PropertyTrees* GetPropertyTrees(Layer* layer,
- PropertyTrees* trees_from_inputs);
-CC_EXPORT PropertyTrees* GetPropertyTrees(LayerImpl* layer,
- PropertyTrees* trees_from_inputs);
+CC_EXPORT PropertyTrees* GetPropertyTrees(Layer* layer);
+CC_EXPORT PropertyTrees* GetPropertyTrees(LayerImpl* layer);
template <typename LayerType, typename RenderSurfaceLayerListType>
LayerTreeHostCommon::CalcDrawPropsInputsForTesting<LayerType,
@@ -255,6 +258,8 @@ LayerTreeHostCommon::CalcDrawPropsInputsForTesting<LayerType,
1.f,
1.f,
NULL,
+ NULL,
+ NULL,
gfx::Vector2dF(),
NULL,
std::numeric_limits<int>::max() / 2,
@@ -265,7 +270,7 @@ LayerTreeHostCommon::CalcDrawPropsInputsForTesting<LayerType,
true,
render_surface_layer_list,
0,
- GetPropertyTrees(root_layer, &temporary_property_trees)) {
+ GetPropertyTrees(root_layer)) {
DCHECK(root_layer);
DCHECK(render_surface_layer_list);
}
@@ -284,6 +289,8 @@ LayerTreeHostCommon::CalcDrawPropsInputsForTesting<LayerType,
1.f,
1.f,
NULL,
+ NULL,
+ NULL,
gfx::Vector2dF(),
NULL,
std::numeric_limits<int>::max() / 2,
@@ -294,7 +301,7 @@ LayerTreeHostCommon::CalcDrawPropsInputsForTesting<LayerType,
true,
render_surface_layer_list,
0,
- GetPropertyTrees(root_layer, &temporary_property_trees)) {
+ GetPropertyTrees(root_layer)) {
DCHECK(root_layer);
DCHECK(render_surface_layer_list);
}
diff --git a/chromium/cc/trees/layer_tree_host_common_perftest.cc b/chromium/cc/trees/layer_tree_host_common_perftest.cc
index 9a5de06bb0f..49831328d1e 100644
--- a/chromium/cc/trees/layer_tree_host_common_perftest.cc
+++ b/chromium/cc/trees/layer_tree_host_common_perftest.cc
@@ -77,48 +77,9 @@ class LayerTreeHostCommonPerfTest : public LayerTreeTest {
std::string json_;
};
-class CalcDrawPropsMainTest : public LayerTreeHostCommonPerfTest {
+class CalcDrawPropsTest : public LayerTreeHostCommonPerfTest {
public:
- void RunCalcDrawProps() { RunTest(false, false, false); }
-
- void BeginTest() override {
- timer_.Reset();
-
- do {
- bool can_render_to_separate_surface = true;
- bool verify_property_trees = false;
- int max_texture_size = 8096;
- RenderSurfaceLayerList update_list;
- PropertyTrees property_trees;
- LayerTreeHostCommon::CalcDrawPropsMainInputs inputs(
- layer_tree_host()->root_layer(),
- layer_tree_host()->device_viewport_size(), gfx::Transform(),
- layer_tree_host()->device_scale_factor(),
- layer_tree_host()->page_scale_factor(),
- layer_tree_host()->overscroll_elasticity_layer(),
- layer_tree_host()->elastic_overscroll(),
- layer_tree_host()->page_scale_layer(), max_texture_size,
- layer_tree_host()->settings().can_use_lcd_text,
- layer_tree_host()->settings().layers_always_allowed_lcd_text,
- can_render_to_separate_surface,
- layer_tree_host()
- ->settings()
- .layer_transforms_should_scale_layer_contents,
- verify_property_trees, &update_list, 0, &property_trees);
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
-
- timer_.NextLap();
- } while (!timer_.HasTimeLimitExpired());
-
- EndTest();
- }
-};
-
-class CalcDrawPropsImplTest : public LayerTreeHostCommonPerfTest {
- public:
- void RunCalcDrawProps() {
- RunTestWithImplSidePainting();
- }
+ void RunCalcDrawProps() { RunTest(false, false); }
void BeginTest() override { PostSetNeedsCommitToMainThread(); }
@@ -152,6 +113,8 @@ class CalcDrawPropsImplTest : public LayerTreeHostCommonPerfTest {
host_impl->DrawTransform(), active_tree->device_scale_factor(),
active_tree->current_page_scale_factor(),
active_tree->InnerViewportContainerLayer(),
+ active_tree->InnerViewportScrollLayer(),
+ active_tree->OuterViewportScrollLayer(),
active_tree->elastic_overscroll()->Current(active_tree->IsActiveTree()),
active_tree->overscroll_elasticity_layer(), max_texture_size,
host_impl->settings().can_use_lcd_text,
@@ -163,10 +126,10 @@ class CalcDrawPropsImplTest : public LayerTreeHostCommonPerfTest {
}
};
-class BspTreePerfTest : public CalcDrawPropsImplTest {
+class BspTreePerfTest : public CalcDrawPropsTest {
public:
BspTreePerfTest() : num_duplicates_(1) {}
- void RunSortLayers() { RunTest(false, false, false); }
+ void RunSortLayers() { RunTest(false, false); }
void SetNumberOfDuplicates(int num_duplicates) {
num_duplicates_ = num_duplicates;
@@ -193,10 +156,8 @@ class BspTreePerfTest : public CalcDrawPropsImplTest {
for (LayerImplList::iterator it = base_list.begin(); it != base_list.end();
++it) {
DrawPolygon* draw_polygon =
- new DrawPolygon(NULL,
- gfx::RectF((*it)->content_bounds()),
- (*it)->draw_transform(),
- polygon_counter++);
+ new DrawPolygon(NULL, gfx::RectF((*it)->bounds()),
+ (*it)->draw_transform(), polygon_counter++);
polygon_list.push_back(scoped_ptr<DrawPolygon>(draw_polygon));
}
@@ -230,49 +191,25 @@ class BspTreePerfTest : public CalcDrawPropsImplTest {
int num_duplicates_;
};
-TEST_F(CalcDrawPropsMainTest, TenTen) {
- SetTestName("10_10_main_thread");
- ReadTestFile("10_10_layer_tree");
- RunCalcDrawProps();
-}
-
-TEST_F(CalcDrawPropsMainTest, HeavyPage) {
- SetTestName("heavy_page_main_thread");
- ReadTestFile("heavy_layer_tree");
- RunCalcDrawProps();
-}
-
-TEST_F(CalcDrawPropsMainTest, TouchRegionLight) {
- SetTestName("touch_region_light_main_thread");
- ReadTestFile("touch_region_light");
- RunCalcDrawProps();
-}
-
-TEST_F(CalcDrawPropsMainTest, TouchRegionHeavy) {
- SetTestName("touch_region_heavy_main_thread");
- ReadTestFile("touch_region_heavy");
- RunCalcDrawProps();
-}
-
-TEST_F(CalcDrawPropsImplTest, TenTen) {
+TEST_F(CalcDrawPropsTest, TenTen) {
SetTestName("10_10");
ReadTestFile("10_10_layer_tree");
RunCalcDrawProps();
}
-TEST_F(CalcDrawPropsImplTest, HeavyPage) {
+TEST_F(CalcDrawPropsTest, HeavyPage) {
SetTestName("heavy_page");
ReadTestFile("heavy_layer_tree");
RunCalcDrawProps();
}
-TEST_F(CalcDrawPropsImplTest, TouchRegionLight) {
+TEST_F(CalcDrawPropsTest, TouchRegionLight) {
SetTestName("touch_region_light");
ReadTestFile("touch_region_light");
RunCalcDrawProps();
}
-TEST_F(CalcDrawPropsImplTest, TouchRegionHeavy) {
+TEST_F(CalcDrawPropsTest, TouchRegionHeavy) {
SetTestName("touch_region_heavy");
ReadTestFile("touch_region_heavy");
RunCalcDrawProps();
diff --git a/chromium/cc/trees/layer_tree_host_common_unittest.cc b/chromium/cc/trees/layer_tree_host_common_unittest.cc
index 591f48c4329..43e2bb02123 100644
--- a/chromium/cc/trees/layer_tree_host_common_unittest.cc
+++ b/chromium/cc/trees/layer_tree_host_common_unittest.cc
@@ -10,7 +10,6 @@
#include "cc/animation/layer_animation_controller.h"
#include "cc/animation/transform_operations.h"
#include "cc/base/math_util.h"
-#include "cc/layers/content_layer.h"
#include "cc/layers/content_layer_client.h"
#include "cc/layers/layer.h"
#include "cc/layers/layer_client.h"
@@ -21,9 +20,7 @@
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
#include "cc/test/animation_test_common.h"
-#include "cc/test/fake_content_layer.h"
#include "cc/test/fake_content_layer_client.h"
-#include "cc/test/fake_content_layer_impl.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_layer_tree_host.h"
#include "cc/test/fake_layer_tree_host_impl.h"
@@ -46,7 +43,8 @@ namespace {
class LayerWithForcedDrawsContent : public Layer {
public:
- LayerWithForcedDrawsContent() {}
+ explicit LayerWithForcedDrawsContent(const LayerSettings& settings)
+ : Layer(settings) {}
bool DrawsContent() const override;
@@ -63,26 +61,20 @@ class MockContentLayerClient : public ContentLayerClient {
void PaintContents(SkCanvas* canvas,
const gfx::Rect& clip,
PaintingControlSetting picture_control) override {}
- void PaintContentsToDisplayList(
- DisplayItemList* display_list,
+ scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
const gfx::Rect& clip,
PaintingControlSetting picture_control) override {
NOTIMPLEMENTED();
+ return nullptr;
}
bool FillsBoundsCompletely() const override { return false; }
};
scoped_refptr<FakePictureLayer> CreateDrawablePictureLayer(
+ const LayerSettings& settings,
ContentLayerClient* delegate) {
scoped_refptr<FakePictureLayer> to_return =
- FakePictureLayer::Create(delegate);
- to_return->SetIsDrawable(true);
- return to_return;
-}
-
-scoped_refptr<ContentLayer> CreateDrawableContentLayer(
- ContentLayerClient* delegate) {
- scoped_refptr<ContentLayer> to_return = ContentLayer::Create(delegate);
+ FakePictureLayer::Create(settings, delegate);
to_return->SetIsDrawable(true);
return to_return;
}
@@ -93,25 +85,37 @@ scoped_refptr<ContentLayer> CreateDrawableContentLayer(
EXPECT_FLOAT_EQ(expected, layer->contents_scale_y()); \
} while (false)
-#define EXPECT_IDEAL_SCALE_EQ(expected, layer) \
- do { \
- EXPECT_FLOAT_EQ(expected, layer->draw_properties().ideal_contents_scale); \
+#define EXPECT_IDEAL_SCALE_EQ(expected, layer) \
+ do { \
+ EXPECT_FLOAT_EQ(expected, layer->GetIdealContentsScale()); \
} while (false)
+class LayerTreeSettingsScaleContent : public LayerTreeSettings {
+ public:
+ LayerTreeSettingsScaleContent() {
+ layer_transforms_should_scale_layer_contents = true;
+ }
+};
+
+class LayerTreeHostCommonScalingTest : public LayerTreeHostCommonTest {
+ public:
+ LayerTreeHostCommonScalingTest()
+ : LayerTreeHostCommonTest(LayerTreeSettingsScaleContent()) {}
+};
+
TEST_F(LayerTreeHostCommonTest, TransformsForNoOpLayer) {
// Sanity check: For layers positioned at zero, with zero size,
// and with identity transforms, then the draw transform,
// screen space transform, and the hierarchy passed on to children
// layers should also be identity transforms.
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
- scoped_refptr<Layer> grand_child = Layer::Create();
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
parent->AddChild(child);
child->AddChild(grand_child);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
gfx::Transform identity_matrix;
SetLayerPropertiesForTesting(parent.get(),
@@ -148,14 +152,13 @@ TEST_F(LayerTreeHostCommonTest, TransformsForNoOpLayer) {
}
TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) {
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
- scoped_refptr<Layer> grand_child = Layer::Create();
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
parent->AddChild(child);
child->AddChild(grand_child);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
gfx::Transform identity_matrix;
SetLayerPropertiesForTesting(parent.get(),
@@ -195,9 +198,9 @@ TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) {
TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) {
gfx::Transform identity_matrix;
- scoped_refptr<Layer> layer = Layer::Create();
+ scoped_refptr<Layer> layer = Layer::Create(layer_settings());
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(root.get(),
identity_matrix,
gfx::Point3F(),
@@ -207,8 +210,7 @@ TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) {
false);
root->AddChild(layer);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
// Case 2: Setting the bounds of the layer should not affect either the draw
// transform or the screenspace transform.
@@ -319,14 +321,14 @@ TEST_F(LayerTreeHostCommonTest, TransformsAboutScrollOffset) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
gfx::Transform identity_matrix;
scoped_ptr<LayerImpl> sublayer_scoped_ptr(
LayerImpl::Create(host_impl.active_tree(), 1));
LayerImpl* sublayer = sublayer_scoped_ptr.get();
- sublayer->SetContentsScale(kPageScale * kDeviceScale,
- kPageScale * kDeviceScale);
SetLayerPropertiesForTesting(sublayer, identity_matrix, gfx::Point3F(),
gfx::PointF(), gfx::Size(500, 500), true, false,
false);
@@ -364,9 +366,12 @@ TEST_F(LayerTreeHostCommonTest, TransformsAboutScrollOffset) {
root.get(), kDeviceScale, kPageScale, scroll_layer->parent());
gfx::Transform expected_transform = identity_matrix;
gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta;
- sub_layer_screen_position.Scale(kPageScale * kDeviceScale);
- expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x()),
- MathUtil::Round(sub_layer_screen_position.y()));
+ expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x() *
+ kPageScale * kDeviceScale),
+ MathUtil::Round(sub_layer_screen_position.y() *
+ kPageScale * kDeviceScale));
+ expected_transform.Scale(kPageScale * kDeviceScale,
+ kPageScale * kDeviceScale);
EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform,
sublayer->draw_transform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform,
@@ -384,25 +389,28 @@ TEST_F(LayerTreeHostCommonTest, TransformsAboutScrollOffset) {
expected_transform.MakeIdentity();
expected_transform.Translate(
MathUtil::Round(kTranslateX * kPageScale * kDeviceScale +
- sub_layer_screen_position.x()),
+ sub_layer_screen_position.x() * kPageScale *
+ kDeviceScale),
MathUtil::Round(kTranslateY * kPageScale * kDeviceScale +
- sub_layer_screen_position.y()));
+ sub_layer_screen_position.y() * kPageScale *
+ kDeviceScale));
+ expected_transform.Scale(kPageScale * kDeviceScale,
+ kPageScale * kDeviceScale);
EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform,
sublayer->draw_transform());
}
TEST_F(LayerTreeHostCommonTest, TransformsForSimpleHierarchy) {
gfx::Transform identity_matrix;
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
- scoped_refptr<Layer> grand_child = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
root->AddChild(parent);
parent->AddChild(child);
child->AddChild(grand_child);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
// One-time setup of root layer
SetLayerPropertiesForTesting(root.get(),
@@ -519,17 +527,16 @@ TEST_F(LayerTreeHostCommonTest, TransformsForSimpleHierarchy) {
}
TEST_F(LayerTreeHostCommonTest, TransformsForSingleRenderSurface) {
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> grand_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(parent);
parent->AddChild(child);
child->AddChild(grand_child);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
// One-time setup of root layer
gfx::Transform identity_matrix;
@@ -614,19 +621,18 @@ TEST_F(LayerTreeHostCommonTest, TransformsForSingleRenderSurface) {
}
TEST_F(LayerTreeHostCommonTest, TransformsForReplica) {
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
- scoped_refptr<Layer> child_replica = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child_replica = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> grand_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(parent);
parent->AddChild(child);
child->AddChild(grand_child);
child->SetReplicaLayer(child_replica.get());
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
// One-time setup of root layer
gfx::Transform identity_matrix;
@@ -720,20 +726,20 @@ TEST_F(LayerTreeHostCommonTest, TransformsForRenderSurfaceHierarchy) {
// - verifying that each layer has a reference to the correct render surface
// and render target values.
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> render_surface1 = Layer::Create();
- scoped_refptr<Layer> render_surface2 = Layer::Create();
- scoped_refptr<Layer> child_of_root = Layer::Create();
- scoped_refptr<Layer> child_of_rs1 = Layer::Create();
- scoped_refptr<Layer> child_of_rs2 = Layer::Create();
- scoped_refptr<Layer> replica_of_rs1 = Layer::Create();
- scoped_refptr<Layer> replica_of_rs2 = Layer::Create();
- scoped_refptr<Layer> grand_child_of_root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface2 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child_of_root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child_of_rs1 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child_of_rs2 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> replica_of_rs1 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> replica_of_rs2 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child_of_root = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> grand_child_of_rs1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> grand_child_of_rs2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(parent);
parent->AddChild(render_surface1);
parent->AddChild(child_of_root);
@@ -746,8 +752,7 @@ TEST_F(LayerTreeHostCommonTest, TransformsForRenderSurfaceHierarchy) {
render_surface1->SetReplicaLayer(replica_of_rs1.get());
render_surface2->SetReplicaLayer(replica_of_rs2.get());
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
// In combination with descendant draws content, opacity != 1 forces the layer
// to have a new render surface.
@@ -1006,12 +1011,12 @@ TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) {
// Note that the way the code is currently implemented, it is not expected to
// use a canonical orthographic projection.
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> grand_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> great_grand_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
gfx::Transform rotation_about_y_axis;
rotation_about_y_axis.RotateAboutYAxis(30.0);
@@ -1047,8 +1052,7 @@ TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) {
grand_child->AddChild(great_grand_child);
child->SetForceRenderSurface(true);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
// No layers in this test should preserve 3d.
ASSERT_TRUE(root->should_flatten_transform());
@@ -1102,10 +1106,10 @@ TEST_F(LayerTreeHostCommonTest, TransformsForDegenerateIntermediateLayer) {
// implicitly inherited by the rest of the subtree, which then is positioned
// incorrectly as a result.
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> grand_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
// The child height is zero, but has non-zero width that should be accounted
// for while computing draw transforms.
@@ -1136,8 +1140,7 @@ TEST_F(LayerTreeHostCommonTest, TransformsForDegenerateIntermediateLayer) {
child->AddChild(grand_child);
child->SetForceRenderSurface(true);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
ExecuteCalculateDrawProperties(root.get());
@@ -1155,14 +1158,13 @@ TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
// to child layers instead of applied to the root RenderSurface.
const gfx::Transform identity_matrix;
scoped_refptr<LayerWithForcedDrawsContent> root =
- new LayerWithForcedDrawsContent;
+ new LayerWithForcedDrawsContent(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child =
- new LayerWithForcedDrawsContent;
+ new LayerWithForcedDrawsContent(layer_settings());
child->SetScrollClipLayerId(root->id());
root->AddChild(child);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
SetLayerPropertiesForTesting(root.get(),
identity_matrix,
@@ -1191,8 +1193,6 @@ TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
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());
- EXPECT_EQ(1.f, root->draw_properties().device_scale_factor);
- EXPECT_EQ(1.f, child->draw_properties().device_scale_factor);
}
gfx::Transform scale;
@@ -1207,8 +1207,6 @@ TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
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());
- EXPECT_EQ(2.f, root->draw_properties().device_scale_factor);
- EXPECT_EQ(2.f, child->draw_properties().device_scale_factor);
}
gfx::Transform rotate;
@@ -1223,8 +1221,6 @@ TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
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());
- EXPECT_EQ(1.f, root->draw_properties().device_scale_factor);
- EXPECT_EQ(1.f, child->draw_properties().device_scale_factor);
}
gfx::Transform composite;
@@ -1261,9 +1257,6 @@ TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
EXPECT_EQ(device_scaled_translate,
child->draw_properties().target_space_transform);
EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
- EXPECT_EQ(device_scale_factor, root->draw_properties().device_scale_factor);
- EXPECT_EQ(device_scale_factor,
- child->draw_properties().device_scale_factor);
}
// Verify it composes correctly with page scale.
@@ -1274,18 +1267,17 @@ TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
root.get(), root->bounds(), translate, &render_surface_layer_list);
inputs.page_scale_factor = page_scale_factor;
- inputs.page_scale_application_layer = root.get();
+ inputs.page_scale_layer = root.get();
inputs.can_adjust_raster_scales = true;
inputs.property_trees->needs_rebuild = true;
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
gfx::Transform page_scaled_translate = translate;
page_scaled_translate.Scale(page_scale_factor, page_scale_factor);
- EXPECT_EQ(translate, root->draw_properties().target_space_transform);
+ EXPECT_EQ(page_scaled_translate,
+ root->draw_properties().target_space_transform);
EXPECT_EQ(page_scaled_translate,
child->draw_properties().target_space_transform);
EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
- EXPECT_EQ(1.f, root->draw_properties().device_scale_factor);
- EXPECT_EQ(1.f, child->draw_properties().device_scale_factor);
}
// Verify that it composes correctly with transforms directly on root layer.
@@ -1309,13 +1301,12 @@ TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
TEST_F(LayerTreeHostCommonTest,
RenderSurfaceListForRenderSurfaceWithClippedLayer) {
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> render_surface1 = Layer::Create();
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
const gfx::Transform identity_matrix;
SetLayerPropertiesForTesting(parent.get(),
@@ -1363,38 +1354,23 @@ TEST_F(LayerTreeHostCommonTest,
}
TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForTransparentChild) {
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> render_surface1 = Layer::Create();
- scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
-
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ LayerImpl* parent = root_layer();
+ LayerImpl* render_surface1 = AddChild<LayerImpl>(parent);
+ LayerImpl* child = AddChild<LayerImpl>(render_surface1);
+ child->SetDrawsContent(true);
const gfx::Transform identity_matrix;
- SetLayerPropertiesForTesting(render_surface1.get(),
- identity_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(10, 10),
- true,
- false);
- SetLayerPropertiesForTesting(child.get(),
- identity_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(10, 10),
- true,
+ SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(10, 10), true, false,
+ true);
+ SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(10, 10), true, false,
false);
-
- parent->AddChild(render_surface1);
- render_surface1->AddChild(child);
- render_surface1->SetForceRenderSurface(true);
render_surface1->SetOpacity(0.f);
- RenderSurfaceLayerList render_surface_layer_list;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- parent.get(), parent->bounds(), &render_surface_layer_list);
+ LayerImplList render_surface_layer_list;
+ LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
+ parent, parent->bounds(), &render_surface_layer_list);
inputs.can_adjust_raster_scales = true;
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
@@ -1409,12 +1385,11 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForTransparentChild) {
}
TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) {
- scoped_refptr<Layer> parent = Layer::Create();
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
const gfx::Transform identity_matrix;
const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode;
@@ -1439,14 +1414,13 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) {
}
TEST_F(LayerTreeHostCommonTest, ForceRenderSurface) {
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> render_surface1 = Layer::Create();
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
render_surface1->SetForceRenderSurface(true);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
const gfx::Transform identity_matrix;
SetLayerPropertiesForTesting(parent.get(),
@@ -1508,12 +1482,12 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) {
// Render surfaces act as a flattening point for their subtree, so should
// always flatten the target-to-screen space transform seen by descendants.
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> parent = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> grand_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
gfx::Transform rotation_about_y_axis;
rotation_about_y_axis.RotateAboutYAxis(30.0);
@@ -1538,8 +1512,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) {
grand_child->SetShouldFlattenTransform(false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
// Only grand_child should preserve 3d.
EXPECT_TRUE(root->should_flatten_transform());
@@ -1590,20 +1563,19 @@ TEST_F(LayerTreeHostCommonTest, ClipRectCullsRenderSurfaces) {
//
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
- scoped_refptr<Layer> grand_child = Layer::Create();
- scoped_refptr<Layer> great_grand_child = Layer::Create();
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
+ scoped_refptr<Layer> great_grand_child = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> leaf_node1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> leaf_node2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
parent->AddChild(child);
child->AddChild(grand_child);
grand_child->AddChild(great_grand_child);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
// leaf_node1 ensures that parent and child are kept on the
// render_surface_layer_list, even though grand_child and great_grand_child
@@ -1691,17 +1663,16 @@ TEST_F(LayerTreeHostCommonTest, ClipRectCullsSurfaceWithoutVisibleContent) {
// in the render_surface_layer_list.
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
- scoped_refptr<Layer> grand_child = Layer::Create();
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> leaf_node =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
parent->AddChild(child);
child->AddChild(grand_child);
grand_child->AddChild(leaf_node);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
SetLayerPropertiesForTesting(parent.get(),
identity_matrix,
@@ -1786,15 +1757,15 @@ TEST_F(LayerTreeHostCommonTest, IsClippedIsSetCorrectly) {
// and propagates the clip to the subtree.
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> child1 = Layer::Create();
- scoped_refptr<Layer> child2 = Layer::Create();
- scoped_refptr<Layer> grand_child = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child1 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child2 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> leaf_node1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> leaf_node2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(parent);
parent->AddChild(child1);
parent->AddChild(child2);
@@ -1802,8 +1773,7 @@ TEST_F(LayerTreeHostCommonTest, IsClippedIsSetCorrectly) {
child2->AddChild(leaf_node2);
grand_child->AddChild(leaf_node1);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
child2->SetForceRenderSurface(true);
@@ -1947,12 +1917,12 @@ TEST_F(LayerTreeHostCommonTest, DrawableContentRectForLayers) {
//
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
- scoped_refptr<Layer> grand_child1 = Layer::Create();
- scoped_refptr<Layer> grand_child2 = Layer::Create();
- scoped_refptr<Layer> grand_child3 = Layer::Create();
- scoped_refptr<Layer> grand_child4 = Layer::Create();
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child1 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child2 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child3 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child4 = Layer::Create(layer_settings());
parent->AddChild(child);
child->AddChild(grand_child1);
@@ -1960,8 +1930,7 @@ TEST_F(LayerTreeHostCommonTest, DrawableContentRectForLayers) {
child->AddChild(grand_child3);
child->AddChild(grand_child4);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
SetLayerPropertiesForTesting(parent.get(),
identity_matrix,
@@ -2037,20 +2006,20 @@ TEST_F(LayerTreeHostCommonTest, ClipRectIsPropagatedCorrectlyToSurfaces) {
// They may still have a clip rect of their own layer bounds, however, if
// masksToBounds was true.
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
- scoped_refptr<Layer> grand_child1 = Layer::Create();
- scoped_refptr<Layer> grand_child2 = Layer::Create();
- scoped_refptr<Layer> grand_child3 = Layer::Create();
- scoped_refptr<Layer> grand_child4 = Layer::Create();
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child1 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child2 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child3 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child4 = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> leaf_node1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> leaf_node2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> leaf_node3 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> leaf_node4 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
parent->AddChild(child);
child->AddChild(grand_child1);
@@ -2058,8 +2027,7 @@ TEST_F(LayerTreeHostCommonTest, ClipRectIsPropagatedCorrectlyToSurfaces) {
child->AddChild(grand_child3);
child->AddChild(grand_child4);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
// the leaf nodes ensure that these grand_children become render surfaces for
// this test.
@@ -2175,99 +2143,49 @@ TEST_F(LayerTreeHostCommonTest, ClipRectIsPropagatedCorrectlyToSurfaces) {
}
TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) {
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> render_surface1 = Layer::Create();
- scoped_refptr<Layer> render_surface2 = Layer::Create();
- scoped_refptr<Layer> child_of_root = Layer::Create();
- scoped_refptr<Layer> child_of_rs1 = Layer::Create();
- scoped_refptr<Layer> child_of_rs2 = Layer::Create();
- scoped_refptr<Layer> grand_child_of_root = Layer::Create();
- scoped_refptr<LayerWithForcedDrawsContent> grand_child_of_rs1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
- scoped_refptr<LayerWithForcedDrawsContent> grand_child_of_rs2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
- parent->AddChild(render_surface1);
- parent->AddChild(child_of_root);
- render_surface1->AddChild(child_of_rs1);
- render_surface1->AddChild(render_surface2);
- render_surface2->AddChild(child_of_rs2);
- child_of_root->AddChild(grand_child_of_root);
- child_of_rs1->AddChild(grand_child_of_rs1);
- child_of_rs2->AddChild(grand_child_of_rs2);
-
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
-
- // Make our render surfaces.
- render_surface1->SetForceRenderSurface(true);
- render_surface2->SetForceRenderSurface(true);
+ LayerImpl* parent = root_layer();
+ LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>();
+ LayerImpl* child_of_rs1 = AddChild<LayerImpl>(render_surface1);
+ LayerImpl* grand_child_of_rs1 = AddChild<LayerImpl>(child_of_rs1);
+ LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1);
+ LayerImpl* child_of_rs2 = AddChild<LayerImpl>(render_surface2);
+ LayerImpl* grand_child_of_rs2 = AddChild<LayerImpl>(child_of_rs2);
+ LayerImpl* child_of_root = AddChildToRoot<LayerImpl>();
+ LayerImpl* grand_child_of_root = AddChild<LayerImpl>(child_of_root);
+
+ grand_child_of_rs1->SetDrawsContent(true);
+ grand_child_of_rs2->SetDrawsContent(true);
gfx::Transform layer_transform;
layer_transform.Translate(1.0, 1.0);
- SetLayerPropertiesForTesting(parent.get(),
- layer_transform,
- gfx::Point3F(0.25f, 0.f, 0.f),
- gfx::PointF(2.5f, 0.f),
- gfx::Size(10, 10),
- true,
- false);
- SetLayerPropertiesForTesting(render_surface1.get(),
- layer_transform,
- gfx::Point3F(0.25f, 0.f, 0.f),
- gfx::PointF(2.5f, 0.f),
- gfx::Size(10, 10),
- true,
- false);
- SetLayerPropertiesForTesting(render_surface2.get(),
- layer_transform,
- gfx::Point3F(0.25f, 0.f, 0.f),
- gfx::PointF(2.5f, 0.f),
- gfx::Size(10, 10),
- true,
- false);
- SetLayerPropertiesForTesting(child_of_root.get(),
- layer_transform,
- gfx::Point3F(0.25f, 0.f, 0.f),
- gfx::PointF(2.5f, 0.f),
- gfx::Size(10, 10),
- true,
- false);
- SetLayerPropertiesForTesting(child_of_rs1.get(),
- layer_transform,
- gfx::Point3F(0.25f, 0.f, 0.f),
- gfx::PointF(2.5f, 0.f),
- gfx::Size(10, 10),
- true,
- false);
- SetLayerPropertiesForTesting(child_of_rs2.get(),
- layer_transform,
- gfx::Point3F(0.25f, 0.f, 0.f),
- gfx::PointF(2.5f, 0.f),
- gfx::Size(10, 10),
- true,
- false);
- SetLayerPropertiesForTesting(grand_child_of_root.get(),
- layer_transform,
- gfx::Point3F(0.25f, 0.f, 0.f),
- gfx::PointF(2.5f, 0.f),
- gfx::Size(10, 10),
- true,
- false);
- SetLayerPropertiesForTesting(grand_child_of_rs1.get(),
- layer_transform,
- gfx::Point3F(0.25f, 0.f, 0.f),
- gfx::PointF(2.5f, 0.f),
- gfx::Size(10, 10),
- true,
- false);
- SetLayerPropertiesForTesting(grand_child_of_rs2.get(),
- layer_transform,
- gfx::Point3F(0.25f, 0.f, 0.f),
- gfx::PointF(2.5f, 0.f),
- gfx::Size(10, 10),
- true,
- false);
+ SetLayerPropertiesForTesting(
+ parent, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f),
+ gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, true);
+ SetLayerPropertiesForTesting(
+ render_surface1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f),
+ gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, true);
+ SetLayerPropertiesForTesting(
+ render_surface2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f),
+ gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, true);
+ SetLayerPropertiesForTesting(
+ child_of_root, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f),
+ gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false);
+ SetLayerPropertiesForTesting(
+ child_of_rs1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f),
+ gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false);
+ SetLayerPropertiesForTesting(
+ child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f),
+ gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false);
+ SetLayerPropertiesForTesting(
+ grand_child_of_root, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f),
+ gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false);
+ SetLayerPropertiesForTesting(
+ grand_child_of_rs1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f),
+ gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false);
+ SetLayerPropertiesForTesting(
+ grand_child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f),
+ gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false);
// Put an animated opacity on the render surface.
AddOpacityTransitionToController(
@@ -2288,7 +2206,7 @@ TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) {
AddAnimatedTransformToController(
grand_child_of_rs2->layer_animation_controller(), 10.0, 30, 0);
- ExecuteCalculateDrawProperties(parent.get());
+ ExecuteCalculateDrawProperties(parent);
// Only layers that are associated with render surfaces should have an actual
// RenderSurface() value.
@@ -2305,17 +2223,17 @@ TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) {
ASSERT_FALSE(grand_child_of_rs2->render_surface());
// Verify all render target accessors
- EXPECT_EQ(parent.get(), parent->render_target());
- EXPECT_EQ(parent.get(), child_of_root->render_target());
- EXPECT_EQ(parent.get(), grand_child_of_root->render_target());
+ EXPECT_EQ(parent, parent->render_target());
+ EXPECT_EQ(parent, child_of_root->render_target());
+ EXPECT_EQ(parent, grand_child_of_root->render_target());
- EXPECT_EQ(render_surface1.get(), render_surface1->render_target());
- EXPECT_EQ(render_surface1.get(), child_of_rs1->render_target());
- EXPECT_EQ(render_surface1.get(), grand_child_of_rs1->render_target());
+ EXPECT_EQ(render_surface1, render_surface1->render_target());
+ EXPECT_EQ(render_surface1, child_of_rs1->render_target());
+ EXPECT_EQ(render_surface1, grand_child_of_rs1->render_target());
- EXPECT_EQ(render_surface2.get(), render_surface2->render_target());
- EXPECT_EQ(render_surface2.get(), child_of_rs2->render_target());
- EXPECT_EQ(render_surface2.get(), grand_child_of_rs2->render_target());
+ EXPECT_EQ(render_surface2, render_surface2->render_target());
+ EXPECT_EQ(render_surface2, child_of_rs2->render_target());
+ EXPECT_EQ(render_surface2, grand_child_of_rs2->render_target());
// Verify draw_opacity_is_animating values
EXPECT_FALSE(parent->draw_opacity_is_animating());
@@ -2671,20 +2589,42 @@ TEST_F(LayerTreeHostCommonTest, VisibleRectForPerspectiveUnprojection) {
EXPECT_EQ(expected, actual);
}
+TEST_F(LayerTreeHostCommonTest,
+ VisibleRectsForPositionedRootLayerClippedByViewport) {
+ scoped_refptr<Layer> root =
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
+ host()->SetRootLayer(root);
+
+ gfx::Transform identity_matrix;
+ // Root layer is positioned at (60, 70). The default device viewport size
+ // is (0, 0, 100x100) in target space. So the root layer's visible rect
+ // will be clipped by the viewport to be (0, 0, 40x30) in layer's space.
+ SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
+ gfx::PointF(60, 70), gfx::Size(100, 100), true,
+ false);
+ ExecuteCalculateDrawProperties(root.get());
+
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
+ root->render_surface()->DrawableContentRect());
+ // In target space, not clipped.
+ EXPECT_EQ(gfx::Rect(60, 70, 100, 100), root->drawable_content_rect());
+ // In layer space, clipped.
+ EXPECT_EQ(gfx::Rect(0, 0, 40, 30), root->visible_layer_rect());
+}
+
TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child3 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(child1);
root->AddChild(child2);
root->AddChild(child3);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform identity_matrix;
SetLayerPropertiesForTesting(root.get(),
@@ -2722,13 +2662,13 @@ TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) {
root->render_surface()->DrawableContentRect());
EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
- // Layers that do not draw content should have empty visible_content_rects.
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect());
+ // Layers that do not draw content should have empty visible_layer_rects.
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
- // layer visible_content_rects are clipped by their target surface.
- EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_content_rect());
- EXPECT_TRUE(child3->visible_content_rect().IsEmpty());
+ // layer visible_layer_rects are clipped by their target surface.
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect());
+ EXPECT_TRUE(child3->visible_layer_rect().IsEmpty());
// layer drawable_content_rects are not clipped.
EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->drawable_content_rect());
@@ -2738,21 +2678,20 @@ TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) {
TEST_F(LayerTreeHostCommonTest,
DrawableAndVisibleContentRectsForLayersClippedByLayer) {
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> grand_child1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> grand_child2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> grand_child3 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(child);
child->AddChild(grand_child1);
child->AddChild(grand_child2);
child->AddChild(grand_child3);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform identity_matrix;
SetLayerPropertiesForTesting(root.get(),
@@ -2801,13 +2740,13 @@ TEST_F(LayerTreeHostCommonTest,
EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
// Layers that do not draw content should have empty visible content rects.
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child->visible_layer_rect());
// All grandchild visible content rects should be clipped by child.
- EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grand_child1->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_content_rect());
- EXPECT_TRUE(grand_child3->visible_content_rect().IsEmpty());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grand_child1->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_layer_rect());
+ EXPECT_TRUE(grand_child3->visible_layer_rect().IsEmpty());
// All grandchild DrawableContentRects should also be clipped by child.
EXPECT_EQ(gfx::Rect(5, 5, 50, 50), grand_child1->drawable_content_rect());
@@ -2816,15 +2755,14 @@ TEST_F(LayerTreeHostCommonTest,
}
TEST_F(LayerTreeHostCommonTest, VisibleContentRectWithClippingAndScaling) {
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> grand_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(child);
child->AddChild(grand_child);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform identity_matrix;
gfx::Transform child_scale_matrix;
@@ -2840,7 +2778,7 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectWithClippingAndScaling) {
gfx::Size(100, 100), true, false);
child->SetMasksToBounds(true);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
// The visible rect is expanded to integer coordinates in target space before
// being projected back to layer space, where it is once again expanded to
@@ -2850,21 +2788,20 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectWithClippingAndScaling) {
TEST_F(LayerTreeHostCommonTest,
DrawableAndVisibleContentRectsForLayersInUnclippedRenderSurface) {
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> render_surface1 = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child3 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(render_surface1);
render_surface1->AddChild(child1);
render_surface1->AddChild(child2);
render_surface1->AddChild(child3);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform identity_matrix;
SetLayerPropertiesForTesting(root.get(),
@@ -2913,8 +2850,8 @@ TEST_F(LayerTreeHostCommonTest,
EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
// Layers that do not draw content should have empty visible content rects.
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_layer_rect());
// An unclipped surface grows its DrawableContentRect to include all drawable
// regions of the subtree.
@@ -2922,9 +2859,9 @@ TEST_F(LayerTreeHostCommonTest,
render_surface1->render_surface()->DrawableContentRect());
// All layers that draw content into the unclipped surface are also unclipped.
- EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect());
EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
@@ -2933,19 +2870,18 @@ TEST_F(LayerTreeHostCommonTest,
TEST_F(LayerTreeHostCommonTest,
VisibleContentRectsForClippedSurfaceWithEmptyClip) {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child3 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(child1);
root->AddChild(child2);
root->AddChild(child3);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform identity_matrix;
SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
@@ -2976,20 +2912,19 @@ TEST_F(LayerTreeHostCommonTest,
// Visible content rect calculation will check if the target surface is
// clipped or not. An empty clip rect does not indicate the render surface
// is unclipped.
- EXPECT_EQ(empty, child1->visible_content_rect());
- EXPECT_EQ(empty, child2->visible_content_rect());
- EXPECT_EQ(empty, child3->visible_content_rect());
+ EXPECT_EQ(empty, child1->visible_layer_rect());
+ EXPECT_EQ(empty, child2->visible_layer_rect());
+ EXPECT_EQ(empty, child3->visible_layer_rect());
}
TEST_F(LayerTreeHostCommonTest,
DrawableAndVisibleContentRectsForLayersWithUninvertibleTransform) {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(child);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
// Case 1: a truly degenerate matrix
gfx::Transform identity_matrix;
@@ -3013,7 +2948,7 @@ TEST_F(LayerTreeHostCommonTest,
ExecuteCalculateDrawProperties(root.get());
- EXPECT_TRUE(child->visible_content_rect().IsEmpty());
+ EXPECT_TRUE(child->visible_layer_rect().IsEmpty());
EXPECT_TRUE(child->drawable_content_rect().IsEmpty());
// Case 2: a matrix with flattened z, uninvertible and not visible according
@@ -3032,7 +2967,7 @@ TEST_F(LayerTreeHostCommonTest,
ExecuteCalculateDrawProperties(root.get());
- EXPECT_TRUE(child->visible_content_rect().IsEmpty());
+ EXPECT_TRUE(child->visible_layer_rect().IsEmpty());
EXPECT_TRUE(child->drawable_content_rect().IsEmpty());
// Case 3: a matrix with flattened z, also uninvertible and not visible.
@@ -3051,19 +2986,18 @@ TEST_F(LayerTreeHostCommonTest,
ExecuteCalculateDrawProperties(root.get());
- EXPECT_TRUE(child->visible_content_rect().IsEmpty());
+ EXPECT_TRUE(child->visible_layer_rect().IsEmpty());
EXPECT_TRUE(child->drawable_content_rect().IsEmpty());
}
TEST_F(LayerTreeHostCommonTest,
SingularTransformDoesNotPreventClearingDrawProperties) {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(child);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform identity_matrix;
gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
@@ -3084,7 +3018,7 @@ TEST_F(LayerTreeHostCommonTest,
true,
false);
- child->draw_properties().sorted_for_recursion = true;
+ child->set_sorted_for_recursion(true);
TransformOperations start_transform_operations;
start_transform_operations.AppendScale(1.f, 0.f, 0.f);
@@ -3099,15 +3033,14 @@ TEST_F(LayerTreeHostCommonTest,
ExecuteCalculateDrawProperties(root.get());
- EXPECT_FALSE(child->draw_properties().sorted_for_recursion);
+ EXPECT_FALSE(child->sorted_for_recursion());
}
TEST_F(LayerTreeHostCommonTest,
SingularNonAnimatingTransformDoesNotPreventClearingDrawProperties) {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform identity_matrix;
gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
@@ -3121,32 +3054,31 @@ TEST_F(LayerTreeHostCommonTest,
true,
false);
- root->draw_properties().sorted_for_recursion = true;
+ root->set_sorted_for_recursion(true);
EXPECT_FALSE(root->TransformIsAnimating());
ExecuteCalculateDrawProperties(root.get());
- EXPECT_FALSE(root->draw_properties().sorted_for_recursion);
+ EXPECT_FALSE(root->sorted_for_recursion());
}
TEST_F(LayerTreeHostCommonTest,
DrawableAndVisibleContentRectsForLayersInClippedRenderSurface) {
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> render_surface1 = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child3 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(render_surface1);
render_surface1->AddChild(child1);
render_surface1->AddChild(child2);
render_surface1->AddChild(child3);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform identity_matrix;
SetLayerPropertiesForTesting(root.get(),
@@ -3196,8 +3128,8 @@ TEST_F(LayerTreeHostCommonTest,
EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
// Layers that do not draw content should have empty visible content rects.
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_layer_rect());
// A clipped surface grows its DrawableContentRect to include all drawable
// regions of the subtree, but also gets clamped by the ancestor's clip.
@@ -3206,9 +3138,9 @@ TEST_F(LayerTreeHostCommonTest,
// All layers that draw content into the surface have their visible content
// rect clipped by the surface clip rect.
- EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_content_rect());
- EXPECT_TRUE(child3->visible_content_rect().IsEmpty());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect());
+ EXPECT_TRUE(child3->visible_layer_rect().IsEmpty());
// But the DrawableContentRects are unclipped.
EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
@@ -3219,23 +3151,22 @@ TEST_F(LayerTreeHostCommonTest,
TEST_F(LayerTreeHostCommonTest,
DrawableAndVisibleContentRectsForSurfaceHierarchy) {
// Check that clipping does not propagate down surfaces.
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> render_surface1 = Layer::Create();
- scoped_refptr<Layer> render_surface2 = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface2 = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child3 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(render_surface1);
render_surface1->AddChild(render_surface2);
render_surface2->AddChild(child1);
render_surface2->AddChild(child2);
render_surface2->AddChild(child3);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform identity_matrix;
SetLayerPropertiesForTesting(root.get(),
@@ -3294,9 +3225,9 @@ TEST_F(LayerTreeHostCommonTest,
EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
// Layers that do not draw content should have empty visible content rects.
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface2->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface2->visible_layer_rect());
// A clipped surface grows its DrawableContentRect to include all drawable
// regions of the subtree, but also gets clamped by the ancestor's clip.
@@ -3310,9 +3241,9 @@ TEST_F(LayerTreeHostCommonTest,
render_surface2->render_surface()->DrawableContentRect());
// All layers that draw content into render_surface2 think they are unclipped.
- EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect());
// DrawableContentRects are also unclipped.
EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
@@ -3325,15 +3256,14 @@ TEST_F(LayerTreeHostCommonTest,
// Layers that have non-axis aligned bounds (due to transforms) have an
// expanded, axis-aligned DrawableContentRect and visible content rect.
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> render_surface1 = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(render_surface1);
render_surface1->AddChild(child1);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform identity_matrix;
gfx::Transform child_rotation;
@@ -3370,8 +3300,8 @@ TEST_F(LayerTreeHostCommonTest,
EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
// Layers that do not draw content should have empty visible content rects.
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_layer_rect());
// The unclipped surface grows its DrawableContentRect to include all drawable
// regions of the subtree.
@@ -3385,7 +3315,7 @@ TEST_F(LayerTreeHostCommonTest,
render_surface1->render_surface()->DrawableContentRect());
// All layers that draw content into the unclipped surface are also unclipped.
- EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
EXPECT_EQ(expected_surface_drawable_content, child1->drawable_content_rect());
}
@@ -3394,15 +3324,14 @@ TEST_F(LayerTreeHostCommonTest,
// Layers that have non-axis aligned bounds (due to transforms) have an
// expanded, axis-aligned DrawableContentRect and visible content rect.
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> render_surface1 = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(render_surface1);
render_surface1->AddChild(child1);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform identity_matrix;
gfx::Transform child_rotation;
@@ -3453,7 +3382,7 @@ TEST_F(LayerTreeHostCommonTest,
// up covering the full left half of child1.
//
// Given the floating point math, this number is a little bit fuzzy.
- EXPECT_EQ(gfx::Rect(0, 0, 26, 50), child1->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 26, 50), child1->visible_layer_rect());
// The child's DrawableContentRect is unclipped.
EXPECT_EQ(unclipped_surface_content, child1->drawable_content_rect());
@@ -3462,22 +3391,24 @@ TEST_F(LayerTreeHostCommonTest,
TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsInHighDPI) {
MockContentLayerClient client;
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<FakePictureLayer> render_surface1 =
- CreateDrawablePictureLayer(&client);
+ CreateDrawablePictureLayer(layer_settings(), &client);
scoped_refptr<FakePictureLayer> render_surface2 =
- CreateDrawablePictureLayer(&client);
- scoped_refptr<FakePictureLayer> child1 = CreateDrawablePictureLayer(&client);
- scoped_refptr<FakePictureLayer> child2 = CreateDrawablePictureLayer(&client);
- scoped_refptr<FakePictureLayer> child3 = CreateDrawablePictureLayer(&client);
+ CreateDrawablePictureLayer(layer_settings(), &client);
+ scoped_refptr<FakePictureLayer> child1 =
+ CreateDrawablePictureLayer(layer_settings(), &client);
+ scoped_refptr<FakePictureLayer> child2 =
+ CreateDrawablePictureLayer(layer_settings(), &client);
+ scoped_refptr<FakePictureLayer> child3 =
+ CreateDrawablePictureLayer(layer_settings(), &client);
root->AddChild(render_surface1);
render_surface1->AddChild(render_surface2);
render_surface2->AddChild(child1);
render_surface2->AddChild(child2);
render_surface2->AddChild(child3);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform identity_matrix;
SetLayerPropertiesForTesting(root.get(),
@@ -3551,15 +3482,15 @@ TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsInHighDPI) {
EXPECT_EQ(gfx::Rect(250, 250, 100, 100), child3->drawable_content_rect());
// The root layer does not actually draw content of its own.
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
// All layer visible content rects are not expressed in content space of each
// layer, so they are not scaled by the device_scale_factor.
- EXPECT_EQ(gfx::Rect(0, 0, 3, 4), render_surface1->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 7, 13), render_surface2->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 3, 4), render_surface1->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 7, 13), render_surface2->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect());
}
TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) {
@@ -3568,27 +3499,27 @@ TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) {
// "flattened" to each parent layer according to current W3C spec.
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> parent = Layer::Create();
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> front_facing_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> back_facing_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent>
front_facing_child_of_front_facing_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent>
back_facing_child_of_front_facing_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent>
front_facing_child_of_back_facing_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent>
back_facing_child_of_back_facing_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
parent->AddChild(front_facing_child);
parent->AddChild(back_facing_child);
@@ -3599,8 +3530,7 @@ TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) {
back_facing_surface->AddChild(front_facing_child_of_back_facing_surface);
back_facing_surface->AddChild(back_facing_child_of_back_facing_surface);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
// Nothing is double-sided
front_facing_child->SetDoubleSided(false);
@@ -3770,31 +3700,31 @@ TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) {
// is used.
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> parent = Layer::Create();
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> front_facing_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> back_facing_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent>
- front_facing_child_of_front_facing_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ front_facing_child_of_front_facing_surface =
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent>
- back_facing_child_of_front_facing_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ back_facing_child_of_front_facing_surface =
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent>
- front_facing_child_of_back_facing_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ front_facing_child_of_back_facing_surface =
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent>
- back_facing_child_of_back_facing_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ back_facing_child_of_back_facing_surface =
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> dummy_replica_layer1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> dummy_replica_layer2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
parent->AddChild(front_facing_child);
parent->AddChild(back_facing_child);
@@ -3805,8 +3735,7 @@ TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) {
back_facing_surface->AddChild(front_facing_child_of_back_facing_surface);
back_facing_surface->AddChild(back_facing_child_of_back_facing_surface);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
// Nothing is double-sided
front_facing_child->SetDoubleSided(false);
@@ -3955,17 +3884,17 @@ TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) {
// transforms should be treated as "unknown" so we can not be sure that their
// back face is really showing.
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> parent = Layer::Create();
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> animating_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child_of_animating_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> animating_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
parent->AddChild(child);
parent->AddChild(animating_surface);
@@ -3973,8 +3902,7 @@ TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) {
parent->AddChild(animating_child);
parent->AddChild(child2);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
// Nothing is double-sided
child->SetDoubleSided(false);
@@ -4084,18 +4012,18 @@ TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) {
render_surface_layer_list.at(1)
->render_surface()->layer_list().at(1)->id());
- EXPECT_FALSE(child2->visible_content_rect().IsEmpty());
+ EXPECT_FALSE(child2->visible_layer_rect().IsEmpty());
// The animating layers should have a visible content rect that represents the
// area of the front face that is within the viewport.
- EXPECT_EQ(animating_child->visible_content_rect(),
- gfx::Rect(animating_child->content_bounds()));
- EXPECT_EQ(animating_surface->visible_content_rect(),
- gfx::Rect(animating_surface->content_bounds()));
+ EXPECT_EQ(animating_child->visible_layer_rect(),
+ gfx::Rect(animating_child->bounds()));
+ EXPECT_EQ(animating_surface->visible_layer_rect(),
+ gfx::Rect(animating_surface->bounds()));
// And layers in the subtree of the animating layer should have valid visible
// content rects also.
- EXPECT_EQ(child_of_animating_surface->visible_content_rect(),
- gfx::Rect(child_of_animating_surface->content_bounds()));
+ EXPECT_EQ(child_of_animating_surface->visible_layer_rect(),
+ gfx::Rect(child_of_animating_surface->bounds()));
}
TEST_F(LayerTreeHostCommonTest,
@@ -4104,23 +4032,22 @@ TEST_F(LayerTreeHostCommonTest,
// created when it flattens its subtree, and its parent has preserves-3d.
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> parent = Layer::Create();
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
parent->AddChild(front_facing_surface);
parent->AddChild(back_facing_surface);
front_facing_surface->AddChild(child1);
back_facing_surface->AddChild(child2);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
// RenderSurfaces are not double-sided
front_facing_surface->SetDoubleSided(false);
@@ -4212,110 +4139,50 @@ TEST_F(LayerTreeHostCommonTest,
->render_surface()->layer_list().at(1)->id());
}
-class NoScaleContentLayer : public ContentLayer {
- public:
- static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) {
- return make_scoped_refptr(new NoScaleContentLayer(client));
- }
-
- void CalculateContentsScale(float ideal_contents_scale,
- float* contents_scale_x,
- float* contents_scale_y,
- gfx::Size* content_bounds) override {
- // Skip over the ContentLayer to the base Layer class.
- Layer::CalculateContentsScale(ideal_contents_scale,
- contents_scale_x,
- contents_scale_y,
- content_bounds);
- }
-
- protected:
- explicit NoScaleContentLayer(ContentLayerClient* client)
- : ContentLayer(client) {}
- ~NoScaleContentLayer() override {}
-};
-
-scoped_refptr<NoScaleContentLayer> CreateNoScaleDrawableContentLayer(
- ContentLayerClient* delegate) {
- scoped_refptr<NoScaleContentLayer> to_return =
- NoScaleContentLayer::Create(delegate);
- to_return->SetIsDrawable(true);
- return to_return;
-}
-
-TEST_F(LayerTreeHostCommonTest, LayerTransformsInHighDPI) {
+TEST_F(LayerTreeHostCommonScalingTest, LayerTransformsInHighDPI) {
// Verify draw and screen space transforms of layers not in a surface.
- MockContentLayerClient delegate;
gfx::Transform identity_matrix;
- scoped_refptr<FakePictureLayer> parent =
- CreateDrawablePictureLayer(&delegate);
- SetLayerPropertiesForTesting(parent.get(),
- identity_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(100, 100),
- false,
- true);
-
- scoped_refptr<FakePictureLayer> child = CreateDrawablePictureLayer(&delegate);
- SetLayerPropertiesForTesting(child.get(),
- identity_matrix,
- gfx::Point3F(),
- gfx::PointF(2.f, 2.f),
- gfx::Size(10, 10),
- false,
+ LayerImpl* parent = root_layer();
+ SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), false, true,
true);
- scoped_refptr<FakePictureLayer> child_empty =
- CreateDrawablePictureLayer(&delegate);
- SetLayerPropertiesForTesting(child_empty.get(),
- identity_matrix,
- gfx::Point3F(),
- gfx::PointF(2.f, 2.f),
- gfx::Size(),
- false,
- true);
-
- parent->AddChild(child);
- parent->AddChild(child_empty);
+ LayerImpl* child = AddChildToRoot<LayerImpl>();
+ SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
+ gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false,
+ true, false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ LayerImpl* child_empty = AddChildToRoot<LayerImpl>();
+ SetLayerPropertiesForTesting(child_empty, identity_matrix, gfx::Point3F(),
+ gfx::PointF(2.f, 2.f), gfx::Size(), false, true,
+ false);
float device_scale_factor = 2.5f;
- float page_scale_factor = 1.f;
+ gfx::Size viewport_size(100, 100);
+ ExecuteCalculateDrawProperties(parent, device_scale_factor);
- RenderSurfaceLayerList render_surface_layer_list;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- parent.get(), parent->bounds(), &render_surface_layer_list);
- inputs.device_scale_factor = device_scale_factor;
- inputs.page_scale_factor = page_scale_factor;
- inputs.can_adjust_raster_scales = true;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
-
- EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, parent);
- EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, child);
- EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, child_empty);
+ EXPECT_IDEAL_SCALE_EQ(device_scale_factor, parent);
+ EXPECT_IDEAL_SCALE_EQ(device_scale_factor, child);
+ EXPECT_IDEAL_SCALE_EQ(device_scale_factor, child_empty);
- EXPECT_EQ(1u, render_surface_layer_list.size());
+ EXPECT_EQ(1u, render_surface_layer_list_impl()->size());
// Verify parent transforms
gfx::Transform expected_parent_transform;
- expected_parent_transform.Scale(device_scale_factor * page_scale_factor,
- device_scale_factor * page_scale_factor);
+ expected_parent_transform.Scale(device_scale_factor, device_scale_factor);
EXPECT_TRANSFORMATION_MATRIX_EQ(expected_parent_transform,
parent->screen_space_transform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expected_parent_transform,
parent->draw_transform());
// Verify results of transformed parent rects
- gfx::RectF parent_content_bounds(parent->content_bounds());
+ gfx::RectF parent_bounds(parent->bounds());
gfx::RectF parent_draw_rect =
- MathUtil::MapClippedRect(parent->draw_transform(), parent_content_bounds);
- gfx::RectF parent_screen_space_rect = MathUtil::MapClippedRect(
- parent->screen_space_transform(), parent_content_bounds);
+ MathUtil::MapClippedRect(parent->draw_transform(), parent_bounds);
+ gfx::RectF parent_screen_space_rect =
+ MathUtil::MapClippedRect(parent->screen_space_transform(), parent_bounds);
gfx::RectF expected_parent_draw_rect(parent->bounds());
expected_parent_draw_rect.Scale(device_scale_factor);
@@ -4338,17 +4205,17 @@ TEST_F(LayerTreeHostCommonTest, LayerTransformsInHighDPI) {
// Verify results of transformed child and child_empty rects. They should
// match.
- gfx::RectF child_content_bounds(child->content_bounds());
+ gfx::RectF child_bounds(child->bounds());
gfx::RectF child_draw_rect =
- MathUtil::MapClippedRect(child->draw_transform(), child_content_bounds);
- gfx::RectF child_screen_space_rect = MathUtil::MapClippedRect(
- child->screen_space_transform(), child_content_bounds);
+ MathUtil::MapClippedRect(child->draw_transform(), child_bounds);
+ gfx::RectF child_screen_space_rect =
+ MathUtil::MapClippedRect(child->screen_space_transform(), child_bounds);
- gfx::RectF child_empty_draw_rect = MathUtil::MapClippedRect(
- child_empty->draw_transform(), child_content_bounds);
+ gfx::RectF child_empty_draw_rect =
+ MathUtil::MapClippedRect(child_empty->draw_transform(), child_bounds);
gfx::RectF child_empty_screen_space_rect = MathUtil::MapClippedRect(
- child_empty->screen_space_transform(), child_content_bounds);
+ child_empty->screen_space_transform(), child_bounds);
gfx::RectF expected_child_draw_rect(child->position(), child->bounds());
expected_child_draw_rect.Scale(device_scale_factor);
@@ -4358,70 +4225,41 @@ TEST_F(LayerTreeHostCommonTest, LayerTransformsInHighDPI) {
EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_empty_screen_space_rect);
}
-TEST_F(LayerTreeHostCommonTest, SurfaceLayerTransformsInHighDPI) {
+TEST_F(LayerTreeHostCommonScalingTest, SurfaceLayerTransformsInHighDPI) {
// Verify draw and screen space transforms of layers in a surface.
- MockContentLayerClient delegate;
gfx::Transform identity_matrix;
-
gfx::Transform perspective_matrix;
perspective_matrix.ApplyPerspectiveDepth(2.0);
gfx::Transform scale_small_matrix;
scale_small_matrix.Scale(SK_MScalar1 / 10.f, SK_MScalar1 / 12.f);
- scoped_refptr<Layer> root = Layer::Create();
-
- scoped_refptr<FakePictureLayer> parent =
- CreateDrawablePictureLayer(&delegate);
- SetLayerPropertiesForTesting(parent.get(),
- identity_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(100, 100),
- false,
- true);
+ LayerImpl* root = root_layer();
+ SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), false, true,
+ false);
+ LayerImpl* parent = AddChildToRoot<LayerImpl>();
+ SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), false, true,
+ false);
- scoped_refptr<FakePictureLayer> perspective_surface =
- CreateDrawablePictureLayer(&delegate);
- SetLayerPropertiesForTesting(perspective_surface.get(),
+ LayerImpl* perspective_surface = AddChild<LayerImpl>(parent);
+ SetLayerPropertiesForTesting(perspective_surface,
perspective_matrix * scale_small_matrix,
- gfx::Point3F(),
- gfx::PointF(2.f, 2.f),
- gfx::Size(10, 10),
- false,
- true);
+ gfx::Point3F(), gfx::PointF(2.f, 2.f),
+ gfx::Size(10, 10), false, true, true);
+ perspective_surface->SetDrawsContent(true);
- scoped_refptr<FakePictureLayer> scale_surface =
- CreateDrawablePictureLayer(&delegate);
- SetLayerPropertiesForTesting(scale_surface.get(),
- scale_small_matrix,
- gfx::Point3F(),
- gfx::PointF(2.f, 2.f),
- gfx::Size(10, 10),
- false,
- true);
-
- perspective_surface->SetForceRenderSurface(true);
- scale_surface->SetForceRenderSurface(true);
-
- parent->AddChild(perspective_surface);
- parent->AddChild(scale_surface);
- root->AddChild(parent);
-
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ LayerImpl* scale_surface = AddChild<LayerImpl>(parent);
+ SetLayerPropertiesForTesting(scale_surface, scale_small_matrix,
+ gfx::Point3F(), gfx::PointF(2.f, 2.f),
+ gfx::Size(10, 10), false, true, true);
+ scale_surface->SetDrawsContent(true);
float device_scale_factor = 2.5f;
float page_scale_factor = 3.f;
-
- RenderSurfaceLayerList render_surface_layer_list;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root.get(), parent->bounds(), &render_surface_layer_list);
- inputs.device_scale_factor = device_scale_factor;
- inputs.page_scale_factor = page_scale_factor;
- inputs.page_scale_application_layer = root.get();
- inputs.can_adjust_raster_scales = true;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
+ ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor,
+ root);
EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, parent);
EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor,
@@ -4446,7 +4284,7 @@ TEST_F(LayerTreeHostCommonTest, SurfaceLayerTransformsInHighDPI) {
std::max(target_space_transform_scales.x(),
target_space_transform_scales.y()));
- EXPECT_EQ(3u, render_surface_layer_list.size());
+ EXPECT_EQ(3u, render_surface_layer_list_impl()->size());
gfx::Transform expected_parent_draw_transform;
expected_parent_draw_transform.Scale(device_scale_factor * page_scale_factor,
@@ -4478,422 +4316,7 @@ TEST_F(LayerTreeHostCommonTest, SurfaceLayerTransformsInHighDPI) {
perspective_surface->draw_transform());
}
-// TODO(sohanjg): Remove this test when ContentLayer is removed.
-TEST_F(LayerTreeHostCommonTest,
- LayerTransformsInHighDPIAccurateScaleZeroChildPosition) {
- // Verify draw and screen space transforms of layers not in a surface.
- MockContentLayerClient delegate;
- gfx::Transform identity_matrix;
-
- scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(parent.get(),
- identity_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(133, 133),
- false,
- true);
-
- scoped_refptr<ContentLayer> child = CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(child.get(),
- identity_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(13, 13),
- false,
- true);
-
- scoped_refptr<NoScaleContentLayer> child_no_scale =
- CreateNoScaleDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(child_no_scale.get(),
- identity_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(13, 13),
- false,
- true);
-
- parent->AddChild(child);
- parent->AddChild(child_no_scale);
-
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
-
- float device_scale_factor = 1.7f;
- float page_scale_factor = 1.f;
-
- RenderSurfaceLayerList render_surface_layer_list;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- parent.get(), parent->bounds(), &render_surface_layer_list);
- inputs.device_scale_factor = device_scale_factor;
- inputs.page_scale_factor = page_scale_factor;
- inputs.page_scale_application_layer = parent.get();
- inputs.can_adjust_raster_scales = true;
- inputs.verify_property_trees = false;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
-
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, parent);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, child);
- EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale);
-
- EXPECT_EQ(1u, render_surface_layer_list.size());
-
- // Verify parent transforms
- gfx::Transform expected_parent_transform;
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_parent_transform,
- parent->screen_space_transform());
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_parent_transform,
- parent->draw_transform());
-
- // Verify results of transformed parent rects
- gfx::RectF parent_content_bounds(parent->content_bounds());
-
- gfx::RectF parent_draw_rect =
- MathUtil::MapClippedRect(parent->draw_transform(), parent_content_bounds);
- gfx::RectF parent_screen_space_rect = MathUtil::MapClippedRect(
- parent->screen_space_transform(), parent_content_bounds);
-
- gfx::RectF expected_parent_draw_rect(parent->bounds());
- expected_parent_draw_rect.Scale(device_scale_factor);
- expected_parent_draw_rect.set_width(ceil(expected_parent_draw_rect.width()));
- expected_parent_draw_rect.set_height(
- ceil(expected_parent_draw_rect.height()));
- EXPECT_FLOAT_RECT_EQ(expected_parent_draw_rect, parent_draw_rect);
- EXPECT_FLOAT_RECT_EQ(expected_parent_draw_rect, parent_screen_space_rect);
-
- // Verify child transforms
- gfx::Transform expected_child_transform;
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform,
- child->draw_transform());
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform,
- child->screen_space_transform());
-
- // Verify results of transformed child rects
- gfx::RectF child_content_bounds(child->content_bounds());
-
- gfx::RectF child_draw_rect =
- MathUtil::MapClippedRect(child->draw_transform(), child_content_bounds);
- gfx::RectF child_screen_space_rect = MathUtil::MapClippedRect(
- child->screen_space_transform(), child_content_bounds);
-
- gfx::RectF expected_child_draw_rect(child->bounds());
- expected_child_draw_rect.Scale(device_scale_factor);
- expected_child_draw_rect.set_width(ceil(expected_child_draw_rect.width()));
- expected_child_draw_rect.set_height(ceil(expected_child_draw_rect.height()));
- EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_draw_rect);
- EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_screen_space_rect);
-
- // Verify child_no_scale transforms
- gfx::Transform expected_child_no_scale_transform = child->draw_transform();
- // All transforms operate on content rects. The child's content rect
- // incorporates device scale, but the child_no_scale does not; add it here.
- expected_child_no_scale_transform.Scale(device_scale_factor,
- device_scale_factor);
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_no_scale_transform,
- child_no_scale->draw_transform());
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_no_scale_transform,
- child_no_scale->screen_space_transform());
-}
-
-// TODO(sohanjg): Remove this test when ContentLayer is removed.
-TEST_F(LayerTreeHostCommonTest, ContentsScale) {
- MockContentLayerClient delegate;
- gfx::Transform identity_matrix;
-
- gfx::Transform parent_scale_matrix;
- SkMScalar initial_parent_scale = 1.75;
- parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
-
- gfx::Transform child_scale_matrix;
- SkMScalar initial_child_scale = 1.25;
- child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
-
- scoped_refptr<Layer> root = Layer::Create();
- root->SetBounds(gfx::Size(100, 100));
-
- scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(parent.get(),
- parent_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(100, 100),
- false,
- true);
-
- scoped_refptr<ContentLayer> child_scale =
- CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(child_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(2.f, 2.f),
- gfx::Size(10, 10),
- false,
- true);
-
- scoped_refptr<ContentLayer> child_empty =
- CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(child_empty.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(2.f, 2.f),
- gfx::Size(),
- false,
- true);
-
- scoped_refptr<NoScaleContentLayer> child_no_scale =
- CreateNoScaleDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(child_no_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(12.f, 12.f),
- gfx::Size(10, 10),
- false,
- true);
-
- root->AddChild(parent);
-
- parent->AddChild(child_scale);
- parent->AddChild(child_empty);
- parent->AddChild(child_no_scale);
-
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
-
- float device_scale_factor = 2.5f;
- float page_scale_factor = 1.f;
-
- {
- RenderSurfaceLayerList render_surface_layer_list;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root.get(), root->bounds(), &render_surface_layer_list);
- inputs.device_scale_factor = device_scale_factor;
- inputs.page_scale_factor = page_scale_factor;
- inputs.page_scale_application_layer = root.get();
- inputs.can_adjust_raster_scales = true;
- inputs.verify_property_trees = false;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
-
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale, parent);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- child_scale);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- child_empty);
- EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale);
-
- // The parent is scaled up and shouldn't need to scale during draw. The
- // child that can scale its contents should also not need to scale during
- // draw. This shouldn't change if the child has empty bounds. The other
- // children should.
- EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().get(1, 1));
- EXPECT_FLOAT_EQ(1.0, child_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(1.0, child_scale->draw_transform().matrix().get(1, 1));
- EXPECT_FLOAT_EQ(1.0, child_empty->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(1.0, child_empty->draw_transform().matrix().get(1, 1));
- EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- child_no_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- child_no_scale->draw_transform().matrix().get(1, 1));
- }
-
- // If the device_scale_factor or page_scale_factor changes, then it should be
- // updated using the initial transform as the raster scale.
- device_scale_factor = 2.25f;
- page_scale_factor = 1.25f;
-
- {
- RenderSurfaceLayerList render_surface_layer_list;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root.get(), root->bounds(), &render_surface_layer_list);
- inputs.device_scale_factor = device_scale_factor;
- inputs.page_scale_factor = page_scale_factor;
- inputs.page_scale_application_layer = root.get();
- inputs.can_adjust_raster_scales = true;
- inputs.verify_property_trees = false;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
-
- EXPECT_CONTENTS_SCALE_EQ(
- device_scale_factor * page_scale_factor * initial_parent_scale, parent);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- child_scale);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- child_empty);
- EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale);
- }
-
- // If the transform changes, we expect the raster scale to be reset to 1.0.
- SkMScalar second_child_scale = 1.75;
- child_scale_matrix.Scale(second_child_scale / initial_child_scale,
- second_child_scale / initial_child_scale);
- child_scale->SetTransform(child_scale_matrix);
- child_empty->SetTransform(child_scale_matrix);
-
- {
- RenderSurfaceLayerList render_surface_layer_list;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root.get(), root->bounds(), &render_surface_layer_list);
- inputs.device_scale_factor = device_scale_factor;
- inputs.page_scale_factor = page_scale_factor;
- inputs.page_scale_application_layer = root.get();
- inputs.can_adjust_raster_scales = true;
- inputs.verify_property_trees = false;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
-
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale,
- parent);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor,
- child_scale);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor,
- child_empty);
- EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale);
- }
-
- // If the device_scale_factor or page_scale_factor changes, then it should be
- // updated, but still using 1.0 as the raster scale.
- device_scale_factor = 2.75f;
- page_scale_factor = 1.75f;
-
- {
- RenderSurfaceLayerList render_surface_layer_list;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root.get(), root->bounds(), &render_surface_layer_list);
- inputs.device_scale_factor = device_scale_factor;
- inputs.page_scale_factor = page_scale_factor;
- inputs.page_scale_application_layer = root.get();
- inputs.can_adjust_raster_scales = true;
- inputs.verify_property_trees = false;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
-
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale,
- parent);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor,
- child_scale);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor,
- child_empty);
- EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale);
- }
-}
-
-// TODO(sohanjg): Remove this test when ContentLayer is removed.
-TEST_F(LayerTreeHostCommonTest,
- ContentsScale_LayerTransformsDontAffectContentsScale) {
- MockContentLayerClient delegate;
- gfx::Transform identity_matrix;
-
- gfx::Transform parent_scale_matrix;
- SkMScalar initial_parent_scale = 1.75;
- parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
-
- gfx::Transform child_scale_matrix;
- SkMScalar initial_child_scale = 1.25;
- child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
-
- scoped_refptr<Layer> root = Layer::Create();
- root->SetBounds(gfx::Size(100, 100));
-
- scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(parent.get(),
- parent_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(100, 100),
- false,
- true);
-
- scoped_refptr<ContentLayer> child_scale =
- CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(child_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(2.f, 2.f),
- gfx::Size(10, 10),
- false,
- true);
-
- scoped_refptr<ContentLayer> child_empty =
- CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(child_empty.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(2.f, 2.f),
- gfx::Size(),
- false,
- true);
-
- scoped_refptr<NoScaleContentLayer> child_no_scale =
- CreateNoScaleDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(child_no_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(12.f, 12.f),
- gfx::Size(10, 10),
- false,
- true);
-
- root->AddChild(parent);
-
- parent->AddChild(child_scale);
- parent->AddChild(child_empty);
- parent->AddChild(child_no_scale);
-
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
-
- RenderSurfaceLayerList render_surface_layer_list;
-
- float device_scale_factor = 2.5f;
- float page_scale_factor = 1.f;
-
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root.get(), root->bounds(), &render_surface_layer_list);
- inputs.device_scale_factor = device_scale_factor;
- inputs.page_scale_factor = page_scale_factor;
- inputs.page_scale_application_layer = root.get();
- inputs.verify_property_trees = false;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
-
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, parent);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor,
- child_scale);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor,
- child_empty);
- EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale);
-
- // Since the transform scale does not affect contents scale, it should affect
- // the draw transform instead.
- EXPECT_FLOAT_EQ(initial_parent_scale,
- parent->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(initial_parent_scale,
- parent->draw_transform().matrix().get(1, 1));
- EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale,
- child_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale,
- child_scale->draw_transform().matrix().get(1, 1));
- EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale,
- child_empty->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale,
- child_empty->draw_transform().matrix().get(1, 1));
- EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- child_no_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- child_no_scale->draw_transform().matrix().get(1, 1));
-}
-
-TEST_F(LayerTreeHostCommonTest, SmallIdealScale) {
- MockContentLayerClient delegate;
- gfx::Transform identity_matrix;
-
+TEST_F(LayerTreeHostCommonScalingTest, SmallIdealScale) {
gfx::Transform parent_scale_matrix;
SkMScalar initial_parent_scale = 1.75;
parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
@@ -4902,48 +4325,25 @@ TEST_F(LayerTreeHostCommonTest, SmallIdealScale) {
SkMScalar initial_child_scale = 0.25;
child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
- scoped_refptr<Layer> root = Layer::Create();
+ LayerImpl* root = root_layer();
root->SetBounds(gfx::Size(100, 100));
- scoped_refptr<FakePictureLayer> parent =
- CreateDrawablePictureLayer(&delegate);
- SetLayerPropertiesForTesting(parent.get(),
- parent_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(100, 100),
- false,
- true);
-
- scoped_refptr<FakePictureLayer> child_scale =
- CreateDrawablePictureLayer(&delegate);
- SetLayerPropertiesForTesting(child_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(2.f, 2.f),
- gfx::Size(10, 10),
- false,
- true);
-
- root->AddChild(parent);
-
- parent->AddChild(child_scale);
+ LayerImpl* parent = AddChildToRoot<LayerImpl>();
+ SetLayerPropertiesForTesting(parent, parent_scale_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), false, true,
+ false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ LayerImpl* child_scale = AddChild<LayerImpl>(parent);
+ SetLayerPropertiesForTesting(child_scale, child_scale_matrix, gfx::Point3F(),
+ gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false,
+ true, false);
float device_scale_factor = 2.5f;
float page_scale_factor = 0.01f;
{
- RenderSurfaceLayerList render_surface_layer_list;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root.get(), root->bounds(), &render_surface_layer_list);
- inputs.device_scale_factor = device_scale_factor;
- inputs.page_scale_factor = page_scale_factor;
- inputs.page_scale_application_layer = root.get();
- inputs.can_adjust_raster_scales = true;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
+ ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor,
+ root);
// The ideal scale is able to go below 1.
float expected_ideal_scale =
@@ -4958,422 +4358,7 @@ TEST_F(LayerTreeHostCommonTest, SmallIdealScale) {
}
}
-TEST_F(LayerTreeHostCommonTest, ContentsScaleForSurfaces) {
- MockContentLayerClient delegate;
- gfx::Transform identity_matrix;
-
- gfx::Transform parent_scale_matrix;
- SkMScalar initial_parent_scale = 2.0;
- parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
-
- gfx::Transform child_scale_matrix;
- SkMScalar initial_child_scale = 3.0;
- child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
-
- scoped_refptr<Layer> root = Layer::Create();
- root->SetBounds(gfx::Size(100, 100));
-
- scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(parent.get(),
- parent_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(100, 100),
- false,
- true);
-
- scoped_refptr<ContentLayer> surface_scale =
- CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(surface_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(2.f, 2.f),
- gfx::Size(10, 10),
- false,
- true);
-
- scoped_refptr<ContentLayer> surface_scale_child_scale =
- CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(surface_scale_child_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(10, 10),
- false,
- true);
-
- scoped_refptr<NoScaleContentLayer> surface_scale_child_no_scale =
- CreateNoScaleDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(surface_scale_child_no_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(10, 10),
- false,
- true);
-
- scoped_refptr<NoScaleContentLayer> surface_no_scale =
- CreateNoScaleDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(surface_no_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(12.f, 12.f),
- gfx::Size(10, 10),
- false,
- true);
-
- scoped_refptr<ContentLayer> surface_no_scale_child_scale =
- CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(surface_no_scale_child_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(10, 10),
- false,
- true);
-
- scoped_refptr<NoScaleContentLayer> surface_no_scale_child_no_scale =
- CreateNoScaleDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(surface_no_scale_child_no_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(10, 10),
- false,
- true);
-
- root->AddChild(parent);
-
- parent->AddChild(surface_scale);
- parent->AddChild(surface_no_scale);
-
- surface_scale->SetForceRenderSurface(true);
- surface_scale->AddChild(surface_scale_child_scale);
- surface_scale->AddChild(surface_scale_child_no_scale);
-
- surface_no_scale->SetForceRenderSurface(true);
- surface_no_scale->AddChild(surface_no_scale_child_scale);
- surface_no_scale->AddChild(surface_no_scale_child_no_scale);
-
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
-
- SkMScalar device_scale_factor = 5;
- SkMScalar page_scale_factor = 7;
-
- RenderSurfaceLayerList render_surface_layer_list;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root.get(), root->bounds(), &render_surface_layer_list);
- inputs.device_scale_factor = device_scale_factor;
- inputs.page_scale_factor = page_scale_factor;
- inputs.page_scale_application_layer = root.get();
- inputs.can_adjust_raster_scales = true;
- inputs.verify_property_trees = false;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
-
- EXPECT_CONTENTS_SCALE_EQ(
- device_scale_factor * page_scale_factor * initial_parent_scale, parent);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- surface_scale);
- EXPECT_CONTENTS_SCALE_EQ(1, surface_no_scale);
- EXPECT_CONTENTS_SCALE_EQ(
- device_scale_factor * page_scale_factor * initial_parent_scale *
- initial_child_scale * initial_child_scale,
- surface_scale_child_scale);
- EXPECT_CONTENTS_SCALE_EQ(1, surface_scale_child_no_scale);
- EXPECT_CONTENTS_SCALE_EQ(
- device_scale_factor * page_scale_factor * initial_parent_scale *
- initial_child_scale * initial_child_scale,
- surface_no_scale_child_scale);
- EXPECT_CONTENTS_SCALE_EQ(1, surface_no_scale_child_no_scale);
-
- // The parent is scaled up and shouldn't need to scale during draw.
- EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().get(1, 1));
-
- // RenderSurfaces should always be 1:1 with their target.
- EXPECT_FLOAT_EQ(
- 1.0,
- surface_scale->render_surface()->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(
- 1.0,
- surface_scale->render_surface()->draw_transform().matrix().get(1, 1));
-
- // The surface_scale can apply contents scale so the layer shouldn't need to
- // scale during draw.
- EXPECT_FLOAT_EQ(1.0, surface_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(1.0, surface_scale->draw_transform().matrix().get(1, 1));
-
- // The surface_scale_child_scale can apply contents scale so it shouldn't need
- // to scale during draw.
- EXPECT_FLOAT_EQ(
- 1.0, surface_scale_child_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(
- 1.0, surface_scale_child_scale->draw_transform().matrix().get(1, 1));
-
- // The surface_scale_child_no_scale can not apply contents scale, so it needs
- // to be scaled during draw.
- EXPECT_FLOAT_EQ(
- device_scale_factor * page_scale_factor * initial_parent_scale *
- initial_child_scale * initial_child_scale,
- surface_scale_child_no_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(
- device_scale_factor * page_scale_factor * initial_parent_scale *
- initial_child_scale * initial_child_scale,
- surface_scale_child_no_scale->draw_transform().matrix().get(1, 1));
-
- // RenderSurfaces should always be 1:1 with their target.
- EXPECT_FLOAT_EQ(
- 1.0,
- surface_no_scale->render_surface()->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(
- 1.0,
- surface_no_scale->render_surface()->draw_transform().matrix().get(1, 1));
-
- // The surface_no_scale layer can not apply contents scale, so it needs to be
- // scaled during draw.
- EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- surface_no_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- surface_no_scale->draw_transform().matrix().get(1, 1));
-
- // The surface_scale_child_scale can apply contents scale so it shouldn't need
- // to scale during draw.
- EXPECT_FLOAT_EQ(
- 1.0, surface_no_scale_child_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(
- 1.0, surface_no_scale_child_scale->draw_transform().matrix().get(1, 1));
-
- // The surface_scale_child_no_scale can not apply contents scale, so it needs
- // to be scaled during draw.
- EXPECT_FLOAT_EQ(
- device_scale_factor * page_scale_factor * initial_parent_scale *
- initial_child_scale * initial_child_scale,
- surface_no_scale_child_no_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(
- device_scale_factor * page_scale_factor * initial_parent_scale *
- initial_child_scale * initial_child_scale,
- surface_no_scale_child_no_scale->draw_transform().matrix().get(1, 1));
-}
-
-// TODO(sohanjg): Remove this test when ContentLayer is removed.
-TEST_F(LayerTreeHostCommonTest,
- ContentsScaleForSurfaces_LayerTransformsDontAffectContentsScale) {
- MockContentLayerClient delegate;
- gfx::Transform identity_matrix;
-
- gfx::Transform parent_scale_matrix;
- SkMScalar initial_parent_scale = 2.0;
- parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
-
- gfx::Transform child_scale_matrix;
- SkMScalar initial_child_scale = 3.0;
- child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
-
- scoped_refptr<Layer> root = Layer::Create();
- root->SetBounds(gfx::Size(100, 100));
-
- scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(parent.get(),
- parent_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(100, 100),
- false,
- true);
-
- scoped_refptr<ContentLayer> surface_scale =
- CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(surface_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(2.f, 2.f),
- gfx::Size(10, 10),
- false,
- true);
-
- scoped_refptr<ContentLayer> surface_scale_child_scale =
- CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(surface_scale_child_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(10, 10),
- false,
- true);
-
- scoped_refptr<NoScaleContentLayer> surface_scale_child_no_scale =
- CreateNoScaleDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(surface_scale_child_no_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(10, 10),
- false,
- true);
-
- scoped_refptr<NoScaleContentLayer> surface_no_scale =
- CreateNoScaleDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(surface_no_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(12.f, 12.f),
- gfx::Size(10, 10),
- false,
- true);
-
- scoped_refptr<ContentLayer> surface_no_scale_child_scale =
- CreateDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(surface_no_scale_child_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(10, 10),
- false,
- true);
-
- scoped_refptr<NoScaleContentLayer> surface_no_scale_child_no_scale =
- CreateNoScaleDrawableContentLayer(&delegate);
- SetLayerPropertiesForTesting(surface_no_scale_child_no_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(10, 10),
- false,
- true);
-
- root->AddChild(parent);
-
- parent->AddChild(surface_scale);
- parent->AddChild(surface_no_scale);
-
- surface_scale->SetForceRenderSurface(true);
- surface_scale->AddChild(surface_scale_child_scale);
- surface_scale->AddChild(surface_scale_child_no_scale);
-
- surface_no_scale->SetForceRenderSurface(true);
- surface_no_scale->AddChild(surface_no_scale_child_scale);
- surface_no_scale->AddChild(surface_no_scale_child_no_scale);
-
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
-
- RenderSurfaceLayerList render_surface_layer_list;
-
- SkMScalar device_scale_factor = 5.0;
- SkMScalar page_scale_factor = 7.0;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root.get(), root->bounds(), &render_surface_layer_list);
- inputs.device_scale_factor = device_scale_factor;
- inputs.page_scale_factor = page_scale_factor;
- inputs.page_scale_application_layer = root.get();
- inputs.verify_property_trees = false;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
-
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor,
- parent);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor,
- surface_scale);
- EXPECT_CONTENTS_SCALE_EQ(1.f, surface_no_scale);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor,
- surface_scale_child_scale);
- EXPECT_CONTENTS_SCALE_EQ(1.f, surface_scale_child_no_scale);
- EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor,
- surface_no_scale_child_scale);
- EXPECT_CONTENTS_SCALE_EQ(1.f, surface_no_scale_child_no_scale);
-
- // The parent is scaled up during draw, since its contents are not scaled by
- // the transform hierarchy.
- EXPECT_FLOAT_EQ(initial_parent_scale,
- parent->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(initial_parent_scale,
- parent->draw_transform().matrix().get(1, 1));
-
- // The child surface is not scaled up during draw since its subtree is scaled
- // by the transform hierarchy.
- EXPECT_FLOAT_EQ(
- 1.f,
- surface_scale->render_surface()->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(
- 1.f,
- surface_scale->render_surface()->draw_transform().matrix().get(1, 1));
-
- // The surface_scale's RenderSurface is not scaled during draw, so the layer
- // needs to be scaled when drawing into its surface.
- EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale,
- surface_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale,
- surface_scale->draw_transform().matrix().get(1, 1));
-
- // The surface_scale_child_scale is not scaled when drawing into its surface,
- // since its content bounds are scaled by the transform hierarchy.
- EXPECT_FLOAT_EQ(
- initial_child_scale * initial_child_scale * initial_parent_scale,
- surface_scale_child_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(
- initial_child_scale * initial_child_scale * initial_parent_scale,
- surface_scale_child_scale->draw_transform().matrix().get(1, 1));
-
- // The surface_scale_child_no_scale is scaled by the device scale, page scale
- // and transform hierarchy.
- EXPECT_FLOAT_EQ(
- device_scale_factor * page_scale_factor * initial_parent_scale *
- initial_child_scale * initial_child_scale,
- surface_scale_child_no_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(
- device_scale_factor * page_scale_factor * initial_parent_scale *
- initial_child_scale * initial_child_scale,
- surface_scale_child_no_scale->draw_transform().matrix().get(1, 1));
-
- // The child surface is not scaled up during draw since its subtree is scaled
- // by the transform hierarchy.
- EXPECT_FLOAT_EQ(
- 1.f,
- surface_no_scale->render_surface()->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(
- 1.f,
- surface_no_scale->render_surface()->draw_transform().matrix().get(1, 1));
-
- // The surface_no_scale layer has a fixed contents scale of 1, so it needs to
- // be scaled by the device and page scale factors. Its surface is already
- // scaled by the transform hierarchy so those don't need to scale the layer's
- // drawing.
- EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale *
- device_scale_factor * page_scale_factor,
- surface_no_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale *
- device_scale_factor * page_scale_factor,
- surface_no_scale->draw_transform().matrix().get(1, 1));
-
- // The surface_no_scale_child_scale has its contents scaled by the page and
- // device scale factors, but needs to be scaled by the transform hierarchy
- // when drawing.
- EXPECT_FLOAT_EQ(
- initial_parent_scale * initial_child_scale * initial_child_scale,
- surface_no_scale_child_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(
- initial_parent_scale * initial_child_scale * initial_child_scale,
- surface_no_scale_child_scale->draw_transform().matrix().get(1, 1));
-
- // The surface_no_scale_child_no_scale needs to be scaled by the device and
- // page scale factors and by any transform heirarchy below its target surface.
- EXPECT_FLOAT_EQ(
- device_scale_factor * page_scale_factor * initial_parent_scale *
- initial_child_scale * initial_child_scale,
- surface_no_scale_child_no_scale->draw_transform().matrix().get(0, 0));
- EXPECT_FLOAT_EQ(
- device_scale_factor * page_scale_factor * initial_parent_scale *
- initial_child_scale * initial_child_scale,
- surface_no_scale_child_no_scale->draw_transform().matrix().get(1, 1));
-}
-
-TEST_F(LayerTreeHostCommonTest, IdealScaleForAnimatingLayer) {
- MockContentLayerClient delegate;
- gfx::Transform identity_matrix;
-
+TEST_F(LayerTreeHostCommonScalingTest, IdealScaleForAnimatingLayer) {
gfx::Transform parent_scale_matrix;
SkMScalar initial_parent_scale = 1.75;
parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
@@ -5382,42 +4367,21 @@ TEST_F(LayerTreeHostCommonTest, IdealScaleForAnimatingLayer) {
SkMScalar initial_child_scale = 1.25;
child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
- scoped_refptr<Layer> root = Layer::Create();
+ LayerImpl* root = root_layer();
root->SetBounds(gfx::Size(100, 100));
- scoped_refptr<FakePictureLayer> parent =
- CreateDrawablePictureLayer(&delegate);
- SetLayerPropertiesForTesting(parent.get(),
- parent_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(100, 100),
- false,
- true);
-
- scoped_refptr<FakePictureLayer> child_scale =
- CreateDrawablePictureLayer(&delegate);
- SetLayerPropertiesForTesting(child_scale.get(),
- child_scale_matrix,
- gfx::Point3F(),
- gfx::PointF(2.f, 2.f),
- gfx::Size(10, 10),
- false,
- true);
-
- root->AddChild(parent);
-
- parent->AddChild(child_scale);
+ LayerImpl* parent = AddChildToRoot<LayerImpl>();
+ SetLayerPropertiesForTesting(parent, parent_scale_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), false, true,
+ false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ LayerImpl* child_scale = AddChild<LayerImpl>(parent);
+ SetLayerPropertiesForTesting(child_scale, child_scale_matrix, gfx::Point3F(),
+ gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false,
+ true, false);
{
- RenderSurfaceLayerList render_surface_layer_list;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root.get(), root->bounds(), &render_surface_layer_list);
- inputs.can_adjust_raster_scales = true;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
+ ExecuteCalculateDrawProperties(root);
EXPECT_IDEAL_SCALE_EQ(initial_parent_scale, parent);
// Animating layers compute ideal scale in the same way as when
@@ -5427,74 +4391,12 @@ TEST_F(LayerTreeHostCommonTest, IdealScaleForAnimatingLayer) {
}
}
-// TODO(sohanjg): Remove this test when ContentLayer is removed.
-TEST_F(LayerTreeHostCommonTest,
- ChangeInContentBoundsOrScaleTriggersPushProperties) {
- MockContentLayerClient delegate;
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> child = CreateDrawableContentLayer(&delegate);
- root->AddChild(child);
-
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
-
- gfx::Transform identity_matrix;
- SetLayerPropertiesForTesting(root.get(),
- identity_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(100, 100),
- true,
- false);
- SetLayerPropertiesForTesting(child.get(),
- identity_matrix,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(100, 100),
- true,
- false);
-
- root->reset_needs_push_properties_for_testing();
- child->reset_needs_push_properties_for_testing();
-
- gfx::Size device_viewport_size = gfx::Size(100, 100);
- RenderSurfaceLayerList render_surface_layer_list;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root.get(), device_viewport_size, &render_surface_layer_list);
- inputs.device_scale_factor = 1.f;
- inputs.can_adjust_raster_scales = true;
- inputs.verify_property_trees = false;
-
- // This will change both layers' content bounds.
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
- EXPECT_TRUE(root->needs_push_properties());
- EXPECT_TRUE(child->needs_push_properties());
-
- root->reset_needs_push_properties_for_testing();
- child->reset_needs_push_properties_for_testing();
-
- // This will change only the child layer's contents scale and content bounds,
- // since the root layer is not a ContentsScalingLayer.
- inputs.device_scale_factor = 2.f;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
- EXPECT_FALSE(root->needs_push_properties());
- EXPECT_TRUE(child->needs_push_properties());
-
- root->reset_needs_push_properties_for_testing();
- child->reset_needs_push_properties_for_testing();
-
- // This will not change either layer's contents scale or content bounds.
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
- EXPECT_FALSE(root->needs_push_properties());
- EXPECT_FALSE(child->needs_push_properties());
-}
-
TEST_F(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) {
MockContentLayerClient delegate;
gfx::Transform identity_matrix;
scoped_refptr<FakePictureLayer> parent =
- CreateDrawablePictureLayer(&delegate);
+ CreateDrawablePictureLayer(layer_settings(), &delegate);
SetLayerPropertiesForTesting(parent.get(),
identity_matrix,
gfx::Point3F(),
@@ -5503,7 +4405,8 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) {
false,
true);
- scoped_refptr<FakePictureLayer> child = CreateDrawablePictureLayer(&delegate);
+ scoped_refptr<FakePictureLayer> child =
+ CreateDrawablePictureLayer(layer_settings(), &delegate);
SetLayerPropertiesForTesting(child.get(),
identity_matrix,
gfx::Point3F(),
@@ -5515,7 +4418,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) {
gfx::Transform replica_transform;
replica_transform.Scale(1.0, -1.0);
scoped_refptr<FakePictureLayer> replica =
- CreateDrawablePictureLayer(&delegate);
+ CreateDrawablePictureLayer(layer_settings(), &delegate);
SetLayerPropertiesForTesting(replica.get(),
replica_transform,
gfx::Point3F(),
@@ -5527,7 +4430,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) {
// This layer should end up in the same surface as child, with the same draw
// and screen space transforms.
scoped_refptr<FakePictureLayer> duplicate_child_non_owner =
- CreateDrawablePictureLayer(&delegate);
+ CreateDrawablePictureLayer(layer_settings(), &delegate);
SetLayerPropertiesForTesting(duplicate_child_non_owner.get(),
identity_matrix,
gfx::Point3F(),
@@ -5540,8 +4443,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) {
child->AddChild(duplicate_child_non_owner);
child->SetReplicaLayer(replica.get());
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
RenderSurfaceLayerList render_surface_layer_list;
@@ -5585,8 +4487,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) {
duplicate_child_non_owner->screen_space_transform());
EXPECT_EQ(child->drawable_content_rect(),
duplicate_child_non_owner->drawable_content_rect());
- EXPECT_EQ(child->content_bounds(),
- duplicate_child_non_owner->content_bounds());
+ EXPECT_EQ(child->bounds(), duplicate_child_non_owner->bounds());
gfx::Transform expected_render_surface_draw_transform;
expected_render_surface_draw_transform.Translate(
@@ -5634,7 +4535,7 @@ TEST_F(LayerTreeHostCommonTest,
gfx::Transform identity_matrix;
scoped_refptr<FakePictureLayer> parent =
- CreateDrawablePictureLayer(&delegate);
+ CreateDrawablePictureLayer(layer_settings(), &delegate);
SetLayerPropertiesForTesting(parent.get(),
identity_matrix,
gfx::Point3F(),
@@ -5643,7 +4544,8 @@ TEST_F(LayerTreeHostCommonTest,
false,
true);
- scoped_refptr<FakePictureLayer> child = CreateDrawablePictureLayer(&delegate);
+ scoped_refptr<FakePictureLayer> child =
+ CreateDrawablePictureLayer(layer_settings(), &delegate);
SetLayerPropertiesForTesting(child.get(),
identity_matrix,
gfx::Point3F(),
@@ -5655,7 +4557,7 @@ TEST_F(LayerTreeHostCommonTest,
gfx::Transform replica_transform;
replica_transform.Scale(1.0, -1.0);
scoped_refptr<FakePictureLayer> replica =
- CreateDrawablePictureLayer(&delegate);
+ CreateDrawablePictureLayer(layer_settings(), &delegate);
SetLayerPropertiesForTesting(replica.get(),
replica_transform,
gfx::Point3F(),
@@ -5667,8 +4569,7 @@ TEST_F(LayerTreeHostCommonTest,
parent->AddChild(child);
child->SetReplicaLayer(replica.get());
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(parent);
+ host()->SetRootLayer(parent);
float device_scale_factor = 1.7f;
@@ -5705,19 +4606,18 @@ TEST_F(LayerTreeHostCommonTest,
}
TEST_F(LayerTreeHostCommonTest, SubtreeSearch) {
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
- scoped_refptr<Layer> grand_child = Layer::Create();
- scoped_refptr<Layer> mask_layer = Layer::Create();
- scoped_refptr<Layer> replica_layer = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
+ scoped_refptr<Layer> mask_layer = Layer::Create(layer_settings());
+ scoped_refptr<Layer> replica_layer = Layer::Create(layer_settings());
grand_child->SetReplicaLayer(replica_layer.get());
child->AddChild(grand_child.get());
child->SetMaskLayer(mask_layer.get());
root->AddChild(child.get());
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
int nonexistent_id = -1;
EXPECT_EQ(root.get(),
@@ -5738,10 +4638,10 @@ TEST_F(LayerTreeHostCommonTest, SubtreeSearch) {
}
TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) {
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> grand_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
const gfx::Transform identity_matrix;
SetLayerPropertiesForTesting(root.get(),
@@ -5770,8 +4670,7 @@ TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) {
child->AddChild(grand_child);
child->SetOpacity(0.5f);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
ExecuteCalculateDrawProperties(root.get());
@@ -5781,7 +4680,9 @@ TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) {
TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
host_impl.CreatePendingTree();
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1);
@@ -5818,12 +4719,12 @@ TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) {
}
using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>;
-class LCDTextTest
- : public LayerTreeHostCommonTestBase,
- public testing::TestWithParam<LCDTextTestParam> {
+class LCDTextTest : public LayerTreeHostCommonTestBase,
+ public testing::TestWithParam<LCDTextTestParam> {
public:
LCDTextTest()
- : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_),
+ : LayerTreeHostCommonTestBase(LayerTreeSettings()),
+ host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_),
root_(nullptr),
child_(nullptr),
grand_child_(nullptr) {}
@@ -5853,6 +4754,10 @@ class LCDTextTest
child_->SetContentsOpaque(true);
grand_child_->SetContentsOpaque(true);
+ root_->SetDrawsContent(true);
+ child_->SetDrawsContent(true);
+ grand_child_->SetDrawsContent(true);
+
gfx::Transform identity_matrix;
SetLayerPropertiesForTesting(root_, identity_matrix, gfx::Point3F(),
gfx::PointF(), gfx::Size(1, 1), true, false,
@@ -5894,6 +4799,7 @@ TEST_P(LCDTextTest, CanUseLCDText) {
gfx::Transform integral_translation;
integral_translation.Translate(1.0, 2.0);
child_->SetTransform(integral_translation);
+ child_->layer_tree_impl()->property_trees()->needs_rebuild = true;
ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
layers_always_allowed_lcd_text_);
EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
@@ -5904,6 +4810,7 @@ TEST_P(LCDTextTest, CanUseLCDText) {
gfx::Transform non_integral_translation;
non_integral_translation.Translate(1.5, 2.5);
child_->SetTransform(non_integral_translation);
+ child_->layer_tree_impl()->property_trees()->needs_rebuild = true;
ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
layers_always_allowed_lcd_text_);
EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
@@ -5914,6 +4821,7 @@ TEST_P(LCDTextTest, CanUseLCDText) {
gfx::Transform rotation;
rotation.Rotate(10.0);
child_->SetTransform(rotation);
+ child_->layer_tree_impl()->property_trees()->needs_rebuild = true;
ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
layers_always_allowed_lcd_text_);
EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
@@ -5924,6 +4832,7 @@ TEST_P(LCDTextTest, CanUseLCDText) {
gfx::Transform scale;
scale.Scale(2.0, 2.0);
child_->SetTransform(scale);
+ child_->layer_tree_impl()->property_trees()->needs_rebuild = true;
ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
layers_always_allowed_lcd_text_);
EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
@@ -5934,6 +4843,7 @@ TEST_P(LCDTextTest, CanUseLCDText) {
gfx::Transform skew;
skew.SkewX(10.0);
child_->SetTransform(skew);
+ child_->layer_tree_impl()->property_trees()->needs_rebuild = true;
ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
layers_always_allowed_lcd_text_);
EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
@@ -5942,6 +4852,7 @@ TEST_P(LCDTextTest, CanUseLCDText) {
// Case 7: Translucent.
child_->SetTransform(identity_matrix);
+ child_->layer_tree_impl()->property_trees()->needs_rebuild = true;
child_->SetOpacity(0.5f);
ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
layers_always_allowed_lcd_text_);
@@ -5951,6 +4862,7 @@ TEST_P(LCDTextTest, CanUseLCDText) {
// Case 8: Sanity check: restore transform and opacity.
child_->SetTransform(identity_matrix);
+ child_->layer_tree_impl()->property_trees()->needs_rebuild = true;
child_->SetOpacity(1.f);
ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
layers_always_allowed_lcd_text_);
@@ -5988,6 +4900,7 @@ TEST_P(LCDTextTest, CanUseLCDTextWithAnimation) {
// Add opacity animation.
child_->SetOpacity(0.9f);
+ child_->layer_tree_impl()->property_trees()->needs_rebuild = true;
AddOpacityTransitionToController(
child_->layer_animation_controller(), 10.0, 0.9f, 0.1f, false);
@@ -6032,11 +4945,13 @@ INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest,
TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayer) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
host_impl.CreatePendingTree();
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(root.get(),
identity_matrix,
gfx::Point3F(),
@@ -6046,7 +4961,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayer) {
false);
root->SetIsDrawable(true);
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(child.get(),
identity_matrix,
gfx::Point3F(),
@@ -6056,7 +4971,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayer) {
false);
child->SetIsDrawable(true);
- scoped_refptr<Layer> grand_child = Layer::Create();
+ scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(grand_child.get(),
identity_matrix,
gfx::Point3F(),
@@ -6070,8 +4985,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayer) {
child->AddChild(grand_child);
root->AddChild(child);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
RenderSurfaceLayerList render_surface_layer_list;
LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
@@ -6090,7 +5004,9 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayer) {
TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
host_impl.CreatePendingTree();
const gfx::Transform identity_matrix;
@@ -6135,11 +5051,13 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) {
TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayers) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
host_impl.CreatePendingTree();
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(root.get(),
identity_matrix,
gfx::Point3F(),
@@ -6149,7 +5067,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayers) {
false);
root->SetIsDrawable(true);
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(child.get(),
identity_matrix,
gfx::Point3F(),
@@ -6160,7 +5078,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayers) {
child->SetIsDrawable(true);
child->SetHideLayerAndSubtree(true);
- scoped_refptr<Layer> grand_child = Layer::Create();
+ scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(grand_child.get(),
identity_matrix,
gfx::Point3F(),
@@ -6173,8 +5091,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayers) {
child->AddChild(grand_child);
root->AddChild(child);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
RenderSurfaceLayerList render_surface_layer_list;
LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
@@ -6192,7 +5109,9 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayers) {
TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
host_impl.CreatePendingTree();
const gfx::Transform identity_matrix;
@@ -6237,11 +5156,13 @@ void EmptyCopyOutputCallback(scoped_ptr<CopyOutputResult> result) {}
TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
host_impl.CreatePendingTree();
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(root.get(),
identity_matrix,
gfx::Point3F(),
@@ -6251,7 +5172,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
false);
root->SetIsDrawable(true);
- scoped_refptr<Layer> copy_grand_parent = Layer::Create();
+ scoped_refptr<Layer> copy_grand_parent = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(copy_grand_parent.get(),
identity_matrix,
gfx::Point3F(),
@@ -6261,7 +5182,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
false);
copy_grand_parent->SetIsDrawable(true);
- scoped_refptr<Layer> copy_parent = Layer::Create();
+ scoped_refptr<Layer> copy_parent = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(copy_parent.get(),
identity_matrix,
gfx::Point3F(),
@@ -6272,7 +5193,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
copy_parent->SetIsDrawable(true);
copy_parent->SetForceRenderSurface(true);
- scoped_refptr<Layer> copy_layer = Layer::Create();
+ scoped_refptr<Layer> copy_layer = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(copy_layer.get(),
identity_matrix,
gfx::Point3F(),
@@ -6282,7 +5203,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
false);
copy_layer->SetIsDrawable(true);
- scoped_refptr<Layer> copy_child = Layer::Create();
+ scoped_refptr<Layer> copy_child = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(copy_child.get(),
identity_matrix,
gfx::Point3F(),
@@ -6292,7 +5213,8 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
false);
copy_child->SetIsDrawable(true);
- scoped_refptr<Layer> copy_grand_parent_sibling_before = Layer::Create();
+ scoped_refptr<Layer> copy_grand_parent_sibling_before =
+ Layer::Create(layer_settings());
SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(),
identity_matrix,
gfx::Point3F(),
@@ -6302,7 +5224,8 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
false);
copy_grand_parent_sibling_before->SetIsDrawable(true);
- scoped_refptr<Layer> copy_grand_parent_sibling_after = Layer::Create();
+ scoped_refptr<Layer> copy_grand_parent_sibling_after =
+ Layer::Create(layer_settings());
SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(),
identity_matrix,
gfx::Point3F(),
@@ -6319,8 +5242,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
root->AddChild(copy_grand_parent);
root->AddChild(copy_grand_parent_sibling_after);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
// Hide the copy_grand_parent and its subtree. But make a copy request in that
// hidden subtree on copy_layer.
@@ -6384,11 +5306,13 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
host_impl.CreatePendingTree();
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(root.get(),
identity_matrix,
gfx::Point3F(),
@@ -6398,7 +5322,7 @@ TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
false);
root->SetIsDrawable(true);
- scoped_refptr<Layer> copy_parent = Layer::Create();
+ scoped_refptr<Layer> copy_parent = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(copy_parent.get(),
identity_matrix,
gfx::Point3F(),
@@ -6409,7 +5333,7 @@ TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
copy_parent->SetIsDrawable(true);
copy_parent->SetMasksToBounds(true);
- scoped_refptr<Layer> copy_layer = Layer::Create();
+ scoped_refptr<Layer> copy_layer = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(copy_layer.get(),
identity_matrix,
gfx::Point3F(),
@@ -6419,7 +5343,7 @@ TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
false);
copy_layer->SetIsDrawable(true);
- scoped_refptr<Layer> copy_child = Layer::Create();
+ scoped_refptr<Layer> copy_child = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(copy_child.get(),
identity_matrix,
gfx::Point3F(),
@@ -6433,8 +5357,7 @@ TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
copy_parent->AddChild(copy_layer);
root->AddChild(copy_parent);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateRequest(
base::Bind(&EmptyCopyOutputCallback)));
@@ -6459,11 +5382,13 @@ TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
host_impl.CreatePendingTree();
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(root.get(),
identity_matrix,
gfx::Point3F(),
@@ -6474,7 +5399,7 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) {
root->SetIsDrawable(true);
// The surface is moved slightly outside of the viewport.
- scoped_refptr<Layer> surface = Layer::Create();
+ scoped_refptr<Layer> surface = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(surface.get(),
identity_matrix,
gfx::Point3F(),
@@ -6484,7 +5409,7 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) {
false);
surface->SetForceRenderSurface(true);
- scoped_refptr<Layer> surface_child = Layer::Create();
+ scoped_refptr<Layer> surface_child = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(surface_child.get(),
identity_matrix,
gfx::Point3F(),
@@ -6497,8 +5422,7 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) {
surface->AddChild(surface_child);
root->AddChild(surface);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
RenderSurfaceLayerList render_surface_layer_list;
LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
@@ -6506,10 +5430,10 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) {
inputs.can_adjust_raster_scales = true;
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
- // The visible_content_rect for the |surface_child| should not be clipped by
+ // The visible_layer_rect for the |surface_child| should not be clipped by
// the viewport.
EXPECT_EQ(gfx::Rect(50, 50).ToString(),
- surface_child->visible_content_rect().ToString());
+ surface_child->visible_layer_rect().ToString());
}
TEST_F(LayerTreeHostCommonTest, TransformedClipParent) {
@@ -6524,12 +5448,12 @@ TEST_F(LayerTreeHostCommonTest, TransformedClipParent) {
//
// The render surface should be resized correctly and the clip child should
// inherit the right clip rect.
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> render_surface = Layer::Create();
- scoped_refptr<Layer> clip_parent = Layer::Create();
- scoped_refptr<Layer> intervening = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface = Layer::Create(layer_settings());
+ scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> intervening = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> clip_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(render_surface);
render_surface->AddChild(clip_parent);
@@ -6584,8 +5508,7 @@ TEST_F(LayerTreeHostCommonTest, TransformedClipParent) {
true,
false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
ExecuteCalculateDrawProperties(root.get());
@@ -6626,13 +5549,13 @@ TEST_F(LayerTreeHostCommonTest, ClipParentWithInterveningRenderSurface) {
// + render_surface2 (also sets opacity)
// + clip_child
//
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> clip_parent = Layer::Create();
- scoped_refptr<Layer> render_surface1 = Layer::Create();
- scoped_refptr<Layer> intervening = Layer::Create();
- scoped_refptr<Layer> render_surface2 = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> intervening = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface2 = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> clip_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(clip_parent);
clip_parent->AddChild(render_surface1);
@@ -6695,8 +5618,7 @@ TEST_F(LayerTreeHostCommonTest, ClipParentWithInterveningRenderSurface) {
true,
false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
ExecuteCalculateDrawProperties(root.get());
@@ -6737,7 +5659,7 @@ TEST_F(LayerTreeHostCommonTest, ClipParentWithInterveningRenderSurface) {
EXPECT_EQ(gfx::Rect(-1, -1, 40, 40).ToString(),
clip_child->clip_rect().ToString());
EXPECT_EQ(gfx::Rect(9, 9, 40, 40).ToString(),
- clip_child->visible_content_rect().ToString());
+ clip_child->visible_layer_rect().ToString());
EXPECT_TRUE(clip_child->is_clipped());
}
@@ -6753,13 +5675,13 @@ TEST_F(LayerTreeHostCommonTest, ClipParentScrolledInterveningLayer) {
// + render_surface2 (also sets opacity)
// + clip_child
//
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> clip_parent = Layer::Create();
- scoped_refptr<Layer> render_surface1 = Layer::Create();
- scoped_refptr<Layer> intervening = Layer::Create();
- scoped_refptr<Layer> render_surface2 = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> intervening = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface2 = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> clip_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(clip_parent);
clip_parent->AddChild(render_surface1);
@@ -6824,8 +5746,7 @@ TEST_F(LayerTreeHostCommonTest, ClipParentScrolledInterveningLayer) {
true,
false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
ExecuteCalculateDrawProperties(root.get());
@@ -6866,7 +5787,7 @@ TEST_F(LayerTreeHostCommonTest, ClipParentScrolledInterveningLayer) {
EXPECT_EQ(gfx::Rect(2, 2, 40, 40).ToString(),
clip_child->clip_rect().ToString());
EXPECT_EQ(gfx::Rect(12, 12, 40, 40).ToString(),
- clip_child->visible_content_rect().ToString());
+ clip_child->visible_layer_rect().ToString());
EXPECT_TRUE(clip_child->is_clipped());
}
@@ -6879,12 +5800,12 @@ TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) {
// + clip_child
// + child
//
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> clip_parent = Layer::Create();
- scoped_refptr<Layer> intervening = Layer::Create();
- scoped_refptr<Layer> clip_child = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> intervening = Layer::Create(layer_settings());
+ scoped_refptr<Layer> clip_child = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(clip_parent);
clip_parent->AddChild(intervening);
@@ -6933,8 +5854,7 @@ TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) {
true,
false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
ExecuteCalculateDrawProperties(root.get());
@@ -6946,7 +5866,7 @@ TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) {
clip_child->clip_rect().ToString());
EXPECT_TRUE(clip_child->is_clipped());
EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(),
- child->visible_content_rect().ToString());
+ child->visible_layer_rect().ToString());
EXPECT_TRUE(child->is_clipped());
}
@@ -6963,14 +5883,14 @@ TEST_F(LayerTreeHostCommonTest,
// + non_clip_child
//
// In this example render_surface2 should be unaffected by clip_child.
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> clip_parent = Layer::Create();
- scoped_refptr<Layer> render_surface1 = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> clip_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
- scoped_refptr<Layer> render_surface2 = Layer::Create();
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
+ scoped_refptr<Layer> render_surface2 = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> non_clip_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(clip_parent);
clip_parent->AddChild(render_surface1);
@@ -7030,8 +5950,7 @@ TEST_F(LayerTreeHostCommonTest,
render_surface1->SetForceRenderSurface(true);
render_surface2->SetForceRenderSurface(true);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
ExecuteCalculateDrawProperties(root.get());
@@ -7063,14 +5982,16 @@ TEST_F(LayerTreeHostCommonTest,
render_surface2->render_surface()->content_rect().ToString());
// Sanity check our num_unclipped_descendants values.
- EXPECT_EQ(1, render_surface1->num_unclipped_descendants());
- EXPECT_EQ(0, render_surface2->num_unclipped_descendants());
+ EXPECT_EQ(1u, render_surface1->num_unclipped_descendants());
+ EXPECT_EQ(0u, render_surface2->num_unclipped_descendants());
}
TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
scoped_ptr<LayerImpl> root =
LayerImpl::Create(host_impl.active_tree(), 12345);
scoped_ptr<LayerImpl> child1 =
@@ -7120,8 +6041,8 @@ TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
int count_represents_target_render_surface = 0;
int count_represents_contributing_render_surface = 0;
int count_represents_itself = 0;
- auto end = LayerIterator<LayerImpl>::End(&render_surface_layer_list);
- for (auto it = LayerIterator<LayerImpl>::Begin(&render_surface_layer_list);
+ LayerIterator end = LayerIterator::End(&render_surface_layer_list);
+ for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list);
it != end; ++it) {
if (it.represents_target_render_surface())
count_represents_target_render_surface++;
@@ -7151,8 +6072,8 @@ TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
int count_represents_target_render_surface = 0;
int count_represents_contributing_render_surface = 0;
int count_represents_itself = 0;
- auto end = LayerIterator<LayerImpl>::End(&render_surface_layer_list);
- for (auto it = LayerIterator<LayerImpl>::Begin(&render_surface_layer_list);
+ LayerIterator end = LayerIterator::End(&render_surface_layer_list);
+ for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list);
it != end; ++it) {
if (it.represents_target_render_surface())
count_represents_target_render_surface++;
@@ -7172,66 +6093,53 @@ TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
}
TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) {
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> render_surface = Layer::Create();
- scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
-
- root->AddChild(render_surface);
- render_surface->AddChild(child);
+ LayerImpl* root = root_layer();
+ LayerImpl* render_surface = AddChild<LayerImpl>(root);
+ LayerImpl* child = AddChild<LayerImpl>(render_surface);
+ child->SetDrawsContent(true);
gfx::Transform identity_transform;
- SetLayerPropertiesForTesting(root.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(50, 50),
- true,
- false);
- SetLayerPropertiesForTesting(render_surface.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(30, 30),
- false,
+ SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(50, 50), true, false,
true);
- SetLayerPropertiesForTesting(child.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(20, 20),
- true,
+ SetLayerPropertiesForTesting(render_surface, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
+ false, true, true);
+ SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(20, 20), true, false,
false);
root->SetShouldFlattenTransform(false);
root->Set3dSortingContextId(1);
render_surface->SetDoubleSided(false);
- render_surface->SetForceRenderSurface(true);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ ExecuteCalculateDrawProperties(root);
- ExecuteCalculateDrawProperties(root.get());
-
- EXPECT_EQ(2u, render_surface_layer_list()->size());
- EXPECT_EQ(1u,
- render_surface_layer_list()->at(0)
- ->render_surface()->layer_list().size());
- EXPECT_EQ(1u,
- render_surface_layer_list()->at(1)
- ->render_surface()->layer_list().size());
+ EXPECT_EQ(2u, render_surface_layer_list_impl()->size());
+ EXPECT_EQ(1u, render_surface_layer_list_impl()
+ ->at(0)
+ ->render_surface()
+ ->layer_list()
+ .size());
+ EXPECT_EQ(1u, render_surface_layer_list_impl()
+ ->at(1)
+ ->render_surface()
+ ->layer_list()
+ .size());
gfx::Transform rotation_transform = identity_transform;
rotation_transform.RotateAboutXAxis(180.0);
render_surface->SetTransform(rotation_transform);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawProperties(root);
- EXPECT_EQ(1u, render_surface_layer_list()->size());
- EXPECT_EQ(0u,
- render_surface_layer_list()->at(0)
- ->render_surface()->layer_list().size());
+ EXPECT_EQ(1u, render_surface_layer_list_impl()->size());
+ EXPECT_EQ(0u, render_surface_layer_list_impl()
+ ->at(0)
+ ->render_surface()
+ ->layer_list()
+ .size());
}
TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) {
@@ -7244,13 +6152,13 @@ TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) {
// | + scroll_parent
// + scroll_child
//
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> scroll_parent_border = Layer::Create();
- scoped_refptr<Layer> scroll_parent_clip = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> scroll_parent_border = Layer::Create(layer_settings());
+ scoped_refptr<Layer> scroll_parent_clip = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> scroll_parent =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> scroll_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(scroll_child);
@@ -7299,8 +6207,7 @@ TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) {
true,
false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
ExecuteCalculateDrawProperties(root.get());
@@ -7313,11 +6220,11 @@ TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) {
TEST_F(LayerTreeHostCommonTest, SingularTransformSubtreesDoNotDraw) {
scoped_refptr<LayerWithForcedDrawsContent> root =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> parent =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(parent);
parent->AddChild(child);
@@ -7348,8 +6255,7 @@ TEST_F(LayerTreeHostCommonTest, SingularTransformSubtreesDoNotDraw) {
true);
child->SetForceRenderSurface(true);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
ExecuteCalculateDrawProperties(root.get());
@@ -7380,70 +6286,45 @@ TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) {
// still results in correct clipping.
//
// + root
- // + scroll_child
// + scroll_parent_border
// + scroll_parent_clip
// + scroll_parent
+ // + scroll_child
//
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> scroll_parent_border = Layer::Create();
- scoped_refptr<Layer> scroll_parent_clip = Layer::Create();
- scoped_refptr<LayerWithForcedDrawsContent> scroll_parent =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
- scoped_refptr<LayerWithForcedDrawsContent> scroll_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
-
- root->AddChild(scroll_parent_border);
- scroll_parent_border->AddChild(scroll_parent_clip);
- scroll_parent_clip->AddChild(scroll_parent);
+ LayerImpl* root = root_layer();
+ LayerImpl* scroll_parent_border = AddChild<LayerImpl>(root);
+ LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border);
+ LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip);
+ LayerImpl* scroll_child = AddChild<LayerImpl>(root);
- root->AddChild(scroll_child);
+ scroll_parent->SetDrawsContent(true);
+ scroll_child->SetDrawsContent(true);
scroll_parent_clip->SetMasksToBounds(true);
- scroll_child->SetScrollParent(scroll_parent.get());
+ scroll_child->SetScrollParent(scroll_parent);
+ scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>);
+ scroll_children->insert(scroll_child);
+ scroll_parent->SetScrollChildren(scroll_children.release());
gfx::Transform identity_transform;
- SetLayerPropertiesForTesting(root.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(50, 50),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_parent_border.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(40, 40),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_parent_clip.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(30, 30),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_parent.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(50, 50),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_child.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(50, 50),
- true,
+ SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(50, 50), true, false,
+ true);
+ SetLayerPropertiesForTesting(scroll_parent_border, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40),
+ true, false, false);
+ SetLayerPropertiesForTesting(scroll_parent_clip, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
+ true, false, false);
+ SetLayerPropertiesForTesting(scroll_parent, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
+ true, false, false);
+ SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(50, 50), true, false,
false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
-
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawProperties(root);
EXPECT_TRUE(root->render_surface());
@@ -7465,98 +6346,60 @@ TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollGrandparent) {
// + scroll_grandparent_clip
// + scroll_grandparent
//
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> scroll_parent_border = Layer::Create();
- scoped_refptr<Layer> scroll_parent_clip = Layer::Create();
- scoped_refptr<LayerWithForcedDrawsContent> scroll_parent =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
-
- scoped_refptr<Layer> scroll_grandparent_border = Layer::Create();
- scoped_refptr<Layer> scroll_grandparent_clip = Layer::Create();
- scoped_refptr<LayerWithForcedDrawsContent> scroll_grandparent =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
-
- scoped_refptr<LayerWithForcedDrawsContent> scroll_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
-
- root->AddChild(scroll_child);
-
- root->AddChild(scroll_parent_border);
- scroll_parent_border->AddChild(scroll_parent_clip);
- scroll_parent_clip->AddChild(scroll_parent);
-
- root->AddChild(scroll_grandparent_border);
- scroll_grandparent_border->AddChild(scroll_grandparent_clip);
- scroll_grandparent_clip->AddChild(scroll_grandparent);
+ LayerImpl* root = root_layer();
+ LayerImpl* scroll_child = AddChild<LayerImpl>(root);
+ LayerImpl* scroll_parent_border = AddChild<LayerImpl>(root);
+ LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border);
+ LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip);
+ LayerImpl* scroll_grandparent_border = AddChild<LayerImpl>(root);
+ LayerImpl* scroll_grandparent_clip =
+ AddChild<LayerImpl>(scroll_grandparent_border);
+ LayerImpl* scroll_grandparent = AddChild<LayerImpl>(scroll_grandparent_clip);
+
+ scroll_parent->SetDrawsContent(true);
+ scroll_grandparent->SetDrawsContent(true);
+ scroll_child->SetDrawsContent(true);
scroll_parent_clip->SetMasksToBounds(true);
scroll_grandparent_clip->SetMasksToBounds(true);
- scroll_child->SetScrollParent(scroll_parent.get());
- scroll_parent_border->SetScrollParent(scroll_grandparent.get());
+ scroll_child->SetScrollParent(scroll_parent);
+ scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>);
+ scroll_children->insert(scroll_child);
+ scroll_parent->SetScrollChildren(scroll_children.release());
+
+ scroll_parent_border->SetScrollParent(scroll_grandparent);
+ scroll_children.reset(new std::set<LayerImpl*>);
+ scroll_children->insert(scroll_parent_border);
+ scroll_grandparent->SetScrollChildren(scroll_children.release());
gfx::Transform identity_transform;
- SetLayerPropertiesForTesting(root.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(50, 50),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_grandparent_border.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(40, 40),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_grandparent_clip.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(20, 20),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_grandparent.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(50, 50),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_parent_border.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(40, 40),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_parent_clip.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(30, 30),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_parent.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(50, 50),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_child.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(50, 50),
- true,
+ SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(50, 50), true, false,
+ true);
+ SetLayerPropertiesForTesting(scroll_grandparent_border, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40),
+ true, false, false);
+ SetLayerPropertiesForTesting(scroll_grandparent_clip, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20),
+ true, false, false);
+ SetLayerPropertiesForTesting(scroll_grandparent, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
+ true, false, false);
+ SetLayerPropertiesForTesting(scroll_parent_border, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40),
+ true, false, false);
+ SetLayerPropertiesForTesting(scroll_parent_clip, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
+ true, false, false);
+ SetLayerPropertiesForTesting(scroll_parent, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
+ true, false, false);
+ SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(50, 50), true, false,
false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
-
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawProperties(root);
EXPECT_TRUE(root->render_surface());
@@ -7567,12 +6410,9 @@ TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollGrandparent) {
// Despite the fact that we visited the above layers out of order to get the
// correct clip, the layer lists should be unaffected.
EXPECT_EQ(3u, root->render_surface()->layer_list().size());
- EXPECT_EQ(scroll_child.get(),
- root->render_surface()->layer_list().at(0).get());
- EXPECT_EQ(scroll_parent.get(),
- root->render_surface()->layer_list().at(1).get());
- EXPECT_EQ(scroll_grandparent.get(),
- root->render_surface()->layer_list().at(2).get());
+ EXPECT_EQ(scroll_child, root->render_surface()->layer_list().at(0));
+ EXPECT_EQ(scroll_parent, root->render_surface()->layer_list().at(1));
+ EXPECT_EQ(scroll_grandparent, root->render_surface()->layer_list().at(2));
}
TEST_F(LayerTreeHostCommonTest, OutOfOrderClippingRequiresRSLLSorting) {
@@ -7583,136 +6423,79 @@ TEST_F(LayerTreeHostCommonTest, OutOfOrderClippingRequiresRSLLSorting) {
// + scroll_parent_border
// + scroll_parent_clip
// + scroll_parent
- // + render_surface1
+ // + render_surface2
// + scroll_grandparent_border
// + scroll_grandparent_clip
// + scroll_grandparent
- // + render_surface2
+ // + render_surface1
//
- scoped_refptr<LayerWithForcedDrawsContent> root =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
-
- scoped_refptr<Layer> scroll_parent_border = Layer::Create();
- scoped_refptr<Layer> scroll_parent_clip = Layer::Create();
- scoped_refptr<LayerWithForcedDrawsContent> scroll_parent =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
- scoped_refptr<LayerWithForcedDrawsContent> render_surface1 =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
-
- scoped_refptr<Layer> scroll_grandparent_border = Layer::Create();
- scoped_refptr<Layer> scroll_grandparent_clip = Layer::Create();
- scoped_refptr<LayerWithForcedDrawsContent> scroll_grandparent =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
- scoped_refptr<LayerWithForcedDrawsContent> render_surface2 =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
-
- scoped_refptr<LayerWithForcedDrawsContent> scroll_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
+ LayerImpl* root = root_layer();
+ root->SetDrawsContent(true);
- root->AddChild(scroll_child);
+ LayerImpl* scroll_child = AddChild<LayerImpl>(root);
+ scroll_child->SetDrawsContent(true);
- root->AddChild(scroll_parent_border);
- scroll_parent_border->AddChild(scroll_parent_clip);
- scroll_parent_clip->AddChild(scroll_parent);
- scroll_parent->AddChild(render_surface2);
+ LayerImpl* scroll_parent_border = AddChild<LayerImpl>(root);
+ LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border);
+ LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip);
+ LayerImpl* render_surface2 = AddChild<LayerImpl>(scroll_parent);
+ LayerImpl* scroll_grandparent_border = AddChild<LayerImpl>(root);
+ LayerImpl* scroll_grandparent_clip =
+ AddChild<LayerImpl>(scroll_grandparent_border);
+ LayerImpl* scroll_grandparent = AddChild<LayerImpl>(scroll_grandparent_clip);
+ LayerImpl* render_surface1 = AddChild<LayerImpl>(scroll_grandparent);
- root->AddChild(scroll_grandparent_border);
- scroll_grandparent_border->AddChild(scroll_grandparent_clip);
- scroll_grandparent_clip->AddChild(scroll_grandparent);
- scroll_grandparent->AddChild(render_surface1);
+ scroll_parent->SetDrawsContent(true);
+ render_surface1->SetDrawsContent(true);
+ scroll_grandparent->SetDrawsContent(true);
+ render_surface2->SetDrawsContent(true);
scroll_parent_clip->SetMasksToBounds(true);
scroll_grandparent_clip->SetMasksToBounds(true);
- scroll_child->SetScrollParent(scroll_parent.get());
- scroll_parent_border->SetScrollParent(scroll_grandparent.get());
+ scroll_child->SetScrollParent(scroll_parent);
+ scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>);
+ scroll_children->insert(scroll_child);
+ scroll_parent->SetScrollChildren(scroll_children.release());
- render_surface1->SetForceRenderSurface(true);
- render_surface2->SetForceRenderSurface(true);
+ scroll_parent_border->SetScrollParent(scroll_grandparent);
+ scroll_children.reset(new std::set<LayerImpl*>);
+ scroll_children->insert(scroll_parent_border);
+ scroll_grandparent->SetScrollChildren(scroll_children.release());
gfx::Transform identity_transform;
- SetLayerPropertiesForTesting(root.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(50, 50),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_grandparent_border.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(40, 40),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_grandparent_clip.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(20, 20),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_grandparent.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(50, 50),
- true,
- false);
- SetLayerPropertiesForTesting(render_surface1.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(50, 50),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_parent_border.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(40, 40),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_parent_clip.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(30, 30),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_parent.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(50, 50),
- true,
- false);
- SetLayerPropertiesForTesting(render_surface2.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(50, 50),
- true,
- false);
- SetLayerPropertiesForTesting(scroll_child.get(),
- identity_transform,
- gfx::Point3F(),
- gfx::PointF(),
- gfx::Size(50, 50),
- true,
+ SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(50, 50), true, false,
+ true);
+ SetLayerPropertiesForTesting(scroll_grandparent_border, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40),
+ true, false, false);
+ SetLayerPropertiesForTesting(scroll_grandparent_clip, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20),
+ true, false, false);
+ SetLayerPropertiesForTesting(scroll_grandparent, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
+ true, false, false);
+ SetLayerPropertiesForTesting(render_surface1, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
+ true, false, true);
+ SetLayerPropertiesForTesting(scroll_parent_border, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40),
+ true, false, false);
+ SetLayerPropertiesForTesting(scroll_parent_clip, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
+ true, false, false);
+ SetLayerPropertiesForTesting(scroll_parent, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
+ true, false, false);
+ SetLayerPropertiesForTesting(render_surface2, identity_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
+ true, false, true);
+ SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(50, 50), true, false,
false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
-
- RenderSurfaceLayerList render_surface_layer_list;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root.get(),
- root->bounds(),
- identity_transform,
- &render_surface_layer_list);
-
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
+ ExecuteCalculateDrawProperties(root);
EXPECT_TRUE(root->render_surface());
@@ -7722,13 +6505,13 @@ TEST_F(LayerTreeHostCommonTest, OutOfOrderClippingRequiresRSLLSorting) {
// Despite the fact that we had to process the layers out of order to get the
// right clip, our render_surface_layer_list's order should be unaffected.
- EXPECT_EQ(3u, render_surface_layer_list.size());
- EXPECT_EQ(root.get(), render_surface_layer_list.at(0));
- EXPECT_EQ(render_surface2.get(), render_surface_layer_list.at(1));
- EXPECT_EQ(render_surface1.get(), render_surface_layer_list.at(2));
- EXPECT_TRUE(render_surface_layer_list.at(0)->render_surface());
- EXPECT_TRUE(render_surface_layer_list.at(1)->render_surface());
- EXPECT_TRUE(render_surface_layer_list.at(2)->render_surface());
+ EXPECT_EQ(3u, render_surface_layer_list_impl()->size());
+ EXPECT_EQ(root, render_surface_layer_list_impl()->at(0));
+ EXPECT_EQ(render_surface2, render_surface_layer_list_impl()->at(1));
+ EXPECT_EQ(render_surface1, render_surface_layer_list_impl()->at(2));
+ EXPECT_TRUE(render_surface_layer_list_impl()->at(0)->render_surface());
+ EXPECT_TRUE(render_surface_layer_list_impl()->at(1)->render_surface());
+ EXPECT_TRUE(render_surface_layer_list_impl()->at(2)->render_surface());
}
TEST_F(LayerTreeHostCommonTest, FixedPositionWithInterveningRenderSurface) {
@@ -7742,13 +6525,13 @@ TEST_F(LayerTreeHostCommonTest, FixedPositionWithInterveningRenderSurface) {
// + fixed
// + child
//
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> render_surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> fixed =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(render_surface);
render_surface->AddChild(fixed);
@@ -7773,8 +6556,7 @@ TEST_F(LayerTreeHostCommonTest, FixedPositionWithInterveningRenderSurface) {
gfx::PointF(1.f, 2.f), gfx::Size(50, 50), true,
false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
ExecuteCalculateDrawProperties(root.get());
@@ -7808,7 +6590,9 @@ TEST_F(LayerTreeHostCommonTest, ScrollCompensationWithRounding) {
//
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
host_impl.CreatePendingTree();
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1);
scoped_ptr<LayerImpl> container =
@@ -7952,7 +6736,9 @@ TEST_F(LayerTreeHostCommonTest,
//
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
host_impl.CreatePendingTree();
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1);
scoped_ptr<LayerImpl> container =
@@ -8046,7 +6832,9 @@ class AnimationScaleFactorTrackingLayerImpl : public LayerImpl {
TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
gfx::Transform identity_matrix;
scoped_ptr<AnimationScaleFactorTrackingLayerImpl> grand_parent =
AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 1);
@@ -8178,6 +6966,7 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
scale_matrix.Scale(1.f, 2.f);
grand_parent->SetTransform(scale_matrix);
parent_raw->SetTransform(scale_matrix);
+ grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true;
AddAnimatedTransformToLayer(parent_raw, 1.0, TransformOperations(), scale);
ExecuteCalculateDrawProperties(grand_parent.get());
@@ -8196,6 +6985,7 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
gfx::Transform perspective_matrix;
perspective_matrix.ApplyPerspectiveDepth(2.f);
child_raw->SetTransform(perspective_matrix);
+ grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true;
ExecuteCalculateDrawProperties(grand_parent.get());
// |child| has a transform that's neither a translation nor a scale.
@@ -8208,6 +6998,7 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
parent_raw->SetTransform(perspective_matrix);
+ grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true;
ExecuteCalculateDrawProperties(grand_parent.get());
// |parent| and |child| have transforms that are neither translations nor
@@ -8223,6 +7014,7 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
parent_raw->SetTransform(identity_matrix);
child_raw->SetTransform(identity_matrix);
grand_parent->SetTransform(perspective_matrix);
+ grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true;
ExecuteCalculateDrawProperties(grand_parent.get());
@@ -8242,10 +7034,9 @@ static int membership_id(LayerImpl* layer) {
static void GatherDrawnLayers(LayerImplList* rsll,
std::set<LayerImpl*>* drawn_layers) {
- for (LayerIterator<LayerImpl> it = LayerIterator<LayerImpl>::Begin(rsll),
- end = LayerIterator<LayerImpl>::End(rsll);
- it != end;
- ++it) {
+ for (LayerIterator it = LayerIterator::Begin(rsll),
+ end = LayerIterator::End(rsll);
+ it != end; ++it) {
LayerImpl* layer = *it;
if (it.represents_itself())
drawn_layers->insert(layer);
@@ -8263,7 +7054,9 @@ static void GatherDrawnLayers(LayerImplList* rsll,
TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
gfx::Transform identity_matrix;
scoped_ptr<LayerImpl> grand_parent =
@@ -8506,7 +7299,11 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) {
TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ LayerTreeSettings settings;
+ settings.layer_transforms_should_scale_layer_contents = true;
+ FakeLayerTreeHostImpl host_impl(settings, &proxy, &shared_bitmap_manager,
+ &task_graph_runner);
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1);
LayerImpl* root_layer = root.get();
@@ -8553,16 +7350,10 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) {
ExecuteCalculateDrawProperties(root_layer);
- EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale);
- EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().ideal_contents_scale);
- EXPECT_FLOAT_EQ(
- 3.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale);
- EXPECT_FLOAT_EQ(3.f,
- child1_layer->replica_layer()
- ->mask_layer()
- ->draw_properties()
- .ideal_contents_scale);
- EXPECT_FLOAT_EQ(5.f, child2_layer->draw_properties().ideal_contents_scale);
+ EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale());
+ EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale());
+ EXPECT_FLOAT_EQ(3.f, child1_layer->mask_layer()->GetIdealContentsScale());
+ EXPECT_FLOAT_EQ(5.f, child2_layer->GetIdealContentsScale());
EXPECT_FLOAT_EQ(
0.f, root_layer->draw_properties().maximum_animation_contents_scale);
@@ -8580,28 +7371,6 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) {
EXPECT_FLOAT_EQ(
8.f, child2_layer->draw_properties().maximum_animation_contents_scale);
- EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor);
- EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().page_scale_factor);
- EXPECT_FLOAT_EQ(
- 1.f, child1_layer->mask_layer()->draw_properties().page_scale_factor);
- EXPECT_FLOAT_EQ(1.f,
- child1_layer->replica_layer()
- ->mask_layer()
- ->draw_properties()
- .page_scale_factor);
- EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().page_scale_factor);
-
- EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().device_scale_factor);
- EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().device_scale_factor);
- EXPECT_FLOAT_EQ(
- 1.f, child1_layer->mask_layer()->draw_properties().device_scale_factor);
- EXPECT_FLOAT_EQ(1.f,
- child1_layer->replica_layer()
- ->mask_layer()
- ->draw_properties()
- .device_scale_factor);
- EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().device_scale_factor);
-
// Changing page-scale would affect ideal_contents_scale and
// maximum_animation_contents_scale.
@@ -8616,19 +7385,16 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) {
inputs.page_scale_factor = page_scale_factor;
inputs.can_adjust_raster_scales = true;
- inputs.page_scale_application_layer = root_layer;
+ inputs.page_scale_layer = root_layer;
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
- EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale);
- EXPECT_FLOAT_EQ(9.f, child1_layer->draw_properties().ideal_contents_scale);
+ EXPECT_FLOAT_EQ(3.f, root_layer->GetIdealContentsScale());
+ EXPECT_FLOAT_EQ(9.f, child1_layer->GetIdealContentsScale());
+ EXPECT_FLOAT_EQ(9.f, child1_layer->mask_layer()->GetIdealContentsScale());
EXPECT_FLOAT_EQ(
- 9.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale);
- EXPECT_FLOAT_EQ(9.f,
- child1_layer->replica_layer()
- ->mask_layer()
- ->draw_properties()
- .ideal_contents_scale);
- EXPECT_FLOAT_EQ(15.f, child2_layer->draw_properties().ideal_contents_scale);
+ 9.f,
+ child1_layer->replica_layer()->mask_layer()->GetIdealContentsScale());
+ EXPECT_FLOAT_EQ(15.f, child2_layer->GetIdealContentsScale());
EXPECT_FLOAT_EQ(
0.f, root_layer->draw_properties().maximum_animation_contents_scale);
@@ -8646,28 +7412,6 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) {
EXPECT_FLOAT_EQ(
24.f, child2_layer->draw_properties().maximum_animation_contents_scale);
- EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor);
- EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().page_scale_factor);
- EXPECT_FLOAT_EQ(
- 3.f, child1_layer->mask_layer()->draw_properties().page_scale_factor);
- EXPECT_FLOAT_EQ(3.f,
- child1_layer->replica_layer()
- ->mask_layer()
- ->draw_properties()
- .page_scale_factor);
- EXPECT_FLOAT_EQ(3.f, child2_layer->draw_properties().page_scale_factor);
-
- EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().device_scale_factor);
- EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().device_scale_factor);
- EXPECT_FLOAT_EQ(
- 1.f, child1_layer->mask_layer()->draw_properties().device_scale_factor);
- EXPECT_FLOAT_EQ(1.f,
- child1_layer->replica_layer()
- ->mask_layer()
- ->draw_properties()
- .device_scale_factor);
- EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().device_scale_factor);
-
// Changing device-scale would affect ideal_contents_scale and
// maximum_animation_contents_scale.
@@ -8676,16 +7420,13 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) {
inputs.can_adjust_raster_scales = true;
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
- EXPECT_FLOAT_EQ(4.f, root_layer->draw_properties().ideal_contents_scale);
- EXPECT_FLOAT_EQ(36.f, child1_layer->draw_properties().ideal_contents_scale);
+ EXPECT_FLOAT_EQ(12.f, root_layer->GetIdealContentsScale());
+ EXPECT_FLOAT_EQ(36.f, child1_layer->GetIdealContentsScale());
+ EXPECT_FLOAT_EQ(36.f, child1_layer->mask_layer()->GetIdealContentsScale());
EXPECT_FLOAT_EQ(
- 36.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale);
- EXPECT_FLOAT_EQ(36.f,
- child1_layer->replica_layer()
- ->mask_layer()
- ->draw_properties()
- .ideal_contents_scale);
- EXPECT_FLOAT_EQ(60.f, child2_layer->draw_properties().ideal_contents_scale);
+ 36.f,
+ child1_layer->replica_layer()->mask_layer()->GetIdealContentsScale());
+ EXPECT_FLOAT_EQ(60.f, child2_layer->GetIdealContentsScale());
EXPECT_FLOAT_EQ(
0.f, root_layer->draw_properties().maximum_animation_contents_scale);
@@ -8702,32 +7443,10 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) {
.maximum_animation_contents_scale);
EXPECT_FLOAT_EQ(
96.f, child2_layer->draw_properties().maximum_animation_contents_scale);
-
- EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor);
- EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().page_scale_factor);
- EXPECT_FLOAT_EQ(
- 3.f, child1_layer->mask_layer()->draw_properties().page_scale_factor);
- EXPECT_FLOAT_EQ(3.f,
- child1_layer->replica_layer()
- ->mask_layer()
- ->draw_properties()
- .page_scale_factor);
- EXPECT_FLOAT_EQ(3.f, child2_layer->draw_properties().page_scale_factor);
-
- EXPECT_FLOAT_EQ(4.f, root_layer->draw_properties().device_scale_factor);
- EXPECT_FLOAT_EQ(4.f, child1_layer->draw_properties().device_scale_factor);
- EXPECT_FLOAT_EQ(
- 4.f, child1_layer->mask_layer()->draw_properties().device_scale_factor);
- EXPECT_FLOAT_EQ(4.f,
- child1_layer->replica_layer()
- ->mask_layer()
- ->draw_properties()
- .device_scale_factor);
- EXPECT_FLOAT_EQ(4.f, child2_layer->draw_properties().device_scale_factor);
}
TEST_F(LayerTreeHostCommonTest, VisibleContentRectInChildRenderSurface) {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(root.get(),
gfx::Transform(),
gfx::Point3F(),
@@ -8737,7 +7456,7 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectInChildRenderSurface) {
false);
root->SetIsDrawable(true);
- scoped_refptr<Layer> clip = Layer::Create();
+ scoped_refptr<Layer> clip = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(clip.get(),
gfx::Transform(),
gfx::Point3F(),
@@ -8747,7 +7466,7 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectInChildRenderSurface) {
false);
clip->SetMasksToBounds(true);
- scoped_refptr<Layer> content = Layer::Create();
+ scoped_refptr<Layer> content = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(content.get(),
gfx::Transform(),
gfx::Point3F(),
@@ -8761,32 +7480,32 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectInChildRenderSurface) {
root->AddChild(clip);
clip->AddChild(content);
- FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
- scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&client);
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Size device_viewport_size(768, 582);
RenderSurfaceLayerList render_surface_layer_list;
LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- host->root_layer(), device_viewport_size, &render_surface_layer_list);
+ host()->root_layer(), device_viewport_size, &render_surface_layer_list);
inputs.device_scale_factor = 2.f;
inputs.page_scale_factor = 1.f;
- inputs.page_scale_application_layer = NULL;
+ inputs.page_scale_layer = NULL;
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
// Layers in the root render surface have their visible content rect clipped
// by the viewport.
- EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_layer_rect());
// Layers drawing to a child render surface should still have their visible
// content rect clipped by the viewport.
- EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_layer_rect());
}
TEST_F(LayerTreeHostCommonTest, BoundsDeltaAffectVisibleContentRect) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
// Set two layers: the root layer clips it's child,
// the child draws its content.
@@ -8800,6 +7519,7 @@ TEST_F(LayerTreeHostCommonTest, BoundsDeltaAffectVisibleContentRect) {
gfx::Size device_viewport_size = gfx::Size(300, 600);
gfx::Transform identity_matrix;
+ host_impl.SetViewportSize(device_viewport_size);
host_impl.active_tree()->SetRootLayer(
LayerImpl::Create(host_impl.active_tree(), 1));
@@ -8812,8 +7532,6 @@ TEST_F(LayerTreeHostCommonTest, BoundsDeltaAffectVisibleContentRect) {
false,
false,
true);
-
- root->SetContentBounds(root_size);
root->SetMasksToBounds(true);
root->AddChild(LayerImpl::Create(host_impl.active_tree(), 2));
@@ -8827,8 +7545,6 @@ TEST_F(LayerTreeHostCommonTest, BoundsDeltaAffectVisibleContentRect) {
false,
false,
false);
-
- sublayer->SetContentBounds(sublayer_size);
sublayer->SetDrawsContent(true);
LayerImplList layer_impl_list;
@@ -8837,7 +7553,7 @@ TEST_F(LayerTreeHostCommonTest, BoundsDeltaAffectVisibleContentRect) {
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
- EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_layer_rect());
root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0));
@@ -8845,19 +7561,80 @@ TEST_F(LayerTreeHostCommonTest, BoundsDeltaAffectVisibleContentRect) {
gfx::Rect affected_by_delta(0, 0, root_size.width(),
root_size.height() + 50);
- EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect());
+ EXPECT_EQ(affected_by_delta, sublayer->visible_layer_rect());
+}
+
+TEST_F(LayerTreeHostCommonTest, NodesAffectedByBoundsDeltaGetUpdated) {
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> inner_viewport_container_layer =
+ Layer::Create(layer_settings());
+ scoped_refptr<Layer> inner_viewport_scroll_layer =
+ Layer::Create(layer_settings());
+ scoped_refptr<Layer> outer_viewport_container_layer =
+ Layer::Create(layer_settings());
+ scoped_refptr<Layer> outer_viewport_scroll_layer =
+ Layer::Create(layer_settings());
+
+ root->AddChild(inner_viewport_container_layer);
+ inner_viewport_container_layer->AddChild(inner_viewport_scroll_layer);
+ inner_viewport_scroll_layer->AddChild(outer_viewport_container_layer);
+ outer_viewport_container_layer->AddChild(outer_viewport_scroll_layer);
+
+ inner_viewport_scroll_layer->SetScrollClipLayerId(
+ inner_viewport_container_layer->id());
+ outer_viewport_scroll_layer->SetScrollClipLayerId(
+ outer_viewport_container_layer->id());
+
+ inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true);
+ outer_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true);
+
+ host()->SetRootLayer(root);
+ host()->RegisterViewportLayers(nullptr, root, inner_viewport_scroll_layer,
+ outer_viewport_scroll_layer);
+
+ scoped_refptr<Layer> fixed_to_inner = Layer::Create(layer_settings());
+ scoped_refptr<Layer> fixed_to_outer = Layer::Create(layer_settings());
+
+ inner_viewport_scroll_layer->AddChild(fixed_to_inner);
+ outer_viewport_scroll_layer->AddChild(fixed_to_outer);
+
+ LayerPositionConstraint fixed_to_right;
+ fixed_to_right.set_is_fixed_position(true);
+ fixed_to_right.set_is_fixed_to_right_edge(true);
+
+ fixed_to_inner->SetPositionConstraint(fixed_to_right);
+ fixed_to_outer->SetPositionConstraint(fixed_to_right);
+
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
+
+ TransformTree& transform_tree = host()->property_trees()->transform_tree;
+ EXPECT_TRUE(transform_tree.HasNodesAffectedByInnerViewportBoundsDelta());
+ EXPECT_TRUE(transform_tree.HasNodesAffectedByOuterViewportBoundsDelta());
+
+ LayerPositionConstraint fixed_to_left;
+ fixed_to_left.set_is_fixed_position(true);
+ fixed_to_inner->SetPositionConstraint(fixed_to_left);
+
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
+ EXPECT_FALSE(transform_tree.HasNodesAffectedByInnerViewportBoundsDelta());
+ EXPECT_TRUE(transform_tree.HasNodesAffectedByOuterViewportBoundsDelta());
+
+ fixed_to_outer->SetPositionConstraint(fixed_to_left);
+
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
+ EXPECT_FALSE(transform_tree.HasNodesAffectedByInnerViewportBoundsDelta());
+ EXPECT_FALSE(transform_tree.HasNodesAffectedByOuterViewportBoundsDelta());
}
TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) {
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> animated =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(animated);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
gfx::PointF(), gfx::Size(100, 100), true, false);
@@ -8871,7 +7648,7 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) {
AddOpacityTransitionToController(animated->layer_animation_controller(), 10.0,
0.f, 1.f, false);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_FALSE(animated->visible_rect_from_property_trees().IsEmpty());
}
@@ -8879,14 +7656,14 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) {
TEST_F(LayerTreeHostCommonTest,
VisibleContentRectForAnimatedLayerWithSingularTransform) {
const gfx::Transform identity_matrix;
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> clip = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> clip = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> animated =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> surface =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(clip);
clip->AddChild(animated);
@@ -8896,8 +7673,7 @@ TEST_F(LayerTreeHostCommonTest,
clip->SetMasksToBounds(true);
surface->SetForceRenderSurface(true);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform uninvertible_matrix;
uninvertible_matrix.Scale3d(6.f, 6.f, 0.f);
@@ -8922,7 +7698,7 @@ TEST_F(LayerTreeHostCommonTest,
AddAnimatedTransformToLayer(animated.get(), 10.0, start_transform_operations,
end_transform_operations);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
// The animated layer has a singular transform and maps to a non-empty rect in
// clipped target space, so is treated as fully visible.
@@ -8939,7 +7715,7 @@ TEST_F(LayerTreeHostCommonTest,
SetLayerPropertiesForTesting(animated.get(), zero_matrix, gfx::Point3F(),
gfx::PointF(), gfx::Size(120, 120), true, false);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
// The animated layer maps to the empty rect in clipped target space, so is
// treated as having an empty visible rect.
@@ -8956,9 +7732,9 @@ TEST_F(LayerTreeHostCommonTest,
// Verify that having an animated filter (but no current filter, as these
// are mutually exclusive) correctly creates a render surface.
TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) {
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
- scoped_refptr<Layer> grandchild = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grandchild = Layer::Create(layer_settings());
root->AddChild(child);
child->AddChild(grandchild);
@@ -8970,8 +7746,7 @@ TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) {
SetLayerPropertiesForTesting(grandchild.get(), identity_transform,
gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
true, false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
AddAnimatedFilterToLayer(child.get(), 10.0, 0.1f, 0.2f);
@@ -8993,10 +7768,10 @@ TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) {
// Ensures that the property tree code accounts for offsets between fixed
// position layers and their respective containers.
TEST_F(LayerTreeHostCommonTest, PropertyTreesAccountForFixedParentOffset) {
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> grandchild =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(child);
child->AddChild(grandchild);
@@ -9019,10 +7794,49 @@ TEST_F(LayerTreeHostCommonTest, PropertyTreesAccountForFixedParentOffset) {
root->SetIsContainerForFixedPositionLayers(true);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
+
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50),
+ grandchild->visible_rect_from_property_trees());
+}
+
+// Ensures that the property tree code accounts for offsets between fixed
+// position containers and their transform tree parents, when a fixed position
+// layer's container is its layer tree parent, but this parent doesn't have its
+// own transform tree node.
+TEST_F(LayerTreeHostCommonTest,
+ PropertyTreesAccountForFixedParentOffsetWhenContainerIsParent) {
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
+ scoped_refptr<LayerWithForcedDrawsContent> grandchild =
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
+
+ root->AddChild(child);
+ child->AddChild(grandchild);
+
+ gfx::Transform identity_transform;
+ SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(50, 50), true, false);
+ SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(),
+ gfx::PointF(1000, 1000), gfx::Size(50, 50), true,
+ false);
+ SetLayerPropertiesForTesting(grandchild.get(), identity_transform,
+ gfx::Point3F(), gfx::PointF(-1000, -1000),
+ gfx::Size(50, 50), true, false);
+
+ root->SetMasksToBounds(true);
+ child->SetIsContainerForFixedPositionLayers(true);
+ LayerPositionConstraint constraint;
+ constraint.set_is_fixed_position(true);
+ grandchild->SetPositionConstraint(constraint);
+
+ root->SetIsContainerForFixedPositionLayers(true);
+
+ host()->SetRootLayer(root);
+
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(0, 0, 50, 50),
grandchild->visible_rect_from_property_trees());
@@ -9038,35 +7852,35 @@ TEST_F(LayerTreeHostCommonTest, CombineClipsUsingContentTarget) {
rotate.Rotate(5);
gfx::Transform identity;
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(2500, 1500), true,
false);
- scoped_refptr<Layer> frame_clip = Layer::Create();
+ scoped_refptr<Layer> frame_clip = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(frame_clip.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(2500, 1500), true,
false);
frame_clip->SetMasksToBounds(true);
- scoped_refptr<Layer> rotated = Layer::Create();
+ scoped_refptr<Layer> rotated = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(rotated.get(), rotate,
gfx::Point3F(1250, 250, 0), gfx::PointF(),
gfx::Size(2500, 500), true, false);
- scoped_refptr<Layer> surface = Layer::Create();
+ scoped_refptr<Layer> surface = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(surface.get(), rotate, gfx::Point3F(),
gfx::PointF(), gfx::Size(2500, 500), true,
false);
surface->SetOpacity(0.5);
scoped_refptr<LayerWithForcedDrawsContent> container =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
SetLayerPropertiesForTesting(container.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(300, 300), true, false);
scoped_refptr<LayerWithForcedDrawsContent> box =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
SetLayerPropertiesForTesting(box.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(100, 100), true, false);
@@ -9076,8 +7890,7 @@ TEST_F(LayerTreeHostCommonTest, CombineClipsUsingContentTarget) {
surface->AddChild(container);
surface->AddChild(box);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
ExecuteCalculateDrawProperties(root.get());
}
@@ -9087,19 +7900,19 @@ TEST_F(LayerTreeHostCommonTest, OnlyApplyFixedPositioningOnce) {
gfx::Transform translate_z;
translate_z.Translate3d(0, 0, 10);
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(800, 800), true, false);
root->SetIsContainerForFixedPositionLayers(true);
- scoped_refptr<Layer> frame_clip = Layer::Create();
+ scoped_refptr<Layer> frame_clip = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(frame_clip.get(), translate_z, gfx::Point3F(),
gfx::PointF(500, 100), gfx::Size(100, 100), true,
false);
frame_clip->SetMasksToBounds(true);
scoped_refptr<LayerWithForcedDrawsContent> fixed =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
SetLayerPropertiesForTesting(fixed.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(1000, 1000), true,
false);
@@ -9111,10 +7924,9 @@ TEST_F(LayerTreeHostCommonTest, OnlyApplyFixedPositioningOnce) {
root->AddChild(frame_clip);
frame_clip->AddChild(fixed);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
gfx::Rect expected(0, 0, 100, 100);
EXPECT_EQ(expected, fixed->visible_rect_from_property_trees());
@@ -9126,19 +7938,19 @@ TEST_F(LayerTreeHostCommonTest,
gfx::Transform translate_z;
translate_z.Translate3d(0, 0, 10);
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(800, 800), true, false);
root->SetIsContainerForFixedPositionLayers(true);
- scoped_refptr<Layer> frame_clip = Layer::Create();
+ scoped_refptr<Layer> frame_clip = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(frame_clip.get(), translate_z, gfx::Point3F(),
gfx::PointF(500, 100), gfx::Size(100, 100), true,
false);
frame_clip->SetMasksToBounds(true);
scoped_refptr<LayerWithForcedDrawsContent> scroller =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
SetLayerPropertiesForTesting(scroller.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(1000, 1000), true,
false);
@@ -9148,7 +7960,7 @@ TEST_F(LayerTreeHostCommonTest,
scroller->SetScrollClipLayerId(frame_clip->id());
scoped_refptr<LayerWithForcedDrawsContent> fixed =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
SetLayerPropertiesForTesting(fixed.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(50, 50), true, false);
@@ -9157,7 +7969,7 @@ TEST_F(LayerTreeHostCommonTest,
fixed->SetPositionConstraint(constraint);
scoped_refptr<LayerWithForcedDrawsContent> fixed_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
SetLayerPropertiesForTesting(fixed_child.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(10, 10), true, false);
@@ -9168,10 +7980,9 @@ TEST_F(LayerTreeHostCommonTest,
scroller->AddChild(fixed);
fixed->AddChild(fixed_child);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
gfx::Rect expected(0, 0, 50, 50);
EXPECT_EQ(expected, fixed->visible_rect_from_property_trees());
@@ -9183,19 +7994,19 @@ TEST_F(LayerTreeHostCommonTest,
TEST_F(LayerTreeHostCommonTest, FixedClipsShouldBeAssociatedWithTheRightNode) {
gfx::Transform identity;
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(800, 800), true, false);
root->SetIsContainerForFixedPositionLayers(true);
- scoped_refptr<Layer> frame_clip = Layer::Create();
+ scoped_refptr<Layer> frame_clip = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(frame_clip.get(), identity, gfx::Point3F(),
gfx::PointF(500, 100), gfx::Size(100, 100), true,
false);
frame_clip->SetMasksToBounds(true);
scoped_refptr<LayerWithForcedDrawsContent> scroller =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
SetLayerPropertiesForTesting(scroller.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(1000, 1000), true,
false);
@@ -9204,7 +8015,7 @@ TEST_F(LayerTreeHostCommonTest, FixedClipsShouldBeAssociatedWithTheRightNode) {
scroller->SetScrollClipLayerId(frame_clip->id());
scoped_refptr<LayerWithForcedDrawsContent> fixed =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
SetLayerPropertiesForTesting(fixed.get(), identity, gfx::Point3F(),
gfx::PointF(100, 100), gfx::Size(50, 50), true,
false);
@@ -9219,10 +8030,9 @@ TEST_F(LayerTreeHostCommonTest, FixedClipsShouldBeAssociatedWithTheRightNode) {
frame_clip->AddChild(scroller);
scroller->AddChild(fixed);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
gfx::Rect expected(0, 0, 50, 50);
EXPECT_EQ(expected, fixed->visible_rect_from_property_trees());
@@ -9236,31 +8046,30 @@ TEST_F(LayerTreeHostCommonTest, ChangingAxisAlignmentTriggersRebuild) {
translate.Translate(10, 10);
rotate.Rotate(45);
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(800, 800), true, false);
root->SetIsContainerForFixedPositionLayers(true);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
+ EXPECT_FALSE(host()->property_trees()->needs_rebuild);
root->SetTransform(translate);
- EXPECT_FALSE(host->property_trees()->needs_rebuild);
+ EXPECT_FALSE(host()->property_trees()->needs_rebuild);
root->SetTransform(rotate);
- EXPECT_TRUE(host->property_trees()->needs_rebuild);
+ EXPECT_TRUE(host()->property_trees()->needs_rebuild);
}
TEST_F(LayerTreeHostCommonTest, ChangeTransformOrigin) {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(child);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform identity_matrix;
gfx::Transform scale_matrix;
@@ -9270,29 +8079,28 @@ TEST_F(LayerTreeHostCommonTest, ChangeTransformOrigin) {
SetLayerPropertiesForTesting(child.get(), scale_matrix, gfx::Point3F(),
gfx::PointF(), gfx::Size(10, 10), true, false);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(10, 10), child->visible_rect_from_property_trees());
child->SetTransformOrigin(gfx::Point3F(10.f, 10.f, 10.f));
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(5, 5, 5, 5), child->visible_rect_from_property_trees());
}
TEST_F(LayerTreeHostCommonTest, UpdateScrollChildPosition) {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> scroll_parent =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> scroll_child =
- make_scoped_refptr(new LayerWithForcedDrawsContent);
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
root->AddChild(scroll_child);
root->AddChild(scroll_parent);
scroll_child->SetScrollParent(scroll_parent.get());
scroll_parent->SetScrollClipLayerId(root->id());
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
gfx::Transform identity_transform;
gfx::Transform scale;
@@ -9305,13 +8113,13 @@ TEST_F(LayerTreeHostCommonTest, UpdateScrollChildPosition) {
gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
true, false);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(25, 25),
scroll_child->visible_rect_from_property_trees());
scroll_child->SetPosition(gfx::PointF(0, -10.f));
scroll_parent->SetScrollOffset(gfx::ScrollOffset(0.f, 10.f));
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(0, 5, 25, 25),
scroll_child->visible_rect_from_property_trees());
}
@@ -9322,13 +8130,13 @@ static void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {
TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) {
gfx::Transform identity;
FakeContentLayerClient client;
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_refptr<LayerWithForcedDrawsContent> grandchild =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
- scoped_refptr<FakeContentLayer> greatgrandchild(
- FakeContentLayer::Create(&client));
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
+ scoped_refptr<FakePictureLayer> greatgrandchild(
+ FakePictureLayer::Create(layer_settings(), &client));
SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(100, 100), true, false);
SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(),
@@ -9342,11 +8150,10 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) {
child->AddChild(grandchild);
grandchild->AddChild(greatgrandchild);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
// Check the non-skipped case.
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_rect_from_property_trees());
// Now we will reset the visible rect from property trees for the grandchild,
@@ -9358,41 +8165,43 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) {
singular.matrix().set(0, 0, 0);
child->SetTransform(singular);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees());
child->SetTransform(identity);
child->SetHideLayerAndSubtree(true);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees());
child->SetHideLayerAndSubtree(false);
child->SetOpacity(0.f);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees());
// Now, even though child has zero opacity, we will configure |grandchild| and
// |greatgrandchild| in several ways that should force the subtree to be
// processed anyhow.
grandchild->SetTouchEventHandlerRegion(Region(gfx::Rect(0, 0, 10, 10)));
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_rect_from_property_trees());
grandchild->set_visible_rect_from_property_trees(gfx::Rect());
grandchild->SetTouchEventHandlerRegion(Region());
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees());
grandchild->set_visible_rect_from_property_trees(gfx::Rect());
greatgrandchild->RequestCopyOfOutput(
CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback)));
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_rect_from_property_trees());
}
TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
- FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
gfx::Transform identity;
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1);
@@ -9400,8 +8209,8 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) {
scoped_ptr<LayerImpl> grandchild =
LayerImpl::Create(host_impl.active_tree(), 3);
- scoped_ptr<FakeContentLayerImpl> greatgrandchild(
- FakeContentLayerImpl::Create(host_impl.active_tree(), 4));
+ scoped_ptr<FakePictureLayerImpl> greatgrandchild(
+ FakePictureLayerImpl::Create(host_impl.active_tree(), 4));
child->SetDrawsContent(true);
grandchild->SetDrawsContent(true);
@@ -9429,7 +8238,7 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) {
root->AddChild(child.Pass());
// Check the non-skipped case.
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(10, 10),
grandchild_ptr->visible_rect_from_property_trees());
@@ -9442,19 +8251,19 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) {
singular.matrix().set(0, 0, 0);
child_ptr->SetTransform(singular);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(0, 0),
grandchild_ptr->visible_rect_from_property_trees());
child_ptr->SetTransform(identity);
child_ptr->SetHideLayerAndSubtree(true);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(0, 0),
grandchild_ptr->visible_rect_from_property_trees());
child_ptr->SetHideLayerAndSubtree(false);
child_ptr->SetOpacity(0.f);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(0, 0),
grandchild_ptr->visible_rect_from_property_trees());
@@ -9462,12 +8271,12 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) {
// |greatgrandchild| in several ways that should force the subtree to be
// processed anyhow.
grandchild_ptr->SetTouchEventHandlerRegion(Region(gfx::Rect(0, 0, 10, 10)));
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(10, 10),
grandchild_ptr->visible_rect_from_property_trees());
grandchild_ptr->set_visible_rect_from_property_trees(gfx::Rect());
grandchild_ptr->SetTouchEventHandlerRegion(Region());
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(0, 0),
grandchild_ptr->visible_rect_from_property_trees());
grandchild_ptr->set_visible_rect_from_property_trees(gfx::Rect());
@@ -9476,7 +8285,7 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) {
requests.push_back(CopyOutputRequest::CreateEmptyRequest());
greatgrandchild_ptr->PassCopyRequests(&requests);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(10, 10),
grandchild_ptr->visible_rect_from_property_trees());
}
@@ -9484,29 +8293,28 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) {
TEST_F(LayerTreeHostCommonTest, SkippingLayer) {
gfx::Transform identity;
FakeContentLayerClient client;
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child =
- make_scoped_refptr(new LayerWithForcedDrawsContent());
+ make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(100, 100), true, false);
SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(10, 10), true, false);
root->AddChild(child);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(10, 10), child->visible_rect_from_property_trees());
child->set_visible_rect_from_property_trees(gfx::Rect());
child->SetHideLayerAndSubtree(true);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees());
child->SetHideLayerAndSubtree(false);
child->SetBounds(gfx::Size());
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees());
child->SetBounds(gfx::Size(10, 10));
@@ -9514,22 +8322,22 @@ TEST_F(LayerTreeHostCommonTest, SkippingLayer) {
child->SetDoubleSided(false);
rotate.RotateAboutXAxis(180.f);
child->SetTransform(rotate);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees());
child->SetDoubleSided(true);
child->SetTransform(identity);
child->SetOpacity(0.f);
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees());
}
TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) {
// Ensure that the treewalk in LayerTreeHostCommom::
// PreCalculateMetaInformation happens when its required.
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> parent = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> parent = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
root->AddChild(parent);
parent->AddChild(child);
@@ -9545,11 +8353,10 @@ TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) {
SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(100, 100), true, false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
ExecuteCalculateDrawProperties(root.get());
- EXPECT_EQ(parent->draw_properties().num_unclipped_descendants, 1);
+ EXPECT_EQ(parent->draw_properties().num_unclipped_descendants, 1u);
// Ensure the dynamic update to input handlers happens.
child->SetHaveWheelEventHandlers(true);
@@ -9572,8 +8379,8 @@ TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) {
TEST_F(LayerTreeHostCommonTest, InputHandlersRecursiveUpdateTest) {
// Ensure that the treewalk in LayertreeHostCommon::
// PreCalculateMetaInformation updates input handlers correctly.
- scoped_refptr<Layer> root = Layer::Create();
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
root->AddChild(child);
@@ -9586,8 +8393,7 @@ TEST_F(LayerTreeHostCommonTest, InputHandlersRecursiveUpdateTest) {
SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(),
gfx::PointF(), gfx::Size(100, 100), true, false);
- scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
- host->SetRootLayer(root);
+ host()->SetRootLayer(root);
EXPECT_EQ(root->num_layer_or_descendants_with_input_handler(), 0);
ExecuteCalculateDrawProperties(root.get());
@@ -9596,5 +8402,69 @@ TEST_F(LayerTreeHostCommonTest, InputHandlersRecursiveUpdateTest) {
EXPECT_EQ(root->num_layer_or_descendants_with_input_handler(), 0);
}
+TEST_F(LayerTreeHostCommonTest, ResetPropertyTreeIndices) {
+ gfx::Transform identity;
+ gfx::Transform translate_z;
+ translate_z.Translate3d(0, 0, 10);
+
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(800, 800), true, false);
+
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
+ SetLayerPropertiesForTesting(child.get(), translate_z, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false);
+
+ root->AddChild(child);
+
+ host()->SetRootLayer(root);
+
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
+ EXPECT_NE(-1, child->transform_tree_index());
+
+ child->RemoveFromParent();
+
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
+ EXPECT_EQ(-1, child->transform_tree_index());
+}
+
+TEST_F(LayerTreeHostCommonTest, ResetLayerDrawPropertiestest) {
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
+
+ root->AddChild(child);
+ gfx::Transform identity;
+
+ SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false);
+ SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false);
+
+ host()->SetRootLayer(root);
+
+ EXPECT_FALSE(root->layer_or_descendant_is_drawn());
+ EXPECT_FALSE(root->visited());
+ EXPECT_FALSE(root->sorted_for_recursion());
+ EXPECT_FALSE(child->layer_or_descendant_is_drawn());
+ EXPECT_FALSE(child->visited());
+ EXPECT_FALSE(child->sorted_for_recursion());
+
+ root->set_layer_or_descendant_is_drawn(true);
+ root->set_visited(true);
+ root->set_sorted_for_recursion(true);
+ child->set_layer_or_descendant_is_drawn(true);
+ child->set_visited(true);
+ child->set_sorted_for_recursion(true);
+
+ LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root.get());
+
+ EXPECT_FALSE(root->layer_or_descendant_is_drawn());
+ EXPECT_FALSE(root->visited());
+ EXPECT_FALSE(root->sorted_for_recursion());
+ EXPECT_FALSE(child->layer_or_descendant_is_drawn());
+ EXPECT_FALSE(child->visited());
+ EXPECT_FALSE(child->sorted_for_recursion());
+}
+
} // namespace
} // namespace cc
diff --git a/chromium/cc/trees/layer_tree_host_impl.cc b/chromium/cc/trees/layer_tree_host_impl.cc
index 9e1474586cb..f616d517a3f 100644
--- a/chromium/cc/trees/layer_tree_host_impl.cc
+++ b/chromium/cc/trees/layer_tree_host_impl.cc
@@ -14,15 +14,16 @@
#include "base/containers/small_map.h"
#include "base/json/json_writer.h"
#include "base/metrics/histogram.h"
+#include "base/numerics/safe_conversions.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/trace_event_argument.h"
+#include "cc/animation/animation_host.h"
#include "cc/animation/animation_id_provider.h"
#include "cc/animation/scroll_offset_animation_curve.h"
#include "cc/animation/scrollbar_animation_controller.h"
#include "cc/animation/timing_function.h"
#include "cc/base/math_util.h"
-#include "cc/base/util.h"
#include "cc/debug/benchmark_instrumentation.h"
#include "cc/debug/debug_rect_history.h"
#include "cc/debug/devtools_instrumentation.h"
@@ -60,7 +61,6 @@
#include "cc/raster/tile_task_worker_pool.h"
#include "cc/raster/zero_copy_tile_task_worker_pool.h"
#include "cc/resources/memory_history.h"
-#include "cc/resources/prioritized_resource_manager.h"
#include "cc/resources/resource_pool.h"
#include "cc/resources/ui_resource_bitmap.h"
#include "cc/scheduler/delay_based_time_source.h"
@@ -76,7 +76,6 @@
#include "cc/trees/tree_synchronizer.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/gles2_interface.h"
-#include "ui/gfx/frame_time.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/scroll_offset.h"
#include "ui/gfx/geometry/size_conversions.h"
@@ -158,6 +157,16 @@ size_t GetMaxStagingResourceCount() {
return 32;
}
+size_t GetDefaultMemoryAllocationLimit() {
+ // TODO(ccameron): (http://crbug.com/137094) This 64MB default is a straggler
+ // from the old texture manager and is just to give us a default memory
+ // allocation before we get a callback from the GPU memory manager. We
+ // should probaby either:
+ // - wait for the callback before rendering anything instead
+ // - push this into the GPU memory manager somehow.
+ return 64 * 1024 * 1024;
+}
+
} // namespace
LayerTreeHostImpl::FrameData::FrameData() : has_no_damage(false) {
@@ -190,6 +199,7 @@ LayerTreeHostImpl::LayerTreeHostImpl(
int id)
: client_(client),
proxy_(proxy),
+ current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE),
content_is_suitable_for_gpu_rasterization_(true),
has_gpu_rasterization_trigger_(false),
use_gpu_rasterization_(false),
@@ -207,23 +217,27 @@ LayerTreeHostImpl::LayerTreeHostImpl(
settings_(settings),
visible_(true),
cached_managed_memory_policy_(
- PrioritizedResourceManager::DefaultMemoryAllocationLimit(),
+ GetDefaultMemoryAllocationLimit(),
gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING,
ManagedMemoryPolicy::kDefaultNumResourcesLimit),
+ // Must be initialized after settings_ and proxy_.
+ tile_manager_(
+ TileManager::Create(this,
+ GetTaskRunner(),
+ IsSynchronousSingleThreaded()
+ ? std::numeric_limits<size_t>::max()
+ : settings.scheduled_raster_task_limit)),
pinch_gesture_active_(false),
pinch_gesture_end_should_clear_scrolling_layer_(false),
fps_counter_(FrameRateCounter::Create(proxy_->HasImplThread())),
paint_time_counter_(PaintTimeCounter::Create()),
memory_history_(MemoryHistory::Create()),
debug_rect_history_(DebugRectHistory::Create()),
- texture_mailbox_deleter_(new TextureMailboxDeleter(
- proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner()
- : proxy_->MainThreadTaskRunner())),
+ texture_mailbox_deleter_(new TextureMailboxDeleter(GetTaskRunner())),
max_memory_needed_bytes_(0),
device_scale_factor_(1.f),
resourceless_software_draw_(false),
- begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()),
- animation_registrar_(AnimationRegistrar::Create()),
+ animation_registrar_(),
rendering_stats_instrumentation_(rendering_stats_instrumentation),
micro_benchmark_controller_(this),
shared_bitmap_manager_(shared_bitmap_manager),
@@ -232,11 +246,24 @@ LayerTreeHostImpl::LayerTreeHostImpl(
id_(id),
requires_high_res_to_draw_(false),
is_likely_to_require_a_draw_(false),
- frame_timing_tracker_(FrameTimingTracker::Create()) {
+ frame_timing_tracker_(FrameTimingTracker::Create(this)) {
+ if (settings.use_compositor_animation_timelines) {
+ if (settings.accelerated_animation_enabled) {
+ animation_host_ = AnimationHost::Create(ThreadInstance::IMPL);
+ animation_host_->SetMutatorHostClient(this);
+ animation_host_->SetSupportsScrollAnimations(
+ proxy_->SupportsImplScrolling());
+ }
+ } else {
+ animation_registrar_ = AnimationRegistrar::Create();
+ animation_registrar_->set_supports_scroll_animations(
+ proxy_->SupportsImplScrolling());
+ }
+
DCHECK(proxy_->IsImplThread());
+ DCHECK_IMPLIES(settings.use_one_copy, !settings.use_zero_copy);
+ DCHECK_IMPLIES(settings.use_zero_copy, !settings.use_one_copy);
DidVisibilityChange(this, visible_);
- animation_registrar_->set_supports_scroll_animations(
- proxy_->SupportsImplScrolling());
SetDebugState(settings.initial_debug_state);
@@ -280,29 +307,36 @@ LayerTreeHostImpl::~LayerTreeHostImpl() {
recycle_tree_ = nullptr;
pending_tree_ = nullptr;
active_tree_ = nullptr;
- DestroyTileManager();
+
+ if (animation_host_) {
+ animation_host_->ClearTimelines();
+ animation_host_->SetMutatorHostClient(nullptr);
+ }
+
+ CleanUpTileManager();
}
void LayerTreeHostImpl::BeginMainFrameAborted(CommitEarlyOutReason reason) {
// If the begin frame data was handled, then scroll and scale set was applied
// by the main thread, so the active tree needs to be updated as if these sent
// values were applied and committed.
- if (CommitEarlyOutHandledCommit(reason)) {
+ if (CommitEarlyOutHandledCommit(reason))
active_tree_->ApplySentScrollAndScaleDeltasFromAbortedCommit();
- active_tree_->ResetContentsTexturesPurged();
- }
}
void LayerTreeHostImpl::BeginCommit() {
TRACE_EVENT0("cc", "LayerTreeHostImpl::BeginCommit");
// Ensure all textures are returned so partial texture updates can happen
- // during the commit. Impl-side-painting doesn't upload during commits, so
- // is unaffected.
- if (!settings_.impl_side_painting && output_surface_)
+ // during the commit.
+ // TODO(ericrk): We should not need to ForceReclaimResources when using
+ // Impl-side-painting as it doesn't upload during commits. However,
+ // Display::Draw currently relies on resource being reclaimed to block drawing
+ // between BeginCommit / Swap. See crbug.com/489515.
+ if (output_surface_)
output_surface_->ForceReclaimResources();
- if (settings_.impl_side_painting && !proxy_->CommitToActiveTree())
+ if (!proxy_->CommitToActiveTree())
CreatePendingTree();
}
@@ -314,31 +348,25 @@ void LayerTreeHostImpl::CommitComplete() {
UpdateTreeResourcesForGpuRasterizationIfNeeded();
sync_tree()->set_needs_update_draw_properties();
- if (settings_.impl_side_painting) {
- // Impl-side painting needs an update immediately post-commit to have the
- // opportunity to create tilings. Other paths can call UpdateDrawProperties
- // more lazily when needed prior to drawing. Because invalidations may
- // be coming from the main thread, it's safe to do an update for lcd text
- // at this point and see if lcd text needs to be disabled on any layers.
- bool update_lcd_text = true;
- sync_tree()->UpdateDrawProperties(update_lcd_text);
- // Start working on newly created tiles immediately if needed.
- if (tile_manager_ && tile_priorities_dirty_) {
- PrepareTiles();
- } else {
- NotifyReadyToActivate();
-
- // Ensure we get ReadyToDraw signal even when PrepareTiles not run. This
- // is important for SingleThreadProxy and impl-side painting case. For
- // STP, we commit to active tree and RequiresHighResToDraw, and set
- // Scheduler to wait for ReadyToDraw signal to avoid Checkerboard.
- if (proxy_->CommitToActiveTree())
- NotifyReadyToDraw();
- }
- } else {
- // If we're not in impl-side painting, the tree is immediately considered
- // active.
- ActivateSyncTree();
+ // We need an update immediately post-commit to have the opportunity to create
+ // tilings. Because invalidations may be coming from the main thread, it's
+ // safe to do an update for lcd text at this point and see if lcd text needs
+ // to be disabled on any layers.
+ bool update_lcd_text = true;
+ sync_tree()->UpdateDrawProperties(update_lcd_text);
+ // Start working on newly created tiles immediately if needed.
+ // TODO(vmpstr): Investigate always having PrepareTiles issue
+ // NotifyReadyToActivate, instead of handling it here.
+ bool did_prepare_tiles = PrepareTiles();
+ if (!did_prepare_tiles) {
+ NotifyReadyToActivate();
+
+ // Ensure we get ReadyToDraw signal even when PrepareTiles not run. This
+ // is important for SingleThreadProxy and impl-side painting case. For
+ // STP, we commit to active tree and RequiresHighResToDraw, and set
+ // Scheduler to wait for ReadyToDraw signal to avoid Checkerboard.
+ if (proxy_->CommitToActiveTree())
+ NotifyReadyToDraw();
}
micro_benchmark_controller_.DidCompleteCommit();
@@ -381,12 +409,6 @@ bool LayerTreeHostImpl::CanDraw() const {
TRACE_EVENT_SCOPE_THREAD);
return false;
}
- if (active_tree_->ContentsTexturesPurged()) {
- TRACE_EVENT_INSTANT0(
- "cc", "LayerTreeHostImpl::CanDraw contents textures purged",
- TRACE_EVENT_SCOPE_THREAD);
- return false;
- }
if (EvictedUIResourcesExist()) {
TRACE_EVENT_INSTANT0(
"cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated",
@@ -397,24 +419,31 @@ bool LayerTreeHostImpl::CanDraw() const {
}
void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) {
- if (input_handler_client_)
- input_handler_client_->Animate(monotonic_time);
+ // mithro(TODO): Enable these checks.
+ // DCHECK(!current_begin_frame_tracker_.HasFinished());
+ // DCHECK(monotonic_time == current_begin_frame_tracker_.Current().frame_time)
+ // << "Called animate with unknown frame time!?";
+ if (!root_layer_scroll_offset_delegate_ ||
+ (CurrentlyScrollingLayer() != InnerViewportScrollLayer() &&
+ CurrentlyScrollingLayer() != OuterViewportScrollLayer())) {
+ AnimateInput(monotonic_time);
+ }
AnimatePageScale(monotonic_time);
AnimateLayers(monotonic_time);
AnimateScrollbars(monotonic_time);
AnimateTopControls(monotonic_time);
}
-void LayerTreeHostImpl::PrepareTiles() {
- if (!tile_manager_)
- return;
+bool LayerTreeHostImpl::PrepareTiles() {
if (!tile_priorities_dirty_)
- return;
-
- tile_priorities_dirty_ = false;
- tile_manager_->PrepareTiles(global_tile_state_);
+ return false;
+ client_->WillPrepareTiles();
+ bool did_prepare_tiles = tile_manager_->PrepareTiles(global_tile_state_);
+ if (did_prepare_tiles)
+ tile_priorities_dirty_ = false;
client_->DidPrepareTiles();
+ return did_prepare_tiles;
}
void LayerTreeHostImpl::StartPageScaleAnimation(
@@ -457,6 +486,22 @@ void LayerTreeHostImpl::StartPageScaleAnimation(
client_->RenewTreePriority();
}
+void LayerTreeHostImpl::SetNeedsAnimateInput() {
+ if (root_layer_scroll_offset_delegate_ &&
+ (CurrentlyScrollingLayer() == InnerViewportScrollLayer() ||
+ CurrentlyScrollingLayer() == OuterViewportScrollLayer())) {
+ if (root_layer_animation_callback_.is_null()) {
+ root_layer_animation_callback_ =
+ base::Bind(&LayerTreeHostImpl::AnimateInput, AsWeakPtr());
+ }
+ root_layer_scroll_offset_delegate_->SetNeedsAnimate(
+ root_layer_animation_callback_);
+ return;
+ }
+
+ SetNeedsAnimate();
+}
+
bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt(
const gfx::Point& viewport_point,
InputHandler::ScrollInputType type) {
@@ -566,10 +611,9 @@ void LayerTreeHostImpl::TrackDamageForAllSurfaces(
// must compute all damage tracking before drawing anything, so that we know
// the root damage rect. The root damage rect is then used to scissor each
// surface.
-
- for (int surface_index = render_surface_layer_list.size() - 1;
- surface_index >= 0;
- --surface_index) {
+ size_t render_surface_layer_list_size = render_surface_layer_list.size();
+ for (size_t i = 0; i < render_surface_layer_list_size; ++i) {
+ size_t surface_index = render_surface_layer_list_size - 1 - i;
LayerImpl* render_surface_layer = render_surface_layer_list[surface_index];
RenderSurfaceImpl* render_surface = render_surface_layer->render_surface();
DCHECK(render_surface);
@@ -745,9 +789,10 @@ DrawResult LayerTreeHostImpl::CalculateRenderPasses(
"RequiresHighResToDraw", RequiresHighResToDraw());
// Create the render passes in dependency order.
- for (int surface_index = frame->render_surface_layer_list->size() - 1;
- surface_index >= 0;
- --surface_index) {
+ size_t render_surface_layer_list_size =
+ frame->render_surface_layer_list->size();
+ for (size_t i = 0; i < render_surface_layer_list_size; ++i) {
+ size_t surface_index = render_surface_layer_list_size - 1 - i;
LayerImpl* render_surface_layer =
(*frame->render_surface_layer_list)[surface_index];
RenderSurfaceImpl* render_surface = render_surface_layer->render_surface();
@@ -795,9 +840,9 @@ DrawResult LayerTreeHostImpl::CalculateRenderPasses(
bool have_copy_request = false;
bool have_missing_animated_tiles = false;
- auto end = LayerIterator<LayerImpl>::End(frame->render_surface_layer_list);
- for (auto it =
- LayerIterator<LayerImpl>::Begin(frame->render_surface_layer_list);
+ LayerIterator end = LayerIterator::End(frame->render_surface_layer_list);
+ for (LayerIterator it =
+ LayerIterator::Begin(frame->render_surface_layer_list);
it != end; ++it) {
RenderPassId target_render_pass_id =
it.target_render_surface_layer()->render_surface()->GetRenderPassId();
@@ -822,11 +867,10 @@ DrawResult LayerTreeHostImpl::CalculateRenderPasses(
*it,
contributing_render_pass,
&append_quads_data);
- } else if (it.represents_itself() &&
- !it->visible_content_rect().IsEmpty()) {
+ } else if (it.represents_itself() && !it->visible_layer_rect().IsEmpty()) {
bool occluded =
it->draw_properties().occlusion_in_content_space.IsOccluded(
- it->visible_content_rect());
+ it->visible_layer_rect());
if (!occluded && it->WillDraw(draw_mode, resource_provider_.get())) {
DCHECK_EQ(active_tree_, it->layer_tree_impl());
@@ -852,9 +896,7 @@ DrawResult LayerTreeHostImpl::CalculateRenderPasses(
// For layers that represent themselves, add composite frame timing
// requests if the visible rect intersects the requested rect.
for (const auto& request : it->frame_timing_requests()) {
- const gfx::Rect& request_content_rect =
- it->LayerRectToContentRect(request.rect());
- if (request_content_rect.Intersects(it->visible_content_rect())) {
+ if (request.rect().Intersects(it->visible_layer_rect())) {
frame->composite_events.push_back(
FrameTimingTracker::FrameAndRectIds(
active_tree_->source_frame_number(), request.id()));
@@ -866,7 +908,7 @@ DrawResult LayerTreeHostImpl::CalculateRenderPasses(
}
rendering_stats_instrumentation_->AddVisibleContentArea(
- append_quads_data.visible_content_area);
+ append_quads_data.visible_layer_area);
rendering_stats_instrumentation_->AddApproximatedVisibleContentArea(
append_quads_data.approximated_visible_content_area);
rendering_stats_instrumentation_->AddCheckerboardedVisibleContentArea(
@@ -991,25 +1033,26 @@ DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) {
input_handler_client_->ReconcileElasticOverscrollAndRootScroll();
UMA_HISTOGRAM_CUSTOM_COUNTS(
- "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20);
+ "Compositing.NumActiveLayers",
+ base::saturated_cast<int>(active_tree_->NumLayers()), 1, 400, 20);
size_t total_picture_memory = 0;
for (const PictureLayerImpl* layer : active_tree()->picture_layers())
total_picture_memory += layer->GetRasterSource()->GetPictureMemoryUsage();
if (total_picture_memory != 0) {
- UMA_HISTOGRAM_COUNTS("Compositing.PictureMemoryUsageKb",
- total_picture_memory / 1024);
+ UMA_HISTOGRAM_COUNTS(
+ "Compositing.PictureMemoryUsageKb",
+ base::saturated_cast<int>(total_picture_memory / 1024));
}
bool update_lcd_text = false;
bool ok = active_tree_->UpdateDrawProperties(update_lcd_text);
DCHECK(ok) << "UpdateDrawProperties failed during draw";
- // This will cause NotifyTileStateChanged() to be called for any visible tiles
- // that completed, which will add damage to the frame for them so they appear
- // as part of the current frame being drawn.
- if (tile_manager_)
- tile_manager_->UpdateVisibleTiles(global_tile_state_);
+ // This will cause NotifyTileStateChanged() to be called for any tiles that
+ // completed, which will add damage for visible tiles to the frame for them so
+ // they appear as part of the current frame being drawn.
+ tile_manager_->Flush();
frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList();
frame->render_passes.clear();
@@ -1122,7 +1165,7 @@ void LayerTreeHostImpl::RemoveRenderPasses(FrameData* frame) {
}
void LayerTreeHostImpl::EvictTexturesForTesting() {
- EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0));
+ UpdateTileManagerMemoryPolicy(ManagedMemoryPolicy(0));
}
void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) {
@@ -1144,29 +1187,13 @@ void LayerTreeHostImpl::ResetTreesForTesting() {
recycle_tree_ = nullptr;
}
-void LayerTreeHostImpl::EnforceManagedMemoryPolicy(
- const ManagedMemoryPolicy& policy) {
-
- bool evicted_resources = client_->ReduceContentsTextureMemoryOnImplThread(
- visible_ ? policy.bytes_limit_when_visible : 0,
- ManagedMemoryPolicy::PriorityCutoffToValue(
- visible_ ? policy.priority_cutoff_when_visible
- : gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING));
- if (evicted_resources) {
- active_tree_->SetContentsTexturesPurged();
- if (pending_tree_)
- pending_tree_->SetContentsTexturesPurged();
- client_->SetNeedsCommitOnImplThread();
- client_->OnCanDrawStateChanged(CanDraw());
- client_->RenewTreePriority();
- }
-
- UpdateTileManagerMemoryPolicy(policy);
+size_t LayerTreeHostImpl::SourceAnimationFrameNumberForTesting() const {
+ return fps_counter_->current_frame_number();
}
void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy(
const ManagedMemoryPolicy& policy) {
- if (!tile_manager_)
+ if (!resource_pool_)
return;
global_tile_state_.hard_memory_limit_in_bytes = 0;
@@ -1186,6 +1213,16 @@ void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy(
gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING);
global_tile_state_.num_resources_limit = policy.num_resources_limit;
+ if (output_surface_ && global_tile_state_.hard_memory_limit_in_bytes > 0) {
+ // If |global_tile_state_.hard_memory_limit_in_bytes| is greater than 0, we
+ // allow the worker context to retain allocated resources. Notify the worker
+ // context. If the memory policy has become zero, we'll handle the
+ // notification in NotifyAllTileTasksCompleted, after in-progress work
+ // finishes.
+ output_surface_->SetWorkerContextShouldAggressivelyFreeResources(
+ false /* aggressively_free_resources */);
+ }
+
// TODO(reveman): We should avoid keeping around unused resources if
// possible. crbug.com/224475
// Unused limit is calculated from soft-limit, as hard-limit may
@@ -1217,7 +1254,6 @@ void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy(
}
void LayerTreeHostImpl::DidModifyTilePriorities() {
- DCHECK(settings_.impl_side_painting);
// Mark priorities as dirty and schedule a PrepareTiles().
tile_priorities_dirty_ = true;
client_->SetNeedsPrepareTilesOnImplThread();
@@ -1269,6 +1305,15 @@ void LayerTreeHostImpl::NotifyReadyToDraw() {
client_->NotifyReadyToDraw();
}
+void LayerTreeHostImpl::NotifyAllTileTasksCompleted() {
+ // The tile tasks started by the most recent call to PrepareTiles have
+ // completed. Now is a good time to free resources if necessary.
+ if (output_surface_ && global_tile_state_.hard_memory_limit_in_bytes == 0) {
+ output_surface_->SetWorkerContextShouldAggressivelyFreeResources(
+ true /* aggressively_free_resources */);
+ }
+}
+
void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) {
TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged");
@@ -1300,14 +1345,17 @@ void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) {
// This is short term solution to synchronously drop tile resources when
// using synchronous compositing to avoid memory usage regression.
// TODO(boliu): crbug.com/499004 to track removing this.
- if (!policy.bytes_limit_when_visible && tile_manager_ &&
+ if (!policy.bytes_limit_when_visible && resource_pool_ &&
settings_.using_synchronous_renderer_compositor) {
ReleaseTreeResources();
- // TileManager destruction will synchronoulsy wait for all tile workers to
- // be cancelled or completed. This allows all resources to be freed
- // synchronously.
- DestroyTileManager();
- CreateAndSetTileManager();
+ CleanUpTileManager();
+
+ // Force a call to NotifyAllTileTasks completed - otherwise this logic may
+ // be skipped if no work was enqueued at the time the tile manager was
+ // destroyed.
+ NotifyAllTileTasksCompleted();
+
+ CreateTileManagerResources();
RecreateTreeResources();
}
}
@@ -1315,7 +1363,6 @@ void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) {
void LayerTreeHostImpl::SetTreeActivationCallback(
const base::Closure& callback) {
DCHECK(proxy_->IsImplThread());
- DCHECK(settings_.impl_side_painting || callback.is_null());
tree_activation_callback_ = callback;
}
@@ -1336,10 +1383,10 @@ void LayerTreeHostImpl::SetManagedMemoryPolicy(
// In single-thread mode, this can be called on the main thread by
// GLRenderer::OnMemoryAllocationChanged.
DebugScopedSetImplThread impl_thread(proxy_);
- EnforceManagedMemoryPolicy(actual_policy);
+ UpdateTileManagerMemoryPolicy(actual_policy);
} else {
DCHECK(proxy_->IsImplThread());
- EnforceManagedMemoryPolicy(actual_policy);
+ UpdateTileManagerMemoryPolicy(actual_policy);
}
// If there is already enough memory to draw everything imaginable and the
@@ -1415,9 +1462,7 @@ void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) {
// In OOM, we now might be able to release more resources that were held
// because they were exported.
- if (tile_manager_) {
- DCHECK(resource_pool_);
-
+ if (resource_pool_) {
resource_pool_->CheckBusyResources(false);
resource_pool_->ReduceResourceUsage();
}
@@ -1496,10 +1541,7 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame) {
!output_surface_->context_provider());
rendering_stats_instrumentation_->IncrementFrameCount(1);
- if (tile_manager_) {
- memory_history_->SaveEntry(
- tile_manager_->memory_stats_from_last_assign());
- }
+ memory_history_->SaveEntry(tile_manager_->memory_stats_from_last_assign());
if (debug_state_.ShowHudRects()) {
debug_rect_history_->SaveDebugRectsForCurrentFrame(
@@ -1509,13 +1551,6 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame) {
debug_state_);
}
- if (!settings_.impl_side_painting && debug_state_.continuous_painting) {
- const RenderingStats& stats =
- rendering_stats_instrumentation_->GetRenderingStats();
- paint_time_counter_->SavePaintTime(
- stats.begin_main_frame_to_commit_duration.GetLastTimeDelta());
- }
-
bool is_new_trace;
TRACE_EVENT_IS_NEW_TRACE(&is_new_trace);
if (is_new_trace) {
@@ -1549,7 +1584,9 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame) {
if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) {
bool disable_picture_quad_image_filtering =
- IsActivelyScrolling() || animation_registrar_->needs_animate_layers();
+ IsActivelyScrolling() ||
+ (animation_host_ ? animation_host_->NeedsAnimateLayers()
+ : animation_registrar_->needs_animate_layers());
scoped_ptr<SoftwareRenderer> temp_software_renderer =
SoftwareRenderer::Create(this, &settings_.renderer_settings,
@@ -1593,10 +1630,6 @@ void LayerTreeHostImpl::DidDrawAllLayers(const FrameData& frame) {
for (auto& it : video_frame_controllers_)
it->DidDrawFrame();
-
- // Once all layers have been drawn, pending texture uploads should no
- // longer block future uploads.
- resource_provider_->MarkPendingUploadsAsNonBlocking();
}
void LayerTreeHostImpl::FinishAllRendering() {
@@ -1674,11 +1707,13 @@ void LayerTreeHostImpl::UpdateTreeResourcesForGpuRasterizationIfNeeded() {
return;
// Clean up and replace existing tile manager with another one that uses
- // appropriate rasterizer.
+ // appropriate rasterizer. Only do this however if we already have a
+ // resource pool, since otherwise we might not be able to create a new
+ // one.
ReleaseTreeResources();
- if (tile_manager_) {
- DestroyTileManager();
- CreateAndSetTileManager();
+ if (resource_pool_) {
+ CleanUpTileManager();
+ CreateTileManagerResources();
}
RecreateTreeResources();
@@ -1723,16 +1758,7 @@ bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) {
}
void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) {
- // Sample the frame time now. This time will be used for updating animations
- // when we draw.
- DCHECK(!current_begin_frame_args_.IsValid());
- current_begin_frame_args_ = args;
- // TODO(mithro): Stop overriding the frame time once the usage of frame
- // timing is unified.
- current_begin_frame_args_.frame_time = gfx::FrameTime::Now();
-
- // Cache the begin impl frame interval
- begin_impl_frame_interval_ = args.interval;
+ current_begin_frame_tracker_.Start(args);
if (is_likely_to_require_a_draw_) {
// Optimistically schedule a draw. This will let us expect the tile manager
@@ -1746,8 +1772,7 @@ void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) {
}
void LayerTreeHostImpl::DidFinishImplFrame() {
- DCHECK(current_begin_frame_args_.IsValid());
- current_begin_frame_args_ = BeginFrameArgs();
+ current_begin_frame_tracker_.Finish();
}
void LayerTreeHostImpl::UpdateViewportContainerSizes() {
@@ -1806,8 +1831,7 @@ void LayerTreeHostImpl::UpdateViewportContainerSizes() {
void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() {
// Only valid for the single-threaded non-scheduled/synchronous case
// using the zero copy raster worker pool.
- if (tile_manager_)
- single_thread_synchronous_task_graph_runner_->RunUntilIdle();
+ single_thread_synchronous_task_graph_runner_->RunUntilIdle();
}
void LayerTreeHostImpl::DidLoseOutputSurface() {
@@ -1837,11 +1861,15 @@ LayerImpl* LayerTreeHostImpl::CurrentlyScrollingLayer() const {
}
bool LayerTreeHostImpl::IsActivelyScrolling() const {
- return (did_lock_scrolling_layer_ && CurrentlyScrollingLayer()) ||
- (InnerViewportScrollLayer() &&
- InnerViewportScrollLayer()->IsExternalFlingActive()) ||
- (OuterViewportScrollLayer() &&
- OuterViewportScrollLayer()->IsExternalFlingActive());
+ if (!CurrentlyScrollingLayer())
+ return false;
+ if (root_layer_scroll_offset_delegate_ &&
+ (CurrentlyScrollingLayer() == InnerViewportScrollLayer() ||
+ CurrentlyScrollingLayer() == OuterViewportScrollLayer())) {
+ // ScrollDelegate cannot determine current scroll, so assume no.
+ return false;
+ }
+ return did_lock_scrolling_layer_;
}
// Content layers can be either directly scrollable or contained in an outer
@@ -1911,15 +1939,16 @@ void LayerTreeHostImpl::ActivateSyncTree() {
active_tree_->ProcessUIResourceRequestQueue();
}
+ // bounds_delta isn't a pushed property, so the newly-pushed property tree
+ // won't already account for current bounds_delta values.
+ active_tree_->UpdatePropertyTreesForBoundsDelta();
active_tree_->DidBecomeActive();
ActivateAnimations();
- if (settings_.impl_side_painting) {
- client_->RenewTreePriority();
- // If we have any picture layers, then by activating we also modified tile
- // priorities.
- if (!active_tree_->picture_layers().empty())
- DidModifyTilePriorities();
- }
+ client_->RenewTreePriority();
+ // If we have any picture layers, then by activating we also modified tile
+ // priorities.
+ if (!active_tree_->picture_layers().empty())
+ DidModifyTilePriorities();
client_->OnCanDrawStateChanged(CanDraw());
client_->DidActivateSyncTree();
@@ -1954,7 +1983,7 @@ void LayerTreeHostImpl::SetVisible(bool visible) {
return;
visible_ = visible;
DidVisibilityChange(this, visible_);
- EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
+ UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy());
// If we just became visible, we have to ensure that we draw high res tiles,
// to prevent checkerboard/low res flashes.
@@ -1963,10 +1992,11 @@ void LayerTreeHostImpl::SetVisible(bool visible) {
else
EvictAllUIResources();
- // Evict tiles immediately if invisible since this tab may never get another
- // draw or timer tick.
- if (!visible_)
- PrepareTiles();
+ // Call PrepareTiles unconditionally on visibility change since this tab may
+ // never get another draw or timer tick. When becoming visible we care about
+ // unblocking the scheduler which might be waiting for activation / ready to
+ // draw. When becoming invisible we care about evicting tiles immediately.
+ PrepareTiles();
if (!renderer_)
return;
@@ -2000,11 +2030,6 @@ size_t LayerTreeHostImpl::memory_allocation_limit_bytes() const {
return ActualManagedMemoryPolicy().bytes_limit_when_visible;
}
-int LayerTreeHostImpl::memory_allocation_priority_cutoff() const {
- return ManagedMemoryPolicy::PriorityCutoffToValue(
- ActualManagedMemoryPolicy().priority_cutoff_when_visible);
-}
-
void LayerTreeHostImpl::ReleaseTreeResources() {
active_tree_->ReleaseResources();
if (pending_tree_)
@@ -2056,28 +2081,13 @@ void LayerTreeHostImpl::CreateAndSetRenderer() {
client_->UpdateRendererCapabilitiesOnImplThread();
}
-void LayerTreeHostImpl::CreateAndSetTileManager() {
- DCHECK(!tile_manager_);
- DCHECK(settings_.impl_side_painting);
- DCHECK(output_surface_);
- DCHECK(resource_provider_);
-
+void LayerTreeHostImpl::CreateTileManagerResources() {
CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_,
&staging_resource_pool_);
- DCHECK(tile_task_worker_pool_);
- DCHECK(resource_pool_);
-
- base::SingleThreadTaskRunner* task_runner =
- proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner()
- : proxy_->MainThreadTaskRunner();
- DCHECK(task_runner);
- size_t scheduled_raster_task_limit =
+ tile_manager_->SetResources(
+ resource_pool_.get(), tile_task_worker_pool_->AsTileTaskRunner(),
IsSynchronousSingleThreaded() ? std::numeric_limits<size_t>::max()
- : settings_.scheduled_raster_task_limit;
- tile_manager_ = TileManager::Create(
- this, task_runner, resource_pool_.get(),
- tile_task_worker_pool_->AsTileTaskRunner(), scheduled_raster_task_limit);
-
+ : settings_.scheduled_raster_task_limit);
UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy());
}
@@ -2085,10 +2095,7 @@ void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool(
scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool,
scoped_ptr<ResourcePool>* resource_pool,
scoped_ptr<ResourcePool>* staging_resource_pool) {
- base::SingleThreadTaskRunner* task_runner =
- proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner()
- : proxy_->MainThreadTaskRunner();
- DCHECK(task_runner);
+ DCHECK(GetTaskRunner());
// Pass the single-threaded synchronous task graph runner to the worker pool
// if we're in synchronous single-threaded mode.
@@ -2105,7 +2112,7 @@ void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool(
ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D);
*tile_task_worker_pool = BitmapTileTaskWorkerPool::Create(
- task_runner, task_graph_runner, resource_provider_.get());
+ GetTaskRunner(), task_graph_runner, resource_provider_.get());
return;
}
@@ -2117,42 +2124,51 @@ void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool(
use_msaa_ ? settings_.gpu_rasterization_msaa_sample_count : 0;
*tile_task_worker_pool = GpuTileTaskWorkerPool::Create(
- task_runner, task_graph_runner, context_provider,
+ GetTaskRunner(), task_graph_runner, context_provider,
resource_provider_.get(), settings_.use_distance_field_text,
msaa_sample_count);
return;
}
- if (GetRendererCapabilities().using_image) {
- unsigned image_target = settings_.use_image_texture_target;
- DCHECK_IMPLIES(
- image_target == GL_TEXTURE_RECTANGLE_ARB,
- context_provider->ContextCapabilities().gpu.texture_rectangle);
- DCHECK_IMPLIES(
- image_target == GL_TEXTURE_EXTERNAL_OES,
- context_provider->ContextCapabilities().gpu.egl_image_external);
+ DCHECK(GetRendererCapabilities().using_image);
+ unsigned image_target = settings_.use_image_texture_target;
+ DCHECK_IMPLIES(image_target == GL_TEXTURE_RECTANGLE_ARB,
+ context_provider->ContextCapabilities().gpu.texture_rectangle);
+ DCHECK_IMPLIES(
+ image_target == GL_TEXTURE_EXTERNAL_OES,
+ context_provider->ContextCapabilities().gpu.egl_image_external);
- if (settings_.use_zero_copy || IsSynchronousSingleThreaded()) {
- *resource_pool =
- ResourcePool::Create(resource_provider_.get(), image_target);
+ if (settings_.use_zero_copy) {
+ *resource_pool =
+ ResourcePool::Create(resource_provider_.get(), image_target);
- *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create(
- task_runner, task_graph_runner, resource_provider_.get());
- return;
- }
+ *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create(
+ GetTaskRunner(), task_graph_runner, resource_provider_.get());
+ return;
+ }
- if (settings_.use_one_copy) {
- // We need to create a staging resource pool when using copy rasterizer.
- *staging_resource_pool =
- ResourcePool::Create(resource_provider_.get(), image_target);
- *resource_pool =
- ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D);
-
- *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create(
- task_runner, task_graph_runner, context_provider,
- resource_provider_.get(), staging_resource_pool_.get());
- return;
- }
+ if (settings_.use_one_copy) {
+ // Synchronous single-threaded mode depends on tiles being ready to
+ // draw when raster is complete. Therefore, it must use one of zero
+ // copy, software raster, or GPU raster.
+ DCHECK(!IsSynchronousSingleThreaded());
+
+ // We need to create a staging resource pool when using copy rasterizer.
+ *staging_resource_pool =
+ ResourcePool::Create(resource_provider_.get(), image_target);
+ *resource_pool =
+ ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D);
+
+ int max_copy_texture_chromium_size =
+ context_provider->ContextCapabilities()
+ .gpu.max_copy_texture_chromium_size;
+
+ *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create(
+ GetTaskRunner(), task_graph_runner, context_provider,
+ resource_provider_.get(), staging_resource_pool_.get(),
+ max_copy_texture_chromium_size,
+ settings_.use_persistent_map_for_gpu_memory_buffers);
+ return;
}
// Synchronous single-threaded mode depends on tiles being ready to
@@ -2164,7 +2180,7 @@ void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool(
resource_provider_.get(), GL_TEXTURE_2D);
*tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create(
- task_runner, task_graph_runner_, context_provider,
+ GetTaskRunner(), task_graph_runner_, context_provider,
resource_provider_.get(),
GetMaxTransferBufferUsageBytes(context_provider->ContextCapabilities(),
settings_.renderer_settings.refresh_rate));
@@ -2184,8 +2200,15 @@ void LayerTreeHostImpl::RecordMainFrameTiming(
request_ids, start_time, end_time, active_tree_->source_frame_number());
}
-void LayerTreeHostImpl::DestroyTileManager() {
- tile_manager_ = nullptr;
+void LayerTreeHostImpl::PostFrameTimingEvents(
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
+ scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
+ client_->PostFrameTimingEventsOnImplThread(composite_events.Pass(),
+ main_frame_events.Pass());
+}
+
+void LayerTreeHostImpl::CleanUpTileManager() {
+ tile_manager_->FinishTasksAndCleanUp();
resource_pool_ = nullptr;
staging_resource_pool_ = nullptr;
tile_task_worker_pool_ = nullptr;
@@ -2207,7 +2230,7 @@ bool LayerTreeHostImpl::InitializeRenderer(
// Note: order is important here.
renderer_ = nullptr;
- DestroyTileManager();
+ CleanUpTileManager();
resource_provider_ = nullptr;
output_surface_ = nullptr;
@@ -2224,15 +2247,15 @@ bool LayerTreeHostImpl::InitializeRenderer(
proxy_->blocking_main_thread_task_runner(),
settings_.renderer_settings.highp_threshold_min,
settings_.renderer_settings.use_rgba_4444_textures,
- settings_.renderer_settings.texture_id_allocation_chunk_size);
+ settings_.renderer_settings.texture_id_allocation_chunk_size,
+ settings_.use_persistent_map_for_gpu_memory_buffers);
CreateAndSetRenderer();
// Since the new renderer may be capable of MSAA, update status here.
UpdateGpuRasterizationStatus();
- if (settings_.impl_side_painting && settings_.raster_enabled)
- CreateAndSetTileManager();
+ CreateTileManagerResources();
RecreateTreeResources();
// Initialize vsync parameters to sane values.
@@ -2419,18 +2442,42 @@ static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) {
return false;
}
+InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl(
+ LayerImpl* scrolling_layer_impl,
+ InputHandler::ScrollInputType type) {
+ if (!scrolling_layer_impl)
+ return SCROLL_IGNORED;
+
+ top_controls_manager_->ScrollBegin();
+
+ active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl);
+ should_bubble_scrolls_ = (type != NON_BUBBLING_GESTURE);
+ wheel_scrolling_ = (type == WHEEL);
+ client_->RenewTreePriority();
+ UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false);
+ return SCROLL_STARTED;
+}
+
+InputHandler::ScrollStatus LayerTreeHostImpl::RootScrollBegin(
+ InputHandler::ScrollInputType type) {
+ TRACE_EVENT0("cc", "LayerTreeHostImpl::RootScrollBegin");
+
+ DCHECK(!CurrentlyScrollingLayer());
+ ClearCurrentlyScrollingLayer();
+
+ return ScrollBeginImpl(InnerViewportScrollLayer(), type);
+}
+
InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin(
const gfx::Point& viewport_point,
InputHandler::ScrollInputType type) {
TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin");
- top_controls_manager_->ScrollBegin();
-
DCHECK(!CurrentlyScrollingLayer());
ClearCurrentlyScrollingLayer();
- gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point,
- device_scale_factor_);
+ gfx::PointF device_viewport_point =
+ gfx::ScalePoint(viewport_point, device_scale_factor_);
LayerImpl* layer_impl =
active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
@@ -2443,27 +2490,16 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin(
}
bool scroll_on_main_thread = false;
- LayerImpl* scrolling_layer_impl =
- FindScrollLayerForDeviceViewportPoint(device_viewport_point,
- type,
- layer_impl,
- &scroll_on_main_thread,
- &scroll_affects_scroll_handler_);
+ LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint(
+ device_viewport_point, type, layer_impl, &scroll_on_main_thread,
+ &scroll_affects_scroll_handler_);
if (scroll_on_main_thread) {
UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true);
return SCROLL_ON_MAIN_THREAD;
}
- if (scrolling_layer_impl) {
- active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl);
- should_bubble_scrolls_ = (type != NON_BUBBLING_GESTURE);
- wheel_scrolling_ = (type == WHEEL);
- client_->RenewTreePriority();
- UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false);
- return SCROLL_STARTED;
- }
- return SCROLL_IGNORED;
+ return ScrollBeginImpl(scrolling_layer_impl, type);
}
InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated(
@@ -2555,13 +2591,6 @@ gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta(
if (start_clipped || end_clipped)
return gfx::Vector2dF();
- // local_start_point and local_end_point are in content space but we want to
- // move them to layer space for scrolling.
- float width_scale = 1.f / layer_impl->contents_scale_x();
- float height_scale = 1.f / layer_impl->contents_scale_y();
- local_start_point.Scale(width_scale, height_scale);
- local_end_point.Scale(width_scale, height_scale);
-
// Apply the scroll delta.
gfx::ScrollOffset previous_offset = layer_impl->CurrentScrollOffset();
layer_impl->ScrollBy(local_end_point - local_start_point);
@@ -2572,16 +2601,11 @@ gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta(
// ScreenSpaceTransform.
gfx::PointF actual_local_end_point =
local_start_point + gfx::Vector2dF(scrolled.x(), scrolled.y());
- gfx::PointF actual_local_content_end_point =
- gfx::ScalePoint(actual_local_end_point,
- 1.f / width_scale,
- 1.f / height_scale);
// Calculate the applied scroll delta in viewport space coordinates.
gfx::PointF actual_screen_space_end_point =
MathUtil::MapPoint(layer_impl->screen_space_transform(),
- actual_local_content_end_point,
- &end_clipped);
+ actual_local_end_point, &end_clipped);
DCHECK(!end_clipped);
if (end_clipped)
return gfx::Vector2dF();
@@ -2601,7 +2625,10 @@ static gfx::Vector2dF ScrollLayerWithLocalDelta(
layer_impl->ScrollBy(delta);
gfx::ScrollOffset scrolled =
layer_impl->CurrentScrollOffset() - previous_offset;
- return gfx::Vector2dF(scrolled.x(), scrolled.y());
+ gfx::Vector2dF consumed_scroll(scrolled.x(), scrolled.y());
+ consumed_scroll.Scale(page_scale_factor);
+
+ return consumed_scroll;
}
gfx::Vector2dF LayerTreeHostImpl::ScrollLayer(LayerImpl* layer_impl,
@@ -2645,6 +2672,13 @@ InputHandlerScrollResult LayerTreeHostImpl::ScrollBy(
bool did_scroll_y = false;
bool did_scroll_top_controls = false;
+ if (pinch_gesture_active_ && settings().invert_viewport_scroll_order) {
+ // Scrolls during a pinch gesture should pan the visual viewport, rather
+ // than a typical bubbling scroll.
+ viewport()->Pan(pending_delta);
+ return InputHandlerScrollResult();
+ }
+
for (LayerImpl* layer_impl = CurrentlyScrollingLayer();
layer_impl;
layer_impl = nextLayerInScrollOrder(layer_impl)) {
@@ -2656,9 +2690,11 @@ InputHandlerScrollResult LayerTreeHostImpl::ScrollBy(
gfx::Vector2dF applied_delta;
if (layer_impl == InnerViewportScrollLayer()) {
+ bool affect_top_controls = true;
Viewport::ScrollResult result = viewport()->ScrollBy(pending_delta,
viewport_point,
- wheel_scrolling_);
+ wheel_scrolling_,
+ affect_top_controls);
applied_delta = result.applied_delta;
unused_root_delta = result.unused_scroll_delta;
did_scroll_top_controls = result.top_controls_applied_delta.y() != 0;
@@ -2807,19 +2843,15 @@ void LayerTreeHostImpl::ScrollEnd() {
}
InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() {
- if (!active_tree_->CurrentlyScrollingLayer())
- return SCROLL_IGNORED;
-
- if (settings_.ignore_root_layer_flings &&
- (active_tree_->CurrentlyScrollingLayer() == InnerViewportScrollLayer() ||
- active_tree_->CurrentlyScrollingLayer() == OuterViewportScrollLayer())) {
- ClearCurrentlyScrollingLayer();
+ if (!CurrentlyScrollingLayer())
return SCROLL_IGNORED;
- }
- if (!wheel_scrolling_) {
+ bool currently_scrolling_viewport =
+ CurrentlyScrollingLayer() == OuterViewportScrollLayer() ||
+ CurrentlyScrollingLayer() == InnerViewportScrollLayer();
+ if (!wheel_scrolling_ && !currently_scrolling_viewport) {
// Allow the fling to lock to the first layer that moves after the initial
- // fling |ScrollBy()| event.
+ // fling |ScrollBy()| event, unless we're already scrolling the viewport.
did_lock_scrolling_layer_ = false;
should_bubble_scrolls_ = false;
}
@@ -2833,8 +2865,7 @@ float LayerTreeHostImpl::DeviceSpaceDistanceToLayer(
if (!layer_impl)
return std::numeric_limits<float>::max();
- gfx::Rect layer_impl_bounds(
- layer_impl->content_bounds());
+ gfx::Rect layer_impl_bounds(layer_impl->bounds());
gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect(
layer_impl->screen_space_transform(),
@@ -2913,7 +2944,6 @@ bool LayerTreeHostImpl::HandleMouseOverScrollbar(LayerImpl* layer_impl,
void LayerTreeHostImpl::PinchGestureBegin() {
pinch_gesture_active_ = true;
- previous_pinch_anchor_ = gfx::Point();
client_->RenewTreePriority();
pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer();
if (active_tree_->OuterViewportScrollLayer()) {
@@ -2938,35 +2968,7 @@ void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta,
// the pinch update.
active_tree_->SetRootLayerScrollOffsetDelegate(NULL);
- // Keep the center-of-pinch anchor specified by (x, y) in a stable
- // position over the course of the magnify.
- float page_scale = active_tree_->current_page_scale_factor();
- gfx::PointF previous_scale_anchor = gfx::ScalePoint(anchor, 1.f / page_scale);
- active_tree_->SetPageScaleOnActiveTree(page_scale * magnify_delta);
- page_scale = active_tree_->current_page_scale_factor();
- gfx::PointF new_scale_anchor = gfx::ScalePoint(anchor, 1.f / page_scale);
- gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor;
-
- previous_pinch_anchor_ = anchor;
-
- // If clamping the inner viewport scroll offset causes a change, it should
- // be accounted for from the intended move.
- move -= InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset();
-
- // We manually manage the bubbling behaviour here as it is different to that
- // implemented in LayerTreeHostImpl::ScrollBy(). Specifically:
- // 1) we want to explicit limit the bubbling to the outer/inner viewports,
- // 2) we don't want the directional limitations on the unused parts that
- // ScrollBy() implements, and
- // 3) pinching should not engage the top controls manager.
- gfx::Vector2dF unused = OuterViewportScrollLayer()
- ? OuterViewportScrollLayer()->ScrollBy(move)
- : move;
-
- if (!unused.IsZero()) {
- InnerViewportScrollLayer()->ScrollBy(unused);
- InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset();
- }
+ viewport()->PinchUpdate(magnify_delta, anchor);
active_tree_->SetRootLayerScrollOffsetDelegate(
root_layer_scroll_offset_delegate_);
@@ -2982,6 +2984,7 @@ void LayerTreeHostImpl::PinchGestureEnd() {
pinch_gesture_end_should_clear_scrolling_layer_ = false;
ClearCurrentlyScrollingLayer();
}
+ viewport()->PinchEnd();
top_controls_manager_->PinchEnd();
client_->SetNeedsCommitOnImplThread();
// When a pinch ends, we may be displaying content cached at incorrect scales,
@@ -3049,6 +3052,12 @@ void LayerTreeHostImpl::ScrollViewportBy(gfx::Vector2dF scroll_delta) {
InnerViewportScrollLayer()->ScrollBy(unused_delta);
}
+void LayerTreeHostImpl::AnimateInput(base::TimeTicks monotonic_time) {
+ DCHECK(proxy_->IsImplThread());
+ if (input_handler_client_)
+ input_handler_client_->Animate(monotonic_time);
+}
+
void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) {
if (!page_scale_animation_)
return;
@@ -3115,18 +3124,31 @@ void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) {
if (!settings_.accelerated_animation_enabled || !active_tree_->root_layer())
return;
- if (animation_registrar_->AnimateLayers(monotonic_time))
- SetNeedsAnimate();
+ if (animation_host_) {
+ if (animation_host_->AnimateLayers(monotonic_time))
+ SetNeedsAnimate();
+ } else {
+ if (animation_registrar_->AnimateLayers(monotonic_time))
+ SetNeedsAnimate();
+ }
}
void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) {
if (!settings_.accelerated_animation_enabled || !active_tree_->root_layer())
return;
- scoped_ptr<AnimationEventsVector> events =
- animation_registrar_->CreateEvents();
- const bool has_active_animations = animation_registrar_->UpdateAnimationState(
- start_ready_animations, events.get());
+ bool has_active_animations = false;
+ scoped_ptr<AnimationEventsVector> events;
+
+ if (animation_host_) {
+ events = animation_host_->CreateEvents();
+ has_active_animations = animation_host_->UpdateAnimationState(
+ start_ready_animations, events.get());
+ } else {
+ events = animation_registrar_->CreateEvents();
+ has_active_animations = animation_registrar_->UpdateAnimationState(
+ start_ready_animations, events.get());
+ }
if (!events->empty())
client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass());
@@ -3139,8 +3161,13 @@ void LayerTreeHostImpl::ActivateAnimations() {
if (!settings_.accelerated_animation_enabled || !active_tree_->root_layer())
return;
- if (animation_registrar_->ActivateAnimations())
- SetNeedsAnimate();
+ if (animation_host_) {
+ if (animation_host_->ActivateAnimations())
+ SetNeedsAnimate();
+ } else {
+ if (animation_registrar_->ActivateAnimations())
+ SetNeedsAnimate();
+ }
}
std::string LayerTreeHostImpl::LayerTreeAsJson() const {
@@ -3148,15 +3175,11 @@ std::string LayerTreeHostImpl::LayerTreeAsJson() const {
if (active_tree_->root_layer()) {
scoped_ptr<base::Value> json(active_tree_->root_layer()->LayerTreeAsJson());
base::JSONWriter::WriteWithOptions(
- json.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &str);
+ *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &str);
}
return str;
}
-int LayerTreeHostImpl::SourceAnimationFrameNumber() const {
- return fps_counter_->current_frame_number();
-}
-
void LayerTreeHostImpl::StartAnimatingScrollbarAnimationController(
ScrollbarAnimationController* controller) {
scrollbar_animation_controllers_.insert(controller);
@@ -3182,8 +3205,9 @@ void LayerTreeHostImpl::AddVideoFrameController(
VideoFrameController* controller) {
bool was_empty = video_frame_controllers_.empty();
video_frame_controllers_.insert(controller);
- if (current_begin_frame_args_.IsValid())
- controller->OnBeginFrame(current_begin_frame_args_);
+ if (current_begin_frame_tracker_.DangerousMethodHasStarted() &&
+ !current_begin_frame_tracker_.DangerousMethodHasFinished())
+ controller->OnBeginFrame(current_begin_frame_tracker_.Current());
if (was_empty)
client_->SetVideoNeedsBeginFrames(true);
}
@@ -3210,14 +3234,13 @@ TreePriority LayerTreeHostImpl::GetTreePriority() const {
}
BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const {
- // Try to use the current frame time to keep animations non-jittery. But if
- // we're not in a frame (because this is during an input event or a delayed
- // task), fall back to physical time. This should still be monotonic.
- if (current_begin_frame_args_.IsValid())
- return current_begin_frame_args_;
- return BeginFrameArgs::Create(
- BEGINFRAME_FROM_HERE, gfx::FrameTime::Now(), base::TimeTicks(),
- BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL);
+ // TODO(mithro): Replace call with current_begin_frame_tracker_.Current()
+ // once all calls which happens outside impl frames are fixed.
+ return current_begin_frame_tracker_.DangerousMethodCurrentOrLast();
+}
+
+base::TimeDelta LayerTreeHostImpl::CurrentBeginFrameInterval() const {
+ return current_begin_frame_tracker_.Interval();
}
scoped_refptr<base::trace_event::ConvertableToTraceFormat>
@@ -3310,7 +3333,7 @@ void LayerTreeHostImpl::CreateUIResource(UIResourceId uid,
// Allow for multiple creation requests with the same UIResourceId. The
// previous resource is simply deleted.
- ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
+ ResourceId id = ResourceIdForUIResource(uid);
if (id)
DeleteUIResource(uid);
@@ -3343,7 +3366,7 @@ void LayerTreeHostImpl::CreateUIResource(UIResourceId uid,
}
void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
- ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
+ ResourceId id = ResourceIdForUIResource(uid);
if (id) {
resource_provider_->DeleteResource(id);
ui_resource_map_.erase(uid);
@@ -3368,8 +3391,7 @@ void LayerTreeHostImpl::EvictAllUIResources() {
client_->RenewTreePriority();
}
-ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
- UIResourceId uid) const {
+ResourceId LayerTreeHostImpl::ResourceIdForUIResource(UIResourceId uid) const {
UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
if (iter != ui_resource_map_.end())
return iter->second.resource_id;
@@ -3425,6 +3447,10 @@ void LayerTreeHostImpl::ScrollAnimationCreate(
LayerImpl* layer_impl,
const gfx::ScrollOffset& target_offset,
const gfx::ScrollOffset& current_offset) {
+ if (animation_host_)
+ return animation_host_->ImplOnlyScrollAnimationCreate(
+ layer_impl->id(), target_offset, current_offset);
+
scoped_ptr<ScrollOffsetAnimationCurve> curve =
ScrollOffsetAnimationCurve::Create(target_offset,
EaseInOutTimingFunction::Create());
@@ -3441,6 +3467,11 @@ void LayerTreeHostImpl::ScrollAnimationCreate(
bool LayerTreeHostImpl::ScrollAnimationUpdateTarget(
LayerImpl* layer_impl,
const gfx::Vector2dF& scroll_delta) {
+ if (animation_host_)
+ return animation_host_->ImplOnlyScrollAnimationUpdateTarget(
+ layer_impl->id(), scroll_delta, layer_impl->MaxScrollOffset(),
+ CurrentBeginFrameArgs().frame_time);
+
Animation* animation =
layer_impl->layer_animation_controller()
? layer_impl->layer_animation_controller()->GetAnimation(
@@ -3464,4 +3495,132 @@ bool LayerTreeHostImpl::ScrollAnimationUpdateTarget(
return true;
}
+
+bool LayerTreeHostImpl::IsLayerInTree(int layer_id,
+ LayerTreeType tree_type) const {
+ if (tree_type == LayerTreeType::ACTIVE) {
+ return active_tree() ? active_tree()->LayerById(layer_id) != nullptr
+ : false;
+ } else {
+ if (pending_tree() && pending_tree()->LayerById(layer_id))
+ return true;
+ if (recycle_tree() && recycle_tree()->LayerById(layer_id))
+ return true;
+
+ return false;
+ }
+}
+
+void LayerTreeHostImpl::SetMutatorsNeedCommit() {
+ SetNeedsCommit();
+}
+
+void LayerTreeHostImpl::SetTreeLayerFilterMutated(
+ int layer_id,
+ LayerTreeImpl* tree,
+ const FilterOperations& filters) {
+ if (!tree)
+ return;
+
+ LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
+ if (layer)
+ layer->OnFilterAnimated(filters);
+}
+
+void LayerTreeHostImpl::SetTreeLayerOpacityMutated(int layer_id,
+ LayerTreeImpl* tree,
+ float opacity) {
+ if (!tree)
+ return;
+
+ LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
+ if (layer)
+ layer->OnOpacityAnimated(opacity);
+}
+
+void LayerTreeHostImpl::SetTreeLayerTransformMutated(
+ int layer_id,
+ LayerTreeImpl* tree,
+ const gfx::Transform& transform) {
+ if (!tree)
+ return;
+
+ LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
+ if (layer)
+ layer->OnTransformAnimated(transform);
+}
+
+void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated(
+ int layer_id,
+ LayerTreeImpl* tree,
+ const gfx::ScrollOffset& scroll_offset) {
+ if (!tree)
+ return;
+
+ LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
+ if (layer)
+ layer->OnScrollOffsetAnimated(scroll_offset);
+}
+
+void LayerTreeHostImpl::SetLayerFilterMutated(int layer_id,
+ LayerTreeType tree_type,
+ const FilterOperations& filters) {
+ if (tree_type == LayerTreeType::ACTIVE) {
+ SetTreeLayerFilterMutated(layer_id, active_tree(), filters);
+ } else {
+ SetTreeLayerFilterMutated(layer_id, pending_tree(), filters);
+ SetTreeLayerFilterMutated(layer_id, recycle_tree(), filters);
+ }
+}
+
+void LayerTreeHostImpl::SetLayerOpacityMutated(int layer_id,
+ LayerTreeType tree_type,
+ float opacity) {
+ if (tree_type == LayerTreeType::ACTIVE) {
+ SetTreeLayerOpacityMutated(layer_id, active_tree(), opacity);
+ } else {
+ SetTreeLayerOpacityMutated(layer_id, pending_tree(), opacity);
+ SetTreeLayerOpacityMutated(layer_id, recycle_tree(), opacity);
+ }
+}
+
+void LayerTreeHostImpl::SetLayerTransformMutated(
+ int layer_id,
+ LayerTreeType tree_type,
+ const gfx::Transform& transform) {
+ if (tree_type == LayerTreeType::ACTIVE) {
+ SetTreeLayerTransformMutated(layer_id, active_tree(), transform);
+ } else {
+ SetTreeLayerTransformMutated(layer_id, pending_tree(), transform);
+ SetTreeLayerTransformMutated(layer_id, recycle_tree(), transform);
+ }
+}
+
+void LayerTreeHostImpl::SetLayerScrollOffsetMutated(
+ int layer_id,
+ LayerTreeType tree_type,
+ const gfx::ScrollOffset& scroll_offset) {
+ if (tree_type == LayerTreeType::ACTIVE) {
+ SetTreeLayerScrollOffsetMutated(layer_id, active_tree(), scroll_offset);
+ } else {
+ SetTreeLayerScrollOffsetMutated(layer_id, pending_tree(), scroll_offset);
+ SetTreeLayerScrollOffsetMutated(layer_id, recycle_tree(), scroll_offset);
+ }
+}
+
+void LayerTreeHostImpl::ScrollOffsetAnimationFinished() {
+ ScrollEnd();
+}
+
+gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation(
+ int layer_id) const {
+ if (active_tree()) {
+ LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id);
+ if (layer)
+ return layer->ScrollOffsetForAnimation();
+ }
+
+ return gfx::ScrollOffset();
+}
+
} // namespace cc
diff --git a/chromium/cc/trees/layer_tree_host_impl.h b/chromium/cc/trees/layer_tree_host_impl.h
index 42454a61c00..f66f5b1de83 100644
--- a/chromium/cc/trees/layer_tree_host_impl.h
+++ b/chromium/cc/trees/layer_tree_host_impl.h
@@ -32,11 +32,13 @@
#include "cc/quads/render_pass.h"
#include "cc/resources/resource_provider.h"
#include "cc/resources/ui_resource_client.h"
+#include "cc/scheduler/begin_frame_tracker.h"
#include "cc/scheduler/commit_earlyout_reason.h"
#include "cc/scheduler/draw_result.h"
#include "cc/scheduler/video_frame_controller.h"
#include "cc/tiles/tile_manager.h"
#include "cc/trees/layer_tree_settings.h"
+#include "cc/trees/mutator_host_client.h"
#include "cc/trees/proxy.h"
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -48,6 +50,7 @@ class ScrollOffset;
namespace cc {
+class AnimationHost;
class CompletionEvent;
class CompositorFrameMetadata;
class DebugRectHistory;
@@ -109,15 +112,12 @@ class LayerTreeHostImplClient {
virtual void SetVideoNeedsBeginFrames(bool needs_begin_frames) = 0;
virtual void PostAnimationEventsToMainThreadOnImplThread(
scoped_ptr<AnimationEventsVector> events) = 0;
- // Returns true if resources were deleted by this call.
- virtual bool ReduceContentsTextureMemoryOnImplThread(
- size_t limit_bytes,
- int priority_cutoff) = 0;
virtual bool IsInsideDraw() = 0;
virtual void RenewTreePriority() = 0;
virtual void PostDelayedAnimationTaskOnImplThread(const base::Closure& task,
base::TimeDelta delay) = 0;
virtual void DidActivateSyncTree() = 0;
+ virtual void WillPrepareTiles() = 0;
virtual void DidPrepareTiles() = 0;
// Called when page scale animation has completed on the impl thread.
@@ -126,6 +126,10 @@ class LayerTreeHostImplClient {
// Called when output surface asks for a draw.
virtual void OnDrawForOutputSurface() = 0;
+ virtual void PostFrameTimingEventsOnImplThread(
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
+ scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) = 0;
+
protected:
virtual ~LayerTreeHostImplClient() {}
};
@@ -140,6 +144,7 @@ class CC_EXPORT LayerTreeHostImpl
public TopControlsManagerClient,
public ScrollbarAnimationControllerClient,
public VideoFrameControllerClient,
+ public MutatorHostClient,
public base::SupportsWeakPtr<LayerTreeHostImpl> {
public:
static scoped_ptr<LayerTreeHostImpl> Create(
@@ -158,6 +163,8 @@ class CC_EXPORT LayerTreeHostImpl
InputHandler::ScrollStatus ScrollBegin(
const gfx::Point& viewport_point,
InputHandler::ScrollInputType type) override;
+ InputHandler::ScrollStatus RootScrollBegin(
+ InputHandler::ScrollInputType type) override;
InputHandler::ScrollStatus ScrollAnimated(
const gfx::Point& viewport_point,
const gfx::Vector2dF& scroll_delta) override;
@@ -180,7 +187,7 @@ class CC_EXPORT LayerTreeHostImpl
bool anchor_point,
float page_scale,
base::TimeDelta duration);
- void SetNeedsAnimate() override;
+ void SetNeedsAnimateInput() override;
bool IsCurrentlyScrollingLayerAt(const gfx::Point& viewport_point,
InputHandler::ScrollInputType type) override;
bool HaveWheelEventHandlersAt(const gfx::Point& viewport_point) override;
@@ -226,7 +233,39 @@ class CC_EXPORT LayerTreeHostImpl
void DidAnimateScrollOffset();
void SetViewportDamage(const gfx::Rect& damage_rect);
- virtual void PrepareTiles();
+ void SetTreeLayerFilterMutated(int layer_id,
+ LayerTreeImpl* tree,
+ const FilterOperations& filters);
+ void SetTreeLayerOpacityMutated(int layer_id,
+ LayerTreeImpl* tree,
+ float opacity);
+ void SetTreeLayerTransformMutated(int layer_id,
+ LayerTreeImpl* tree,
+ const gfx::Transform& transform);
+ void SetTreeLayerScrollOffsetMutated(int layer_id,
+ LayerTreeImpl* tree,
+ const gfx::ScrollOffset& scroll_offset);
+
+ // LayerTreeMutatorsClient implementation.
+ bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override;
+ void SetMutatorsNeedCommit() override;
+ void SetLayerFilterMutated(int layer_id,
+ LayerTreeType tree_type,
+ const FilterOperations& filters) override;
+ void SetLayerOpacityMutated(int layer_id,
+ LayerTreeType tree_type,
+ float opacity) override;
+ void SetLayerTransformMutated(int layer_id,
+ LayerTreeType tree_type,
+ const gfx::Transform& transform) override;
+ void SetLayerScrollOffsetMutated(
+ int layer_id,
+ LayerTreeType tree_type,
+ const gfx::ScrollOffset& scroll_offset) override;
+ void ScrollOffsetAnimationFinished() override;
+ gfx::ScrollOffset GetScrollOffsetForAnimation(int layer_id) const override;
+
+ virtual bool PrepareTiles();
// Returns DRAW_SUCCESS unless problems occured preparing the frame, and we
// should try to avoid displaying the frame. If PrepareToDraw is called,
@@ -250,6 +289,8 @@ class CC_EXPORT LayerTreeHostImpl
// Resets all of the trees to an empty state.
void ResetTreesForTesting();
+ size_t SourceAnimationFrameNumberForTesting() const;
+
DrawMode GetDrawMode() const;
// Viewport size in draw space: this size is in physical pixels and is used
@@ -265,6 +306,7 @@ class CC_EXPORT LayerTreeHostImpl
// TileManagerClient implementation.
void NotifyReadyToActivate() override;
void NotifyReadyToDraw() override;
+ void NotifyAllTileTasksCompleted() override;
void NotifyTileStateChanged(const Tile* tile) override;
scoped_ptr<RasterTilePriorityQueue> BuildRasterQueue(
TreePriority tree_priority,
@@ -316,7 +358,6 @@ class CC_EXPORT LayerTreeHostImpl
std::string LayerTreeAsJson() const;
void FinishAllRendering();
- int SourceAnimationFrameNumber() const;
virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface);
TileManager* tile_manager() { return tile_manager_.get(); }
@@ -388,12 +429,12 @@ class CC_EXPORT LayerTreeHostImpl
bool AnimationsAreVisible() { return visible() && CanDraw(); }
void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); }
+ void SetNeedsAnimate();
void SetNeedsRedraw();
ManagedMemoryPolicy ActualManagedMemoryPolicy() const;
size_t memory_allocation_limit_bytes() const;
- int memory_allocation_priority_cutoff() const;
void SetViewportSize(const gfx::Size& device_viewport_size);
gfx::Size device_viewport_size() const { return device_viewport_size_; }
@@ -438,6 +479,7 @@ class CC_EXPORT LayerTreeHostImpl
AnimationRegistrar* animation_registrar() const {
return animation_registrar_.get();
}
+ AnimationHost* animation_host() const { return animation_host_.get(); }
void SetDebugState(const LayerTreeDebugState& new_debug_state);
const LayerTreeDebugState& debug_state() const { return debug_state_; }
@@ -451,12 +493,12 @@ class CC_EXPORT LayerTreeHostImpl
void SetTreePriority(TreePriority priority);
TreePriority GetTreePriority() const;
+ // TODO(mithro): Remove this methods which exposes the internal
+ // BeginFrameArgs to external callers.
virtual BeginFrameArgs CurrentBeginFrameArgs() const;
// Expected time between two begin impl frame calls.
- base::TimeDelta begin_impl_frame_interval() const {
- return begin_impl_frame_interval_;
- }
+ base::TimeDelta CurrentBeginFrameInterval() const;
void AsValueWithFrameInto(FrameData* frame,
base::trace_event::TracedValue* value) const;
@@ -473,13 +515,12 @@ class CC_EXPORT LayerTreeHostImpl
void EvictAllUIResources();
bool EvictedUIResourcesExist() const;
- virtual ResourceProvider::ResourceId ResourceIdForUIResource(
- UIResourceId uid) const;
+ virtual ResourceId ResourceIdForUIResource(UIResourceId uid) const;
virtual bool IsUIResourceOpaque(UIResourceId uid) const;
struct UIResourceData {
- ResourceProvider::ResourceId resource_id;
+ ResourceId resource_id;
gfx::Size size;
bool opaque;
};
@@ -538,6 +579,11 @@ class CC_EXPORT LayerTreeHostImpl
const BeginFrameArgs& start_of_main_frame_args,
const BeginFrameArgs& expected_next_main_frame_args);
+ // Post the given frame timing events to the requester.
+ void PostFrameTimingEvents(
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
+ scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events);
+
protected:
LayerTreeHostImpl(
const LayerTreeSettings& settings,
@@ -562,6 +608,8 @@ class CC_EXPORT LayerTreeHostImpl
LayerTreeHostImplClient* client_;
Proxy* proxy_;
+ BeginFrameTracker current_begin_frame_tracker_;
+
private:
gfx::Vector2dF ScrollLayerWithViewportSpaceDelta(
LayerImpl* layer_impl,
@@ -569,8 +617,8 @@ class CC_EXPORT LayerTreeHostImpl
const gfx::Vector2dF& viewport_delta);
void CreateAndSetRenderer();
- void CreateAndSetTileManager();
- void DestroyTileManager();
+ void CleanUpTileManager();
+ void CreateTileManagerResources();
void ReleaseTreeResources();
void RecreateTreeResources();
@@ -587,6 +635,11 @@ class CC_EXPORT LayerTreeHostImpl
// outer if the inner is at its scroll extents.
void ScrollViewportInnerFirst(gfx::Vector2dF scroll_delta);
+ InputHandler::ScrollStatus ScrollBeginImpl(
+ LayerImpl* scrolling_layer_impl,
+ InputHandler::ScrollInputType type);
+
+ void AnimateInput(base::TimeTicks monotonic_time);
void AnimatePageScale(base::TimeTicks monotonic_time);
void AnimateScrollbars(base::TimeTicks monotonic_time);
void AnimateTopControls(base::TimeTicks monotonic_time);
@@ -617,7 +670,6 @@ class CC_EXPORT LayerTreeHostImpl
LayerImpl* layer_impl);
void StartScrollbarFadeRecursive(LayerImpl* layer);
void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy);
- void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy);
void MarkUIResourceNotEvicted(UIResourceId uid);
@@ -630,6 +682,12 @@ class CC_EXPORT LayerTreeHostImpl
bool ScrollAnimationUpdateTarget(LayerImpl* layer_impl,
const gfx::Vector2dF& scroll_delta);
+ base::SingleThreadTaskRunner* GetTaskRunner() const {
+ DCHECK(proxy_);
+ return proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner()
+ : proxy_->MainThreadTaskRunner();
+ }
+
typedef base::hash_map<UIResourceId, UIResourceData>
UIResourceMap;
UIResourceMap ui_resource_map_;
@@ -641,11 +699,7 @@ class CC_EXPORT LayerTreeHostImpl
scoped_ptr<OutputSurface> output_surface_;
- // |resource_provider_| and |tile_manager_| can be NULL, e.g. when using tile-
- // free rendering - see OutputSurface::ForcedDrawToSoftwareDevice().
- // |tile_manager_| can also be NULL when raster_enabled is false.
scoped_ptr<ResourceProvider> resource_provider_;
- scoped_ptr<TileManager> tile_manager_;
bool content_is_suitable_for_gpu_rasterization_;
bool has_gpu_rasterization_trigger_;
bool use_gpu_rasterization_;
@@ -686,16 +740,19 @@ class CC_EXPORT LayerTreeHostImpl
// The optional delegate for the root layer scroll offset.
LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate_;
+ LayerScrollOffsetDelegate::AnimationCallback root_layer_animation_callback_;
+
const LayerTreeSettings settings_;
LayerTreeDebugState debug_state_;
bool visible_;
ManagedMemoryPolicy cached_managed_memory_policy_;
+ scoped_ptr<TileManager> tile_manager_;
+
gfx::Vector2dF accumulated_root_overscroll_;
bool pinch_gesture_active_;
bool pinch_gesture_end_should_clear_scrolling_layer_;
- gfx::Point previous_pinch_anchor_;
scoped_ptr<TopControlsManager> top_controls_manager_;
@@ -737,12 +794,8 @@ class CC_EXPORT LayerTreeHostImpl
gfx::Rect viewport_damage_rect_;
- BeginFrameArgs current_begin_frame_args_;
-
- // Expected time between two begin impl frame calls.
- base::TimeDelta begin_impl_frame_interval_;
-
scoped_ptr<AnimationRegistrar> animation_registrar_;
+ scoped_ptr<AnimationHost> animation_host_;
std::set<ScrollbarAnimationController*> scrollbar_animation_controllers_;
std::set<VideoFrameController*> video_frame_controllers_;
diff --git a/chromium/cc/trees/layer_tree_host_impl_unittest.cc b/chromium/cc/trees/layer_tree_host_impl_unittest.cc
index 8ff2f62a1e3..daa179f62eb 100644
--- a/chromium/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/chromium/cc/trees/layer_tree_host_impl_unittest.cc
@@ -27,8 +27,8 @@
#include "cc/layers/solid_color_layer_impl.h"
#include "cc/layers/solid_color_scrollbar_layer_impl.h"
#include "cc/layers/texture_layer_impl.h"
-#include "cc/layers/tiled_layer_impl.h"
#include "cc/layers/video_layer_impl.h"
+#include "cc/layers/viewport.h"
#include "cc/output/begin_frame_args.h"
#include "cc/output/compositor_frame_ack.h"
#include "cc/output/compositor_frame_metadata.h"
@@ -58,14 +58,12 @@
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/test/test_web_graphics_context_3d.h"
-#include "cc/tiles/layer_tiling_data.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/single_thread_proxy.h"
#include "media/base/media.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkMallocPixelRef.h"
-#include "ui/gfx/frame_time.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
@@ -88,9 +86,6 @@ class LayerTreeHostImplTest : public testing::Test,
base::ThreadTaskRunnerHandle::Get()),
always_impl_thread_(&proxy_),
always_main_thread_blocked_(&proxy_),
- shared_bitmap_manager_(new TestSharedBitmapManager),
- gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager),
- task_graph_runner_(new TestTaskGraphRunner),
on_can_draw_state_changed_called_(false),
did_notify_ready_to_activate_(false),
did_request_commit_(false),
@@ -98,19 +93,15 @@ class LayerTreeHostImplTest : public testing::Test,
did_request_animate_(false),
did_request_prepare_tiles_(false),
did_complete_page_scale_animation_(false),
- reduce_memory_result_(true),
- current_limit_bytes_(0),
- current_priority_cutoff_value_(0) {
+ reduce_memory_result_(true) {
media::InitializeMediaLibrary();
}
LayerTreeSettings DefaultSettings() {
LayerTreeSettings settings;
settings.minimum_occlusion_tracking_size = gfx::Size();
- settings.impl_side_painting = true;
settings.renderer_settings.texture_id_allocation_chunk_size = 1;
settings.report_overscroll_only_for_scrollable_axes = true;
- settings.use_pinch_virtual_viewport = true;
settings.gpu_rasterization_enabled = true;
return settings;
}
@@ -149,12 +140,6 @@ class LayerTreeHostImplTest : public testing::Test,
void SetVideoNeedsBeginFrames(bool needs_begin_frames) override {}
void PostAnimationEventsToMainThreadOnImplThread(
scoped_ptr<AnimationEventsVector> events) override {}
- bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes,
- int priority_cutoff) override {
- current_limit_bytes_ = limit_bytes;
- current_priority_cutoff_value_ = priority_cutoff;
- return reduce_memory_result_;
- }
bool IsInsideDraw() override { return false; }
void RenewTreePriority() override {}
void PostDelayedAnimationTaskOnImplThread(const base::Closure& task,
@@ -163,11 +148,16 @@ class LayerTreeHostImplTest : public testing::Test,
requested_animation_delay_ = delay;
}
void DidActivateSyncTree() override {}
+ void WillPrepareTiles() override {}
void DidPrepareTiles() override {}
void DidCompletePageScaleAnimationOnImplThread() override {
did_complete_page_scale_animation_ = true;
}
void OnDrawForOutputSurface() override {}
+ void PostFrameTimingEventsOnImplThread(
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
+ scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events)
+ override {}
void set_reduce_memory_result(bool reduce_memory_result) {
reduce_memory_result_ = reduce_memory_result;
@@ -177,19 +167,21 @@ class LayerTreeHostImplTest : public testing::Test,
scoped_ptr<OutputSurface> output_surface) {
host_impl_ = LayerTreeHostImpl::Create(
settings, this, &proxy_, &stats_instrumentation_,
- shared_bitmap_manager_.get(), gpu_memory_buffer_manager_.get(),
- task_graph_runner_.get(), 0);
+ &shared_bitmap_manager_, &gpu_memory_buffer_manager_,
+ &task_graph_runner_, 0);
bool init = host_impl_->InitializeRenderer(output_surface.Pass());
host_impl_->SetViewportSize(gfx::Size(10, 10));
+ // Set the BeginFrameArgs so that methods which use it are able to.
+ host_impl_->WillBeginImplFrame(
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
return init;
}
void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) {
root->SetPosition(gfx::PointF());
root->SetBounds(gfx::Size(10, 10));
- root->SetContentBounds(gfx::Size(10, 10));
root->SetDrawsContent(true);
- root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10);
+ root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10);
root->SetHasRenderSurface(true);
host_impl_->active_tree()->SetRootLayer(root.Pass());
}
@@ -200,19 +192,27 @@ class LayerTreeHostImplTest : public testing::Test,
ExpectClearedScrollDeltasRecursive(layer->children()[i]);
}
- static void ExpectContains(const ScrollAndScaleSet& scroll_info,
- int id,
- const gfx::Vector2d& scroll_delta) {
+ static ::testing::AssertionResult ScrollInfoContains(
+ const ScrollAndScaleSet& scroll_info,
+ int id,
+ const gfx::Vector2d& scroll_delta) {
int times_encountered = 0;
for (size_t i = 0; i < scroll_info.scrolls.size(); ++i) {
if (scroll_info.scrolls[i].layer_id != id)
continue;
- EXPECT_VECTOR_EQ(scroll_delta, scroll_info.scrolls[i].scroll_delta);
+
+ if (scroll_delta != scroll_info.scrolls[i].scroll_delta) {
+ return ::testing::AssertionFailure()
+ << "Expected " << scroll_delta.ToString() << ", not "
+ << scroll_info.scrolls[i].scroll_delta.ToString();
+ }
times_encountered++;
}
- ASSERT_EQ(1, times_encountered);
+ if (times_encountered != 1)
+ return ::testing::AssertionFailure() << "No layer found with id " << id;
+ return ::testing::AssertionSuccess();
}
static void ExpectNone(const ScrollAndScaleSet& scroll_info, int id) {
@@ -242,7 +242,6 @@ class LayerTreeHostImplTest : public testing::Test,
scoped_ptr<LayerImpl> root =
LayerImpl::Create(layer_tree_impl, 1);
root->SetBounds(content_size);
- root->SetContentBounds(content_size);
root->SetPosition(gfx::PointF());
root->SetHasRenderSurface(true);
@@ -261,7 +260,6 @@ class LayerTreeHostImplTest : public testing::Test,
inner_scroll->SetScrollClipLayer(inner_clip->id());
inner_scroll->SetBounds(content_size);
- inner_scroll->SetContentBounds(content_size);
inner_scroll->SetPosition(gfx::PointF());
scoped_ptr<LayerImpl> outer_clip =
@@ -274,14 +272,12 @@ class LayerTreeHostImplTest : public testing::Test,
outer_scroll->SetScrollClipLayer(outer_clip->id());
outer_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset());
outer_scroll->SetBounds(content_size);
- outer_scroll->SetContentBounds(content_size);
outer_scroll->SetPosition(gfx::PointF());
scoped_ptr<LayerImpl> contents =
LayerImpl::Create(layer_tree_impl, kContentLayerId);
contents->SetDrawsContent(true);
contents->SetBounds(content_size);
- contents->SetContentBounds(content_size);
contents->SetPosition(gfx::PointF());
outer_scroll->AddChild(contents.Pass());
@@ -307,6 +303,34 @@ class LayerTreeHostImplTest : public testing::Test,
return scroll_layer;
}
+ // Sets up a typical virtual viewport setup with one child content layer.
+ // Returns a pointer to the content layer.
+ LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size,
+ const gfx::Size& content_size) {
+ // CreateScrollAndContentsLayers makes the outer viewport unscrollable and
+ // the inner a different size from the outer. We'll reuse its layer
+ // hierarchy but adjust the sizing to our needs.
+ CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size);
+
+ LayerImpl* content_layer =
+ host_impl_->OuterViewportScrollLayer()->children().back();
+ content_layer->SetBounds(content_size);
+ host_impl_->OuterViewportScrollLayer()->SetBounds(content_size);
+
+ LayerImpl* outer_clip = host_impl_->OuterViewportScrollLayer()->parent();
+ outer_clip->SetBounds(viewport_size);
+
+ LayerImpl* inner_clip_layer =
+ host_impl_->InnerViewportScrollLayer()->parent()->parent();
+ inner_clip_layer->SetBounds(viewport_size);
+ host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size);
+
+ host_impl_->SetViewportSize(viewport_size);
+ host_impl_->active_tree()->DidBecomeActive();
+
+ return content_layer;
+ }
+
// TODO(wjmaclean) Add clip-layer pointer to parameters.
scoped_ptr<LayerImpl> CreateScrollableLayer(int id,
const gfx::Size& size,
@@ -318,7 +342,6 @@ class LayerTreeHostImplTest : public testing::Test,
layer->SetScrollClipLayer(clip_layer->id());
layer->SetDrawsContent(true);
layer->SetBounds(size);
- layer->SetContentBounds(size);
clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2));
return layer.Pass();
}
@@ -374,32 +397,6 @@ class LayerTreeHostImplTest : public testing::Test,
EXPECT_TRUE(host_impl_->CanDraw());
EXPECT_TRUE(on_can_draw_state_changed_called_);
on_can_draw_state_changed_called_ = false;
-
- // Toggle contents textures purged without causing any evictions,
- // and make sure that it does not change can_draw.
- set_reduce_memory_result(false);
- host_impl_->SetMemoryPolicy(ManagedMemoryPolicy(
- host_impl_->memory_allocation_limit_bytes() - 1));
- EXPECT_TRUE(host_impl_->CanDraw());
- EXPECT_FALSE(on_can_draw_state_changed_called_);
- on_can_draw_state_changed_called_ = false;
-
- // Toggle contents textures purged to make sure it toggles can_draw.
- set_reduce_memory_result(true);
- host_impl_->SetMemoryPolicy(ManagedMemoryPolicy(
- host_impl_->memory_allocation_limit_bytes() - 1));
- if (always_draw) {
- EXPECT_TRUE(host_impl_->CanDraw());
- } else {
- EXPECT_FALSE(host_impl_->CanDraw());
- }
- EXPECT_TRUE(on_can_draw_state_changed_called_);
- on_can_draw_state_changed_called_ = false;
-
- host_impl_->active_tree()->ResetContentsTexturesPurged();
- EXPECT_TRUE(host_impl_->CanDraw());
- EXPECT_TRUE(on_can_draw_state_changed_called_);
- on_can_draw_state_changed_called_ = false;
}
void SetupMouseMoveAtWithDeviceScale(float device_scale_factor);
@@ -419,9 +416,9 @@ class LayerTreeHostImplTest : public testing::Test,
DebugScopedSetImplThread always_impl_thread_;
DebugScopedSetMainThreadBlocked always_main_thread_blocked_;
- scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_;
- scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_;
- scoped_ptr<TestTaskGraphRunner> task_graph_runner_;
+ TestSharedBitmapManager shared_bitmap_manager_;
+ TestGpuMemoryBufferManager gpu_memory_buffer_manager_;
+ TestTaskGraphRunner task_graph_runner_;
scoped_ptr<LayerTreeHostImpl> host_impl_;
FakeRenderingStatsInstrumentation stats_instrumentation_;
bool on_can_draw_state_changed_called_;
@@ -434,8 +431,16 @@ class LayerTreeHostImplTest : public testing::Test,
bool reduce_memory_result_;
base::Closure animation_task_;
base::TimeDelta requested_animation_delay_;
- size_t current_limit_bytes_;
- int current_priority_cutoff_value_;
+};
+
+// A test fixture for new animation timelines tests.
+class LayerTreeHostImplTimelinesTest : public LayerTreeHostImplTest {
+ public:
+ void SetUp() override {
+ LayerTreeSettings settings = DefaultSettings();
+ settings.use_compositor_animation_timelines = true;
+ CreateHostImpl(settings, CreateOutputSurface());
+ }
};
TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) {
@@ -510,17 +515,19 @@ TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) {
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(scroll_info->scrolls.size(), 1u);
- ExpectContains(*scroll_info, root->id(), scroll_delta);
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta));
gfx::Vector2d scroll_delta2(-5, 27);
root->ScrollBy(scroll_delta2);
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(scroll_info->scrolls.size(), 1u);
- ExpectContains(*scroll_info, root->id(), scroll_delta + scroll_delta2);
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(),
+ scroll_delta + scroll_delta2));
root->ScrollBy(gfx::Vector2d());
scroll_info = host_impl_->ProcessScrollDeltas();
- ExpectContains(*scroll_info, root->id(), scroll_delta + scroll_delta2);
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(),
+ scroll_delta + scroll_delta2));
}
TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) {
@@ -597,7 +604,8 @@ TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) {
host_impl_->ScrollBy(gfx::Point(), scroll_delta);
host_impl_->ScrollEnd();
scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
- ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta);
+ EXPECT_TRUE(
+ ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta));
}
TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) {
@@ -646,7 +654,6 @@ TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) {
child_layer->SetDrawsContent(true);
child_layer->SetPosition(gfx::PointF(0, 20));
child_layer->SetBounds(gfx::Size(50, 50));
- child_layer->SetContentBounds(gfx::Size(50, 50));
scroll->AddChild(child_layer.Pass());
}
@@ -846,7 +853,6 @@ TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) {
host_impl_->SetViewportSize(gfx::Size(100, 100));
LayerImpl* root = host_impl_->active_tree()->root_layer();
- root->SetContentsScale(2.f, 2.f);
root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
DrawFrame();
@@ -887,7 +893,6 @@ TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) {
host_impl_->SetViewportSize(gfx::Size(100, 100));
LayerImpl* root = host_impl_->active_tree()->root_layer();
- root->SetContentsScale(2.f, 2.f);
root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
root->SetPosition(gfx::PointF(-25.f, 0.f));
@@ -1020,7 +1025,6 @@ TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) {
ASSERT_EQ(1u, scroll_layer->children().size());
LayerImpl* overflow = scroll_layer->children()[0];
overflow->SetBounds(overflow_size);
- overflow->SetContentBounds(overflow_size);
overflow->SetScrollClipLayer(scroll_layer->parent()->id());
overflow->PushScrollOffsetFromMainThread(gfx::ScrollOffset());
overflow->SetPosition(gfx::PointF());
@@ -1126,11 +1130,184 @@ TEST_F(LayerTreeHostImplTest, ImplPinchZoom) {
scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
- ExpectContains(*scroll_info.get(), scroll_layer->id(),
- gfx::Vector2d(0, scroll_delta.y() / page_scale_delta));
+ EXPECT_TRUE(ScrollInfoContains(
+ *scroll_info.get(), scroll_layer->id(),
+ gfx::Vector2d(0, scroll_delta.y() / page_scale_delta)));
}
}
+TEST_F(LayerTreeHostImplTest, ScrollDuringPinchScrollsInnerViewport) {
+ LayerTreeSettings settings = DefaultSettings();
+ settings.invert_viewport_scroll_order = true;
+ CreateHostImpl(settings,
+ CreateOutputSurface());
+
+ const gfx::Size content_size(1000, 1000);
+ const gfx::Size viewport_size(500, 500);
+ CreateBasicVirtualViewportLayers(viewport_size, content_size);
+
+ LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer();
+ LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer();
+
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(500, 500),
+ outer_scroll_layer->MaxScrollOffset());
+
+ host_impl_->ScrollBegin(gfx::Point(250, 250), InputHandler::GESTURE);
+ host_impl_->PinchGestureBegin();
+ host_impl_->PinchGestureUpdate(2, gfx::Point(250, 250));
+ host_impl_->ScrollBy(gfx::Point(250, 250), gfx::Vector2dF(10.f, 10.f));
+ host_impl_->PinchGestureEnd();
+ host_impl_->ScrollEnd();
+
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(0, 0),
+ outer_scroll_layer->CurrentScrollOffset());
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(130, 130),
+ inner_scroll_layer->CurrentScrollOffset());
+}
+
+// Tests the "snapping" of pinch-zoom gestures to the screen edge. That is, when
+// a pinch zoom is anchored within a certain margin of the screen edge, we
+// should assume the user means to scroll into the edge of the screen.
+TEST_F(LayerTreeHostImplTest, PinchZoomSnapsToScreenEdge) {
+ LayerTreeSettings settings = DefaultSettings();
+ settings.invert_viewport_scroll_order = true;
+ CreateHostImpl(settings,
+ CreateOutputSurface());
+
+ const gfx::Size content_size(1000, 1000);
+ const gfx::Size viewport_size(500, 500);
+ CreateBasicVirtualViewportLayers(viewport_size, content_size);
+
+ int offsetFromEdge = Viewport::kPinchZoomSnapMarginDips - 5;
+ gfx::Point anchor(viewport_size.width() - offsetFromEdge,
+ viewport_size.height() - offsetFromEdge);
+
+ // Pinch in within the margins. The scroll should stay exactly locked to the
+ // bottom and right.
+ host_impl_->ScrollBegin(anchor, InputHandler::GESTURE);
+ host_impl_->PinchGestureBegin();
+ host_impl_->PinchGestureUpdate(2, anchor);
+ host_impl_->PinchGestureEnd();
+ host_impl_->ScrollEnd();
+
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(250, 250),
+ host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset());
+
+ // Reset.
+ host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f);
+ host_impl_->InnerViewportScrollLayer()->SetScrollDelta(gfx::Vector2d());
+ host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2d());
+
+ // Pinch in within the margins. The scroll should stay exactly locked to the
+ // top and left.
+ anchor = gfx::Point(offsetFromEdge, offsetFromEdge);
+ host_impl_->ScrollBegin(anchor, InputHandler::GESTURE);
+ host_impl_->PinchGestureBegin();
+ host_impl_->PinchGestureUpdate(2, anchor);
+ host_impl_->PinchGestureEnd();
+ host_impl_->ScrollEnd();
+
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(0, 0),
+ host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset());
+
+ // Reset.
+ host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f);
+ host_impl_->InnerViewportScrollLayer()->SetScrollDelta(gfx::Vector2d());
+ host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2d());
+
+ // Pinch in just outside the margin. There should be no snapping.
+ offsetFromEdge = Viewport::kPinchZoomSnapMarginDips;
+ anchor = gfx::Point(offsetFromEdge, offsetFromEdge);
+ host_impl_->ScrollBegin(anchor, InputHandler::GESTURE);
+ host_impl_->PinchGestureBegin();
+ host_impl_->PinchGestureUpdate(2, anchor);
+ host_impl_->PinchGestureEnd();
+ host_impl_->ScrollEnd();
+
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(50, 50),
+ host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset());
+
+ // Reset.
+ host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f);
+ host_impl_->InnerViewportScrollLayer()->SetScrollDelta(gfx::Vector2d());
+ host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2d());
+
+ // Pinch in just outside the margin. There should be no snapping.
+ offsetFromEdge = Viewport::kPinchZoomSnapMarginDips;
+ anchor = gfx::Point(viewport_size.width() - offsetFromEdge,
+ viewport_size.height() - offsetFromEdge);
+ host_impl_->ScrollBegin(anchor, InputHandler::GESTURE);
+ host_impl_->PinchGestureBegin();
+ host_impl_->PinchGestureUpdate(2, anchor);
+ host_impl_->PinchGestureEnd();
+ host_impl_->ScrollEnd();
+
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(200, 200),
+ host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset());
+}
+
+TEST_F(LayerTreeHostImplTest, ImplPinchZoomWheelBubbleBetweenViewports) {
+ const gfx::Size content_size(200, 200);
+ const gfx::Size viewport_size(100, 100);
+ CreateBasicVirtualViewportLayers(viewport_size, content_size);
+
+ LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer();
+ LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer();
+
+ // Zoom into the page by a 2X factor
+ float min_page_scale = 1.f, max_page_scale = 4.f;
+ float page_scale_factor = 2.f;
+ host_impl_->active_tree()->PushPageScaleFromMainThread(
+ page_scale_factor, min_page_scale, max_page_scale);
+ host_impl_->SetPageScaleOnActiveTree(page_scale_factor);
+
+ // Scroll by a small amount, there should be no bubbling up to the inner
+ // viewport.
+ host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL);
+ host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2dF(10.f, 20.f));
+ host_impl_->ScrollEnd();
+
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(5, 10),
+ outer_scroll_layer->CurrentScrollOffset());
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(),
+ inner_scroll_layer->CurrentScrollOffset());
+
+ // Scroll by the outer viewport's max scroll extent, there the remainder
+ // should bubble up to the inner viewport.
+ host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL);
+ host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2dF(200.f, 200.f));
+ host_impl_->ScrollEnd();
+
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(100, 100),
+ outer_scroll_layer->CurrentScrollOffset());
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(5, 10),
+ inner_scroll_layer->CurrentScrollOffset());
+
+ // Scroll by the inner viewport's max scroll extent, it should all go to the
+ // inner viewport.
+ host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL);
+ host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2dF(90.f, 80.f));
+ host_impl_->ScrollEnd();
+
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(100, 100),
+ outer_scroll_layer->CurrentScrollOffset());
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(50, 50),
+ inner_scroll_layer->CurrentScrollOffset());
+}
+
TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) {
ui::LatencyInfo latency_info;
latency_info.trace_id = 1234;
@@ -1342,7 +1519,8 @@ TEST_F(LayerTreeHostImplTest, PinchGesture) {
scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
- ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
+ gfx::Vector2d(-10, -10)));
}
// Two-finger panning should work when starting fully zoomed out.
@@ -1364,7 +1542,8 @@ TEST_F(LayerTreeHostImplTest, PinchGesture) {
scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
EXPECT_EQ(scroll_info->page_scale_delta, 2.f);
- ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(20, 20));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
+ gfx::Vector2d(20, 20)));
}
}
@@ -1424,7 +1603,8 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
EXPECT_EQ(scroll_info->page_scale_delta, 2);
- ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
+ gfx::Vector2d(-50, -50)));
}
// Anchor zoom-out
@@ -1463,7 +1643,8 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
host_impl_->ProcessScrollDeltas();
EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale);
// Pushed to (0,0) via clamping against contents layer size.
- ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
+ gfx::Vector2d(-50, -50)));
}
}
@@ -1604,7 +1785,8 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) {
scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
EXPECT_EQ(scroll_info->page_scale_delta, target_scale);
- ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
+ gfx::Vector2d(-50, -50)));
}
TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) {
@@ -1646,14 +1828,15 @@ class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl {
LayerTreeHostImplClient* client,
Proxy* proxy,
SharedBitmapManager* manager,
+ TaskGraphRunner* task_graph_runner,
RenderingStatsInstrumentation* rendering_stats_instrumentation)
: LayerTreeHostImpl(settings,
client,
proxy,
rendering_stats_instrumentation,
manager,
- NULL,
- NULL,
+ nullptr,
+ task_graph_runner,
0) {}
BeginFrameArgs CurrentBeginFrameArgs() const override {
@@ -1676,9 +1859,9 @@ class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest {
gfx::Size content_size(100, 100);
LayerTreeHostImplOverridePhysicalTime* host_impl_override_time =
- new LayerTreeHostImplOverridePhysicalTime(settings, this, &proxy_,
- shared_bitmap_manager_.get(),
- &stats_instrumentation_);
+ new LayerTreeHostImplOverridePhysicalTime(
+ settings, this, &proxy_, &shared_bitmap_manager_,
+ &task_graph_runner_, &stats_instrumentation_);
host_impl_ = make_scoped_ptr(host_impl_override_time);
host_impl_->InitializeRenderer(CreateOutputSurface());
host_impl_->SetViewportSize(viewport_size);
@@ -1693,14 +1876,12 @@ class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest {
scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset());
root->SetBounds(viewport_size);
scroll->SetBounds(content_size);
- scroll->SetContentBounds(content_size);
scroll->SetIsContainerForFixedPositionLayers(true);
scoped_ptr<LayerImpl> contents =
LayerImpl::Create(host_impl_->active_tree(), 3);
contents->SetDrawsContent(true);
contents->SetBounds(content_size);
- contents->SetContentBounds(content_size);
scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar =
SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 4,
@@ -1728,7 +1909,7 @@ class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest {
SetupLayers(settings);
- base::TimeTicks fake_now = gfx::FrameTime::Now();
+ base::TimeTicks fake_now = base::TimeTicks::Now();
EXPECT_FALSE(did_request_animate_);
EXPECT_FALSE(did_request_redraw_);
@@ -1851,21 +2032,18 @@ void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale(
scroll->SetScrollClipLayer(root->id());
scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset());
scroll->SetBounds(content_size);
- scroll->SetContentBounds(content_size);
scroll->SetIsContainerForFixedPositionLayers(true);
scoped_ptr<LayerImpl> contents =
LayerImpl::Create(host_impl_->active_tree(), 3);
contents->SetDrawsContent(true);
contents->SetBounds(content_size);
- contents->SetContentBounds(content_size);
// The scrollbar is on the right side.
scoped_ptr<PaintedScrollbarLayerImpl> scrollbar =
PaintedScrollbarLayerImpl::Create(host_impl_->active_tree(), 5, VERTICAL);
scrollbar->SetDrawsContent(true);
scrollbar->SetBounds(gfx::Size(15, viewport_size.height()));
- scrollbar->SetContentBounds(gfx::Size(15, viewport_size.height()));
scrollbar->SetPosition(gfx::Point(285, 0));
scroll->AddChild(contents.Pass());
@@ -2058,9 +2236,8 @@ class DidDrawCheckLayer : public LayerImpl {
append_quads_called_(false),
did_draw_called_(false) {
SetBounds(gfx::Size(10, 10));
- SetContentBounds(gfx::Size(10, 10));
SetDrawsContent(true);
- draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10);
+ draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10);
}
private:
@@ -2124,10 +2301,9 @@ TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) {
root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
DidDrawCheckLayer* layer =
static_cast<DidDrawCheckLayer*>(root->children()[0]);
- // Ensure visible_content_rect for layer is empty.
+ // Ensure visible_layer_rect for layer is empty.
layer->SetPosition(gfx::PointF(100.f, 100.f));
layer->SetBounds(gfx::Size(10, 10));
- layer->SetContentBounds(gfx::Size(10, 10));
LayerTreeHostImpl::FrameData frame;
@@ -2141,9 +2317,9 @@ TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) {
EXPECT_FALSE(layer->will_draw_called());
EXPECT_FALSE(layer->did_draw_called());
- EXPECT_TRUE(layer->visible_content_rect().IsEmpty());
+ EXPECT_TRUE(layer->visible_layer_rect().IsEmpty());
- // Ensure visible_content_rect for layer is not empty
+ // Ensure visible_layer_rect for layer is not empty
layer->SetPosition(gfx::PointF());
EXPECT_FALSE(layer->will_draw_called());
@@ -2156,7 +2332,7 @@ TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) {
EXPECT_TRUE(layer->will_draw_called());
EXPECT_TRUE(layer->did_draw_called());
- EXPECT_FALSE(layer->visible_content_rect().IsEmpty());
+ EXPECT_FALSE(layer->visible_layer_rect().IsEmpty());
}
TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) {
@@ -2179,7 +2355,6 @@ TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) {
// This layer covers the occluded_layer above. Make this layer large so it can
// occlude.
top_layer->SetBounds(big_size);
- top_layer->SetContentBounds(big_size);
top_layer->SetContentsOpaque(true);
LayerTreeHostImpl::FrameData frame;
@@ -2539,8 +2714,6 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest {
: layer_size_(10, 10),
clip_size_(layer_size_),
top_controls_height_(50) {
- settings_.use_pinch_virtual_viewport = true;
-
viewport_size_ = gfx::Size(clip_size_.width(),
clip_size_.height() + top_controls_height_);
}
@@ -2564,7 +2737,6 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest {
root_clip->SetBounds(clip_size_);
root->SetScrollClipLayer(root_clip->id());
root->SetBounds(layer_size_);
- root->SetContentBounds(layer_size_);
root->SetPosition(gfx::PointF());
root->SetDrawsContent(false);
root->SetIsContainerForFixedPositionLayers(true);
@@ -2593,7 +2765,6 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest {
root_clip->SetBounds(clip_size_);
root->SetScrollClipLayer(root_clip->id());
root->SetBounds(layer_size_);
- root->SetContentBounds(layer_size_);
root->SetPosition(gfx::PointF());
root->SetDrawsContent(false);
root->SetIsContainerForFixedPositionLayers(true);
@@ -2635,7 +2806,6 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest {
root_clip->SetBounds(inner_viewport_size);
root->SetScrollClipLayer(root_clip->id());
root->SetBounds(outer_viewport_size);
- root->SetContentBounds(outer_viewport_size);
root->SetPosition(gfx::PointF());
root->SetDrawsContent(false);
root->SetIsContainerForFixedPositionLayers(true);
@@ -2643,7 +2813,6 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest {
outer_clip->SetBounds(outer_viewport_size);
outer_scroll->SetScrollClipLayer(outer_clip->id());
outer_scroll->SetBounds(scroll_layer_size);
- outer_scroll->SetContentBounds(scroll_layer_size);
outer_scroll->SetPosition(gfx::PointF());
outer_scroll->SetDrawsContent(false);
outer_scroll->SetIsContainerForFixedPositionLayers(true);
@@ -2848,7 +3017,6 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsScrollableSublayer) {
child_clip->SetBounds(sub_content_layer_size);
child->SetScrollClipLayer(child_clip->id());
child->SetBounds(sub_content_size);
- child->SetContentBounds(sub_content_size);
child->SetPosition(gfx::PointF());
child->SetDrawsContent(true);
child->SetIsContainerForFixedPositionLayers(true);
@@ -3204,8 +3372,6 @@ TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) {
content_layer->SetDrawsContent(true);
content_layer->SetPosition(gfx::PointF());
content_layer->SetBounds(contents_size);
- content_layer->SetContentBounds(contents_size);
- content_layer->SetContentsScale(2.f, 2.f);
scoped_ptr<LayerImpl> scroll_clip_layer =
LayerImpl::Create(host_impl_->active_tree(), 3);
@@ -3215,7 +3381,6 @@ TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) {
LayerImpl::Create(host_impl_->active_tree(), 2);
scroll_layer->SetScrollClipLayer(3);
scroll_layer->SetBounds(contents_size);
- scroll_layer->SetContentBounds(contents_size);
scroll_layer->SetPosition(gfx::PointF());
scroll_layer->AddChild(content_layer.Pass());
scroll_clip_layer->AddChild(scroll_layer.Pass());
@@ -3238,7 +3403,6 @@ TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) {
gfx::Size contents_size(20, 20);
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
root->SetBounds(surface_size);
- root->SetContentBounds(contents_size);
root->AddChild(CreateScrollableLayer(2, contents_size, root.get()));
root->SetHasRenderSurface(true);
host_impl_->active_tree()->SetRootLayer(root.Pass());
@@ -3362,7 +3526,8 @@ TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) {
page_scale);
scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
- ExpectContains(*scroll_info.get(), root_scroll->id(), expected_scroll_delta);
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), root_scroll->id(),
+ expected_scroll_delta));
// The scroll range should also have been updated.
EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset());
@@ -3418,7 +3583,8 @@ TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) {
// The scroll delta is not scaled because the main thread did not scale.
scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
- ExpectContains(*scroll_info.get(), root_scroll->id(), expected_scroll_delta);
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), root_scroll->id(),
+ expected_scroll_delta));
// The scroll range should also have been updated.
EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset());
@@ -3458,15 +3624,6 @@ TEST_F(LayerTreeHostImplTest, PageScaleDeltaAppliedToRootScrollLayerOnly) {
host_impl_->ScrollEnd();
DrawOneFrame();
- EXPECT_EQ(1.f, root->contents_scale_x());
- EXPECT_EQ(1.f, root->contents_scale_y());
- EXPECT_EQ(1.f, scroll->contents_scale_x());
- EXPECT_EQ(1.f, scroll->contents_scale_y());
- EXPECT_EQ(1.f, child->contents_scale_x());
- EXPECT_EQ(1.f, child->contents_scale_y());
- EXPECT_EQ(1.f, grand_child->contents_scale_x());
- EXPECT_EQ(1.f, grand_child->contents_scale_y());
-
// Make sure all the layers are drawn with the page scale delta applied, i.e.,
// the page scale delta on the root layer is applied hierarchically.
LayerTreeHostImpl::FrameData frame;
@@ -3494,7 +3651,6 @@ TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) {
scoped_ptr<LayerImpl> root_scrolling =
LayerImpl::Create(host_impl_->active_tree(), 2);
root_scrolling->SetBounds(surface_size);
- root_scrolling->SetContentBounds(surface_size);
root_scrolling->SetScrollClipLayer(root->id());
root_scrolling->SetIsContainerForFixedPositionLayers(true);
LayerImpl* root_scrolling_ptr = root_scrolling.get();
@@ -3526,8 +3682,8 @@ TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) {
DrawOneFrame();
scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
- ExpectContains(
- *scroll_info.get(), child_scroll_layer_id, expected_scroll_delta);
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_scroll_layer_id,
+ expected_scroll_delta));
// The scroll range should not have changed.
EXPECT_EQ(child->MaxScrollOffset(), expected_max_scroll);
@@ -3576,10 +3732,12 @@ TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) {
// The grand child should have scrolled up to its limit.
LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0];
LayerImpl* grand_child = child->children()[0];
- ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -5));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
+ gfx::Vector2d(0, -5)));
// The child should have only scrolled on the other axis.
- ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(),
+ gfx::Vector2d(-3, 0)));
}
}
@@ -3631,7 +3789,8 @@ TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) {
LayerImpl* child =
host_impl_->active_tree()->root_layer()->children()[0]->children()[0];
LayerImpl* grand_child = child->children()[0];
- ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -2));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
+ gfx::Vector2d(0, -2)));
// The child should not have scrolled.
ExpectNone(*scroll_info.get(), child->id());
@@ -3649,10 +3808,12 @@ TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) {
scroll_info = host_impl_->ProcessScrollDeltas();
// The child should have scrolled up to its limit.
- ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(0, -3));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(),
+ gfx::Vector2d(0, -3)));
// The grand child should not have scrolled.
- ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -2));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
+ gfx::Vector2d(0, -2)));
// After scrolling the parent, another scroll on the opposite direction
// should still scroll the child.
@@ -3668,11 +3829,12 @@ TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) {
scroll_info = host_impl_->ProcessScrollDeltas();
// The grand child should have scrolled.
- ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 5));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
+ gfx::Vector2d(0, 5)));
// The child should not have scrolled.
- ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(0, -3));
-
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(),
+ gfx::Vector2d(0, -3)));
// Scrolling should be adjusted from viewport space.
host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f);
@@ -3689,7 +3851,8 @@ TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) {
scroll_info = host_impl_->ProcessScrollDeltas();
// Should have scrolled by half the amount in layer space (5 - 2/2)
- ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
+ gfx::Vector2d(0, 4)));
}
}
TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) {
@@ -3731,7 +3894,8 @@ TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) {
// Only the root scroll should have scrolled.
ASSERT_EQ(scroll_info->scrolls.size(), 1u);
- ExpectContains(*scroll_info.get(), root_scroll_id, scroll_delta);
+ EXPECT_TRUE(
+ ScrollInfoContains(*scroll_info.get(), root_scroll_id, scroll_delta));
}
}
@@ -3792,8 +3956,8 @@ TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) {
// The layer should have scrolled down in its local coordinates.
scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
- ExpectContains(*scroll_info.get(), scroll_layer->id(),
- gfx::Vector2d(0, gesture_scroll_delta.x()));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
+ gfx::Vector2d(0, gesture_scroll_delta.x())));
// Reset and scroll down with the wheel.
scroll_layer->SetScrollDelta(gfx::Vector2dF());
@@ -3805,9 +3969,8 @@ TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) {
// The layer should have scrolled down in its local coordinates.
scroll_info = host_impl_->ProcessScrollDeltas();
- ExpectContains(*scroll_info.get(),
- scroll_layer->id(),
- wheel_scroll_delta);
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
+ wheel_scroll_delta));
}
TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) {
@@ -3820,7 +3983,7 @@ TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) {
scoped_ptr<LayerImpl> clip_layer =
LayerImpl::Create(host_impl_->active_tree(), child_clip_layer_id);
scoped_ptr<LayerImpl> child = CreateScrollableLayer(
- child_layer_id, scroll_layer->content_bounds(), clip_layer.get());
+ child_layer_id, scroll_layer->bounds(), clip_layer.get());
gfx::Transform rotate_transform;
rotate_transform.Translate(-50.0, -50.0);
rotate_transform.Rotate(child_layer_angle);
@@ -3857,7 +4020,8 @@ TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) {
std::cos(MathUtil::Deg2Rad(child_layer_angle)));
scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
- ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta);
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id,
+ expected_scroll_delta));
// The root scroll layer should not have scrolled, because the input delta
// was close to the layer's axis of movement.
@@ -3879,7 +4043,8 @@ TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) {
std::sin(MathUtil::Deg2Rad(child_layer_angle)));
scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
- ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta);
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id,
+ expected_scroll_delta));
// The root scroll layer should have scrolled more, since the input scroll
// delta was mostly orthogonal to the child layer's vertical scroll axis.
@@ -3887,9 +4052,83 @@ TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) {
gesture_scroll_delta.x() *
std::pow(std::cos(MathUtil::Deg2Rad(child_layer_angle)), 2),
0);
- ExpectContains(*scroll_info.get(),
- scroll_layer->id(),
- expected_root_scroll_delta);
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
+ expected_root_scroll_delta));
+ }
+}
+
+TEST_F(LayerTreeHostImplTest, ScrollPerspectiveTransformedLayer) {
+ // When scrolling an element with perspective, the distance scrolled
+ // depends on the point at which the scroll begins.
+ LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
+ int child_clip_layer_id = 6;
+ int child_layer_id = 7;
+
+ // Create a child layer that is rotated on its x axis, with perspective.
+ scoped_ptr<LayerImpl> clip_layer =
+ LayerImpl::Create(host_impl_->active_tree(), child_clip_layer_id);
+ scoped_ptr<LayerImpl> child = CreateScrollableLayer(
+ child_layer_id, scroll_layer->bounds(), clip_layer.get());
+ LayerImpl* child_ptr = child.get();
+ gfx::Transform perspective_transform;
+ perspective_transform.Translate(-50.0, -50.0);
+ perspective_transform.ApplyPerspectiveDepth(20);
+ perspective_transform.RotateAboutXAxis(45);
+ perspective_transform.Translate(50.0, 50.0);
+ clip_layer->SetTransform(perspective_transform);
+
+ clip_layer->SetBounds(gfx::Size(child_ptr->bounds().width() / 2,
+ child_ptr->bounds().height() / 2));
+ // The transform depends on the layer's transform origin, and the child layer
+ // is a different size than the clip, so make sure the clip layer's origin
+ // lines up over the child.
+ clip_layer->SetTransformOrigin(gfx::Point3F(
+ clip_layer->bounds().width(), clip_layer->bounds().height(), 0.f));
+ clip_layer->AddChild(child.Pass());
+ scroll_layer->AddChild(clip_layer.Pass());
+
+ gfx::Size surface_size(50, 50);
+ host_impl_->SetViewportSize(surface_size);
+
+ scoped_ptr<ScrollAndScaleSet> scroll_info;
+
+ gfx::Vector2d gesture_scroll_deltas[4];
+ gesture_scroll_deltas[0] = gfx::Vector2d(4, 10);
+ gesture_scroll_deltas[1] = gfx::Vector2d(4, 10);
+ gesture_scroll_deltas[2] = gfx::Vector2d(10, 0);
+ gesture_scroll_deltas[3] = gfx::Vector2d(10, 0);
+
+ gfx::Vector2d expected_scroll_deltas[4];
+ // Perspective affects the vertical delta by a different
+ // amount depending on the vertical position of the |viewport_point|.
+ expected_scroll_deltas[0] = gfx::Vector2d(2, 8);
+ expected_scroll_deltas[1] = gfx::Vector2d(1, 4);
+ // Deltas which start with the same vertical position of the
+ // |viewport_point| are subject to identical perspective effects.
+ expected_scroll_deltas[2] = gfx::Vector2d(4, 0);
+ expected_scroll_deltas[3] = gfx::Vector2d(4, 0);
+
+ gfx::Point viewport_point(1, 1);
+
+ // Scroll in screen coordinates with a gesture. Each scroll starts
+ // where the previous scroll ended, but the scroll position is reset
+ // for each scroll.
+ for (int i = 0; i < 4; ++i) {
+ child_ptr->SetScrollDelta(gfx::Vector2dF());
+ DrawFrame();
+ EXPECT_EQ(InputHandler::SCROLL_STARTED,
+ host_impl_->ScrollBegin(viewport_point, InputHandler::GESTURE));
+ host_impl_->ScrollBy(viewport_point, gesture_scroll_deltas[i]);
+ viewport_point += gesture_scroll_deltas[i];
+ host_impl_->ScrollEnd();
+
+ scroll_info = host_impl_->ProcessScrollDeltas();
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id,
+ expected_scroll_deltas[i]));
+
+ // The root scroll layer should not have scrolled, because the input delta
+ // was close to the layer's axis of movement.
+ EXPECT_EQ(scroll_info->scrolls.size(), 1u);
}
}
@@ -3917,9 +4156,8 @@ TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) {
// The layer should have scrolled down in its local coordinates, but half the
// amount.
scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
- ExpectContains(*scroll_info.get(),
- scroll_layer->id(),
- gfx::Vector2d(0, scroll_delta.y() / scale));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
+ gfx::Vector2d(0, scroll_delta.y() / scale)));
// Reset and scroll down with the wheel.
scroll_layer->SetScrollDelta(gfx::Vector2dF());
@@ -3931,9 +4169,8 @@ TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) {
// It should apply the scale factor to the scroll delta for the wheel event.
scroll_info = host_impl_->ProcessScrollDeltas();
- ExpectContains(*scroll_info.get(),
- scroll_layer->id(),
- wheel_scroll_delta);
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
+ wheel_scroll_delta));
}
TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) {
@@ -3957,7 +4194,8 @@ class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate {
TestScrollOffsetDelegate()
: page_scale_factor_(0.f),
min_page_scale_factor_(-1.f),
- max_page_scale_factor_(-1.f) {}
+ max_page_scale_factor_(-1.f),
+ needs_animate_(false) {}
~TestScrollOffsetDelegate() override {}
@@ -3965,7 +4203,11 @@ class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate {
return getter_return_value_;
}
- bool IsExternalFlingActive() const override { return false; }
+ bool IsExternalScrollActive() const override { return false; }
+
+ void SetNeedsAnimate(const AnimationCallback&) override {
+ needs_animate_ = true;
+ }
void UpdateRootLayerState(const gfx::ScrollOffset& total_scroll_offset,
const gfx::ScrollOffset& max_scroll_offset,
@@ -3985,6 +4227,12 @@ class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate {
set_getter_return_value(last_set_scroll_offset_);
}
+ bool GetAndResetNeedsAnimate() {
+ bool needs_animate = needs_animate_;
+ needs_animate_ = false;
+ return needs_animate;
+ }
+
gfx::ScrollOffset last_set_scroll_offset() {
return last_set_scroll_offset_;
}
@@ -4021,8 +4269,10 @@ class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate {
float page_scale_factor_;
float min_page_scale_factor_;
float max_page_scale_factor_;
+ bool needs_animate_;
};
+// TODO(jdduke): Test root fling animation.
TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) {
TestScrollOffsetDelegate scroll_delegate;
host_impl_->SetViewportSize(gfx::Size(10, 20));
@@ -4270,6 +4520,7 @@ TEST_F(LayerTreeHostImplTest, OverscrollRoot) {
TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) {
// Scroll child layers beyond their maximum scroll range and make sure root
// overscroll does not accumulate.
+ InputHandlerScrollResult scroll_result;
gfx::Size surface_size(10, 10);
scoped_ptr<LayerImpl> root_clip =
LayerImpl::Create(host_impl_->active_tree(), 4);
@@ -4300,7 +4551,9 @@ TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) {
EXPECT_EQ(InputHandler::SCROLL_STARTED,
host_impl_->ScrollBegin(gfx::Point(),
InputHandler::NON_BUBBLING_GESTURE));
- host_impl_->ScrollBy(gfx::Point(), scroll_delta);
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), scroll_delta);
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_FALSE(scroll_result.did_overscroll_root);
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
host_impl_->ScrollEnd();
@@ -4312,7 +4565,9 @@ TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) {
InputHandler::NON_BUBBLING_GESTURE));
EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer);
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
- host_impl_->ScrollBy(gfx::Point(), scroll_delta);
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), scroll_delta);
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_FALSE(scroll_result.did_overscroll_root);
EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_layer);
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
host_impl_->ScrollEnd();
@@ -4324,7 +4579,9 @@ TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) {
host_impl_->ScrollBegin(gfx::Point(5, 5),
InputHandler::NON_BUBBLING_GESTURE));
EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer);
- host_impl_->ScrollBy(gfx::Point(), scroll_delta);
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), scroll_delta);
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_FALSE(scroll_result.did_overscroll_root);
EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer);
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
host_impl_->ScrollEnd();
@@ -4335,6 +4592,7 @@ TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) {
// When we try to scroll a non-scrollable child layer, the scroll delta
// should be applied to one of its ancestors if possible. Overscroll should
// be reflected only when it has bubbled up to the root scrolling layer.
+ InputHandlerScrollResult scroll_result;
gfx::Size surface_size(10, 10);
gfx::Size content_size(20, 20);
scoped_ptr<LayerImpl> root_clip =
@@ -4361,17 +4619,24 @@ TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) {
gfx::Vector2d scroll_delta(0, 8);
EXPECT_EQ(InputHandler::SCROLL_STARTED,
host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL));
- host_impl_->ScrollBy(gfx::Point(), scroll_delta);
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), scroll_delta);
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_FALSE(scroll_result.did_overscroll_root);
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
- host_impl_->ScrollBy(gfx::Point(), scroll_delta);
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), scroll_delta);
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_TRUE(scroll_result.did_overscroll_root);
EXPECT_EQ(gfx::Vector2dF(0, 6), host_impl_->accumulated_root_overscroll());
- host_impl_->ScrollBy(gfx::Point(), scroll_delta);
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), scroll_delta);
+ EXPECT_FALSE(scroll_result.did_scroll);
+ EXPECT_TRUE(scroll_result.did_overscroll_root);
EXPECT_EQ(gfx::Vector2dF(0, 14), host_impl_->accumulated_root_overscroll());
host_impl_->ScrollEnd();
}
}
TEST_F(LayerTreeHostImplTest, OverscrollAlways) {
+ InputHandlerScrollResult scroll_result;
LayerTreeSettings settings;
CreateHostImpl(settings, CreateOutputSurface());
@@ -4386,11 +4651,14 @@ TEST_F(LayerTreeHostImplTest, OverscrollAlways) {
// Even though the layer can't scroll the overscroll still happens.
EXPECT_EQ(InputHandler::SCROLL_STARTED,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL));
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
+ EXPECT_FALSE(scroll_result.did_scroll);
+ EXPECT_TRUE(scroll_result.did_overscroll_root);
EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll());
}
TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) {
+ InputHandlerScrollResult scroll_result;
gfx::Size surface_size(980, 1439);
gfx::Size content_size(980, 1438);
float device_scale_factor = 1.5f;
@@ -4424,7 +4692,9 @@ TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) {
// vertical GlowEffect should not be applied in about:blank page.
EXPECT_EQ(InputHandler::SCROLL_STARTED,
host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL));
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -1));
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -1));
+ EXPECT_FALSE(scroll_result.did_scroll);
+ EXPECT_FALSE(scroll_result.did_overscroll_root);
EXPECT_EQ(gfx::Vector2dF().ToString(),
host_impl_->accumulated_root_overscroll().ToString());
@@ -4433,6 +4703,7 @@ TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) {
}
TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) {
+ InputHandlerScrollResult scroll_result;
gfx::Size surface_size(100, 100);
gfx::Size content_size(200, 200);
scoped_ptr<LayerImpl> root_clip =
@@ -4461,10 +4732,15 @@ TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) {
// called while scrolling up without reaching the edge of the content.
EXPECT_EQ(InputHandler::SCROLL_STARTED,
host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL));
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100));
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100));
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_FALSE(scroll_result.did_overscroll_root);
EXPECT_EQ(gfx::Vector2dF().ToString(),
host_impl_->accumulated_root_overscroll().ToString());
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -2.30f));
+ scroll_result =
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -2.30f));
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_FALSE(scroll_result.did_overscroll_root);
EXPECT_EQ(gfx::Vector2dF().ToString(),
host_impl_->accumulated_root_overscroll().ToString());
host_impl_->ScrollEnd();
@@ -4474,11 +4750,16 @@ TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) {
host_impl_->ScrollBegin(gfx::Point(0, 0),
InputHandler::NON_BUBBLING_GESTURE));
EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin());
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 20));
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 20));
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_TRUE(scroll_result.did_overscroll_root);
EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(),
host_impl_->accumulated_root_overscroll().ToString());
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f));
+ scroll_result =
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f));
+ EXPECT_FALSE(scroll_result.did_scroll);
+ EXPECT_FALSE(scroll_result.did_overscroll_root);
EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(),
host_impl_->accumulated_root_overscroll().ToString());
host_impl_->ScrollEnd();
@@ -4486,7 +4767,10 @@ TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) {
// gloweffect without reaching edge.
EXPECT_EQ(InputHandler::SCROLL_STARTED,
host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL));
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f));
+ scroll_result =
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f));
+ EXPECT_FALSE(scroll_result.did_scroll);
+ EXPECT_FALSE(scroll_result.did_overscroll_root);
EXPECT_EQ(gfx::Vector2dF().ToString(),
host_impl_->accumulated_root_overscroll().ToString());
host_impl_->ScrollEnd();
@@ -4564,7 +4848,6 @@ class BlendStateCheckLayer : public LayerImpl {
RGBA_8888)) {
resource_provider->AllocateForTesting(resource_id_);
SetBounds(gfx::Size(10, 10));
- SetContentBounds(gfx::Size(10, 10));
SetDrawsContent(true);
}
@@ -4574,7 +4857,7 @@ class BlendStateCheckLayer : public LayerImpl {
gfx::Rect quad_rect_;
gfx::Rect opaque_content_rect_;
gfx::Rect quad_visible_rect_;
- ResourceProvider::ResourceId resource_id_;
+ ResourceId resource_id_;
};
TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
@@ -4582,7 +4865,6 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
scoped_ptr<LayerImpl> root =
LayerImpl::Create(host_impl_->active_tree(), 1);
root->SetBounds(gfx::Size(10, 10));
- root->SetContentBounds(root->bounds());
root->SetDrawsContent(false);
root->SetHasRenderSurface(true);
host_impl_->active_tree()->SetRootLayer(root.Pass());
@@ -4602,7 +4884,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
// Opaque layer, drawn without blending.
layer1->SetContentsOpaque(true);
layer1->SetExpectation(false, false);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
@@ -4611,7 +4893,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
// Layer with translucent content and painting, so drawn with blending.
layer1->SetContentsOpaque(false);
layer1->SetExpectation(true, false);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
@@ -4621,7 +4903,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
layer1->SetContentsOpaque(true);
layer1->SetOpacity(0.5f);
layer1->SetExpectation(true, false);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
@@ -4631,7 +4913,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
layer1->SetContentsOpaque(true);
layer1->SetOpacity(0.5f);
layer1->SetExpectation(true, false);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
@@ -4649,11 +4931,11 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
layer1->SetContentsOpaque(true);
layer1->SetOpacity(1.f);
layer1->SetExpectation(false, false);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
layer2->SetContentsOpaque(true);
layer2->SetOpacity(1.f);
layer2->SetExpectation(false, false);
- layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
@@ -4664,9 +4946,9 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
// Child layer with opaque content, drawn without blending.
layer1->SetContentsOpaque(false);
layer1->SetExpectation(true, false);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
layer2->SetExpectation(false, false);
- layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
@@ -4678,9 +4960,9 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
// Child layer with opaque content, drawn without blending.
layer1->SetContentsOpaque(true);
layer1->SetExpectation(false, false);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
layer2->SetExpectation(false, false);
- layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
@@ -4696,9 +4978,9 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
layer1->SetOpacity(0.5f);
layer1->SetHasRenderSurface(true);
layer1->SetExpectation(false, true);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
layer2->SetExpectation(false, false);
- layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
host_impl_->active_tree()->root_layer());
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
@@ -4713,11 +4995,11 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
layer1->SetContentsOpaque(true);
layer1->SetOpacity(1.f);
layer1->SetExpectation(false, false);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
layer2->SetContentsOpaque(true);
layer2->SetOpacity(0.5f);
layer2->SetExpectation(true, false);
- layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
@@ -4728,11 +5010,11 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
layer1->SetContentsOpaque(true);
layer1->SetOpacity(1.f);
layer1->SetExpectation(false, false);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
layer2->SetContentsOpaque(false);
layer2->SetOpacity(1.f);
layer2->SetExpectation(true, false);
- layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
@@ -4744,11 +5026,11 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
layer1->SetContentsOpaque(true);
layer1->SetOpacity(1.f);
layer1->SetExpectation(false, false);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
layer2->SetContentsOpaque(true);
layer2->SetOpacity(1.f);
layer2->SetExpectation(false, false);
- layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
@@ -4761,7 +5043,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5));
layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
layer1->SetExpectation(true, false);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
@@ -4773,7 +5055,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2));
layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
layer1->SetExpectation(true, false);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
@@ -4785,7 +5067,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5));
layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
layer1->SetExpectation(true, false);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
@@ -4798,7 +5080,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5));
layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
layer1->SetExpectation(false, false);
- layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
+ layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
@@ -4839,7 +5121,6 @@ class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
gfx::Rect layer_rect(viewport_size_);
child_->SetPosition(layer_rect.origin());
child_->SetBounds(layer_rect.size());
- child_->SetContentBounds(layer_rect.size());
child_->SetQuadRect(gfx::Rect(layer_rect.size()));
child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
@@ -4860,7 +5141,6 @@ class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
gfx::Rect layer_rect(0, 0, 0, 0);
child_->SetPosition(layer_rect.origin());
child_->SetBounds(layer_rect.size());
- child_->SetContentBounds(layer_rect.size());
child_->SetQuadRect(gfx::Rect(layer_rect.size()));
child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
@@ -4881,7 +5161,6 @@ class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
gfx::Rect layer_rect(500, 500, 200, 200);
child_->SetPosition(layer_rect.origin());
child_->SetBounds(layer_rect.size());
- child_->SetContentBounds(layer_rect.size());
child_->SetQuadRect(gfx::Rect(layer_rect.size()));
child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
@@ -4903,7 +5182,6 @@ class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
viewport_size_.height() + 10);
child_->SetPosition(layer_rect.origin());
child_->SetBounds(layer_rect.size());
- child_->SetContentBounds(layer_rect.size());
child_->SetQuadRect(gfx::Rect(layer_rect.size()));
child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
@@ -5069,7 +5347,6 @@ TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) {
scoped_ptr<LayerImpl> root =
FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
root->SetBounds(gfx::Size(10, 10));
- root->SetContentBounds(gfx::Size(10, 10));
root->SetDrawsContent(true);
root->SetHasRenderSurface(true);
host_impl_->active_tree()->SetRootLayer(root.Pass());
@@ -5128,8 +5405,10 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl =
LayerTreeHostImpl::Create(
settings, this, &proxy_, &stats_instrumentation_,
- shared_bitmap_manager_.get(), NULL, task_graph_runner_.get(), 0);
+ &shared_bitmap_manager_, NULL, &task_graph_runner_, 0);
layer_tree_host_impl->InitializeRenderer(output_surface.Pass());
+ layer_tree_host_impl->WillBeginImplFrame(
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500));
scoped_ptr<LayerImpl> root =
@@ -5139,10 +5418,8 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2);
child->SetPosition(gfx::PointF(12.f, 13.f));
child->SetBounds(gfx::Size(14, 15));
- child->SetContentBounds(gfx::Size(14, 15));
child->SetDrawsContent(true);
root->SetBounds(gfx::Size(500, 500));
- root->SetContentBounds(gfx::Size(500, 500));
root->SetDrawsContent(true);
root->AddChild(child.Pass());
layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass());
@@ -5196,10 +5473,8 @@ TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) {
scoped_ptr<LayerImpl> child =
FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2);
child->SetBounds(gfx::Size(10, 10));
- child->SetContentBounds(gfx::Size(10, 10));
child->SetDrawsContent(true);
root->SetBounds(gfx::Size(10, 10));
- root->SetContentBounds(gfx::Size(10, 10));
root->SetDrawsContent(true);
root->SetHasRenderSurface(true);
root->AddChild(child.Pass());
@@ -5227,7 +5502,7 @@ class FakeLayerWithQuads : public LayerImpl {
PopulateSharedQuadState(shared_quad_state);
SkColor gray = SkColorSetRGB(100, 100, 100);
- gfx::Rect quad_rect(content_bounds());
+ gfx::Rect quad_rect(bounds());
gfx::Rect visible_quad_rect(quad_rect);
SolidColorDrawQuad* my_quad =
render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
@@ -5406,6 +5681,7 @@ static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity(
LayerTreeHostImplClient* client,
Proxy* proxy,
SharedBitmapManager* manager,
+ TaskGraphRunner* task_graph_runner,
RenderingStatsInstrumentation* stats_instrumentation) {
scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
scoped_ptr<OutputSurface> output_surface(
@@ -5415,9 +5691,12 @@ static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity(
LayerTreeSettings settings;
settings.renderer_settings.partial_swap_enabled = partial_swap;
- scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create(
- settings, client, proxy, stats_instrumentation, manager, NULL, NULL, 0);
+ scoped_ptr<LayerTreeHostImpl> my_host_impl =
+ LayerTreeHostImpl::Create(settings, client, proxy, stats_instrumentation,
+ manager, nullptr, task_graph_runner, 0);
my_host_impl->InitializeRenderer(output_surface.Pass());
+ my_host_impl->WillBeginImplFrame(
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
my_host_impl->SetViewportSize(gfx::Size(100, 100));
/*
@@ -5452,23 +5731,20 @@ static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity(
root->SetHasRenderSurface(true);
root->SetPosition(root_rect.origin());
root->SetBounds(root_rect.size());
- root->SetContentBounds(root->bounds());
- root->draw_properties().visible_content_rect = root_rect;
+ root->draw_properties().visible_layer_rect = root_rect;
root->SetDrawsContent(false);
root->render_surface()->SetContentRect(gfx::Rect(root_rect.size()));
child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y()));
child->SetOpacity(0.5f);
child->SetBounds(gfx::Size(child_rect.width(), child_rect.height()));
- child->SetContentBounds(child->bounds());
- child->draw_properties().visible_content_rect = child_rect;
+ child->draw_properties().visible_layer_rect = child_rect;
child->SetDrawsContent(false);
child->SetHasRenderSurface(true);
grand_child->SetPosition(grand_child_rect.origin());
grand_child->SetBounds(grand_child_rect.size());
- grand_child->SetContentBounds(grand_child->bounds());
- grand_child->draw_properties().visible_content_rect = grand_child_rect;
+ grand_child->draw_properties().visible_layer_rect = grand_child_rect;
grand_child->SetDrawsContent(true);
child->AddChild(grand_child.Pass());
@@ -5479,14 +5755,11 @@ static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity(
}
TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) {
- scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
- new TestSharedBitmapManager());
+ TestSharedBitmapManager shared_bitmap_manager;
+ TestTaskGraphRunner task_graph_runner;
scoped_ptr<LayerTreeHostImpl> my_host_impl =
- SetupLayersForOpacity(true,
- this,
- &proxy_,
- shared_bitmap_manager.get(),
- &stats_instrumentation_);
+ SetupLayersForOpacity(true, this, &proxy_, &shared_bitmap_manager,
+ &task_graph_runner, &stats_instrumentation_);
{
LayerTreeHostImpl::FrameData frame;
EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame));
@@ -5506,14 +5779,11 @@ TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) {
}
TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
- scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
- new TestSharedBitmapManager());
+ TestSharedBitmapManager shared_bitmap_manager;
+ TestTaskGraphRunner task_graph_runner;
scoped_ptr<LayerTreeHostImpl> my_host_impl =
- SetupLayersForOpacity(false,
- this,
- &proxy_,
- shared_bitmap_manager.get(),
- &stats_instrumentation_);
+ SetupLayersForOpacity(false, this, &proxy_, &shared_bitmap_manager,
+ &task_graph_runner, &stats_instrumentation_);
{
LayerTreeHostImpl::FrameData frame;
EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame));
@@ -5553,14 +5823,12 @@ TEST_F(LayerTreeHostImplTest, LayersFreeTextures) {
scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create(
host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0);
video_layer->SetBounds(gfx::Size(10, 10));
- video_layer->SetContentBounds(gfx::Size(10, 10));
video_layer->SetDrawsContent(true);
root_layer->AddChild(video_layer.Pass());
scoped_ptr<IOSurfaceLayerImpl> io_surface_layer =
IOSurfaceLayerImpl::Create(host_impl_->active_tree(), 5);
io_surface_layer->SetBounds(gfx::Size(10, 10));
- io_surface_layer->SetContentBounds(gfx::Size(10, 10));
io_surface_layer->SetDrawsContent(true);
io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10));
root_layer->AddChild(io_surface_layer.Pass());
@@ -5627,46 +5895,6 @@ TEST_F(LayerTreeHostImplTest, HasTransparentBackground) {
Mock::VerifyAndClearExpectations(&mock_context);
}
-TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) {
- set_reduce_memory_result(false);
-
- // If changing the memory limit wouldn't result in changing what was
- // committed, then no commit should be requested.
- set_reduce_memory_result(false);
- host_impl_->set_max_memory_needed_bytes(
- host_impl_->memory_allocation_limit_bytes() - 1);
- host_impl_->SetMemoryPolicy(ManagedMemoryPolicy(
- host_impl_->memory_allocation_limit_bytes() - 1));
- EXPECT_FALSE(did_request_commit_);
- did_request_commit_ = false;
-
- // If changing the memory limit would result in changing what was
- // committed, then a commit should be requested, even though nothing was
- // evicted.
- set_reduce_memory_result(false);
- host_impl_->set_max_memory_needed_bytes(
- host_impl_->memory_allocation_limit_bytes());
- host_impl_->SetMemoryPolicy(ManagedMemoryPolicy(
- host_impl_->memory_allocation_limit_bytes() - 1));
- EXPECT_TRUE(did_request_commit_);
- did_request_commit_ = false;
-
- // Especially if changing the memory limit caused evictions, we need
- // to re-commit.
- set_reduce_memory_result(true);
- host_impl_->set_max_memory_needed_bytes(1);
- host_impl_->SetMemoryPolicy(ManagedMemoryPolicy(
- host_impl_->memory_allocation_limit_bytes() - 1));
- EXPECT_TRUE(did_request_commit_);
- did_request_commit_ = false;
-
- // But if we set it to the same value that it was before, we shouldn't
- // re-commit.
- host_impl_->SetMemoryPolicy(ManagedMemoryPolicy(
- host_impl_->memory_allocation_limit_bytes()));
- EXPECT_FALSE(did_request_commit_);
-}
-
class LayerTreeHostImplTestWithDelegatingRenderer
: public LayerTreeHostImplTest {
protected:
@@ -5695,12 +5923,12 @@ class LayerTreeHostImplTestWithDelegatingRenderer
ASSERT_EQ(2u, root_render_pass->quad_list.size());
LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0];
- gfx::RectF expected_child_visible_rect(child->content_bounds());
+ gfx::RectF expected_child_visible_rect(child->bounds());
EXPECT_EQ(expected_child_visible_rect,
root_render_pass->quad_list.front()->visible_rect);
LayerImpl* root = host_impl_->active_tree()->root_layer();
- gfx::RectF expected_root_visible_rect(root->content_bounds());
+ gfx::RectF expected_root_visible_rect(root->bounds());
EXPECT_EQ(expected_root_visible_rect,
root_render_pass->quad_list.ElementAt(1)->visible_rect);
}
@@ -5716,7 +5944,6 @@ TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) {
SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
root->SetPosition(gfx::PointF());
root->SetBounds(gfx::Size(10, 10));
- root->SetContentBounds(gfx::Size(10, 10));
root->SetDrawsContent(true);
root->SetHasRenderSurface(true);
@@ -5725,7 +5952,6 @@ TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) {
SolidColorLayerImpl::Create(host_impl_->active_tree(), 2);
child->SetPosition(gfx::PointF(9.f, 9.f));
child->SetBounds(gfx::Size(1, 1));
- child->SetContentBounds(gfx::Size(1, 1));
child->SetDrawsContent(true);
root->AddChild(child.Pass());
@@ -5761,7 +5987,7 @@ class FakeMaskLayerImpl : public LayerImpl {
return make_scoped_ptr(new FakeMaskLayerImpl(tree_impl, id));
}
- void GetContentsResourceId(ResourceProvider::ResourceId* resource_id,
+ void GetContentsResourceId(ResourceId* resource_id,
gfx::Size* resource_size) const override {
*resource_id = 0;
}
@@ -5834,9 +6060,14 @@ TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) {
ASSERT_LE(1u, frame.render_passes[0]->quad_list.size());
const DrawQuad* quad = frame.render_passes[0]->quad_list.front();
+ bool clipped = false, force_aa = false;
+ gfx::QuadF device_layer_quad = MathUtil::MapQuad(
+ quad->shared_quad_state->quad_to_target_transform,
+ gfx::QuadF(quad->shared_quad_state->visible_quad_layer_rect), &clipped);
+ EXPECT_FALSE(clipped);
bool antialiased =
GLRendererWithSetupQuadForAntialiasing::ShouldAntialiasQuad(
- quad->quadTransform(), quad, false);
+ device_layer_quad, clipped, force_aa);
EXPECT_FALSE(antialiased);
host_impl_->DrawLayers(&frame);
@@ -5949,7 +6180,6 @@ TEST_F(LayerTreeHostImplTest,
scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create(
host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0);
video_layer->SetBounds(gfx::Size(10, 10));
- video_layer->SetContentBounds(gfx::Size(10, 10));
video_layer->SetDrawsContent(true);
root_layer->AddChild(video_layer.Pass());
SetupRootLayerImpl(root_layer.Pass());
@@ -5968,9 +6198,8 @@ TEST_F(LayerTreeHostImplTest,
TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) {
LayerTreeSettings settings;
host_impl_ = LayerTreeHostImpl::Create(
- settings, this, &proxy_, &stats_instrumentation_,
- shared_bitmap_manager_.get(), gpu_memory_buffer_manager_.get(),
- task_graph_runner_.get(), 0);
+ settings, this, &proxy_, &stats_instrumentation_, &shared_bitmap_manager_,
+ &gpu_memory_buffer_manager_, &task_graph_runner_, 0);
scoped_ptr<OutputSurface> output_surface(
FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()));
@@ -5978,51 +6207,6 @@ TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) {
EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes());
}
-TEST_F(LayerTreeHostImplTest, MemoryPolicy) {
- ManagedMemoryPolicy policy1(
- 456, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 1000);
- int everything_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue(
- gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING);
- int allow_nice_to_have_cutoff_value =
- ManagedMemoryPolicy::PriorityCutoffToValue(
- gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE);
- int nothing_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue(
- gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING);
-
- // GPU rasterization should be disabled by default on the tree(s)
- EXPECT_FALSE(host_impl_->active_tree()->use_gpu_rasterization());
- EXPECT_TRUE(host_impl_->pending_tree() == NULL);
-
- host_impl_->SetVisible(true);
- host_impl_->SetMemoryPolicy(policy1);
- EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_);
- EXPECT_EQ(everything_cutoff_value, current_priority_cutoff_value_);
-
- host_impl_->SetVisible(false);
- EXPECT_EQ(0u, current_limit_bytes_);
- EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_);
-
- host_impl_->SetVisible(true);
- EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_);
- EXPECT_EQ(everything_cutoff_value, current_priority_cutoff_value_);
-
- // Now enable GPU rasterization and test if we get nice to have cutoff,
- // when visible.
- LayerTreeSettings settings;
- settings.gpu_rasterization_enabled = true;
- CreateHostImpl(settings, CreateOutputSurface());
- host_impl_->SetContentIsSuitableForGpuRasterization(true);
- host_impl_->SetHasGpuRasterizationTrigger(true);
- host_impl_->SetVisible(true);
- host_impl_->SetMemoryPolicy(policy1);
- EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_);
- EXPECT_EQ(allow_nice_to_have_cutoff_value, current_priority_cutoff_value_);
-
- host_impl_->SetVisible(false);
- EXPECT_EQ(0u, current_limit_bytes_);
- EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_);
-}
-
TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) {
ASSERT_TRUE(host_impl_->active_tree());
@@ -6076,12 +6260,9 @@ TEST_F(LayerTreeHostImplTest, RequireHighResAfterGpuRasterizationToggles) {
class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest {
public:
void SetUp() override {
- LayerTreeSettings settings;
- settings.impl_side_painting = true;
-
- fake_host_impl_ = new FakeLayerTreeHostImpl(settings, &proxy_,
- shared_bitmap_manager_.get(),
- task_graph_runner_.get());
+ fake_host_impl_ =
+ new FakeLayerTreeHostImpl(LayerTreeSettings(), &proxy_,
+ &shared_bitmap_manager_, &task_graph_runner_);
host_impl_.reset(fake_host_impl_);
host_impl_->InitializeRenderer(CreateOutputSurface());
host_impl_->SetViewportSize(gfx::Size(10, 10));
@@ -6111,16 +6292,14 @@ TEST_F(LayerTreeHostImplTest, UIResourceManagement) {
UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque);
host_impl_->CreateUIResource(ui_resource_id, bitmap);
EXPECT_EQ(1u, context3d->NumTextures());
- ResourceProvider::ResourceId id1 =
- host_impl_->ResourceIdForUIResource(ui_resource_id);
+ ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id);
EXPECT_NE(0u, id1);
// Multiple requests with the same id is allowed. The previous texture is
// deleted.
host_impl_->CreateUIResource(ui_resource_id, bitmap);
EXPECT_EQ(1u, context3d->NumTextures());
- ResourceProvider::ResourceId id2 =
- host_impl_->ResourceIdForUIResource(ui_resource_id);
+ ResourceId id2 = host_impl_->ResourceIdForUIResource(ui_resource_id);
EXPECT_NE(0u, id2);
EXPECT_NE(id1, id2);
@@ -6163,8 +6342,7 @@ TEST_F(LayerTreeHostImplTest, CreateETC1UIResource) {
UIResourceId ui_resource_id = 1;
host_impl_->CreateUIResource(ui_resource_id, bitmap);
EXPECT_EQ(1u, context3d->NumTextures());
- ResourceProvider::ResourceId id1 =
- host_impl_->ResourceIdForUIResource(ui_resource_id);
+ ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id);
EXPECT_NE(0u, id1);
}
@@ -6288,7 +6466,8 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) {
// The grand child should have scrolled up to its limit.
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(1u, scroll_info->scrolls.size());
- ExpectContains(*scroll_info, grand_child->id(), scroll_delta);
+ EXPECT_TRUE(
+ ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta));
EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child);
// The child should have received the bubbled delta, but the locked
@@ -6296,8 +6475,9 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) {
EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll);
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(2u, scroll_info->scrolls.size());
- ExpectContains(*scroll_info, grand_child->id(), scroll_delta);
- ExpectContains(*scroll_info, child->id(), scroll_delta);
+ EXPECT_TRUE(
+ ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, child->id(), scroll_delta));
EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child);
// The first |ScrollBy| after the fling should re-lock the scrolling
@@ -6309,8 +6489,10 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) {
// The child should have scrolled up to its limit.
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(2u, scroll_info->scrolls.size());
- ExpectContains(*scroll_info, grand_child->id(), scroll_delta);
- ExpectContains(*scroll_info, child->id(), scroll_delta + scroll_delta);
+ EXPECT_TRUE(
+ ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, child->id(),
+ scroll_delta + scroll_delta));
// As the locked layer is at it's limit, no further scrolling can occur.
EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll);
@@ -6357,7 +6539,8 @@ TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) {
// The root should have scrolled.
ASSERT_EQ(2u, scroll_info->scrolls.size());
- ExpectContains(*scroll_info.get(), root_scroll_id, gfx::Vector2d(0, 10));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), root_scroll_id,
+ gfx::Vector2d(0, 10)));
}
}
@@ -6381,7 +6564,6 @@ TEST_F(LayerTreeHostImplTest, ScrollUnknownNotOnAncestorChain) {
LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id);
occluder_layer->SetDrawsContent(true);
occluder_layer->SetBounds(content_size);
- occluder_layer->SetContentBounds(content_size);
occluder_layer->SetPosition(gfx::PointF());
// The parent of the occluder is *above* the scroller.
@@ -6410,7 +6592,6 @@ TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) {
LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id);
occluder_layer->SetDrawsContent(true);
occluder_layer->SetBounds(content_size);
- occluder_layer->SetContentBounds(content_size);
occluder_layer->SetPosition(gfx::PointF(-10.f, -10.f));
int child_scroll_clip_layer_id = 7;
@@ -6482,7 +6663,6 @@ TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleDescendent) {
LayerImpl::Create(host_impl_->active_tree(), 9);
grand_child_layer->SetDrawsContent(true);
grand_child_layer->SetBounds(content_size);
- grand_child_layer->SetContentBounds(content_size);
// Move the grand child so it's not hit by our test point.
grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f));
@@ -6519,7 +6699,6 @@ TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleScrollChild) {
LayerImpl::Create(host_impl_->active_tree(), scroll_child_id);
scroll_child->SetDrawsContent(true);
scroll_child->SetBounds(content_size);
- scroll_child->SetContentBounds(content_size);
// Move the scroll child so it's not hit by our test point.
scroll_child->SetPosition(gfx::PointF(10.f, 10.f));
@@ -6561,7 +6740,6 @@ TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) {
SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
root->SetPosition(gfx::PointF());
root->SetBounds(gfx::Size(10, 10));
- root->SetContentBounds(gfx::Size(10, 10));
root->SetDrawsContent(true);
root->SetHasRenderSurface(true);
@@ -6602,7 +6780,6 @@ TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) {
SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id);
root->SetPosition(gfx::PointF());
root->SetBounds(gfx::Size(10, 10));
- root->SetContentBounds(gfx::Size(10, 10));
root->SetDrawsContent(true);
root->SetHasRenderSurface(true);
@@ -6918,7 +7095,7 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) {
// The top controls should properly animate until finished, despite the scroll
// offset being at the origin.
- base::TimeTicks animation_time = gfx::FrameTime::Now();
+ base::TimeTicks animation_time = base::TimeTicks::Now();
while (did_request_animate_) {
did_request_redraw_ = false;
did_request_animate_ = false;
@@ -6988,7 +7165,7 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) {
EXPECT_FALSE(did_request_commit_);
// Animate the top controls to the limit.
- base::TimeTicks animation_time = gfx::FrameTime::Now();
+ base::TimeTicks animation_time = base::TimeTicks::Now();
while (did_request_animate_) {
did_request_redraw_ = false;
did_request_animate_ = false;
@@ -7052,7 +7229,7 @@ TEST_F(LayerTreeHostImplWithTopControlsTest,
EXPECT_FALSE(did_request_commit_);
// Animate the top controls to the limit.
- base::TimeTicks animation_time = gfx::FrameTime::Now();
+ base::TimeTicks animation_time = base::TimeTicks::Now();
while (did_request_animate_) {
did_request_redraw_ = false;
did_request_animate_ = false;
@@ -7163,7 +7340,6 @@ class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest {
inner_scroll->SetScrollClipLayer(inner_clip->id());
inner_scroll->SetBounds(outer_viewport);
- inner_scroll->SetContentBounds(outer_viewport);
inner_scroll->SetPosition(gfx::PointF());
scoped_ptr<LayerImpl> outer_clip =
@@ -7176,14 +7352,12 @@ class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest {
outer_scroll->SetScrollClipLayer(outer_clip->id());
outer_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset());
outer_scroll->SetBounds(content_size);
- outer_scroll->SetContentBounds(content_size);
outer_scroll->SetPosition(gfx::PointF());
scoped_ptr<LayerImpl> contents =
LayerImpl::Create(layer_tree_impl, 8);
contents->SetDrawsContent(true);
contents->SetBounds(content_size);
- contents->SetContentBounds(content_size);
contents->SetPosition(gfx::PointF());
outer_scroll->AddChild(contents.Pass());
@@ -7256,13 +7430,17 @@ TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) {
// Make sure the fling goes to the outer viewport first
EXPECT_EQ(InputHandler::SCROLL_STARTED,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE));
+ EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer());
EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin());
+ EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer());
gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height());
host_impl_->ScrollBy(gfx::Point(), scroll_delta);
outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y());
+ EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), outer_scroll);
host_impl_->ScrollEnd();
+ EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer());
EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset());
EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset());
@@ -7270,15 +7448,20 @@ TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) {
// Fling past the outer viewport boundry, make sure inner viewport scrolls.
EXPECT_EQ(InputHandler::SCROLL_STARTED,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE));
+ EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer());
EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin());
+ EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer());
host_impl_->ScrollBy(gfx::Point(), scroll_delta);
outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y());
+ EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer());
host_impl_->ScrollBy(gfx::Point(), scroll_delta);
inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y());
+ EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer());
host_impl_->ScrollEnd();
+ EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer());
EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset());
EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset());
@@ -7366,7 +7549,8 @@ TEST_F(LayerTreeHostImplVirtualViewportTest,
// The child should have scrolled up to its limit.
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(1u, scroll_info->scrolls.size());
- ExpectContains(*scroll_info, child_scroll->id(), scroll_delta);
+ EXPECT_TRUE(
+ ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta));
EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll);
// The first |ScrollBy| after the fling should re-lock the scrolling
@@ -7380,8 +7564,10 @@ TEST_F(LayerTreeHostImplVirtualViewportTest,
// The inner viewport should have scrolled up to its limit.
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(2u, scroll_info->scrolls.size());
- ExpectContains(*scroll_info, child_scroll->id(), scroll_delta);
- ExpectContains(*scroll_info, inner_scroll->id(), scroll_delta);
+ EXPECT_TRUE(
+ ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta));
+ EXPECT_TRUE(
+ ScrollInfoContains(*scroll_info, inner_scroll->id(), scroll_delta));
// As the locked layer is at its limit, no further scrolling can occur.
EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll);
@@ -7392,6 +7578,34 @@ TEST_F(LayerTreeHostImplVirtualViewportTest,
}
}
+TEST_F(LayerTreeHostImplVirtualViewportTest,
+ ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) {
+ gfx::Size content_size = gfx::Size(100, 160);
+ gfx::Size outer_viewport = gfx::Size(50, 80);
+ gfx::Size inner_viewport = gfx::Size(25, 40);
+
+ SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport);
+
+ LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer();
+ LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer();
+
+ scoped_ptr<LayerImpl> child =
+ CreateScrollableLayer(10, outer_viewport, outer_scroll);
+ LayerImpl* child_scroll = child.get();
+ outer_scroll->children()[0]->AddChild(child.Pass());
+
+ DrawFrame();
+
+ EXPECT_EQ(InputHandler::SCROLL_STARTED,
+ host_impl_->RootScrollBegin(InputHandler::GESTURE));
+ EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll);
+ host_impl_->ScrollEnd();
+ EXPECT_EQ(InputHandler::SCROLL_STARTED,
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE));
+ EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll);
+ host_impl_->ScrollEnd();
+}
+
class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest {
public:
void SetUp() override {
@@ -7486,6 +7700,49 @@ TEST_F(LayerTreeHostImplTest, ScrollAnimated) {
EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
}
+// Evolved from LayerTreeHostImplTest.ScrollAnimated.
+TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) {
+ SetupScrollAndContentsLayers(gfx::Size(100, 200));
+ DrawFrame();
+
+ base::TimeTicks start_time =
+ base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
+
+ EXPECT_EQ(InputHandler::SCROLL_STARTED,
+ host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
+
+ LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
+
+ host_impl_->Animate(start_time);
+ host_impl_->UpdateAnimationState(true);
+
+ EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
+
+ host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50));
+ host_impl_->UpdateAnimationState(true);
+
+ float y = scrolling_layer->CurrentScrollOffset().y();
+ EXPECT_TRUE(y > 1 && y < 49);
+
+ // Update target.
+ EXPECT_EQ(InputHandler::SCROLL_STARTED,
+ host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
+
+ host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200));
+ host_impl_->UpdateAnimationState(true);
+
+ y = scrolling_layer->CurrentScrollOffset().y();
+ EXPECT_TRUE(y > 50 && y < 100);
+ EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer());
+
+ host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250));
+ host_impl_->UpdateAnimationState(true);
+
+ EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
+ scrolling_layer->CurrentScrollOffset());
+ EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
+}
+
TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) {
host_impl_->CreatePendingTree();
@@ -7778,6 +8035,8 @@ class FakeVideoFrameController : public VideoFrameController {
};
TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) {
+ host_impl_->DidFinishImplFrame();
+
BeginFrameArgs begin_frame_args =
CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
FakeVideoFrameController controller;
@@ -7801,6 +8060,8 @@ TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) {
}
TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) {
+ host_impl_->DidFinishImplFrame();
+
BeginFrameArgs begin_frame_args =
CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
FakeVideoFrameController controller;
@@ -7884,5 +8145,40 @@ TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusModes) {
EXPECT_TRUE(host_impl_->use_gpu_rasterization());
}
+// A mock output surface which lets us detect calls to ForceReclaimResources.
+class MockReclaimResourcesOutputSurface : public FakeOutputSurface {
+ public:
+ static scoped_ptr<MockReclaimResourcesOutputSurface> Create3d() {
+ return make_scoped_ptr(new MockReclaimResourcesOutputSurface(
+ TestContextProvider::Create(), TestContextProvider::Create(), false));
+ }
+
+ MOCK_METHOD0(ForceReclaimResources, void());
+
+ protected:
+ MockReclaimResourcesOutputSurface(
+ scoped_refptr<ContextProvider> context_provider,
+ scoped_refptr<ContextProvider> worker_context_provider,
+ bool delegated_rendering)
+ : FakeOutputSurface(context_provider,
+ worker_context_provider,
+ delegated_rendering) {}
+};
+
+// Display::Draw (and the planned Display Scheduler) currently rely on resources
+// being reclaimed to block drawing between BeginCommit / Swap. This test
+// ensures that BeginCommit triggers ForceReclaimResources. See
+// crbug.com/489515.
+TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) {
+ scoped_ptr<MockReclaimResourcesOutputSurface> output_surface(
+ MockReclaimResourcesOutputSurface::Create3d());
+ // Hold an unowned pointer to the output surface to use for mock expectations.
+ MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get();
+
+ CreateHostImpl(DefaultSettings(), output_surface.Pass());
+ EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1);
+ host_impl_->BeginCommit();
+}
+
} // namespace
} // namespace cc
diff --git a/chromium/cc/trees/layer_tree_host_perftest.cc b/chromium/cc/trees/layer_tree_host_perftest.cc
index c8e2a8c02c1..eb8183fadf2 100644
--- a/chromium/cc/trees/layer_tree_host_perftest.cc
+++ b/chromium/cc/trees/layer_tree_host_perftest.cc
@@ -12,7 +12,6 @@
#include "base/strings/string_piece.h"
#include "base/time/time.h"
#include "cc/debug/lap_timer.h"
-#include "cc/layers/content_layer.h"
#include "cc/layers/nine_patch_layer.h"
#include "cc/layers/solid_color_layer.h"
#include "cc/layers/texture_layer.h"
@@ -45,7 +44,7 @@ class LayerTreeHostPerfTest : public LayerTreeTest {
}
void InitializeSettings(LayerTreeSettings* settings) override {
- settings->throttle_frame_production = false;
+ settings->renderer_settings.disable_gpu_vsync = true;
}
void BeginTest() override {
@@ -148,13 +147,13 @@ class LayerTreeHostPerfTestJsonReader : public LayerTreeHostPerfTest {
TEST_F(LayerTreeHostPerfTestJsonReader, TenTenSingleThread) {
SetTestName("10_10_single_thread");
ReadTestFile("10_10_layer_tree");
- RunTest(false, false, false);
+ RunTest(false, false);
}
-TEST_F(LayerTreeHostPerfTestJsonReader, TenTenThreadedImplSide) {
+TEST_F(LayerTreeHostPerfTestJsonReader, TenTenThreaded) {
SetTestName("10_10_threaded_impl_side");
ReadTestFile("10_10_layer_tree");
- RunTestWithImplSidePainting();
+ RunTest(true, false);
}
// Simulates a tab switcher scene with two stacks of 10 tabs each.
@@ -163,15 +162,14 @@ TEST_F(LayerTreeHostPerfTestJsonReader,
full_damage_each_frame_ = true;
SetTestName("10_10_single_thread_full_damage_each_frame");
ReadTestFile("10_10_layer_tree");
- RunTest(false, false, false);
+ RunTest(false, false);
}
-TEST_F(LayerTreeHostPerfTestJsonReader,
- TenTenThreadedImplSide_FullDamageEachFrame) {
+TEST_F(LayerTreeHostPerfTestJsonReader, TenTenThreaded_FullDamageEachFrame) {
full_damage_each_frame_ = true;
SetTestName("10_10_threaded_impl_side_full_damage_each_frame");
ReadTestFile("10_10_layer_tree");
- RunTestWithImplSidePainting();
+ RunTest(true, false);
}
// Invalidates a leaf layer in the tree on the main thread after every commit.
@@ -205,13 +203,13 @@ class LayerTreeHostPerfTestLeafInvalidates
TEST_F(LayerTreeHostPerfTestLeafInvalidates, TenTenSingleThread) {
SetTestName("10_10_single_thread_leaf_invalidates");
ReadTestFile("10_10_layer_tree");
- RunTest(false, false, false);
+ RunTest(false, false);
}
-TEST_F(LayerTreeHostPerfTestLeafInvalidates, TenTenThreadedImplSide) {
+TEST_F(LayerTreeHostPerfTestLeafInvalidates, TenTenThreaded) {
SetTestName("10_10_threaded_impl_side_leaf_invalidates");
ReadTestFile("10_10_layer_tree");
- RunTestWithImplSidePainting();
+ RunTest(true, false);
}
// Simulates main-thread scrolling on each frame.
@@ -246,18 +244,18 @@ TEST_F(ScrollingLayerTreePerfTest, LongScrollablePageSingleThread) {
// crbug.com/444219 is fixed.
bool old_verify_property_trees = verify_property_trees();
set_verify_property_trees(false);
- RunTest(false, false, false);
+ RunTest(false, false);
set_verify_property_trees(old_verify_property_trees);
}
-TEST_F(ScrollingLayerTreePerfTest, LongScrollablePageThreadedImplSide) {
+TEST_F(ScrollingLayerTreePerfTest, LongScrollablePageThreaded) {
SetTestName("long_scrollable_page_threaded_impl_side");
ReadTestFile("long_scrollable_page");
// TODO(vollick): Remove verify_property_trees setting after
// crbug.com/444219 is fixed.
bool old_verify_property_trees = verify_property_trees();
set_verify_property_trees(false);
- RunTestWithImplSidePainting();
+ RunTest(true, false);
set_verify_property_trees(old_verify_property_trees);
}
@@ -327,20 +325,20 @@ class BrowserCompositorInvalidateLayerTreePerfTest
bool clean_up_started_;
};
-TEST_F(BrowserCompositorInvalidateLayerTreePerfTest, DenseBrowserUI) {
+TEST_F(BrowserCompositorInvalidateLayerTreePerfTest, DenseBrowserUIThreaded) {
measure_commit_cost_ = true;
SetTestName("dense_layer_tree");
ReadTestFile("dense_layer_tree");
- RunTestWithImplSidePainting();
+ RunTest(true, false);
}
// Simulates a page with several large, transformed and animated layers.
-TEST_F(LayerTreeHostPerfTestJsonReader, HeavyPageThreadedImplSide) {
+TEST_F(LayerTreeHostPerfTestJsonReader, HeavyPageThreaded) {
begin_frame_driven_drawing_ = true;
measure_commit_cost_ = true;
SetTestName("heavy_page");
ReadTestFile("heavy_layer_tree");
- RunTestWithImplSidePainting();
+ RunTest(true, false);
}
} // namespace
diff --git a/chromium/cc/trees/layer_tree_host_pixeltest_blending.cc b/chromium/cc/trees/layer_tree_host_pixeltest_blending.cc
index b31d3e85395..e2715e3907c 100644
--- a/chromium/cc/trees/layer_tree_host_pixeltest_blending.cc
+++ b/chromium/cc/trees/layer_tree_host_pixeltest_blending.cc
@@ -137,7 +137,8 @@ class LayerTreeHostBlendingPixelTest : public LayerTreeHostPixelResourceTest {
canvas.drawRect(
SkRect::MakeXYWH(0, i * kLaneHeight, kLaneWidth, kLaneHeight), paint);
}
- scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create();
+ scoped_refptr<PictureImageLayer> layer =
+ PictureImageLayer::Create(layer_settings());
layer->SetIsDrawable(true);
layer->SetBounds(gfx::Size(width, height));
layer->SetBitmap(backing_store);
@@ -147,7 +148,8 @@ class LayerTreeHostBlendingPixelTest : public LayerTreeHostPixelResourceTest {
void SetupMaskLayer(scoped_refptr<Layer> layer) {
const int kMaskOffset = 2;
gfx::Size bounds = layer->bounds();
- scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create();
+ scoped_refptr<PictureImageLayer> mask =
+ PictureImageLayer::Create(layer_settings());
mask->SetIsDrawable(true);
mask->SetIsMask(true);
mask->SetBounds(bounds);
diff --git a/chromium/cc/trees/layer_tree_host_pixeltest_masks.cc b/chromium/cc/trees/layer_tree_host_pixeltest_masks.cc
index 0cb6aeaa846..6a4bebd4f35 100644
--- a/chromium/cc/trees/layer_tree_host_pixeltest_masks.cc
+++ b/chromium/cc/trees/layer_tree_host_pixeltest_masks.cc
@@ -46,11 +46,11 @@ class MaskContentLayerClient : public ContentLayerClient {
}
}
- void PaintContentsToDisplayList(
- DisplayItemList* display_list,
+ scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
const gfx::Rect& clip,
PaintingControlSetting picture_control) override {
NOTIMPLEMENTED();
+ return nullptr;
}
private:
@@ -67,7 +67,8 @@ TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) {
gfx::Size mask_bounds(50, 50);
MaskContentLayerClient client(mask_bounds);
- scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
+ scoped_refptr<PictureLayer> mask =
+ PictureLayer::Create(layer_settings(), &client);
mask->SetBounds(mask_bounds);
mask->SetIsDrawable(true);
mask->SetIsMask(true);
@@ -83,7 +84,8 @@ TEST_P(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) {
gfx::Size mask_bounds(50, 50);
- scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create();
+ scoped_refptr<PictureImageLayer> mask =
+ PictureImageLayer::Create(layer_settings());
mask->SetIsDrawable(true);
mask->SetIsMask(true);
mask->SetBounds(mask_bounds);
@@ -111,7 +113,7 @@ TEST_P(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) {
gfx::Rect(100, 100), SK_ColorWHITE);
// Clip to the top half of the green layer.
- scoped_refptr<Layer> clip = Layer::Create();
+ scoped_refptr<Layer> clip = Layer::Create(layer_settings());
clip->SetPosition(gfx::Point(0, 0));
clip->SetBounds(gfx::Size(100, 50));
clip->SetMasksToBounds(true);
@@ -123,7 +125,8 @@ TEST_P(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) {
gfx::Size mask_bounds(50, 50);
MaskContentLayerClient client(mask_bounds);
- scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
+ scoped_refptr<PictureLayer> mask =
+ PictureLayer::Create(layer_settings(), &client);
mask->SetBounds(mask_bounds);
mask->SetIsDrawable(true);
mask->SetIsMask(true);
@@ -140,7 +143,8 @@ TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplica) {
gfx::Size mask_bounds(50, 50);
MaskContentLayerClient client(mask_bounds);
- scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
+ scoped_refptr<PictureLayer> mask =
+ PictureLayer::Create(layer_settings(), &client);
mask->SetBounds(mask_bounds);
mask->SetIsDrawable(true);
mask->SetIsMask(true);
@@ -153,7 +157,7 @@ TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplica) {
gfx::Transform replica_transform;
replica_transform.Rotate(-90.0);
- scoped_refptr<Layer> replica = Layer::Create();
+ scoped_refptr<Layer> replica = Layer::Create(layer_settings());
replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f));
replica->SetPosition(gfx::Point(50, 50));
replica->SetTransform(replica_transform);
@@ -169,14 +173,15 @@ TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) {
gfx::Size mask_bounds(50, 50);
MaskContentLayerClient client(mask_bounds);
- scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
+ scoped_refptr<PictureLayer> mask =
+ PictureLayer::Create(layer_settings(), &client);
mask->SetBounds(mask_bounds);
mask->SetIsDrawable(true);
mask->SetIsMask(true);
// Clip to the bottom half of the green layer, and the left half of the
// replica.
- scoped_refptr<Layer> clip = Layer::Create();
+ scoped_refptr<Layer> clip = Layer::Create(layer_settings());
clip->SetPosition(gfx::Point(0, 25));
clip->SetBounds(gfx::Size(75, 75));
clip->SetMasksToBounds(true);
@@ -190,7 +195,7 @@ TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) {
gfx::Transform replica_transform;
replica_transform.Rotate(-90.0);
- scoped_refptr<Layer> replica = Layer::Create();
+ scoped_refptr<Layer> replica = Layer::Create(layer_settings());
replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f));
replica->SetPosition(gfx::Point(50, 50));
replica->SetTransform(replica_transform);
@@ -207,7 +212,8 @@ TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplica) {
gfx::Size mask_bounds(50, 50);
MaskContentLayerClient client(mask_bounds);
- scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
+ scoped_refptr<PictureLayer> mask =
+ PictureLayer::Create(layer_settings(), &client);
mask->SetBounds(mask_bounds);
mask->SetIsDrawable(true);
mask->SetIsMask(true);
@@ -224,7 +230,7 @@ TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplica) {
replica_transform.Rotate(180.0);
replica_transform.Translate(50.0, 0.0);
- scoped_refptr<Layer> replica = Layer::Create();
+ scoped_refptr<Layer> replica = Layer::Create(layer_settings());
replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f));
replica->SetPosition(gfx::Point());
replica->SetTransform(replica_transform);
@@ -241,13 +247,14 @@ TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) {
gfx::Size mask_bounds(50, 50);
MaskContentLayerClient client(mask_bounds);
- scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
+ scoped_refptr<PictureLayer> mask =
+ PictureLayer::Create(layer_settings(), &client);
mask->SetBounds(mask_bounds);
mask->SetIsDrawable(true);
mask->SetIsMask(true);
// Clip to the bottom 3/4 of the green layer, and the top 3/4 of the replica.
- scoped_refptr<Layer> clip = Layer::Create();
+ scoped_refptr<Layer> clip = Layer::Create(layer_settings());
clip->SetPosition(gfx::Point(0, 12));
clip->SetBounds(gfx::Size(100, 75));
clip->SetMasksToBounds(true);
@@ -265,7 +272,7 @@ TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) {
replica_transform.Rotate(180.0);
replica_transform.Translate(50.0, 0.0);
- scoped_refptr<Layer> replica = Layer::Create();
+ scoped_refptr<Layer> replica = Layer::Create(layer_settings());
replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f));
replica->SetPosition(gfx::Point());
replica->SetTransform(replica_transform);
@@ -303,11 +310,11 @@ class CheckerContentLayerClient : public ContentLayerClient {
}
}
}
- void PaintContentsToDisplayList(
- DisplayItemList* display_list,
+ scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
const gfx::Rect& clip,
PaintingControlSetting picture_control) override {
NOTIMPLEMENTED();
+ return nullptr;
}
private:
@@ -334,11 +341,11 @@ class CircleContentLayerClient : public ContentLayerClient {
bounds_.width() / 4,
paint);
}
- void PaintContentsToDisplayList(
- DisplayItemList* display_list,
+ scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
const gfx::Rect& clip,
PaintingControlSetting picture_control) override {
NOTIMPLEMENTED();
+ return nullptr;
}
private:
@@ -369,7 +376,8 @@ TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest,
gfx::Size picture_bounds(100, 100);
CheckerContentLayerClient picture_client(picture_bounds, SK_ColorGREEN, true);
- scoped_refptr<PictureLayer> picture = PictureLayer::Create(&picture_client);
+ scoped_refptr<PictureLayer> picture =
+ PictureLayer::Create(layer_settings(), &picture_client);
picture->SetBounds(picture_bounds);
picture->SetIsDrawable(true);
@@ -384,7 +392,8 @@ TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest,
gfx::Size mask_bounds(100, 100);
CircleContentLayerClient mask_client(mask_bounds);
- scoped_refptr<PictureLayer> mask = PictureLayer::Create(&mask_client);
+ scoped_refptr<PictureLayer> mask =
+ PictureLayer::Create(layer_settings(), &mask_client);
mask->SetBounds(mask_bounds);
mask->SetIsDrawable(true);
mask->SetIsMask(true);
@@ -417,14 +426,14 @@ TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest,
CheckerContentLayerClient picture_client_vertical(
picture_bounds, SK_ColorGREEN, true);
scoped_refptr<PictureLayer> picture_vertical =
- PictureLayer::Create(&picture_client_vertical);
+ PictureLayer::Create(layer_settings(), &picture_client_vertical);
picture_vertical->SetBounds(picture_bounds);
picture_vertical->SetIsDrawable(true);
CheckerContentLayerClient picture_client_horizontal(
picture_bounds, SK_ColorMAGENTA, false);
scoped_refptr<PictureLayer> picture_horizontal =
- PictureLayer::Create(&picture_client_horizontal);
+ PictureLayer::Create(layer_settings(), &picture_client_horizontal);
picture_horizontal->SetBounds(picture_bounds);
picture_horizontal->SetIsDrawable(true);
picture_horizontal->SetContentsOpaque(false);
@@ -435,7 +444,8 @@ TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest,
gfx::Size mask_bounds(128, 128);
CircleContentLayerClient mask_client(mask_bounds);
- scoped_refptr<PictureLayer> mask = PictureLayer::Create(&mask_client);
+ scoped_refptr<PictureLayer> mask =
+ PictureLayer::Create(layer_settings(), &mask_client);
mask->SetBounds(mask_bounds);
mask->SetIsDrawable(true);
mask->SetIsMask(true);
diff --git a/chromium/cc/trees/layer_tree_host_pixeltest_readback.cc b/chromium/cc/trees/layer_tree_host_pixeltest_readback.cc
index b3729047aa5..6af0bb2f8d0 100644
--- a/chromium/cc/trees/layer_tree_host_pixeltest_readback.cc
+++ b/chromium/cc/trees/layer_tree_host_pixeltest_readback.cc
@@ -485,18 +485,18 @@ class LayerTreeHostReadbackDeviceScalePixelTest
TEST_P(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackSubrect) {
scoped_refptr<FakePictureLayer> background =
- FakePictureLayer::Create(&white_client_);
+ FakePictureLayer::Create(layer_settings(), &white_client_);
background->SetBounds(gfx::Size(100, 100));
background->SetIsDrawable(true);
scoped_refptr<FakePictureLayer> green =
- FakePictureLayer::Create(&green_client_);
+ FakePictureLayer::Create(layer_settings(), &green_client_);
green->SetBounds(gfx::Size(100, 100));
green->SetIsDrawable(true);
background->AddChild(green);
scoped_refptr<FakePictureLayer> blue =
- FakePictureLayer::Create(&blue_client_);
+ FakePictureLayer::Create(layer_settings(), &blue_client_);
blue->SetPosition(gfx::Point(50, 50));
blue->SetBounds(gfx::Size(25, 25));
blue->SetIsDrawable(true);
@@ -512,19 +512,19 @@ TEST_P(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackSubrect) {
TEST_P(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackNonRootLayerSubrect) {
scoped_refptr<FakePictureLayer> background =
- FakePictureLayer::Create(&white_client_);
+ FakePictureLayer::Create(layer_settings(), &white_client_);
background->SetBounds(gfx::Size(100, 100));
background->SetIsDrawable(true);
scoped_refptr<FakePictureLayer> green =
- FakePictureLayer::Create(&green_client_);
+ FakePictureLayer::Create(layer_settings(), &green_client_);
green->SetPosition(gfx::Point(10, 20));
green->SetBounds(gfx::Size(90, 80));
green->SetIsDrawable(true);
background->AddChild(green);
scoped_refptr<FakePictureLayer> blue =
- FakePictureLayer::Create(&blue_client_);
+ FakePictureLayer::Create(layer_settings(), &blue_client_);
blue->SetPosition(gfx::Point(50, 50));
blue->SetBounds(gfx::Size(25, 25));
blue->SetIsDrawable(true);
diff --git a/chromium/cc/trees/layer_tree_host_pixeltest_synchronous.cc b/chromium/cc/trees/layer_tree_host_pixeltest_synchronous.cc
index 7dd6d7d856d..a5286a2473e 100644
--- a/chromium/cc/trees/layer_tree_host_pixeltest_synchronous.cc
+++ b/chromium/cc/trees/layer_tree_host_pixeltest_synchronous.cc
@@ -21,6 +21,8 @@ class LayerTreeHostSynchronousPixelTest : public LayerTreePixelTest {
void InitializeSettings(LayerTreeSettings* settings) override {
LayerTreePixelTest::InitializeSettings(settings);
settings->single_thread_proxy_scheduler = false;
+ settings->use_zero_copy = true;
+ settings->use_one_copy = false;
}
void BeginTest() override {
@@ -36,7 +38,8 @@ TEST_F(LayerTreeHostSynchronousPixelTest, OneContentLayer) {
SkPaint green_paint;
green_paint.setColor(SkColorSetARGB(255, 0, 255, 0));
client.add_draw_rect(gfx::RectF(bounds), green_paint);
- scoped_refptr<PictureLayer> root = PictureLayer::Create(&client);
+ scoped_refptr<PictureLayer> root =
+ PictureLayer::Create(layer_settings(), &client);
root->SetBounds(bounds);
root->SetIsDrawable(true);
@@ -66,7 +69,8 @@ TEST_F(LayerTreeHostSynchronousGPUPixelTest, OneContentLayer) {
SkPaint green_paint;
green_paint.setColor(SkColorSetARGB(255, 0, 255, 0));
client.add_draw_rect(gfx::RectF(bounds), green_paint);
- scoped_refptr<PictureLayer> root = PictureLayer::Create(&client);
+ scoped_refptr<PictureLayer> root =
+ PictureLayer::Create(layer_settings(), &client);
root->SetBounds(bounds);
root->SetIsDrawable(true);
diff --git a/chromium/cc/trees/layer_tree_host_pixeltest_tiles.cc b/chromium/cc/trees/layer_tree_host_pixeltest_tiles.cc
new file mode 100644
index 00000000000..7a0af81f4e4
--- /dev/null
+++ b/chromium/cc/trees/layer_tree_host_pixeltest_tiles.cc
@@ -0,0 +1,214 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/layers/content_layer_client.h"
+#include "cc/layers/picture_layer.h"
+#include "cc/output/copy_output_request.h"
+#include "cc/playback/display_item_list.h"
+#include "cc/playback/drawing_display_item.h"
+#include "cc/test/layer_tree_pixel_test.h"
+#include "cc/test/test_gpu_memory_buffer_manager.h"
+#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/core/SkPictureRecorder.h"
+
+#if !defined(OS_ANDROID)
+
+namespace cc {
+namespace {
+
+enum RasterMode {
+ PARTIAL_ONE_COPY,
+ FULL_ONE_COPY,
+ GPU,
+ BITMAP,
+};
+
+class LayerTreeHostTilesPixelTest : public LayerTreePixelTest {
+ protected:
+ void InitializeSettings(LayerTreeSettings* settings) override {
+ LayerTreePixelTest::InitializeSettings(settings);
+ settings->use_display_lists = true;
+ switch (raster_mode_) {
+ case PARTIAL_ONE_COPY:
+ settings->use_one_copy = true;
+ settings->use_zero_copy = false;
+ settings->use_persistent_map_for_gpu_memory_buffers = true;
+ break;
+ case FULL_ONE_COPY:
+ settings->use_one_copy = true;
+ settings->use_zero_copy = false;
+ settings->use_persistent_map_for_gpu_memory_buffers = false;
+ break;
+ case BITMAP:
+ // This is done via context creation. No settings to change here!
+ break;
+ case GPU:
+ settings->gpu_rasterization_enabled = true;
+ settings->gpu_rasterization_forced = true;
+ break;
+ }
+ }
+
+ void BeginTest() override {
+ // Don't set up a readback target at the start of the test.
+ PostSetNeedsCommitToMainThread();
+ }
+
+ void DoReadback() {
+ Layer* target =
+ readback_target_ ? readback_target_ : layer_tree_host()->root_layer();
+ target->RequestCopyOfOutput(CreateCopyOutputRequest());
+ }
+
+ void RunRasterPixelTest(bool threaded,
+ RasterMode mode,
+ scoped_refptr<Layer> content_root,
+ base::FilePath file_name) {
+ raster_mode_ = mode;
+
+ PixelTestType test_type = PIXEL_TEST_SOFTWARE;
+ switch (mode) {
+ case PARTIAL_ONE_COPY:
+ case FULL_ONE_COPY:
+ case GPU:
+ test_type = PIXEL_TEST_GL;
+ break;
+ case BITMAP:
+ test_type = PIXEL_TEST_SOFTWARE;
+ }
+
+ if (threaded)
+ RunPixelTest(test_type, content_root, file_name);
+ else
+ RunSingleThreadedPixelTest(test_type, content_root, file_name);
+ }
+
+ base::FilePath ref_file_;
+ scoped_ptr<SkBitmap> result_bitmap_;
+ RasterMode raster_mode_;
+};
+
+class BlueYellowClient : public ContentLayerClient {
+ public:
+ explicit BlueYellowClient(const gfx::Size& size)
+ : size_(size), blue_top_(true) {}
+
+ void PaintContents(SkCanvas* canvas,
+ const gfx::Rect& clip,
+ PaintingControlSetting painting_status) override {}
+
+ scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
+ const gfx::Rect& clip,
+ PaintingControlSetting painting_status) override {
+ bool use_cached_picture = false;
+ scoped_refptr<DisplayItemList> display_list =
+ DisplayItemList::Create(clip, use_cached_picture);
+
+ SkPictureRecorder recorder;
+ skia::RefPtr<SkCanvas> canvas = skia::SharePtr(
+ recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(size_))));
+ gfx::Rect top(0, 0, size_.width(), size_.height() / 2);
+ gfx::Rect bottom(0, size_.height() / 2, size_.width(), size_.height() / 2);
+
+ gfx::Rect blue_rect = blue_top_ ? top : bottom;
+ gfx::Rect yellow_rect = blue_top_ ? bottom : top;
+
+ SkPaint paint;
+ paint.setStyle(SkPaint::kFill_Style);
+
+ paint.setColor(SK_ColorBLUE);
+ canvas->drawRect(gfx::RectToSkRect(blue_rect), paint);
+ paint.setColor(SK_ColorYELLOW);
+ canvas->drawRect(gfx::RectToSkRect(yellow_rect), paint);
+
+ skia::RefPtr<SkPicture> picture =
+ skia::AdoptRef(recorder.endRecordingAsPicture());
+
+ auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>();
+ item->SetNew(picture.Pass());
+
+ display_list->Finalize();
+ return display_list;
+ }
+
+ bool FillsBoundsCompletely() const override { return true; }
+
+ void set_blue_top(bool b) { blue_top_ = b; }
+
+ private:
+ gfx::Size size_;
+ bool blue_top_;
+};
+
+class LayerTreeHostTilesTestPartialInvalidation
+ : public LayerTreeHostTilesPixelTest {
+ public:
+ LayerTreeHostTilesTestPartialInvalidation()
+ : client_(gfx::Size(200, 200)),
+ picture_layer_(PictureLayer::Create(layer_settings(), &client_)) {
+ picture_layer_->SetBounds(gfx::Size(200, 200));
+ picture_layer_->SetIsDrawable(true);
+ }
+
+ void DidCommitAndDrawFrame() override {
+ switch (layer_tree_host()->source_frame_number()) {
+ case 1:
+ // We have done one frame, so the layer's content has been rastered.
+ // Now we change the picture behind it to record something completely
+ // different, but we give a smaller invalidation rect. The layer should
+ // only re-raster the stuff in the rect. If it doesn't do partial raster
+ // it would re-raster the whole thing instead.
+ client_.set_blue_top(false);
+ picture_layer_->SetNeedsDisplayRect(gfx::Rect(50, 50, 100, 100));
+
+ // Add a copy request to see what happened!
+ DoReadback();
+ break;
+ }
+ }
+
+ protected:
+ BlueYellowClient client_;
+ scoped_refptr<PictureLayer> picture_layer_;
+};
+
+TEST_F(LayerTreeHostTilesTestPartialInvalidation,
+ PartialRaster_SingleThread_OneCopy) {
+ RunRasterPixelTest(
+ false, PARTIAL_ONE_COPY, picture_layer_,
+ base::FilePath(FILE_PATH_LITERAL("blue_yellow_partial_flipped.png")));
+}
+
+TEST_F(LayerTreeHostTilesTestPartialInvalidation,
+ FullRaster_SingleThread_OneCopy) {
+ RunRasterPixelTest(
+ false, FULL_ONE_COPY, picture_layer_,
+ base::FilePath(FILE_PATH_LITERAL("blue_yellow_flipped.png")));
+}
+
+TEST_F(LayerTreeHostTilesTestPartialInvalidation,
+ FullRaster_MultiThread_OneCopy) {
+ RunRasterPixelTest(
+ true, FULL_ONE_COPY, picture_layer_,
+ base::FilePath(FILE_PATH_LITERAL("blue_yellow_flipped.png")));
+}
+
+TEST_F(LayerTreeHostTilesTestPartialInvalidation,
+ PartialRaster_SingleThread_Software) {
+ RunRasterPixelTest(
+ false, BITMAP, picture_layer_,
+ base::FilePath(FILE_PATH_LITERAL("blue_yellow_partial_flipped.png")));
+}
+
+TEST_F(LayerTreeHostTilesTestPartialInvalidation,
+ PartialRaster_SingleThread_GpuRaster) {
+ RunRasterPixelTest(
+ false, GPU, picture_layer_,
+ base::FilePath(FILE_PATH_LITERAL("blue_yellow_partial_flipped.png")));
+}
+
+} // namespace
+} // namespace cc
+
+#endif // !defined(OS_ANDROID)
diff --git a/chromium/cc/trees/layer_tree_host_unittest.cc b/chromium/cc/trees/layer_tree_host_unittest.cc
index 98ac5a11d6e..6d9c9c67199 100644
--- a/chromium/cc/trees/layer_tree_host_unittest.cc
+++ b/chromium/cc/trees/layer_tree_host_unittest.cc
@@ -13,7 +13,6 @@
#include "base/thread_task_runner_handle.h"
#include "cc/animation/timing_function.h"
#include "cc/debug/frame_rate_counter.h"
-#include "cc/layers/content_layer.h"
#include "cc/layers/content_layer_client.h"
#include "cc/layers/io_surface_layer.h"
#include "cc/layers/layer_impl.h"
@@ -31,12 +30,7 @@
#include "cc/quads/io_surface_draw_quad.h"
#include "cc/quads/render_pass_draw_quad.h"
#include "cc/quads/tile_draw_quad.h"
-#include "cc/resources/prioritized_resource.h"
-#include "cc/resources/prioritized_resource_manager.h"
-#include "cc/resources/resource_update_queue.h"
-#include "cc/test/fake_content_layer.h"
#include "cc/test/fake_content_layer_client.h"
-#include "cc/test/fake_content_layer_impl.h"
#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_painted_scrollbar_layer.h"
@@ -47,7 +41,6 @@
#include "cc/test/fake_scoped_ui_resource.h"
#include "cc/test/fake_video_frame_provider.h"
#include "cc/test/geometry_test_utils.h"
-#include "cc/test/impl_side_painting_settings.h"
#include "cc/test/layer_tree_test.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_web_graphics_context_3d.h"
@@ -61,7 +54,6 @@
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
#include "third_party/skia/include/core/SkPicture.h"
-#include "ui/gfx/frame_time.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
@@ -74,28 +66,15 @@ using testing::Mock;
namespace cc {
namespace {
-class LayerTreeHostTest : public LayerTreeTest {
- public:
- LayerTreeHostTest() : contents_texture_manager_(nullptr) {}
-
- void DidInitializeOutputSurface() override {
- contents_texture_manager_ = layer_tree_host()->contents_texture_manager();
- }
-
- protected:
- PrioritizedResourceManager* contents_texture_manager_;
-};
+class LayerTreeHostTest : public LayerTreeTest {};
class LayerTreeHostTestHasImplThreadTest : public LayerTreeHostTest {
public:
LayerTreeHostTestHasImplThreadTest() : threaded_(false) {}
- void RunTest(bool threaded,
- bool delegating_renderer,
- bool impl_side_painting) override {
+ void RunTest(bool threaded, bool delegating_renderer) override {
threaded_ = threaded;
- LayerTreeHostTest::RunTest(threaded, delegating_renderer,
- impl_side_painting);
+ LayerTreeHostTest::RunTest(threaded, delegating_renderer);
}
void BeginTest() override {
@@ -109,7 +88,7 @@ class LayerTreeHostTestHasImplThreadTest : public LayerTreeHostTest {
bool threaded_;
};
-SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestHasImplThreadTest);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestHasImplThreadTest);
class LayerTreeHostTestSetNeedsCommitInsideLayout : public LayerTreeHostTest {
protected:
@@ -128,8 +107,7 @@ class LayerTreeHostTestSetNeedsCommitInsideLayout : public LayerTreeHostTest {
void AfterTest() override {}
};
-SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(
- LayerTreeHostTestSetNeedsCommitInsideLayout);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommitInsideLayout);
class LayerTreeHostTestSetNeedsUpdateInsideLayout : public LayerTreeHostTest {
protected:
@@ -148,8 +126,7 @@ class LayerTreeHostTestSetNeedsUpdateInsideLayout : public LayerTreeHostTest {
void AfterTest() override {}
};
-SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(
- LayerTreeHostTestSetNeedsUpdateInsideLayout);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsUpdateInsideLayout);
// Test if the LTHI receives ReadyToActivate notifications from the TileManager
// when no raster tasks get scheduled.
@@ -193,7 +170,7 @@ class LayerTreeHostTestReadyToActivateEmpty : public LayerTreeHostTest {
size_t required_for_activation_count_;
};
-SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestReadyToActivateEmpty);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestReadyToActivateEmpty);
// Test if the LTHI receives ReadyToActivate notifications from the TileManager
// when some raster tasks flagged as REQUIRED_FOR_ACTIVATION got scheduled.
@@ -203,7 +180,7 @@ class LayerTreeHostTestReadyToActivateNonEmpty
void SetupTree() override {
client_.set_fill_with_nonsolid_color(true);
scoped_refptr<FakePictureLayer> root_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
root_layer->SetBounds(gfx::Size(1024, 1024));
root_layer->SetIsDrawable(true);
@@ -223,7 +200,7 @@ class LayerTreeHostTestReadyToActivateNonEmpty
// Multi-thread only because in single thread the commit goes directly to the
// active tree, so notify ready to activate is skipped.
-MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestReadyToActivateNonEmpty);
+MULTI_THREAD_TEST_F(LayerTreeHostTestReadyToActivateNonEmpty);
// Test if the LTHI receives ReadyToDraw notifications from the TileManager when
// no raster tasks get scheduled.
@@ -263,7 +240,7 @@ class LayerTreeHostTestReadyToDrawEmpty : public LayerTreeHostTest {
size_t required_for_draw_count_;
};
-SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestReadyToDrawEmpty);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestReadyToDrawEmpty);
// Test if the LTHI receives ReadyToDraw notifications from the TileManager when
// some raster tasks flagged as REQUIRED_FOR_DRAW got scheduled.
@@ -273,7 +250,7 @@ class LayerTreeHostTestReadyToDrawNonEmpty
void SetupTree() override {
client_.set_fill_with_nonsolid_color(true);
scoped_refptr<FakePictureLayer> root_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
root_layer->SetBounds(gfx::Size(1024, 1024));
root_layer->SetIsDrawable(true);
@@ -293,7 +270,104 @@ class LayerTreeHostTestReadyToDrawNonEmpty
// Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in
// single threaded mode.
-SINGLE_THREAD_IMPL_TEST_F(LayerTreeHostTestReadyToDrawNonEmpty);
+SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawNonEmpty);
+
+class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest {
+ public:
+ scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
+ auto output_surface = make_scoped_ptr(new testing::StrictMock<
+ MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface>(
+ delegating_renderer()));
+
+ // At init, we expect one call to set visibility to true.
+ testing::Expectation visibility_true =
+ EXPECT_CALL(*output_surface,
+ SetWorkerContextShouldAggressivelyFreeResources(false))
+ .Times(1);
+
+ // After running, we should get exactly one call to
+ // FreeWorkerContextGpuResources.
+ EXPECT_CALL(*output_surface,
+ SetWorkerContextShouldAggressivelyFreeResources(true))
+ .After(visibility_true)
+ .WillOnce(testing::Invoke([this](bool is_visible) { EndTest(); }));
+ return output_surface.Pass();
+ }
+
+ void InitializeSettings(LayerTreeSettings* settings) override {
+ settings->gpu_rasterization_enabled = true;
+ settings->gpu_rasterization_forced = true;
+ }
+
+ void BeginTest() override {
+ // Logic is handled in InitializedRendererOnThread to ensure that our
+ // LTHI is fully set up.
+ }
+
+ void AfterTest() override {
+ // Expectations handled via mock.
+ }
+
+ private:
+ class MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface
+ : public FakeOutputSurface {
+ public:
+ ~MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface() {}
+ explicit MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface(
+ bool delegated_rendering)
+ : FakeOutputSurface(TestContextProvider::Create(),
+ TestContextProvider::Create(),
+ delegated_rendering) {}
+ MOCK_METHOD1(SetWorkerContextShouldAggressivelyFreeResources,
+ void(bool is_visible));
+ };
+};
+
+// Test if the LTH successfully frees resources on the worker context when
+// visibility is set to false.
+class LayerTreeHostFreeWorkerContextResourcesOnInvisible
+ : public LayerTreeHostFreeWorkerContextResourcesTest {
+ public:
+ void InitializedRendererOnThread(LayerTreeHostImpl* host_impl,
+ bool success) override {
+ PostSetVisibleToMainThread(false);
+ }
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostFreeWorkerContextResourcesOnInvisible);
+
+// Test if the LTH successfully frees resources on the worker context when
+// hard memory limit is set to zero.
+class LayerTreeHostFreeWorkerContextResourcesOnZeroMemoryLimit
+ : public LayerTreeHostFreeWorkerContextResourcesTest {
+ public:
+ void InitializedRendererOnThread(LayerTreeHostImpl* host_impl,
+ bool success) override {
+ ManagedMemoryPolicy zero_policy(
+ 0, gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING, 0);
+ host_impl->SetMemoryPolicy(zero_policy);
+ }
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostFreeWorkerContextResourcesOnZeroMemoryLimit);
+
+// Test if the LTH successfully frees resources on the worker context when
+// hard memory limit is set to zero while using a synchronous compositor (like
+// Android WebView).
+class LayerTreeHostFreeWorkerContextResourcesOnZeroMemoryLimitSynchronous
+ : public LayerTreeHostFreeWorkerContextResourcesOnZeroMemoryLimit {
+ public:
+ void InitializeSettings(LayerTreeSettings* settings) override {
+ LayerTreeHostFreeWorkerContextResourcesTest::InitializeSettings(settings);
+ settings->use_external_begin_frame_source = true;
+ settings->using_synchronous_renderer_compositor = true;
+ }
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostFreeWorkerContextResourcesOnZeroMemoryLimitSynchronous);
// Two setNeedsCommits in a row should lead to at least 1 commit and at least 1
// draw with frame 0.
@@ -368,7 +442,7 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit2);
class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest {
protected:
void SetupTree() override {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->CreateRenderSurface();
root->SetBounds(gfx::Size(10, 10));
layer_tree_host()->SetRootLayer(root);
@@ -502,10 +576,7 @@ class LayerTreeHostTestSetNeedsRedrawRect : public LayerTreeHostTest {
: num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {}
void BeginTest() override {
- if (layer_tree_host()->settings().impl_side_painting)
- root_layer_ = FakePictureLayer::Create(&client_);
- else
- root_layer_ = ContentLayer::Create(&client_);
+ root_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
root_layer_->SetIsDrawable(true);
root_layer_->SetBounds(bounds_);
layer_tree_host()->SetRootLayer(root_layer_);
@@ -549,7 +620,7 @@ class LayerTreeHostTestSetNeedsRedrawRect : public LayerTreeHostTest {
const gfx::Size bounds_;
const gfx::Rect invalid_rect_;
FakeContentLayerClient client_;
- scoped_refptr<Layer> root_layer_;
+ scoped_refptr<FakePictureLayer> root_layer_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedrawRect);
@@ -563,7 +634,7 @@ class LayerTreeHostTestGpuRasterDeviceSizeChanged : public LayerTreeHostTest {
void BeginTest() override {
client_.set_fill_with_nonsolid_color(true);
- root_layer_ = FakePictureLayer::Create(&client_);
+ root_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
root_layer_->SetIsDrawable(true);
gfx::Transform transform;
// Translate the layer out of the viewport to force it to not update its
@@ -631,8 +702,7 @@ class LayerTreeHostTestGpuRasterDeviceSizeChanged : public LayerTreeHostTest {
scoped_refptr<FakePictureLayer> root_layer_;
};
-SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(
- LayerTreeHostTestGpuRasterDeviceSizeChanged);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterDeviceSizeChanged);
class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest {
public:
@@ -641,14 +711,11 @@ class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest {
}
void SetupTree() override {
- root_layer_ = Layer::Create();
+ root_layer_ = Layer::Create(layer_settings());
root_layer_->SetBounds(gfx::Size(10, 20));
root_layer_->CreateRenderSurface();
- if (layer_tree_host()->settings().impl_side_painting)
- scaled_layer_ = FakePictureLayer::Create(&client_);
- else
- scaled_layer_ = FakeContentLayer::Create(&client_);
+ scaled_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
scaled_layer_->SetBounds(gfx::Size(1, 1));
root_layer_->AddChild(scaled_layer_);
@@ -695,14 +762,14 @@ class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate
}
void SetupTree() override {
- root_layer_ = Layer::Create();
+ root_layer_ = Layer::Create(layer_settings());
root_layer_->SetBounds(gfx::Size(10, 20));
root_layer_->CreateRenderSurface();
bool paint_scrollbar = true;
bool has_thumb = false;
scrollbar_ = FakePaintedScrollbarLayer::Create(
- paint_scrollbar, has_thumb, root_layer_->id());
+ layer_settings(), paint_scrollbar, has_thumb, root_layer_->id());
scrollbar_->SetPosition(gfx::Point(0, 10));
scrollbar_->SetBounds(gfx::Size(10, 10));
@@ -752,10 +819,7 @@ class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest {
: num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {}
void BeginTest() override {
- if (layer_tree_host()->settings().impl_side_painting)
- root_layer_ = FakePictureLayer::Create(&client_);
- else
- root_layer_ = ContentLayer::Create(&client_);
+ root_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
root_layer_->SetIsDrawable(true);
root_layer_->SetBounds(bounds_);
layer_tree_host()->SetRootLayer(root_layer_);
@@ -764,7 +828,7 @@ class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest {
}
void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
- if (num_draws_ == 3 && host_impl->settings().impl_side_painting)
+ if (num_draws_ == 3)
host_impl->SetNeedsRedrawRect(invalid_rect_);
}
@@ -810,10 +874,7 @@ class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest {
// Should force full frame damage on the next commit
PostSetNextCommitForcesRedrawToMainThread();
PostSetNeedsCommitToMainThread();
- if (host_impl->settings().impl_side_painting)
- host_impl->BlockNotifyReadyToActivateForTesting(true);
- else
- num_draws_++;
+ host_impl->BlockNotifyReadyToActivateForTesting(true);
break;
case 3:
host_impl->BlockNotifyReadyToActivateForTesting(false);
@@ -832,18 +893,16 @@ class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest {
const gfx::Size bounds_;
const gfx::Rect invalid_rect_;
FakeContentLayerClient client_;
- scoped_refptr<Layer> root_layer_;
+ scoped_refptr<FakePictureLayer> root_layer_;
};
-SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F(
- LayerTreeHostTestSetNextCommitForcesRedraw);
+// This test blocks activation which is not supported for single thread mode.
+MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostTestSetNextCommitForcesRedraw);
// Tests that if a layer is not drawn because of some reason in the parent then
// its damage is preserved until the next time it is drawn.
class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest {
public:
- LayerTreeHostTestUndrawnLayersDamageLater() {}
-
void InitializeSettings(LayerTreeSettings* settings) override {
// If we don't set the minimum contents scale, it's harder to verify whether
// the damage we get is correct. For other scale amounts, please see
@@ -852,28 +911,19 @@ class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest {
}
void SetupTree() override {
- if (layer_tree_host()->settings().impl_side_painting)
- root_layer_ = FakePictureLayer::Create(&client_);
- else
- root_layer_ = ContentLayer::Create(&client_);
+ root_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
root_layer_->SetIsDrawable(true);
root_layer_->SetBounds(gfx::Size(50, 50));
layer_tree_host()->SetRootLayer(root_layer_);
// The initially transparent layer has a larger child layer, which is
// not initially drawn because of the this (parent) layer.
- if (layer_tree_host()->settings().impl_side_painting)
- parent_layer_ = FakePictureLayer::Create(&client_);
- else
- parent_layer_ = FakeContentLayer::Create(&client_);
+ parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
parent_layer_->SetBounds(gfx::Size(15, 15));
parent_layer_->SetOpacity(0.0f);
root_layer_->AddChild(parent_layer_);
- if (layer_tree_host()->settings().impl_side_painting)
- child_layer_ = FakePictureLayer::Create(&client_);
- else
- child_layer_ = FakeContentLayer::Create(&client_);
+ child_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
child_layer_->SetBounds(gfx::Size(25, 25));
parent_layer_->AddChild(child_layer_);
@@ -938,9 +988,9 @@ class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest {
private:
FakeContentLayerClient client_;
- scoped_refptr<Layer> root_layer_;
- scoped_refptr<Layer> parent_layer_;
- scoped_refptr<Layer> child_layer_;
+ scoped_refptr<FakePictureLayer> root_layer_;
+ scoped_refptr<FakePictureLayer> parent_layer_;
+ scoped_refptr<FakePictureLayer> child_layer_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater);
@@ -955,17 +1005,16 @@ class LayerTreeHostTestDamageWithScale : public LayerTreeHostTest {
client_.set_fill_with_nonsolid_color(true);
scoped_ptr<FakePicturePile> pile(
- new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale,
- ImplSidePaintingSettings().default_tile_grid_size));
- root_layer_ =
- FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass());
+ new FakePicturePile(LayerTreeSettings().minimum_contents_scale,
+ LayerTreeSettings().default_tile_grid_size));
+ root_layer_ = FakePictureLayer::CreateWithRecordingSource(
+ layer_settings(), &client_, pile.Pass());
root_layer_->SetBounds(gfx::Size(50, 50));
- pile.reset(
- new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale,
- ImplSidePaintingSettings().default_tile_grid_size));
- child_layer_ =
- FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass());
+ pile.reset(new FakePicturePile(LayerTreeSettings().minimum_contents_scale,
+ LayerTreeSettings().default_tile_grid_size));
+ child_layer_ = FakePictureLayer::CreateWithRecordingSource(
+ layer_settings(), &client_, pile.Pass());
child_layer_->SetBounds(gfx::Size(25, 25));
child_layer_->SetIsDrawable(true);
child_layer_->SetContentsOpaque(true);
@@ -1051,79 +1100,7 @@ class LayerTreeHostTestDamageWithScale : public LayerTreeHostTest {
scoped_refptr<Layer> child_layer_;
};
-MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestDamageWithScale);
-
-// Tests that if a layer is not drawn because of some reason in the parent,
-// causing its content bounds to not be computed, then when it is later drawn,
-// its content bounds get pushed.
-class LayerTreeHostTestUndrawnLayersPushContentBoundsLater
- : public LayerTreeHostTest {
- public:
- LayerTreeHostTestUndrawnLayersPushContentBoundsLater()
- : root_layer_(Layer::Create()) {}
-
- void SetupTree() override {
- root_layer_->CreateRenderSurface();
- root_layer_->SetIsDrawable(true);
- root_layer_->SetBounds(gfx::Size(20, 20));
- layer_tree_host()->SetRootLayer(root_layer_);
-
- parent_layer_ = Layer::Create();
- parent_layer_->SetBounds(gfx::Size(20, 20));
- parent_layer_->SetOpacity(0.0f);
- root_layer_->AddChild(parent_layer_);
-
- child_layer_ = Layer::Create();
- child_layer_->SetBounds(gfx::Size(15, 15));
- parent_layer_->AddChild(child_layer_);
-
- LayerTreeHostTest::SetupTree();
- }
-
- void BeginTest() override { PostSetNeedsCommitToMainThread(); }
-
- void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
- LayerImpl* root = host_impl->active_tree()->root_layer();
- LayerImpl* parent = root->children()[0];
- LayerImpl* child = parent->children()[0];
-
- switch (host_impl->active_tree()->source_frame_number()) {
- case 0:
- EXPECT_EQ(0.f, parent->opacity());
- EXPECT_EQ(gfx::SizeF(), child->content_bounds());
- break;
- case 1:
- EXPECT_EQ(1.f, parent->opacity());
- EXPECT_EQ(gfx::SizeF(15.f, 15.f), child->content_bounds());
- EndTest();
- break;
- default:
- NOTREACHED();
- }
- }
-
- void DidCommit() override {
- switch (layer_tree_host()->source_frame_number()) {
- case 1:
- parent_layer_->SetOpacity(1.0f);
- break;
- case 2:
- break;
- default:
- NOTREACHED();
- }
- }
-
- void AfterTest() override {}
-
- private:
- scoped_refptr<Layer> root_layer_;
- scoped_refptr<Layer> parent_layer_;
- scoped_refptr<Layer> child_layer_;
-};
-
-SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(
- LayerTreeHostTestUndrawnLayersPushContentBoundsLater);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDamageWithScale);
// This test verifies that properties on the layer tree host are commited
// to the impl side.
@@ -1168,8 +1145,7 @@ class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
void BeginCommitOnThread(LayerTreeHostImpl* impl) override {
EXPECT_EQ(frame_count_with_pending_tree_, 0);
- if (impl->settings().impl_side_painting)
- impl->BlockNotifyReadyToActivateForTesting(true);
+ impl->BlockNotifyReadyToActivateForTesting(true);
}
void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl,
@@ -1180,27 +1156,21 @@ class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
if (frame_count_with_pending_tree_ == 1) {
EXPECT_EQ(first_frame_time_.ToInternalValue(), 0);
first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time;
- } else if (frame_count_with_pending_tree_ == 2 &&
- impl->settings().impl_side_painting) {
+ } else if (frame_count_with_pending_tree_ == 2) {
impl->BlockNotifyReadyToActivateForTesting(false);
}
}
void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
- if (frame_count_with_pending_tree_ > 1) {
- EXPECT_NE(first_frame_time_.ToInternalValue(), 0);
- EXPECT_NE(first_frame_time_.ToInternalValue(),
- impl->CurrentBeginFrameArgs().frame_time.ToInternalValue());
- EndTest();
- return;
- }
-
- EXPECT_FALSE(impl->settings().impl_side_painting);
+ EXPECT_GT(frame_count_with_pending_tree_, 1);
+ EXPECT_NE(first_frame_time_.ToInternalValue(), 0);
+ EXPECT_NE(first_frame_time_.ToInternalValue(),
+ impl->CurrentBeginFrameArgs().frame_time.ToInternalValue());
EndTest();
}
+
void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
- if (impl->settings().impl_side_painting)
- EXPECT_NE(frame_count_with_pending_tree_, 1);
+ EXPECT_GT(frame_count_with_pending_tree_, 1);
}
void AfterTest() override {}
@@ -1210,7 +1180,8 @@ class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
base::TimeTicks first_frame_time_;
};
-SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F(
+// This test blocks activation which is not supported for single thread mode.
+MULTI_THREAD_BLOCKNOTIFY_TEST_F(
LayerTreeHostTestFrameTimeUpdatesAfterActivationFails);
// This test verifies that LayerTreeHostImpl's current frame time gets
@@ -1234,7 +1205,7 @@ class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest {
// Since we might use a low-resolution clock on Windows, we need to
// make sure that the clock has incremented past first_frame_time_.
- while (first_frame_time_ == gfx::FrameTime::Now()) {
+ while (first_frame_time_ == base::TimeTicks::Now()) {
}
return;
@@ -1271,7 +1242,8 @@ class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest {
void SetupTree() override {
LayerTreeHostTest::SetupTree();
- scoped_refptr<FakePictureLayer> layer = FakePictureLayer::Create(&client_);
+ scoped_refptr<FakePictureLayer> layer =
+ FakePictureLayer::Create(layer_settings(), &client_);
layer->set_always_update_resources(true);
scroll_layer_ = layer;
@@ -1291,7 +1263,9 @@ class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest {
void BeginTest() override { PostSetNeedsCommitToMainThread(); }
- void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
+ void ApplyViewportDeltas(const gfx::Vector2dF& scroll_delta,
+ const gfx::Vector2dF&,
+ const gfx::Vector2dF& elastic_overscroll_delta,
float scale,
float) override {
gfx::ScrollOffset offset = scroll_layer_->scroll_offset();
@@ -1335,7 +1309,8 @@ class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest {
scoped_refptr<Layer> scroll_layer_;
};
-MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestStartPageScaleAnimation);
+// Single thread proxy does not support impl-side page scale changes.
+MULTI_THREAD_TEST_F(LayerTreeHostTestStartPageScaleAnimation);
class LayerTreeHostTestSetVisible : public LayerTreeHostTest {
public:
@@ -1377,11 +1352,11 @@ class TestOpacityChangeLayerDelegate : public ContentLayerClient {
if (test_layer_)
test_layer_->SetOpacity(0.f);
}
- void PaintContentsToDisplayList(
- DisplayItemList* display_list,
+ scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
const gfx::Rect& clip,
PaintingControlSetting picture_control) override {
NOTIMPLEMENTED();
+ return nullptr;
}
bool FillsBoundsCompletely() const override { return false; }
@@ -1389,78 +1364,34 @@ class TestOpacityChangeLayerDelegate : public ContentLayerClient {
Layer* test_layer_;
};
-class ContentLayerWithUpdateTracking : public ContentLayer {
- public:
- static scoped_refptr<ContentLayerWithUpdateTracking> Create(
- ContentLayerClient* client) {
- return make_scoped_refptr(new ContentLayerWithUpdateTracking(client));
- }
-
- int PaintContentsCount() { return paint_contents_count_; }
- void ResetPaintContentsCount() { paint_contents_count_ = 0; }
-
- bool Update(ResourceUpdateQueue* queue,
- const OcclusionTracker<Layer>* occlusion) override {
- bool updated = ContentLayer::Update(queue, occlusion);
- paint_contents_count_++;
- return updated;
- }
-
- private:
- explicit ContentLayerWithUpdateTracking(ContentLayerClient* client)
- : ContentLayer(client), paint_contents_count_(0) {
- SetBounds(gfx::Size(10, 10));
- SetIsDrawable(true);
- }
- ~ContentLayerWithUpdateTracking() override {}
-
- int paint_contents_count_;
-};
-
// Layer opacity change during paint should not prevent compositor resources
// from being updated during commit.
class LayerTreeHostTestOpacityChange : public LayerTreeHostTest {
public:
LayerTreeHostTestOpacityChange() : test_opacity_change_delegate_() {}
- void BeginTest() override {
- if (layer_tree_host()->settings().impl_side_painting) {
- update_check_picture_layer_ =
- FakePictureLayer::Create(&test_opacity_change_delegate_);
- test_opacity_change_delegate_.SetTestLayer(
- update_check_picture_layer_.get());
- is_impl_paint_ = true;
- } else {
- update_check_content_layer_ = ContentLayerWithUpdateTracking::Create(
- &test_opacity_change_delegate_);
- test_opacity_change_delegate_.SetTestLayer(
- update_check_content_layer_.get());
- is_impl_paint_ = false;
- }
- layer_tree_host()->SetViewportSize(gfx::Size(10, 10));
- if (layer_tree_host()->settings().impl_side_painting)
- layer_tree_host()->root_layer()->AddChild(update_check_picture_layer_);
- else
- layer_tree_host()->root_layer()->AddChild(update_check_content_layer_);
+ void SetupTree() override {
+ LayerTreeHostTest::SetupTree();
- PostSetNeedsCommitToMainThread();
+ update_check_picture_layer_ = FakePictureLayer::Create(
+ layer_settings(), &test_opacity_change_delegate_);
+ test_opacity_change_delegate_.SetTestLayer(
+ update_check_picture_layer_.get());
+ layer_tree_host()->root_layer()->AddChild(update_check_picture_layer_);
}
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { EndTest(); }
void AfterTest() override {
// Update() should have been called once.
- if (is_impl_paint_)
- EXPECT_EQ(1u, update_check_picture_layer_->update_count());
- else
- EXPECT_EQ(1, update_check_content_layer_->PaintContentsCount());
+ EXPECT_EQ(1, update_check_picture_layer_->update_count());
}
private:
TestOpacityChangeLayerDelegate test_opacity_change_delegate_;
- scoped_refptr<ContentLayerWithUpdateTracking> update_check_content_layer_;
scoped_refptr<FakePictureLayer> update_check_picture_layer_;
- bool is_impl_paint_;
};
MULTI_THREAD_TEST_F(LayerTreeHostTestOpacityChange);
@@ -1470,15 +1401,10 @@ class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers
public:
LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() {}
- void InitializeSettings(LayerTreeSettings* settings) override {
- // PictureLayer can only be used with impl side painting enabled.
- settings->impl_side_painting = true;
- }
-
void BeginTest() override {
client_.set_fill_with_nonsolid_color(true);
- root_layer_ = FakePictureLayer::Create(&client_);
- child_layer_ = FakePictureLayer::Create(&client_);
+ root_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
+ child_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
layer_tree_host()->SetViewportSize(gfx::Size(60, 60));
layer_tree_host()->SetDeviceScaleFactor(1.5);
@@ -1573,666 +1499,6 @@ class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers
MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers);
-// TODO(sohanjg) : Remove it once impl-side painting ships everywhere.
-// Verify atomicity of commits and reuse of textures.
-class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest {
- public:
- void InitializeSettings(LayerTreeSettings* settings) override {
- settings->renderer_settings.texture_id_allocation_chunk_size = 1;
- // Make sure partial texture updates are turned off.
- settings->max_partial_texture_updates = 0;
- // Linear fade animator prevents scrollbars from drawing immediately.
- settings->scrollbar_animator = LayerTreeSettings::NO_ANIMATOR;
- }
-
- void SetupTree() override {
- layer_ = FakeContentLayer::Create(&client_);
- layer_->SetBounds(gfx::Size(10, 20));
-
- bool paint_scrollbar = true;
- bool has_thumb = false;
- scrollbar_ = FakePaintedScrollbarLayer::Create(
- paint_scrollbar, has_thumb, layer_->id());
- scrollbar_->SetPosition(gfx::Point(0, 10));
- scrollbar_->SetBounds(gfx::Size(10, 10));
-
- layer_->AddChild(scrollbar_);
-
- layer_tree_host()->SetRootLayer(layer_);
- LayerTreeHostTest::SetupTree();
- }
-
- void BeginTest() override {
- drew_frame_ = -1;
- PostSetNeedsCommitToMainThread();
- }
-
- void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
- ASSERT_EQ(0u, impl->settings().max_partial_texture_updates);
-
- TestWebGraphicsContext3D* context = TestContext();
-
- switch (impl->active_tree()->source_frame_number()) {
- case 0:
- // Number of textures should be one for each layer
- ASSERT_EQ(2u, context->NumTextures());
- // Number of textures used for commit should be one for each layer.
- EXPECT_EQ(2u, context->NumUsedTextures());
- // Verify that used texture is correct.
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(0)));
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(1)));
-
- context->ResetUsedTextures();
- break;
- case 1:
- // Number of textures should be one for scrollbar layer since it was
- // requested and deleted on the impl-thread, and double for the content
- // layer since its first texture is used by impl thread and cannot by
- // used for update.
- ASSERT_EQ(3u, context->NumTextures());
- // Number of textures used for commit should be one for each layer.
- EXPECT_EQ(2u, context->NumUsedTextures());
- // First textures should not have been used.
- EXPECT_FALSE(context->UsedTexture(context->TextureAt(0)));
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(1)));
- // New textures should have been used.
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(2)));
- context->ResetUsedTextures();
- break;
- case 2:
- EndTest();
- break;
- default:
- NOTREACHED();
- break;
- }
- }
-
- void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
- TestWebGraphicsContext3D* context = TestContext();
-
- if (drew_frame_ == impl->active_tree()->source_frame_number()) {
- EXPECT_EQ(0u, context->NumUsedTextures()) << "For frame " << drew_frame_;
- return;
- }
- drew_frame_ = impl->active_tree()->source_frame_number();
-
- // We draw/ship one texture each frame for each layer.
- EXPECT_EQ(2u, context->NumUsedTextures());
- context->ResetUsedTextures();
-
- if (!TestEnded())
- PostSetNeedsCommitToMainThread();
- }
-
- void Layout() override {
- layer_->SetNeedsDisplay();
- scrollbar_->SetNeedsDisplay();
- }
-
- void AfterTest() override {}
-
- protected:
- FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> layer_;
- scoped_refptr<FakePaintedScrollbarLayer> scrollbar_;
- int drew_frame_;
-};
-
-MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F(
- LayerTreeHostTestDirectRendererAtomicCommit);
-
-// TODO(sohanjg) : Remove it once impl-side painting ships everywhere.
-class LayerTreeHostTestDelegatingRendererAtomicCommit
- : public LayerTreeHostTestDirectRendererAtomicCommit {
- public:
- void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
- ASSERT_EQ(0u, impl->settings().max_partial_texture_updates);
-
- TestWebGraphicsContext3D* context = TestContext();
-
- switch (impl->active_tree()->source_frame_number()) {
- case 0:
- // Number of textures should be one for each layer
- ASSERT_EQ(2u, context->NumTextures());
- // Number of textures used for commit should be one for each layer.
- EXPECT_EQ(2u, context->NumUsedTextures());
- // Verify that used texture is correct.
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(0)));
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(1)));
- break;
- case 1:
- // Number of textures should be doubled as the first context layer
- // texture is being used by the impl-thread and cannot be used for
- // update. The scrollbar behavior is different direct renderer because
- // UI resource deletion with delegating renderer occurs after tree
- // activation.
- ASSERT_EQ(4u, context->NumTextures());
- // Number of textures used for commit should still be
- // one for each layer.
- EXPECT_EQ(2u, context->NumUsedTextures());
- // First textures should not have been used.
- EXPECT_FALSE(context->UsedTexture(context->TextureAt(0)));
- EXPECT_FALSE(context->UsedTexture(context->TextureAt(1)));
- // New textures should have been used.
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(2)));
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(3)));
- break;
- case 2:
- EndTest();
- break;
- default:
- NOTREACHED();
- break;
- }
- }
-};
-
-MULTI_THREAD_DELEGATING_RENDERER_NOIMPL_TEST_F(
- LayerTreeHostTestDelegatingRendererAtomicCommit);
-
-static void SetLayerPropertiesForTesting(Layer* layer,
- Layer* parent,
- const gfx::Transform& transform,
- const gfx::Point3F& transform_origin,
- const gfx::PointF& position,
- const gfx::Size& bounds,
- bool opaque) {
- layer->RemoveAllChildren();
- if (parent)
- parent->AddChild(layer);
- layer->SetTransform(transform);
- layer->SetTransformOrigin(transform_origin);
- layer->SetPosition(position);
- layer->SetBounds(bounds);
- layer->SetContentsOpaque(opaque);
-}
-
-// TODO(sohanjg) : Remove it once impl-side painting ships everywhere.
-class LayerTreeHostTestAtomicCommitWithPartialUpdate
- : public LayerTreeHostTest {
- public:
- void InitializeSettings(LayerTreeSettings* settings) override {
- settings->renderer_settings.texture_id_allocation_chunk_size = 1;
- // Allow one partial texture update.
- settings->max_partial_texture_updates = 1;
- // No partial updates when impl side painting is enabled.
- settings->impl_side_painting = false;
- }
-
- void SetupTree() override {
- parent_ = FakeContentLayer::Create(&client_);
- parent_->SetBounds(gfx::Size(10, 20));
-
- child_ = FakeContentLayer::Create(&client_);
- child_->SetPosition(gfx::Point(0, 10));
- child_->SetBounds(gfx::Size(3, 10));
-
- parent_->AddChild(child_);
-
- layer_tree_host()->SetRootLayer(parent_);
- LayerTreeHostTest::SetupTree();
- }
-
- void BeginTest() override { PostSetNeedsCommitToMainThread(); }
-
- void DidCommitAndDrawFrame() override {
- switch (layer_tree_host()->source_frame_number()) {
- case 1:
- parent_->SetNeedsDisplay();
- child_->SetNeedsDisplay();
- break;
- case 2:
- // Damage part of layers.
- parent_->SetNeedsDisplayRect(gfx::Rect(5, 5));
- child_->SetNeedsDisplayRect(gfx::Rect(5, 5));
- break;
- case 3:
- child_->SetNeedsDisplay();
- layer_tree_host()->SetViewportSize(gfx::Size(10, 10));
- break;
- case 4:
- layer_tree_host()->SetViewportSize(gfx::Size(10, 20));
- break;
- case 5:
- EndTest();
- break;
- default:
- NOTREACHED() << layer_tree_host()->source_frame_number();
- break;
- }
- }
-
- void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
- ASSERT_EQ(1u, impl->settings().max_partial_texture_updates);
-
- TestWebGraphicsContext3D* context = TestContext();
-
- switch (impl->active_tree()->source_frame_number()) {
- case 0:
- // Number of textures should be one for each layer.
- ASSERT_EQ(2u, context->NumTextures());
- // Number of textures used for commit should be one for each layer.
- EXPECT_EQ(2u, context->NumUsedTextures());
- // Verify that used textures are correct.
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(0)));
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(1)));
- context->ResetUsedTextures();
- break;
- case 1:
- if (HasImplThread()) {
- // Number of textures should be two for each content layer.
- ASSERT_EQ(4u, context->NumTextures());
- } else {
- // In single thread we can always do partial updates, so the limit has
- // no effect.
- ASSERT_EQ(2u, context->NumTextures());
- }
- // Number of textures used for commit should be one for each content
- // layer.
- EXPECT_EQ(2u, context->NumUsedTextures());
-
- if (HasImplThread()) {
- // First content textures should not have been used.
- EXPECT_FALSE(context->UsedTexture(context->TextureAt(0)));
- EXPECT_FALSE(context->UsedTexture(context->TextureAt(1)));
- // New textures should have been used.
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(2)));
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(3)));
- } else {
- // In single thread we can always do partial updates, so the limit has
- // no effect.
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(0)));
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(1)));
- }
-
- context->ResetUsedTextures();
- break;
- case 2:
- if (HasImplThread()) {
- // Number of textures should be two for each content layer.
- ASSERT_EQ(4u, context->NumTextures());
- } else {
- // In single thread we can always do partial updates, so the limit has
- // no effect.
- ASSERT_EQ(2u, context->NumTextures());
- }
- // Number of textures used for commit should be one for each content
- // layer.
- EXPECT_EQ(2u, context->NumUsedTextures());
-
- if (HasImplThread()) {
- // One content layer does a partial update also.
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(2)));
- EXPECT_FALSE(context->UsedTexture(context->TextureAt(3)));
- } else {
- // In single thread we can always do partial updates, so the limit has
- // no effect.
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(0)));
- EXPECT_TRUE(context->UsedTexture(context->TextureAt(1)));
- }
-
- context->ResetUsedTextures();
- break;
- case 3:
- // No textures should be used for commit.
- EXPECT_EQ(0u, context->NumUsedTextures());
-
- context->ResetUsedTextures();
- break;
- case 4:
- // Number of textures used for commit should be one, for the
- // content layer.
- EXPECT_EQ(1u, context->NumUsedTextures());
-
- context->ResetUsedTextures();
- break;
- default:
- NOTREACHED();
- break;
- }
- }
-
- void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
- EXPECT_LT(impl->active_tree()->source_frame_number(), 5);
-
- TestWebGraphicsContext3D* context = TestContext();
-
- // Number of textures used for drawing should one per layer except for
- // frame 3 where the viewport only contains one layer.
- if (impl->active_tree()->source_frame_number() == 3) {
- EXPECT_EQ(1u, context->NumUsedTextures());
- } else {
- EXPECT_EQ(2u, context->NumUsedTextures())
- << "For frame " << impl->active_tree()->source_frame_number();
- }
-
- context->ResetUsedTextures();
- }
-
- void AfterTest() override {}
-
- private:
- FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> parent_;
- scoped_refptr<FakeContentLayer> child_;
-};
-
-// Partial updates are not possible with a delegating renderer.
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
- LayerTreeHostTestAtomicCommitWithPartialUpdate);
-
-// TODO(sohanjg) : Make it work with impl-side painting.
-class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit
- : public LayerTreeHostTest {
- protected:
- void SetupTree() override {
- root_layer_ = FakeContentLayer::Create(&client_);
- root_layer_->SetBounds(gfx::Size(100, 100));
-
- surface_layer1_ = FakeContentLayer::Create(&client_);
- surface_layer1_->SetBounds(gfx::Size(100, 100));
- surface_layer1_->SetForceRenderSurface(true);
- surface_layer1_->SetOpacity(0.5f);
- root_layer_->AddChild(surface_layer1_);
-
- surface_layer2_ = FakeContentLayer::Create(&client_);
- surface_layer2_->SetBounds(gfx::Size(100, 100));
- surface_layer2_->SetForceRenderSurface(true);
- surface_layer2_->SetOpacity(0.5f);
- surface_layer1_->AddChild(surface_layer2_);
-
- replica_layer1_ = FakeContentLayer::Create(&client_);
- surface_layer1_->SetReplicaLayer(replica_layer1_.get());
-
- replica_layer2_ = FakeContentLayer::Create(&client_);
- surface_layer2_->SetReplicaLayer(replica_layer2_.get());
-
- layer_tree_host()->SetRootLayer(root_layer_);
- LayerTreeHostTest::SetupTree();
- }
-
- void BeginTest() override { PostSetNeedsCommitToMainThread(); }
-
- void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
- Renderer* renderer = host_impl->renderer();
- RenderPassId surface1_render_pass_id = host_impl->active_tree()
- ->root_layer()
- ->children()[0]
- ->render_surface()
- ->GetRenderPassId();
- RenderPassId surface2_render_pass_id = host_impl->active_tree()
- ->root_layer()
- ->children()[0]
- ->children()[0]
- ->render_surface()
- ->GetRenderPassId();
-
- switch (host_impl->active_tree()->source_frame_number()) {
- case 0:
- EXPECT_TRUE(
- renderer->HasAllocatedResourcesForTesting(surface1_render_pass_id));
- EXPECT_TRUE(
- renderer->HasAllocatedResourcesForTesting(surface2_render_pass_id));
-
- // Reduce the memory limit to only fit the root layer and one render
- // surface. This prevents any contents drawing into surfaces
- // from being allocated.
- host_impl->SetMemoryPolicy(ManagedMemoryPolicy(100 * 100 * 4 * 2));
- break;
- case 1:
- EXPECT_FALSE(
- renderer->HasAllocatedResourcesForTesting(surface1_render_pass_id));
- EXPECT_FALSE(
- renderer->HasAllocatedResourcesForTesting(surface2_render_pass_id));
-
- EndTest();
- break;
- }
- }
-
- void DidCommitAndDrawFrame() override {
- if (layer_tree_host()->source_frame_number() < 2)
- root_layer_->SetNeedsDisplay();
- }
-
- void AfterTest() override {
- EXPECT_LE(2u, root_layer_->update_count());
- EXPECT_LE(2u, surface_layer1_->update_count());
- EXPECT_LE(2u, surface_layer2_->update_count());
- }
-
- FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> root_layer_;
- scoped_refptr<FakeContentLayer> surface_layer1_;
- scoped_refptr<FakeContentLayer> replica_layer1_;
- scoped_refptr<FakeContentLayer> surface_layer2_;
- scoped_refptr<FakeContentLayer> replica_layer2_;
-};
-
-// Surfaces don't exist with a delegated renderer.
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F(
- LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit);
-
-class EvictionTestLayer : public Layer {
- public:
- static scoped_refptr<EvictionTestLayer> Create() {
- return make_scoped_refptr(new EvictionTestLayer());
- }
-
- bool Update(ResourceUpdateQueue*, const OcclusionTracker<Layer>*) override;
- bool DrawsContent() const override { return true; }
-
- scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
- void PushPropertiesTo(LayerImpl* impl) override;
- void SetTexturePriorities(const PriorityCalculator&) override;
-
- bool HaveBackingTexture() const {
- return texture_.get() ? texture_->have_backing_texture() : false;
- }
-
- private:
- EvictionTestLayer() : Layer() {}
- ~EvictionTestLayer() override {}
-
- void CreateTextureIfNeeded() {
- if (texture_)
- return;
- texture_ = PrioritizedResource::Create(
- layer_tree_host()->contents_texture_manager());
- texture_->SetDimensions(gfx::Size(10, 10), RGBA_8888);
- bitmap_.allocN32Pixels(10, 10);
- }
-
- scoped_ptr<PrioritizedResource> texture_;
- SkBitmap bitmap_;
-};
-
-class EvictionTestLayerImpl : public LayerImpl {
- public:
- static scoped_ptr<EvictionTestLayerImpl> Create(LayerTreeImpl* tree_impl,
- int id) {
- return make_scoped_ptr(new EvictionTestLayerImpl(tree_impl, id));
- }
- ~EvictionTestLayerImpl() override {}
-
- void AppendQuads(RenderPass* render_pass,
- AppendQuadsData* append_quads_data) override {
- ASSERT_TRUE(has_texture_);
- ASSERT_NE(0u, layer_tree_impl()->resource_provider()->num_resources());
- }
-
- void SetHasTexture(bool has_texture) { has_texture_ = has_texture; }
-
- private:
- EvictionTestLayerImpl(LayerTreeImpl* tree_impl, int id)
- : LayerImpl(tree_impl, id), has_texture_(false) {}
-
- bool has_texture_;
-};
-
-void EvictionTestLayer::SetTexturePriorities(const PriorityCalculator&) {
- CreateTextureIfNeeded();
- if (!texture_)
- return;
- texture_->set_request_priority(PriorityCalculator::UIPriority(true));
-}
-
-bool EvictionTestLayer::Update(ResourceUpdateQueue* queue,
- const OcclusionTracker<Layer>* occlusion) {
- CreateTextureIfNeeded();
- if (!texture_)
- return false;
-
- gfx::Rect full_rect(0, 0, 10, 10);
- ResourceUpdate upload = ResourceUpdate::Create(
- texture_.get(), &bitmap_, full_rect, full_rect, gfx::Vector2d());
- queue->AppendFullUpload(upload);
- return true;
-}
-
-scoped_ptr<LayerImpl> EvictionTestLayer::CreateLayerImpl(
- LayerTreeImpl* tree_impl) {
- return EvictionTestLayerImpl::Create(tree_impl, layer_id_);
-}
-
-void EvictionTestLayer::PushPropertiesTo(LayerImpl* layer_impl) {
- Layer::PushPropertiesTo(layer_impl);
-
- EvictionTestLayerImpl* test_layer_impl =
- static_cast<EvictionTestLayerImpl*>(layer_impl);
- test_layer_impl->SetHasTexture(texture_->have_backing_texture());
-}
-
-class LayerTreeHostTestEvictTextures : public LayerTreeHostTest {
- public:
- LayerTreeHostTestEvictTextures()
- : layer_(EvictionTestLayer::Create()),
- impl_for_evict_textures_(0),
- num_commits_(0) {}
-
- void BeginTest() override {
- layer_tree_host()->SetRootLayer(layer_);
- layer_tree_host()->SetViewportSize(gfx::Size(10, 20));
-
- gfx::Transform identity_matrix;
- SetLayerPropertiesForTesting(layer_.get(),
- 0,
- identity_matrix,
- gfx::Point3F(0.f, 0.f, 0.f),
- gfx::PointF(0.f, 0.f),
- gfx::Size(10, 20),
- true);
-
- PostSetNeedsCommitToMainThread();
- }
-
- void PostEvictTextures() {
- ImplThreadTaskRunner()->PostTask(
- FROM_HERE,
- base::Bind(&LayerTreeHostTestEvictTextures::EvictTexturesOnImplThread,
- base::Unretained(this)));
- }
-
- void EvictTexturesOnImplThread() {
- DCHECK(impl_for_evict_textures_);
- impl_for_evict_textures_->EvictTexturesForTesting();
- }
-
- // Commit 1: Just commit and draw normally, then post an eviction at the end
- // that will trigger a commit.
- // Commit 2: Triggered by the eviction, let it go through and then set
- // needsCommit.
- // Commit 3: Triggered by the setNeedsCommit. In Layout(), post an eviction
- // task, which will be handled before the commit. Don't set needsCommit, it
- // should have been posted. A frame should not be drawn (note,
- // didCommitAndDrawFrame may be called anyway).
- // Commit 4: Triggered by the eviction, let it go through and then set
- // needsCommit.
- // Commit 5: Triggered by the setNeedsCommit, post an eviction task in
- // Layout(), a frame should not be drawn but a commit will be posted.
- // Commit 6: Triggered by the eviction, post an eviction task in
- // Layout(), which will be a noop, letting the commit (which recreates the
- // textures) go through and draw a frame, then end the test.
- //
- // Commits 1+2 test the eviction recovery path where eviction happens outside
- // of the beginFrame/commit pair.
- // Commits 3+4 test the eviction recovery path where eviction happens inside
- // the beginFrame/commit pair.
- // Commits 5+6 test the path where an eviction happens during the eviction
- // recovery path.
- void DidCommit() override {
- switch (num_commits_) {
- case 1:
- EXPECT_TRUE(layer_->HaveBackingTexture());
- PostEvictTextures();
- break;
- case 2:
- EXPECT_TRUE(layer_->HaveBackingTexture());
- layer_tree_host()->SetNeedsCommit();
- break;
- case 3:
- break;
- case 4:
- EXPECT_TRUE(layer_->HaveBackingTexture());
- layer_tree_host()->SetNeedsCommit();
- break;
- case 5:
- break;
- case 6:
- EXPECT_TRUE(layer_->HaveBackingTexture());
- EndTest();
- break;
- default:
- NOTREACHED();
- break;
- }
- }
-
- void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
- impl_for_evict_textures_ = impl;
- }
-
- void Layout() override {
- ++num_commits_;
- switch (num_commits_) {
- case 1:
- case 2:
- break;
- case 3:
- PostEvictTextures();
- break;
- case 4:
- // We couldn't check in didCommitAndDrawFrame on commit 3,
- // so check here.
- EXPECT_FALSE(layer_->HaveBackingTexture());
- break;
- case 5:
- PostEvictTextures();
- break;
- case 6:
- // We couldn't check in didCommitAndDrawFrame on commit 5,
- // so check here.
- EXPECT_FALSE(layer_->HaveBackingTexture());
- PostEvictTextures();
- break;
- default:
- NOTREACHED();
- break;
- }
- }
-
- void AfterTest() override {}
-
- private:
- FakeContentLayerClient client_;
- scoped_refptr<EvictionTestLayer> layer_;
- LayerTreeHostImpl* impl_for_evict_textures_;
- int num_commits_;
-};
-
-MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestEvictTextures);
-
class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest {
public:
LayerTreeHostTestContinuousInvalidate()
@@ -2242,11 +1508,7 @@ class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest {
layer_tree_host()->SetViewportSize(gfx::Size(10, 10));
layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10));
- if (layer_tree_host()->settings().impl_side_painting)
- layer_ = FakePictureLayer::Create(&client_);
- else
- layer_ = FakeContentLayer::Create(&client_);
-
+ layer_ = FakePictureLayer::Create(layer_settings(), &client_);
layer_->SetBounds(gfx::Size(10, 10));
layer_->SetPosition(gfx::PointF(0.f, 0.f));
layer_->SetIsDrawable(true);
@@ -2364,6 +1626,8 @@ class LayerTreeHostTestCompositeImmediatelyStateTransitions
void InitializeSettings(LayerTreeSettings* settings) override {
settings->single_thread_proxy_scheduler = false;
+ settings->use_zero_copy = true;
+ settings->use_one_copy = false;
}
void BeginTest() override {
@@ -2414,263 +1678,13 @@ class LayerTreeHostTestCompositeImmediatelyStateTransitions
SINGLE_THREAD_TEST_F(LayerTreeHostTestCompositeImmediatelyStateTransitions);
-class LayerTreeHostWithProxy : public LayerTreeHost {
- public:
- LayerTreeHostWithProxy(FakeLayerTreeHostClient* client,
- scoped_ptr<FakeProxy> proxy,
- LayerTreeHost::InitParams* params)
- : LayerTreeHost(params) {
- proxy->SetLayerTreeHost(this);
- client->SetLayerTreeHost(this);
- InitializeForTesting(proxy.Pass());
- }
-};
-
-TEST(LayerTreeHostTest, LimitPartialUpdates) {
- // When partial updates are not allowed, max updates should be 0.
- {
- FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
-
- scoped_ptr<FakeProxy> proxy(new FakeProxy);
- proxy->GetRendererCapabilities().allow_partial_texture_updates = false;
- proxy->SetMaxPartialTextureUpdates(5);
-
- LayerTreeSettings settings;
- settings.impl_side_painting = false;
- settings.max_partial_texture_updates = 10;
-
- LayerTreeHost::InitParams params;
- params.client = &client;
- params.settings = &settings;
- LayerTreeHostWithProxy host(&client, proxy.Pass(), &params);
-
- EXPECT_EQ(0u, host.MaxPartialTextureUpdates());
- }
-
- // When partial updates are allowed,
- // max updates should be limited by the proxy.
- {
- FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
-
- scoped_ptr<FakeProxy> proxy(new FakeProxy);
- proxy->GetRendererCapabilities().allow_partial_texture_updates = true;
- proxy->SetMaxPartialTextureUpdates(5);
-
- LayerTreeSettings settings;
- settings.impl_side_painting = false;
- settings.max_partial_texture_updates = 10;
-
- LayerTreeHost::InitParams params;
- params.client = &client;
- params.settings = &settings;
- LayerTreeHostWithProxy host(&client, proxy.Pass(), &params);
-
- EXPECT_EQ(5u, host.MaxPartialTextureUpdates());
- }
-
- // When partial updates are allowed,
- // max updates should also be limited by the settings.
- {
- FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
-
- scoped_ptr<FakeProxy> proxy(new FakeProxy);
- proxy->GetRendererCapabilities().allow_partial_texture_updates = true;
- proxy->SetMaxPartialTextureUpdates(20);
-
- LayerTreeSettings settings;
- settings.impl_side_painting = false;
- settings.max_partial_texture_updates = 10;
-
- LayerTreeHost::InitParams params;
- params.client = &client;
- params.settings = &settings;
- LayerTreeHostWithProxy host(&client, proxy.Pass(), &params);
-
- EXPECT_EQ(10u, host.MaxPartialTextureUpdates());
- }
-}
-
-TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) {
- FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
-
- LayerTreeSettings settings;
- settings.max_partial_texture_updates = 4;
- settings.single_thread_proxy_scheduler = false;
- settings.impl_side_painting = false;
-
- scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
- new TestSharedBitmapManager());
- LayerTreeHost::InitParams params;
- params.client = &client;
- params.shared_bitmap_manager = shared_bitmap_manager.get();
- params.settings = &settings;
- params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
- scoped_ptr<LayerTreeHost> host =
- LayerTreeHost::CreateSingleThreaded(&client, &params);
- client.SetLayerTreeHost(host.get());
- host->Composite(base::TimeTicks::Now());
-
- EXPECT_EQ(4u, host->settings().max_partial_texture_updates);
-}
-
-TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) {
- FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE);
-
- LayerTreeSettings settings;
- settings.max_partial_texture_updates = 4;
- settings.single_thread_proxy_scheduler = false;
- settings.impl_side_painting = false;
-
- scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
- new TestSharedBitmapManager());
- LayerTreeHost::InitParams params;
- params.client = &client;
- params.shared_bitmap_manager = shared_bitmap_manager.get();
- params.settings = &settings;
- params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
- scoped_ptr<LayerTreeHost> host =
- LayerTreeHost::CreateSingleThreaded(&client, &params);
- client.SetLayerTreeHost(host.get());
- host->Composite(base::TimeTicks::Now());
-
- EXPECT_EQ(4u, host->settings().max_partial_texture_updates);
-}
-
-TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) {
- FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D);
-
- LayerTreeSettings settings;
- settings.max_partial_texture_updates = 4;
- settings.single_thread_proxy_scheduler = false;
- settings.impl_side_painting = false;
-
- scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
- new TestSharedBitmapManager());
- LayerTreeHost::InitParams params;
- params.client = &client;
- params.shared_bitmap_manager = shared_bitmap_manager.get();
- params.settings = &settings;
- params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
- scoped_ptr<LayerTreeHost> host =
- LayerTreeHost::CreateSingleThreaded(&client, &params);
- client.SetLayerTreeHost(host.get());
- host->Composite(base::TimeTicks::Now());
-
- EXPECT_EQ(0u, host->MaxPartialTextureUpdates());
-}
-
-TEST(LayerTreeHostTest,
- PartialUpdatesWithDelegatingRendererAndSoftwareContent) {
- FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE);
-
- LayerTreeSettings settings;
- settings.max_partial_texture_updates = 4;
- settings.single_thread_proxy_scheduler = false;
- settings.impl_side_painting = false;
-
- scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
- new TestSharedBitmapManager());
- LayerTreeHost::InitParams params;
- params.client = &client;
- params.shared_bitmap_manager = shared_bitmap_manager.get();
- params.settings = &settings;
- params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
- scoped_ptr<LayerTreeHost> host =
- LayerTreeHost::CreateSingleThreaded(&client, &params);
- client.SetLayerTreeHost(host.get());
- host->Composite(base::TimeTicks::Now());
-
- EXPECT_EQ(0u, host->MaxPartialTextureUpdates());
-}
-
-// TODO(sohanjg) : Remove it once impl-side painting ships everywhere.
-class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted
- : public LayerTreeHostTest {
- public:
- LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted()
- : root_layer_(FakeContentLayer::Create(&client_)),
- child_layer1_(FakeContentLayer::Create(&client_)),
- child_layer2_(FakeContentLayer::Create(&client_)),
- num_commits_(0) {}
-
- void BeginTest() override {
- layer_tree_host()->SetViewportSize(gfx::Size(100, 100));
- root_layer_->SetBounds(gfx::Size(100, 100));
- child_layer1_->SetBounds(gfx::Size(100, 100));
- child_layer2_->SetBounds(gfx::Size(100, 100));
- root_layer_->AddChild(child_layer1_);
- root_layer_->AddChild(child_layer2_);
- layer_tree_host()->SetRootLayer(root_layer_);
- PostSetNeedsCommitToMainThread();
- }
-
- void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl,
- bool visible) override {
- if (visible) {
- // One backing should remain unevicted.
- EXPECT_EQ(100u * 100u * 4u * 1u,
- contents_texture_manager_->MemoryUseBytes());
- } else {
- EXPECT_EQ(0u, contents_texture_manager_->MemoryUseBytes());
- }
-
- // Make sure that contents textures are marked as having been
- // purged.
- EXPECT_TRUE(host_impl->active_tree()->ContentsTexturesPurged());
- // End the test in this state.
- EndTest();
- }
-
- void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
- ++num_commits_;
- switch (num_commits_) {
- case 1:
- // All three backings should have memory.
- EXPECT_EQ(100u * 100u * 4u * 3u,
- contents_texture_manager_->MemoryUseBytes());
-
- // Set a new policy that will kick out 1 of the 3 resources.
- // Because a resource was evicted, a commit will be kicked off.
- host_impl->SetMemoryPolicy(
- ManagedMemoryPolicy(100 * 100 * 4 * 2,
- gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING,
- 1000));
- break;
- case 2:
- // Only two backings should have memory.
- EXPECT_EQ(100u * 100u * 4u * 2u,
- contents_texture_manager_->MemoryUseBytes());
- // Become backgrounded, which will cause 1 more resource to be
- // evicted.
- PostSetVisibleToMainThread(false);
- break;
- default:
- // No further commits should happen because this is not visible
- // anymore.
- NOTREACHED();
- break;
- }
- }
-
- void AfterTest() override {}
-
- private:
- FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> root_layer_;
- scoped_refptr<FakeContentLayer> child_layer1_;
- scoped_refptr<FakeContentLayer> child_layer2_;
- int num_commits_;
-};
-
-SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(
- LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted);
-
class LayerTreeHostTestLCDChange : public LayerTreeHostTest {
public:
void SetupTree() override {
num_tiles_rastered_ = 0;
- scoped_refptr<Layer> root_layer = PictureLayer::Create(&client_);
+ scoped_refptr<Layer> root_layer =
+ PictureLayer::Create(layer_settings(), &client_);
client_.set_fill_with_nonsolid_color(true);
root_layer->SetIsDrawable(true);
root_layer->SetBounds(gfx::Size(10, 10));
@@ -2751,7 +1765,7 @@ class LayerTreeHostTestLCDChange : public LayerTreeHostTest {
int num_tiles_rastered_;
};
-SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestLCDChange);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDChange);
// Verify that the BeginFrame notification is used to initiate rendering.
class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest {
@@ -2886,7 +1900,7 @@ class LayerTreeHostTestAbortedCommitDoesntStallDisabledVsync
: public LayerTreeHostTestAbortedCommitDoesntStall {
void InitializeSettings(LayerTreeSettings* settings) override {
LayerTreeHostTestAbortedCommitDoesntStall::InitializeSettings(settings);
- settings->throttle_frame_production = false;
+ settings->renderer_settings.disable_gpu_vsync = true;
}
};
@@ -2895,14 +1909,11 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestAbortedCommitDoesntStallDisabledVsync);
class LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation
: public LayerTreeHostTest {
protected:
- void InitializeSettings(LayerTreeSettings* settings) override {
- settings->impl_side_painting = true;
- }
-
void SetupTree() override {
LayerTreeHostTest::SetupTree();
- scoped_refptr<Layer> layer = PictureLayer::Create(&client_);
+ scoped_refptr<Layer> layer =
+ PictureLayer::Create(layer_settings(), &client_);
layer->SetTransform(gfx::Transform(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
layer->SetBounds(gfx::Size(10, 10));
layer_tree_host()->root_layer()->AddChild(layer);
@@ -2919,7 +1930,7 @@ class LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation
FakeContentLayerClient client_;
};
-MULTI_THREAD_TEST_F(
+SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation);
class LayerTreeHostTestChangeLayerPropertiesInPaintContents
@@ -2937,11 +1948,11 @@ class LayerTreeHostTestChangeLayerPropertiesInPaintContents
layer_->SetBounds(gfx::Size(2, 2));
}
- void PaintContentsToDisplayList(
- DisplayItemList* display_list,
+ scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
const gfx::Rect& clip,
PaintingControlSetting picture_control) override {
NOTIMPLEMENTED();
+ return nullptr;
}
bool FillsBoundsCompletely() const override { return false; }
@@ -2953,19 +1964,13 @@ class LayerTreeHostTestChangeLayerPropertiesInPaintContents
LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {}
void SetupTree() override {
- if (layer_tree_host()->settings().impl_side_painting) {
- scoped_refptr<PictureLayer> root_layer = PictureLayer::Create(&client_);
- layer_tree_host()->SetRootLayer(root_layer);
- } else {
- scoped_refptr<ContentLayer> root_layer = ContentLayer::Create(&client_);
- layer_tree_host()->SetRootLayer(root_layer);
- }
- Layer* root_layer = layer_tree_host()->root_layer();
+ scoped_refptr<PictureLayer> root_layer =
+ PictureLayer::Create(layer_settings(), &client_);
root_layer->SetIsDrawable(true);
root_layer->SetBounds(gfx::Size(1, 1));
+ client_.set_layer(root_layer.get());
- client_.set_layer(root_layer);
-
+ layer_tree_host()->SetRootLayer(root_layer);
LayerTreeHostTest::SetupTree();
}
@@ -3041,7 +2046,8 @@ class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest {
io_surface_id_ = 9;
io_surface_size_ = gfx::Size(6, 7);
- scoped_refptr<IOSurfaceLayer> io_surface_layer = IOSurfaceLayer::Create();
+ scoped_refptr<IOSurfaceLayer> io_surface_layer =
+ IOSurfaceLayer::Create(layer_settings());
io_surface_layer->SetBounds(gfx::Size(10, 10));
io_surface_layer->SetIsDrawable(true);
io_surface_layer->SetContentsOpaque(true);
@@ -3102,10 +2108,10 @@ class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest {
const IOSurfaceDrawQuad* io_surface_draw_quad =
IOSurfaceDrawQuad::MaterialCast(quad);
EXPECT_EQ(io_surface_size_, io_surface_draw_quad->io_surface_size);
- EXPECT_NE(0u, io_surface_draw_quad->io_surface_resource_id);
+ EXPECT_NE(0u, io_surface_draw_quad->io_surface_resource_id());
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_RECTANGLE_ARB),
resource_provider->TargetForTesting(
- io_surface_draw_quad->io_surface_resource_id));
+ io_surface_draw_quad->io_surface_resource_id()));
if (delegating_renderer()) {
// The io surface layer's resource should be sent to the parent.
@@ -3182,28 +2188,21 @@ class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest {
int frame_;
};
-// Flaky on all platforms: http://crbug.com/327498
-TEST_F(LayerTreeHostTestNumFramesPending, DISABLED_DelegatingRenderer) {
- RunTest(true, true, true);
-}
-
-TEST_F(LayerTreeHostTestNumFramesPending, DISABLED_GLRenderer) {
- RunTest(true, false, true);
-}
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNumFramesPending);
class LayerTreeHostTestResourcelessSoftwareDraw : public LayerTreeHostTest {
public:
void SetupTree() override {
- root_layer_ = FakePictureLayer::Create(&client_);
+ root_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
root_layer_->SetIsDrawable(true);
root_layer_->SetBounds(gfx::Size(50, 50));
- parent_layer_ = FakePictureLayer::Create(&client_);
+ parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
parent_layer_->SetIsDrawable(true);
parent_layer_->SetBounds(gfx::Size(50, 50));
parent_layer_->SetForceRenderSurface(true);
- child_layer_ = FakePictureLayer::Create(&client_);
+ child_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
child_layer_->SetIsDrawable(true);
child_layer_->SetBounds(gfx::Size(50, 50));
@@ -3280,7 +2279,7 @@ class LayerTreeHostTestResourcelessSoftwareDraw : public LayerTreeHostTest {
int swap_count_;
};
-MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestResourcelessSoftwareDraw);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestResourcelessSoftwareDraw);
// Test for UI Resource management.
class LayerTreeHostTestUIResource : public LayerTreeHostTest {
@@ -3325,7 +2324,7 @@ class LayerTreeHostTestUIResource : public LayerTreeHostTest {
}
}
- void PerformTest(LayerTreeHostImpl* impl) {
+ void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
TestWebGraphicsContext3D* context = TestContext();
int frame = impl->active_tree()->source_frame_number();
@@ -3354,16 +2353,6 @@ class LayerTreeHostTestUIResource : public LayerTreeHostTest {
}
}
- void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
- if (!impl->settings().impl_side_painting)
- PerformTest(impl);
- }
-
- void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
- if (impl->settings().impl_side_painting)
- PerformTest(impl);
- }
-
void AfterTest() override {}
private:
@@ -3420,8 +2409,9 @@ class PushPropertiesCountingLayerImpl : public LayerImpl {
class PushPropertiesCountingLayer : public Layer {
public:
- static scoped_refptr<PushPropertiesCountingLayer> Create() {
- return new PushPropertiesCountingLayer();
+ static scoped_refptr<PushPropertiesCountingLayer> Create(
+ const LayerSettings& settings) {
+ return new PushPropertiesCountingLayer(settings);
}
void PushPropertiesTo(LayerImpl* layer) override {
@@ -3448,8 +2438,10 @@ class PushPropertiesCountingLayer : public Layer {
}
private:
- PushPropertiesCountingLayer()
- : push_properties_count_(0), persist_needs_push_properties_(false) {
+ explicit PushPropertiesCountingLayer(const LayerSettings& settings)
+ : Layer(settings),
+ push_properties_count_(0),
+ persist_needs_push_properties_(false) {
SetBounds(gfx::Size(1, 1));
}
~PushPropertiesCountingLayer() override {}
@@ -3472,12 +2464,13 @@ class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest {
}
void SetupTree() override {
- root_ = PushPropertiesCountingLayer::Create();
+ root_ = PushPropertiesCountingLayer::Create(layer_settings());
root_->CreateRenderSurface();
- child_ = PushPropertiesCountingLayer::Create();
- child2_ = PushPropertiesCountingLayer::Create();
- grandchild_ = PushPropertiesCountingLayer::Create();
- leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create();
+ child_ = PushPropertiesCountingLayer::Create(layer_settings());
+ child2_ = PushPropertiesCountingLayer::Create(layer_settings());
+ grandchild_ = PushPropertiesCountingLayer::Create(layer_settings());
+ leaf_always_pushing_layer_ =
+ PushPropertiesCountingLayer::Create(layer_settings());
leaf_always_pushing_layer_->set_persist_needs_push_properties(true);
root_->AddChild(child_);
@@ -3485,7 +2478,7 @@ class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest {
child_->AddChild(grandchild_);
child2_->AddChild(leaf_always_pushing_layer_);
- other_root_ = PushPropertiesCountingLayer::Create();
+ other_root_ = PushPropertiesCountingLayer::Create(layer_settings());
other_root_->CreateRenderSurface();
// Don't set the root layer here.
@@ -3854,9 +2847,8 @@ class LayerTreeHostTestImplLayersPushProperties
size_t expected_push_properties_grandchild2_impl_;
};
-TEST_F(LayerTreeHostTestImplLayersPushProperties, DelegatingRenderer) {
- RunTestWithImplSidePainting();
-}
+// In single thread there's no pending tree to push properties from.
+MULTI_THREAD_TEST_F(LayerTreeHostTestImplLayersPushProperties);
class LayerTreeHostTestPropertyChangesDuringUpdateArePushed
: public LayerTreeHostTest {
@@ -3864,14 +2856,14 @@ class LayerTreeHostTestPropertyChangesDuringUpdateArePushed
void BeginTest() override { PostSetNeedsCommitToMainThread(); }
void SetupTree() override {
- root_ = Layer::Create();
+ root_ = Layer::Create(layer_settings());
root_->CreateRenderSurface();
root_->SetBounds(gfx::Size(1, 1));
bool paint_scrollbar = true;
bool has_thumb = false;
scrollbar_layer_ = FakePaintedScrollbarLayer::Create(
- paint_scrollbar, has_thumb, root_->id());
+ layer_settings(), paint_scrollbar, has_thumb, root_->id());
root_->AddChild(scrollbar_layer_);
@@ -3921,9 +2913,9 @@ class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest {
void BeginTest() override { PostSetNeedsCommitToMainThread(); }
void SetupTree() override {
- root_ = PushPropertiesCountingLayer::Create();
+ root_ = PushPropertiesCountingLayer::Create(layer_settings());
root_->CreateRenderSurface();
- child_ = PushPropertiesCountingLayer::Create();
+ child_ = PushPropertiesCountingLayer::Create(layer_settings());
root_->AddChild(child_);
layer_tree_host()->SetRootLayer(root_);
@@ -3983,12 +2975,12 @@ class LayerTreeHostTestCasePushPropertiesThreeGrandChildren
}
void SetupTree() override {
- root_ = PushPropertiesCountingLayer::Create();
+ root_ = PushPropertiesCountingLayer::Create(layer_settings());
root_->CreateRenderSurface();
- child_ = PushPropertiesCountingLayer::Create();
- grandchild1_ = PushPropertiesCountingLayer::Create();
- grandchild2_ = PushPropertiesCountingLayer::Create();
- grandchild3_ = PushPropertiesCountingLayer::Create();
+ child_ = PushPropertiesCountingLayer::Create(layer_settings());
+ grandchild1_ = PushPropertiesCountingLayer::Create(layer_settings());
+ grandchild2_ = PushPropertiesCountingLayer::Create(layer_settings());
+ grandchild3_ = PushPropertiesCountingLayer::Create(layer_settings());
root_->AddChild(child_);
child_->AddChild(grandchild1_);
@@ -4388,7 +3380,6 @@ class LayerTreeHostTestTreeActivationCallback : public LayerTreeHostTest {
: num_commits_(0), callback_count_(0) {}
void BeginTest() override {
- EXPECT_TRUE(HasImplThread());
PostSetNeedsCommitToMainThread();
}
@@ -4440,13 +3431,7 @@ class LayerTreeHostTestTreeActivationCallback : public LayerTreeHostTest {
int callback_count_;
};
-TEST_F(LayerTreeHostTestTreeActivationCallback, DirectRenderer) {
- RunTest(true, false, true);
-}
-
-TEST_F(LayerTreeHostTestTreeActivationCallback, DelegatingRenderer) {
- RunTest(true, true, true);
-}
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestTreeActivationCallback);
class LayerInvalidateCausesDraw : public LayerTreeHostTest {
public:
@@ -4496,8 +3481,8 @@ class LayerTreeHostTestVideoLayerInvalidate : public LayerInvalidateCausesDraw {
public:
void SetupTree() override {
LayerTreeHostTest::SetupTree();
- scoped_refptr<VideoLayer> video_layer =
- VideoLayer::Create(&provider_, media::VIDEO_ROTATION_0);
+ scoped_refptr<VideoLayer> video_layer = VideoLayer::Create(
+ layer_settings(), &provider_, media::VIDEO_ROTATION_0);
video_layer->SetBounds(gfx::Size(10, 10));
video_layer->SetIsDrawable(true);
layer_tree_host()->root_layer()->AddChild(video_layer);
@@ -4519,7 +3504,8 @@ class LayerTreeHostTestIOSurfaceLayerInvalidate
public:
void SetupTree() override {
LayerTreeHostTest::SetupTree();
- scoped_refptr<IOSurfaceLayer> layer = IOSurfaceLayer::Create();
+ scoped_refptr<IOSurfaceLayer> layer =
+ IOSurfaceLayer::Create(layer_settings());
layer->SetBounds(gfx::Size(10, 10));
uint32_t fake_io_surface_id = 7;
layer->SetIOSurfaceProperties(fake_io_surface_id, layer->bounds());
@@ -4530,25 +3516,23 @@ class LayerTreeHostTestIOSurfaceLayerInvalidate
}
};
-// TODO(danakj): IOSurface layer can not be transported. crbug.com/239335
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
- LayerTreeHostTestIOSurfaceLayerInvalidate);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestIOSurfaceLayerInvalidate);
class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest {
protected:
void SetupTree() override {
- root_layer_ = Layer::Create();
+ root_layer_ = Layer::Create(layer_settings());
root_layer_->CreateRenderSurface();
root_layer_->SetPosition(gfx::Point());
root_layer_->SetBounds(gfx::Size(10, 10));
- parent_layer_ = SolidColorLayer::Create();
+ parent_layer_ = SolidColorLayer::Create(layer_settings());
parent_layer_->SetPosition(gfx::Point());
parent_layer_->SetBounds(gfx::Size(10, 10));
parent_layer_->SetIsDrawable(true);
root_layer_->AddChild(parent_layer_);
- child_layer_ = SolidColorLayer::Create();
+ child_layer_ = SolidColorLayer::Create(layer_settings());
child_layer_->SetPosition(gfx::Point());
child_layer_->SetBounds(gfx::Size(10, 10));
child_layer_->SetIsDrawable(true);
@@ -4603,12 +3587,8 @@ SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushHiddenLayer);
class LayerTreeHostTestUpdateLayerInEmptyViewport : public LayerTreeHostTest {
protected:
- void InitializeSettings(LayerTreeSettings* settings) override {
- settings->impl_side_painting = true;
- }
-
void SetupTree() override {
- root_layer_ = FakePictureLayer::Create(&client_);
+ root_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
root_layer_->SetBounds(gfx::Size(10, 10));
layer_tree_host()->SetRootLayer(root_layer_);
@@ -4625,7 +3605,7 @@ class LayerTreeHostTestUpdateLayerInEmptyViewport : public LayerTreeHostTest {
void DidCommit() override {
// The layer should be updated even though the viewport is empty, so we
// are capable of drawing it on the impl tree.
- EXPECT_GT(root_layer_->update_count(), 0u);
+ EXPECT_GT(root_layer_->update_count(), 0);
EndTest();
}
@@ -4637,72 +3617,10 @@ class LayerTreeHostTestUpdateLayerInEmptyViewport : public LayerTreeHostTest {
MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport);
-class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest {
- public:
- LayerTreeHostTestAbortEvictedTextures()
- : num_will_begin_main_frames_(0), num_impl_commits_(0) {}
-
- protected:
- void SetupTree() override {
- scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create();
- root_layer->SetBounds(gfx::Size(200, 200));
- root_layer->SetIsDrawable(true);
- root_layer->CreateRenderSurface();
-
- layer_tree_host()->SetRootLayer(root_layer);
- LayerTreeHostTest::SetupTree();
- }
-
- void BeginTest() override { PostSetNeedsCommitToMainThread(); }
-
- void WillBeginMainFrame() override {
- num_will_begin_main_frames_++;
- switch (num_will_begin_main_frames_) {
- case 2:
- // Send a redraw to the compositor thread. This will (wrongly) be
- // ignored unless aborting resets the texture state.
- layer_tree_host()->SetNeedsRedraw();
- break;
- }
- }
-
- void BeginCommitOnThread(LayerTreeHostImpl* impl) override {
- num_impl_commits_++;
- }
-
- void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
- switch (impl->SourceAnimationFrameNumber()) {
- case 1:
- // Prevent draws until commit.
- impl->active_tree()->SetContentsTexturesPurged();
- EXPECT_FALSE(impl->CanDraw());
- // Trigger an abortable commit.
- impl->SetNeedsCommit();
- break;
- case 2:
- EndTest();
- break;
- }
- }
-
- void AfterTest() override {
- // Ensure that the commit was truly aborted.
- EXPECT_EQ(2, num_will_begin_main_frames_);
- EXPECT_EQ(1, num_impl_commits_);
- }
-
- private:
- int num_will_begin_main_frames_;
- int num_impl_commits_;
-};
-
-// Commits can only be aborted when using the thread proxy.
-MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures);
-
class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest {
protected:
void InitializeSettings(LayerTreeSettings* settings) override {
- settings->impl_side_painting = true;
+ // Testing async uploads.
settings->use_zero_copy = false;
settings->use_one_copy = false;
}
@@ -4720,7 +3638,7 @@ class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest {
void SetupTree() override {
client_.set_fill_with_nonsolid_color(true);
scoped_refptr<FakePictureLayer> root_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
root_layer->SetBounds(gfx::Size(1024, 1024));
root_layer->SetIsDrawable(true);
@@ -4748,99 +3666,6 @@ class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest {
// Impl-side painting is a multi-threaded compositor feature.
MULTI_THREAD_TEST_F(LayerTreeHostTestMaxTransferBufferUsageBytes);
-// Test ensuring that memory limits are sent to the prioritized resource
-// manager.
-class LayerTreeHostTestMemoryLimits : public LayerTreeHostTest {
- public:
- LayerTreeHostTestMemoryLimits() : num_commits_(0) {}
-
- void BeginTest() override { PostSetNeedsCommitToMainThread(); }
-
- void WillCommit() override {
- // Some commits are aborted, so increment number of attempted commits here.
- num_commits_++;
- }
-
- void DidCommit() override {
- switch (num_commits_) {
- case 1:
- // Verify default values.
- EXPECT_EQ(PrioritizedResourceManager::DefaultMemoryAllocationLimit(),
- layer_tree_host()
- ->contents_texture_manager()
- ->MaxMemoryLimitBytes());
- EXPECT_EQ(PriorityCalculator::AllowEverythingCutoff(),
- layer_tree_host()
- ->contents_texture_manager()
- ->ExternalPriorityCutoff());
- PostSetNeedsCommitToMainThread();
- break;
- case 2:
- // The values should remain the same until the commit after the policy
- // is changed.
- EXPECT_EQ(PrioritizedResourceManager::DefaultMemoryAllocationLimit(),
- layer_tree_host()
- ->contents_texture_manager()
- ->MaxMemoryLimitBytes());
- EXPECT_EQ(PriorityCalculator::AllowEverythingCutoff(),
- layer_tree_host()
- ->contents_texture_manager()
- ->ExternalPriorityCutoff());
- break;
- case 3:
- // Verify values were correctly passed.
- EXPECT_EQ(16u * 1024u * 1024u,
- layer_tree_host()
- ->contents_texture_manager()
- ->MaxMemoryLimitBytes());
- EXPECT_EQ(PriorityCalculator::AllowVisibleAndNearbyCutoff(),
- layer_tree_host()
- ->contents_texture_manager()
- ->ExternalPriorityCutoff());
- EndTest();
- break;
- case 4:
- // Make sure no extra commits happen.
- NOTREACHED();
- break;
- }
- }
-
- void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
- switch (num_commits_) {
- case 1:
- break;
- case 2:
- // This will trigger a commit because the priority cutoff has changed.
- impl->SetMemoryPolicy(ManagedMemoryPolicy(
- 16u * 1024u * 1024u,
- gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE,
- 1000));
- break;
- case 3:
- // This will not trigger a commit because the priority cutoff has not
- // changed, and there is already enough memory for all allocations.
- impl->SetMemoryPolicy(ManagedMemoryPolicy(
- 32u * 1024u * 1024u,
- gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE,
- 1000));
- break;
- case 4:
- NOTREACHED();
- break;
- }
- }
-
- void AfterTest() override {}
-
- private:
- int num_commits_;
-};
-
-SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestMemoryLimits);
-
-} // namespace
-
class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface
: public LayerTreeHostTest {
protected:
@@ -4874,10 +3699,7 @@ class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface
}
void SetupTree() override {
- if (layer_tree_host()->settings().impl_side_painting)
- root_ = FakePictureLayer::Create(&client_);
- else
- root_ = FakeContentLayer::Create(&client_);
+ root_ = FakePictureLayer::Create(layer_settings(), &client_);
root_->SetBounds(gfx::Size(20, 20));
layer_tree_host()->SetRootLayer(root_);
LayerTreeHostTest::SetupTree();
@@ -5026,7 +3848,12 @@ class LayerTreeHostTestBreakSwapPromise : public LayerTreeHostTest {
if (commit_complete_count_ == 1) {
// This commit will be aborted because no actual update.
PostSetNeedsUpdateLayersToMainThread();
- } else {
+ }
+ }
+
+ void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
+ int frame = host_impl->active_tree()->source_frame_number();
+ if (frame == 2) {
EndTest();
}
}
@@ -5079,7 +3906,7 @@ class LayerTreeHostTestKeepSwapPromise : public LayerTreeTest {
LayerTreeHostTestKeepSwapPromise() {}
void BeginTest() override {
- layer_ = SolidColorLayer::Create();
+ layer_ = SolidColorLayer::Create(layer_settings());
layer_->SetIsDrawable(true);
layer_->SetBounds(gfx::Size(10, 10));
layer_tree_host()->SetRootLayer(layer_);
@@ -5344,10 +4171,6 @@ SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor);
class LayerTreeHostTestHighResRequiredAfterEvictingUIResources
: public LayerTreeHostTest {
protected:
- void InitializeSettings(LayerTreeSettings* settings) override {
- settings->impl_side_painting = true;
- }
-
void SetupTree() override {
LayerTreeHostTest::SetupTree();
ui_resource_ = FakeScopedUIResource::Create(layer_tree_host());
@@ -5389,8 +4212,6 @@ class LayerTreeHostTestHighResRequiredAfterEvictingUIResources
class LayerTreeHostTestGpuRasterizationDefault : public LayerTreeHostTest {
protected:
void InitializeSettings(LayerTreeSettings* settings) override {
- settings->impl_side_painting = true;
-
EXPECT_FALSE(settings->gpu_rasterization_enabled);
EXPECT_FALSE(settings->gpu_rasterization_forced);
}
@@ -5398,7 +4219,8 @@ class LayerTreeHostTestGpuRasterizationDefault : public LayerTreeHostTest {
void SetupTree() override {
LayerTreeHostTest::SetupTree();
- scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_);
+ scoped_refptr<PictureLayer> layer =
+ PictureLayer::Create(layer_settings(), &layer_client_);
layer->SetBounds(gfx::Size(10, 10));
layer->SetIsDrawable(true);
layer_tree_host()->root_layer()->AddChild(layer);
@@ -5443,8 +4265,6 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationDefault);
class LayerTreeHostTestGpuRasterizationEnabled : public LayerTreeHostTest {
protected:
void InitializeSettings(LayerTreeSettings* settings) override {
- settings->impl_side_painting = true;
-
EXPECT_FALSE(settings->gpu_rasterization_enabled);
settings->gpu_rasterization_enabled = true;
}
@@ -5452,7 +4272,8 @@ class LayerTreeHostTestGpuRasterizationEnabled : public LayerTreeHostTest {
void SetupTree() override {
LayerTreeHostTest::SetupTree();
- scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_);
+ scoped_refptr<PictureLayer> layer =
+ PictureLayer::Create(layer_settings(), &layer_client_);
layer->SetBounds(gfx::Size(10, 10));
layer->SetIsDrawable(true);
layer_tree_host()->root_layer()->AddChild(layer);
@@ -5506,8 +4327,6 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled);
class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest {
protected:
void InitializeSettings(LayerTreeSettings* settings) override {
- ASSERT_TRUE(settings->impl_side_painting);
-
EXPECT_FALSE(settings->gpu_rasterization_forced);
settings->gpu_rasterization_forced = true;
}
@@ -5516,7 +4335,7 @@ class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest {
LayerTreeHostTest::SetupTree();
scoped_refptr<FakePictureLayer> layer =
- FakePictureLayer::Create(&layer_client_);
+ FakePictureLayer::Create(layer_settings(), &layer_client_);
layer->SetBounds(gfx::Size(10, 10));
layer->SetIsDrawable(true);
layer_tree_host()->root_layer()->AddChild(layer);
@@ -5565,7 +4384,7 @@ class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest {
FakeContentLayerClient layer_client_;
};
-SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestGpuRasterizationForced);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced);
class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest {
public:
@@ -5576,17 +4395,11 @@ class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest {
enum { kExpectedNumCommits = 10 };
void SetupTree() override {
- scoped_refptr<Layer> root_layer = Layer::Create();
+ scoped_refptr<Layer> root_layer = Layer::Create(layer_settings());
root_layer->SetBounds(bounds_);
root_layer->CreateRenderSurface();
- if (layer_tree_host()->settings().impl_side_painting) {
- picture_layer_ = FakePictureLayer::Create(&client_);
- child_layer_ = picture_layer_.get();
- } else {
- content_layer_ = ContentLayerWithUpdateTracking::Create(&client_);
- child_layer_ = content_layer_.get();
- }
+ child_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
child_layer_->SetBounds(bounds_);
child_layer_->SetIsDrawable(true);
root_layer->AddChild(child_layer_);
@@ -5621,10 +4434,7 @@ class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest {
void AfterTest() override {
EXPECT_LE(kExpectedNumCommits, num_commits_);
EXPECT_LE(kExpectedNumCommits, num_draws_);
- int update_count = content_layer_.get()
- ? content_layer_->PaintContentsCount()
- : picture_layer_->update_count();
- EXPECT_LE(kExpectedNumCommits, update_count);
+ EXPECT_LE(kExpectedNumCommits, child_layer_->update_count());
}
void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
@@ -5654,9 +4464,7 @@ class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest {
int num_draws_;
const gfx::Size bounds_;
FakeContentLayerClient client_;
- scoped_refptr<ContentLayerWithUpdateTracking> content_layer_;
- scoped_refptr<FakePictureLayer> picture_layer_;
- Layer* child_layer_;
+ scoped_refptr<FakePictureLayer> child_layer_;
};
MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting);
@@ -5792,10 +4600,6 @@ class LayerTreeHostTestActivateOnInvisible : public LayerTreeHostTest {
LayerTreeHostTestActivateOnInvisible()
: activation_count_(0), visible_(true) {}
- void InitializeSettings(LayerTreeSettings* settings) override {
- settings->impl_side_painting = true;
- }
-
void BeginTest() override {
// Kick off the test with a commit.
PostSetNeedsCommitToMainThread();
@@ -5841,7 +4645,8 @@ class LayerTreeHostTestActivateOnInvisible : public LayerTreeHostTest {
};
// TODO(vmpstr): Enable with single thread impl-side painting.
-MULTI_THREAD_TEST_F(LayerTreeHostTestActivateOnInvisible);
+// This test blocks activation which is not supported for single thread mode.
+MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostTestActivateOnInvisible);
// Do a synchronous composite and assert that the swap promise succeeds.
class LayerTreeHostTestSynchronousCompositeSwapPromise
@@ -5851,6 +4656,8 @@ class LayerTreeHostTestSynchronousCompositeSwapPromise
void InitializeSettings(LayerTreeSettings* settings) override {
settings->single_thread_proxy_scheduler = false;
+ settings->use_zero_copy = true;
+ settings->use_one_copy = false;
}
void BeginTest() override {
@@ -5858,14 +4665,14 @@ class LayerTreeHostTestSynchronousCompositeSwapPromise
scoped_ptr<SwapPromise> swap_promise0(
new TestSwapPromise(&swap_promise_result_[0]));
layer_tree_host()->QueueSwapPromise(swap_promise0.Pass());
- layer_tree_host()->Composite(gfx::FrameTime::Now());
+ layer_tree_host()->Composite(base::TimeTicks::Now());
// Fail to swap (no damage).
scoped_ptr<SwapPromise> swap_promise1(
new TestSwapPromise(&swap_promise_result_[1]));
layer_tree_host()->QueueSwapPromise(swap_promise1.Pass());
layer_tree_host()->SetNeedsCommit();
- layer_tree_host()->Composite(gfx::FrameTime::Now());
+ layer_tree_host()->Composite(base::TimeTicks::Now());
// Fail to draw (not visible).
scoped_ptr<SwapPromise> swap_promise2(
@@ -5873,7 +4680,7 @@ class LayerTreeHostTestSynchronousCompositeSwapPromise
layer_tree_host()->QueueSwapPromise(swap_promise2.Pass());
layer_tree_host()->SetNeedsDisplayOnAllLayers();
layer_tree_host()->SetVisible(false);
- layer_tree_host()->Composite(gfx::FrameTime::Now());
+ layer_tree_host()->Composite(base::TimeTicks::Now());
EndTest();
}
@@ -5919,8 +4726,7 @@ class LayerTreeHostTestSynchronousCompositeSwapPromise
TestSwapPromiseResult swap_promise_result_[3];
};
-// Impl-side painting is not supported for synchronous compositing.
-SINGLE_THREAD_NOIMPL_TEST_F(LayerTreeHostTestSynchronousCompositeSwapPromise);
+SINGLE_THREAD_TEST_F(LayerTreeHostTestSynchronousCompositeSwapPromise);
// Make sure page scale and top control deltas are applied to the client even
// when the LayerTreeHost doesn't have a root layer.
@@ -5955,15 +4761,6 @@ class LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer
deltas_sent_to_client_ = true;
}
- void ApplyViewportDeltas(
- const gfx::Vector2d& scroll,
- float scale_delta,
- float top_controls_delta) override {
- EXPECT_EQ(info_.page_scale_delta, scale_delta);
- EXPECT_EQ(info_.top_controls_delta, top_controls_delta);
- deltas_sent_to_client_ = true;
- }
-
void AfterTest() override {
EXPECT_TRUE(deltas_sent_to_client_);
}
@@ -5984,21 +4781,22 @@ class LayerTreeHostTestCrispUpAfterPinchEnds : public LayerTreeHostTest {
posted_ = false;
client_.set_fill_with_nonsolid_color(true);
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(gfx::Size(500, 500));
- scoped_refptr<Layer> pinch = Layer::Create();
+ scoped_refptr<Layer> pinch = Layer::Create(layer_settings());
pinch->SetBounds(gfx::Size(500, 500));
pinch->SetScrollClipLayerId(root->id());
pinch->SetIsContainerForFixedPositionLayers(true);
root->AddChild(pinch);
scoped_ptr<FakePicturePile> pile(
- new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale,
- ImplSidePaintingSettings().default_tile_grid_size));
+ new FakePicturePile(LayerTreeSettings().minimum_contents_scale,
+ LayerTreeSettings().default_tile_grid_size));
pile->SetPlaybackAllowedEvent(&playback_allowed_event_);
scoped_refptr<FakePictureLayer> layer =
- FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass());
+ FakePictureLayer::CreateWithRecordingSource(layer_settings(), &client_,
+ pile.Pass());
layer->SetBounds(gfx::Size(500, 500));
layer->SetContentsOpaque(true);
// Avoid LCD text on the layer so we don't cause extra commits when we
@@ -6026,8 +4824,8 @@ class LayerTreeHostTestCrispUpAfterPinchEnds : public LayerTreeHostTest {
const TileDrawQuad* quad = TileDrawQuad::MaterialCast(draw_quad);
float quad_scale =
quad->tex_coord_rect.width() / static_cast<float>(quad->rect.width());
- float transform_scale =
- SkMScalarToFloat(quad->quadTransform().matrix().get(0, 0));
+ float transform_scale = SkMScalarToFloat(
+ quad->shared_quad_state->quad_to_target_transform.matrix().get(0, 0));
float scale = quad_scale / transform_scale;
if (frame_scale != 0.f && frame_scale != scale)
return 0.f;
@@ -6156,7 +4954,9 @@ class LayerTreeHostTestCrispUpAfterPinchEnds : public LayerTreeHostTest {
base::WaitableEvent playback_allowed_event_;
};
-MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds);
+// This test does pinching on the impl side which is not supported in single
+// thread.
+MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds);
class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy
: public LayerTreeHostTestCrispUpAfterPinchEnds {
@@ -6181,28 +4981,30 @@ class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy
}
};
-MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy);
+// This test does pinching on the impl side which is not supported in single
+// thread.
+MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy);
class RasterizeWithGpuRasterizationCreatesResources : public LayerTreeHostTest {
protected:
RasterizeWithGpuRasterizationCreatesResources() {}
void InitializeSettings(LayerTreeSettings* settings) override {
- settings->impl_side_painting = true;
settings->gpu_rasterization_forced = true;
}
void SetupTree() override {
client_.set_fill_with_nonsolid_color(true);
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(gfx::Size(500, 500));
scoped_ptr<FakePicturePile> pile(
- new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale,
- ImplSidePaintingSettings().default_tile_grid_size));
+ new FakePicturePile(LayerTreeSettings().minimum_contents_scale,
+ LayerTreeSettings().default_tile_grid_size));
scoped_refptr<FakePictureLayer> layer =
- FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass());
+ FakePictureLayer::CreateWithRecordingSource(layer_settings(), &client_,
+ pile.Pass());
layer->SetBounds(gfx::Size(500, 500));
layer->SetContentsOpaque(true);
root->AddChild(layer);
@@ -6225,14 +5027,13 @@ class RasterizeWithGpuRasterizationCreatesResources : public LayerTreeHostTest {
FakeContentLayerClient client_;
};
-MULTI_THREAD_IMPL_TEST_F(RasterizeWithGpuRasterizationCreatesResources);
+SINGLE_AND_MULTI_THREAD_TEST_F(RasterizeWithGpuRasterizationCreatesResources);
class GpuRasterizationRasterizesBorderTiles : public LayerTreeHostTest {
protected:
GpuRasterizationRasterizesBorderTiles() : viewport_size_(1024, 2048) {}
void InitializeSettings(LayerTreeSettings* settings) override {
- settings->impl_side_painting = true;
settings->gpu_rasterization_enabled = true;
settings->gpu_rasterization_forced = true;
}
@@ -6241,10 +5042,11 @@ class GpuRasterizationRasterizesBorderTiles : public LayerTreeHostTest {
client_.set_fill_with_nonsolid_color(true);
scoped_ptr<FakePicturePile> pile(
- new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale,
- ImplSidePaintingSettings().default_tile_grid_size));
+ new FakePicturePile(LayerTreeSettings().minimum_contents_scale,
+ LayerTreeSettings().default_tile_grid_size));
scoped_refptr<FakePictureLayer> root =
- FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass());
+ FakePictureLayer::CreateWithRecordingSource(layer_settings(), &client_,
+ pile.Pass());
root->SetBounds(gfx::Size(10000, 10000));
root->SetContentsOpaque(true);
@@ -6270,7 +5072,7 @@ class GpuRasterizationRasterizesBorderTiles : public LayerTreeHostTest {
gfx::Size viewport_size_;
};
-MULTI_THREAD_IMPL_TEST_F(GpuRasterizationRasterizesBorderTiles);
+SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationRasterizesBorderTiles);
class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles
: public LayerTreeHostTest {
@@ -6278,30 +5080,27 @@ class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles
LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles()
: playback_allowed_event_(true, true) {}
- void InitializeSettings(LayerTreeSettings* settings) override {
- settings->impl_side_painting = true;
- }
-
void SetupTree() override {
step_ = 1;
continuous_draws_ = 0;
client_.set_fill_with_nonsolid_color(true);
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(gfx::Size(500, 500));
- scoped_refptr<Layer> pinch = Layer::Create();
+ scoped_refptr<Layer> pinch = Layer::Create(layer_settings());
pinch->SetBounds(gfx::Size(500, 500));
pinch->SetScrollClipLayerId(root->id());
pinch->SetIsContainerForFixedPositionLayers(true);
root->AddChild(pinch);
scoped_ptr<FakePicturePile> pile(
- new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale,
- ImplSidePaintingSettings().default_tile_grid_size));
+ new FakePicturePile(LayerTreeSettings().minimum_contents_scale,
+ LayerTreeSettings().default_tile_grid_size));
pile->SetPlaybackAllowedEvent(&playback_allowed_event_);
scoped_refptr<FakePictureLayer> layer =
- FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass());
+ FakePictureLayer::CreateWithRecordingSource(layer_settings(), &client_,
+ pile.Pass());
layer->SetBounds(gfx::Size(500, 500));
layer->SetContentsOpaque(true);
// Avoid LCD text on the layer so we don't cause extra commits when we
@@ -6326,8 +5125,8 @@ class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles
const TileDrawQuad* quad = TileDrawQuad::MaterialCast(draw_quad);
float quad_scale =
quad->tex_coord_rect.width() / static_cast<float>(quad->rect.width());
- float transform_scale =
- SkMScalarToFloat(quad->quadTransform().matrix().get(0, 0));
+ float transform_scale = SkMScalarToFloat(
+ quad->shared_quad_state->quad_to_target_transform.matrix().get(0, 0));
float scale = quad_scale / transform_scale;
if (frame_scale != 0.f && frame_scale != scale)
return 0.f;
@@ -6460,7 +5259,7 @@ class LayerTreeHostTestOneActivatePerPrepareTiles : public LayerTreeHostTest {
void SetupTree() override {
client_.set_fill_with_nonsolid_color(true);
scoped_refptr<FakePictureLayer> root_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
root_layer->SetBounds(gfx::Size(1500, 1500));
root_layer->SetIsDrawable(true);
@@ -6505,7 +5304,7 @@ class LayerTreeHostTestOneActivatePerPrepareTiles : public LayerTreeHostTest {
size_t scheduled_prepare_tiles_count_;
};
-MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles);
class LayerTreeHostTestFrameTimingRequestsSaveTimestamps
: public LayerTreeHostTest {
@@ -6515,12 +5314,12 @@ class LayerTreeHostTestFrameTimingRequestsSaveTimestamps
void SetupTree() override {
scoped_refptr<FakePictureLayer> root_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
root_layer->SetBounds(gfx::Size(200, 200));
root_layer->SetIsDrawable(true);
scoped_refptr<FakePictureLayer> child_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
child_layer->SetBounds(gfx::Size(1500, 1500));
child_layer->SetIsDrawable(true);
@@ -6591,7 +5390,8 @@ class LayerTreeHostTestFrameTimingRequestsSaveTimestamps
bool check_results_on_commit_;
};
-MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestFrameTimingRequestsSaveTimestamps);
+// Frame timing is not implemented in single thread proxy.
+MULTI_THREAD_TEST_F(LayerTreeHostTestFrameTimingRequestsSaveTimestamps);
class LayerTreeHostTestActivationCausesPrepareTiles : public LayerTreeHostTest {
public:
@@ -6601,7 +5401,7 @@ class LayerTreeHostTestActivationCausesPrepareTiles : public LayerTreeHostTest {
void SetupTree() override {
client_.set_fill_with_nonsolid_color(true);
scoped_refptr<FakePictureLayer> root_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
root_layer->SetBounds(gfx::Size(150, 150));
root_layer->SetIsDrawable(true);
@@ -6635,7 +5435,9 @@ class LayerTreeHostTestActivationCausesPrepareTiles : public LayerTreeHostTest {
int scheduled_prepare_tiles_count_;
};
-MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestActivationCausesPrepareTiles);
+// This test is testing activation from a pending tree and doesn't make sense
+// with single thread commit-to-active.
+MULTI_THREAD_TEST_F(LayerTreeHostTestActivationCausesPrepareTiles);
// This tests an assertion that DidCommit and WillCommit happen in the same
// stack frame with no tasks that run between them. Various embedders of
@@ -6674,90 +5476,11 @@ class LayerTreeHostTestNoTasksBetweenWillAndDidCommit
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit);
-// Verify that if a LayerImpl holds onto a copy request for multiple
-// frames that it will continue to have a render surface through
-// multiple commits, even though the Layer itself has no reason
-// to have a render surface.
-class LayerPreserveRenderSurfaceFromOutputRequests : public LayerTreeHostTest {
- protected:
- void SetupTree() override {
- scoped_refptr<Layer> root = Layer::Create();
- root->CreateRenderSurface();
- root->SetBounds(gfx::Size(10, 10));
- child_ = Layer::Create();
- child_->SetBounds(gfx::Size(20, 20));
- root->AddChild(child_);
-
- layer_tree_host()->SetRootLayer(root);
- LayerTreeHostTest::SetupTree();
- }
-
- static void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {}
-
- void BeginTest() override {
- child_->RequestCopyOfOutput(
- CopyOutputRequest::CreateBitmapRequest(base::Bind(CopyOutputCallback)));
- EXPECT_TRUE(child_->HasCopyRequest());
- PostSetNeedsCommitToMainThread();
- }
-
- void DidCommit() override { EXPECT_FALSE(child_->HasCopyRequest()); }
-
- void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
- LayerImpl* child_impl = host_impl->sync_tree()->LayerById(child_->id());
-
- switch (host_impl->sync_tree()->source_frame_number()) {
- case 0:
- EXPECT_TRUE(child_impl->HasCopyRequest());
- EXPECT_TRUE(child_impl->render_surface());
- break;
- case 1:
- if (host_impl->proxy()->CommitToActiveTree()) {
- EXPECT_TRUE(child_impl->HasCopyRequest());
- EXPECT_TRUE(child_impl->render_surface());
- } else {
- EXPECT_FALSE(child_impl->HasCopyRequest());
- EXPECT_FALSE(child_impl->render_surface());
- }
- break;
- default:
- NOTREACHED();
- break;
- }
- }
-
- void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
- LayerImpl* child_impl = host_impl->active_tree()->LayerById(child_->id());
- EXPECT_TRUE(child_impl->HasCopyRequest());
- EXPECT_TRUE(child_impl->render_surface());
-
- switch (host_impl->active_tree()->source_frame_number()) {
- case 0:
- // Lose output surface to prevent drawing and cause another commit.
- host_impl->DidLoseOutputSurface();
- break;
- case 1:
- EndTest();
- break;
- default:
- NOTREACHED();
- break;
- }
- }
-
- void AfterTest() override {}
-
- private:
- scoped_refptr<Layer> child_;
-};
-
-SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests);
-
class LayerTreeHostTestUpdateCopyRequests : public LayerTreeHostTest {
protected:
void SetupTree() override {
- root = Layer::Create();
- child = Layer::Create();
+ root = Layer::Create(layer_settings());
+ child = Layer::Create(layer_settings());
root->AddChild(child);
layer_tree_host()->SetRootLayer(root);
LayerTreeHostTest::SetupTree();
@@ -6799,21 +5522,21 @@ class LayerTreeTestMaskLayerForSurfaceWithClippedLayer : public LayerTreeTest {
// the surface bounds to be larger. It also has a parent that clips the
// masked layer and its surface.
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
- scoped_refptr<Layer> clipping_layer = Layer::Create();
+ scoped_refptr<Layer> clipping_layer = Layer::Create(layer_settings());
root->AddChild(clipping_layer);
scoped_refptr<FakePictureLayer> content_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
clipping_layer->AddChild(content_layer);
scoped_refptr<FakePictureLayer> content_child_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
content_layer->AddChild(content_child_layer);
scoped_refptr<FakePictureLayer> mask_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
content_layer->SetMaskLayer(mask_layer.get());
gfx::Size root_size(100, 100);
@@ -6893,17 +5616,17 @@ class LayerTreeTestMaskLayerWithScaling : public LayerTreeTest {
// +-- Content Layer
// +--Mask
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
- scoped_refptr<Layer> scaling_layer = Layer::Create();
+ scoped_refptr<Layer> scaling_layer = Layer::Create(layer_settings());
root->AddChild(scaling_layer);
scoped_refptr<FakePictureLayer> content_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
scaling_layer->AddChild(content_layer);
scoped_refptr<FakePictureLayer> mask_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
content_layer->SetMaskLayer(mask_layer.get());
gfx::Size root_size(100, 100);
@@ -6988,14 +5711,14 @@ class LayerTreeTestMaskLayerWithDifferentBounds : public LayerTreeTest {
// The mask layer has bounds 100x100 but is attached to a layer with bounds
// 50x50.
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<FakePictureLayer> content_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
root->AddChild(content_layer);
scoped_refptr<FakePictureLayer> mask_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
content_layer->SetMaskLayer(mask_layer.get());
gfx::Size root_size(100, 100);
@@ -7076,17 +5799,17 @@ class LayerTreeTestReflectionMaskLayerWithDifferentBounds
// The replica's mask layer has bounds 100x100 but the replica is of a
// layer with bounds 50x50.
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<FakePictureLayer> content_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
root->AddChild(content_layer);
- scoped_refptr<Layer> replica_layer = Layer::Create();
+ scoped_refptr<Layer> replica_layer = Layer::Create(layer_settings());
content_layer->SetReplicaLayer(replica_layer.get());
scoped_refptr<FakePictureLayer> mask_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
replica_layer->SetMaskLayer(mask_layer.get());
gfx::Size root_size(100, 100);
@@ -7169,20 +5892,20 @@ class LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild
// The replica is of a layer with bounds 50x50, but it has a child that
// causes the surface bounds to be larger.
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<FakePictureLayer> content_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
root->AddChild(content_layer);
- content_child_layer_ = FakePictureLayer::Create(&client_);
+ content_child_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
content_layer->AddChild(content_child_layer_);
- scoped_refptr<Layer> replica_layer = Layer::Create();
+ scoped_refptr<Layer> replica_layer = Layer::Create(layer_settings());
content_layer->SetReplicaLayer(replica_layer.get());
scoped_refptr<FakePictureLayer> mask_layer =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
replica_layer->SetMaskLayer(mask_layer.get());
gfx::Size root_size(100, 100);
@@ -7262,4 +5985,77 @@ class LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild
SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild);
+class LayerTreeTestPageScaleFlags : public LayerTreeTest {
+ protected:
+ void SetupTree() override {
+ // -root
+ // -pre page scale
+ // -page scale
+ // -page scale child1
+ // -page scale grandchild
+ // -page scale child2
+ // -post page scale
+
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
+ scoped_refptr<Layer> pre_page_scale = Layer::Create(layer_settings());
+ scoped_refptr<Layer> page_scale = Layer::Create(layer_settings());
+ scoped_refptr<Layer> page_scale_child1 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> page_scale_grandchild =
+ Layer::Create(layer_settings());
+ scoped_refptr<Layer> page_scale_child2 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> post_page_scale = Layer::Create(layer_settings());
+
+ root->AddChild(pre_page_scale);
+ root->AddChild(page_scale);
+ root->AddChild(post_page_scale);
+
+ page_scale->AddChild(page_scale_child1);
+ page_scale->AddChild(page_scale_child2);
+ page_scale_child1->AddChild(page_scale_grandchild);
+
+ layer_tree_host()->SetRootLayer(root);
+ LayerTreeTest::SetupTree();
+
+ scoped_refptr<Layer> overscroll_elasticity_layer = nullptr;
+ scoped_refptr<Layer> inner_viewport_scroll_layer = nullptr;
+ scoped_refptr<Layer> outer_viewport_scroll_layer = nullptr;
+ layer_tree_host()->RegisterViewportLayers(
+ overscroll_elasticity_layer, page_scale, inner_viewport_scroll_layer,
+ outer_viewport_scroll_layer);
+
+ affected_by_page_scale_.push_back(page_scale->id());
+ affected_by_page_scale_.push_back(page_scale_child1->id());
+ affected_by_page_scale_.push_back(page_scale_child2->id());
+ affected_by_page_scale_.push_back(page_scale_grandchild->id());
+
+ not_affected_by_page_scale_.push_back(root->id());
+ not_affected_by_page_scale_.push_back(pre_page_scale->id());
+ not_affected_by_page_scale_.push_back(post_page_scale->id());
+ }
+
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
+ LayerTreeHostCommon::CallFunctionForSubtree(
+ host_impl->sync_tree()->root_layer(), [this](LayerImpl* layer) {
+ const std::vector<int>& list =
+ layer->IsAffectedByPageScale()
+ ? this->affected_by_page_scale_
+ : this->not_affected_by_page_scale_;
+ EXPECT_TRUE(std::find(list.begin(), list.end(), layer->id()) !=
+ list.end());
+ });
+
+ EndTest();
+ }
+
+ void AfterTest() override {}
+
+ std::vector<int> affected_by_page_scale_;
+ std::vector<int> not_affected_by_page_scale_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestPageScaleFlags);
+
+} // namespace
} // namespace cc
diff --git a/chromium/cc/trees/layer_tree_host_unittest_animation.cc b/chromium/cc/trees/layer_tree_host_unittest_animation.cc
index ed27a03a2f8..9b16e39cb83 100644
--- a/chromium/cc/trees/layer_tree_host_unittest_animation.cc
+++ b/chromium/cc/trees/layer_tree_host_unittest_animation.cc
@@ -12,8 +12,8 @@
#include "cc/layers/layer.h"
#include "cc/layers/layer_impl.h"
#include "cc/test/animation_test_common.h"
-#include "cc/test/fake_content_layer.h"
#include "cc/test/fake_content_layer_client.h"
+#include "cc/test/fake_picture_layer.h"
#include "cc/test/layer_tree_test.h"
#include "cc/trees/layer_tree_impl.h"
@@ -231,12 +231,12 @@ class LayerTreeHostAnimationTestAddAnimationWithTimingFunction
void SetupTree() override {
LayerTreeHostAnimationTest::SetupTree();
- content_ = FakeContentLayer::Create(&client_);
- content_->SetBounds(gfx::Size(4, 4));
- layer_tree_host()->root_layer()->AddChild(content_);
+ picture_ = FakePictureLayer::Create(layer_settings(), &client_);
+ picture_->SetBounds(gfx::Size(4, 4));
+ layer_tree_host()->root_layer()->AddChild(picture_);
}
- void BeginTest() override { PostAddAnimationToMainThread(content_.get()); }
+ void BeginTest() override { PostAddAnimationToMainThread(picture_.get()); }
void AnimateLayers(LayerTreeHostImpl* host_impl,
base::TimeTicks monotonic_time) override {
@@ -265,7 +265,7 @@ class LayerTreeHostAnimationTestAddAnimationWithTimingFunction
void AfterTest() override {}
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> content_;
+ scoped_refptr<FakePictureLayer> picture_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(
@@ -280,13 +280,13 @@ class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes
void SetupTree() override {
LayerTreeHostAnimationTest::SetupTree();
- content_ = FakeContentLayer::Create(&client_);
- content_->SetBounds(gfx::Size(4, 4));
- content_->set_layer_animation_delegate(this);
- layer_tree_host()->root_layer()->AddChild(content_);
+ picture_ = FakePictureLayer::Create(layer_settings(), &client_);
+ picture_->SetBounds(gfx::Size(4, 4));
+ picture_->set_layer_animation_delegate(this);
+ layer_tree_host()->root_layer()->AddChild(picture_);
}
- void BeginTest() override { PostAddAnimationToMainThread(content_.get()); }
+ void BeginTest() override { PostAddAnimationToMainThread(picture_.get()); }
void NotifyAnimationStarted(base::TimeTicks monotonic_time,
Animation::TargetProperty target_property,
@@ -321,7 +321,7 @@ class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes
base::TimeTicks main_start_time_;
base::TimeTicks impl_start_time_;
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> content_;
+ scoped_refptr<FakePictureLayer> picture_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(
@@ -360,8 +360,8 @@ class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity
: public LayerTreeHostAnimationTest {
public:
LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity()
- : update_check_layer_(FakeContentLayer::Create(&client_)) {
- }
+ : update_check_layer_(
+ FakePictureLayer::Create(layer_settings(), &client_)) {}
void SetupTree() override {
update_check_layer_->SetOpacity(0.f);
@@ -385,7 +385,7 @@ class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity
void AfterTest() override {
// Update() should have been called once, proving that the layer was not
// skipped.
- EXPECT_EQ(1u, update_check_layer_->update_count());
+ EXPECT_EQ(1, update_check_layer_->update_count());
// clear update_check_layer_ so LayerTreeHost dies.
update_check_layer_ = NULL;
@@ -393,7 +393,7 @@ class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity
private:
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> update_check_layer_;
+ scoped_refptr<FakePictureLayer> update_check_layer_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(
@@ -410,7 +410,7 @@ class LayerTreeHostAnimationTestLayerAddedWithAnimation
void DidCommit() override {
if (layer_tree_host()->source_frame_number() == 1) {
- scoped_refptr<Layer> layer = Layer::Create();
+ scoped_refptr<Layer> layer = Layer::Create(layer_settings());
layer->set_layer_animation_delegate(this);
// Any valid AnimationCurve will do here.
@@ -475,8 +475,6 @@ class LayerTreeHostAnimationTestCancelAnimateCommit
int num_begin_frames_;
int num_commit_calls_;
int num_draw_calls_;
- FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> content_;
};
MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestCancelAnimateCommit);
@@ -558,15 +556,15 @@ class LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw
void SetupTree() override {
LayerTreeHostAnimationTest::SetupTree();
- content_ = FakeContentLayer::Create(&client_);
- content_->SetBounds(gfx::Size(4, 4));
- content_->set_layer_animation_delegate(this);
- layer_tree_host()->root_layer()->AddChild(content_);
+ picture_ = FakePictureLayer::Create(layer_settings(), &client_);
+ picture_->SetBounds(gfx::Size(4, 4));
+ picture_->set_layer_animation_delegate(this);
+ layer_tree_host()->root_layer()->AddChild(picture_);
}
void BeginTest() override {
layer_tree_host()->SetViewportSize(gfx::Size());
- PostAddAnimationToMainThread(content_.get());
+ PostAddAnimationToMainThread(picture_.get());
}
void NotifyAnimationStarted(base::TimeTicks monotonic_time,
@@ -586,7 +584,7 @@ class LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw
private:
int started_times_;
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> content_;
+ scoped_refptr<FakePictureLayer> picture_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(
@@ -598,10 +596,10 @@ class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations
: public LayerTreeHostAnimationTest {
void SetupTree() override {
LayerTreeHostAnimationTest::SetupTree();
- content_ = FakeContentLayer::Create(&client_);
- content_->SetBounds(gfx::Size(4, 4));
- content_->set_layer_animation_delegate(this);
- layer_tree_host()->root_layer()->AddChild(content_);
+ picture_ = FakePictureLayer::Create(layer_settings(), &client_);
+ picture_->SetBounds(gfx::Size(4, 4));
+ picture_->set_layer_animation_delegate(this);
+ layer_tree_host()->root_layer()->AddChild(picture_);
}
void InitializeSettings(LayerTreeSettings* settings) override {
@@ -636,12 +634,12 @@ class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations
switch (layer_tree_host()->source_frame_number()) {
case 1:
// The animation is longer than 1 BeginFrame interval.
- AddOpacityTransitionToLayer(content_.get(), 0.1, 0.2f, 0.8f, false);
+ AddOpacityTransitionToLayer(picture_.get(), 0.1, 0.2f, 0.8f, false);
added_animations_++;
break;
case 2:
// This second animation will not be drawn so it should not start.
- AddAnimatedTransformToLayer(content_.get(), 0.1, 5, 5);
+ AddAnimatedTransformToLayer(picture_.get(), 0.1, 5, 5);
added_animations_++;
break;
}
@@ -667,7 +665,7 @@ class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations
int added_animations_;
int started_times_;
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> content_;
+ scoped_refptr<FakePictureLayer> picture_;
};
MULTI_THREAD_TEST_F(
@@ -684,7 +682,7 @@ class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated
void SetupTree() override {
LayerTreeHostAnimationTest::SetupTree();
- scroll_layer_ = FakeContentLayer::Create(&client_);
+ scroll_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id());
scroll_layer_->SetBounds(gfx::Size(1000, 1000));
scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
@@ -722,7 +720,7 @@ class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated
private:
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> scroll_layer_;
+ scoped_refptr<FakePictureLayer> scroll_layer_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(
@@ -741,7 +739,7 @@ class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval
void SetupTree() override {
LayerTreeHostAnimationTest::SetupTree();
- scroll_layer_ = FakeContentLayer::Create(&client_);
+ scroll_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id());
scroll_layer_->SetBounds(gfx::Size(10000, 10000));
scroll_layer_->SetScrollOffset(gfx::ScrollOffset(100.0, 200.0));
@@ -777,8 +775,7 @@ class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval
}
void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override {
- if (host_impl->settings().impl_side_painting)
- host_impl->BlockNotifyReadyToActivateForTesting(true);
+ host_impl->BlockNotifyReadyToActivateForTesting(true);
}
void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl,
@@ -812,8 +809,6 @@ class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval
}
void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
- if (!host_impl->settings().impl_side_painting)
- return;
if (host_impl->pending_tree()->source_frame_number() != 1)
return;
LayerImpl* scroll_layer_impl =
@@ -836,7 +831,7 @@ class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval
private:
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> scroll_layer_;
+ scoped_refptr<FakePictureLayer> scroll_layer_;
const gfx::ScrollOffset final_postion_;
};
@@ -860,7 +855,7 @@ class LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers
AddOpacityTransitionToLayer(
layer_tree_host()->root_layer(), 1, 0.f, 0.5f, true);
- scoped_refptr<Layer> layer = Layer::Create();
+ scoped_refptr<Layer> layer = Layer::Create(layer_settings());
layer_tree_host()->root_layer()->AddChild(layer);
layer->set_layer_animation_delegate(this);
layer->SetBounds(gfx::Size(4, 4));
@@ -869,8 +864,7 @@ class LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers
}
void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override {
- if (host_impl->settings().impl_side_painting)
- host_impl->BlockNotifyReadyToActivateForTesting(true);
+ host_impl->BlockNotifyReadyToActivateForTesting(true);
}
void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
@@ -878,8 +872,7 @@ class LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers
// blocking activation. We want to verify that even with activation blocked,
// the animation on the layer that's already in the active tree won't get a
// head start.
- if (host_impl->settings().impl_side_painting &&
- host_impl->pending_tree()->source_frame_number() != 2) {
+ if (host_impl->pending_tree()->source_frame_number() != 2) {
host_impl->BlockNotifyReadyToActivateForTesting(false);
}
}
@@ -891,8 +884,7 @@ class LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers
return;
frame_count_with_pending_tree_++;
- if (frame_count_with_pending_tree_ == 2 &&
- host_impl->settings().impl_side_painting) {
+ if (frame_count_with_pending_tree_ == 2) {
host_impl->BlockNotifyReadyToActivateForTesting(false);
}
}
@@ -925,20 +917,70 @@ class LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers
int frame_count_with_pending_tree_;
};
-SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F(
+// This test blocks activation which is not supported for single thread mode.
+MULTI_THREAD_BLOCKNOTIFY_TEST_F(
LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers);
-class LayerTreeHostAnimationTestAddAnimationAfterAnimating
+// When a layer with an animation is removed from the tree and later re-added,
+// the animation should resume.
+class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded
: public LayerTreeHostAnimationTest {
public:
- LayerTreeHostAnimationTestAddAnimationAfterAnimating()
- : num_swap_buffers_(0) {}
+ LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded() {}
+
+ void SetupTree() override {
+ LayerTreeHostAnimationTest::SetupTree();
+ layer_ = Layer::Create(layer_settings());
+ layer_->SetBounds(gfx::Size(4, 4));
+ layer_tree_host()->root_layer()->AddChild(layer_);
+ AddOpacityTransitionToLayer(layer_.get(), 10000.0, 0.1f, 0.9f, true);
+ }
+
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ void DidCommit() override {
+ switch (layer_tree_host()->source_frame_number()) {
+ case 1:
+ layer_->RemoveFromParent();
+ break;
+ case 2:
+ layer_tree_host()->root_layer()->AddChild(layer_);
+ break;
+ }
+ }
+ void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
+ switch (host_impl->active_tree()->source_frame_number()) {
+ case 0:
+ EXPECT_TRUE(host_impl->animation_registrar()->needs_animate_layers());
+ break;
+ case 1:
+ EXPECT_FALSE(host_impl->animation_registrar()->needs_animate_layers());
+ break;
+ case 2:
+ EXPECT_TRUE(host_impl->animation_registrar()->needs_animate_layers());
+ EndTest();
+ break;
+ }
+ }
+
+ void AfterTest() override {}
+
+ private:
+ scoped_refptr<Layer> layer_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded);
+
+class LayerTreeHostAnimationTestAddAnimationAfterAnimating
+ : public LayerTreeHostAnimationTest {
+ public:
void SetupTree() override {
LayerTreeHostAnimationTest::SetupTree();
- content_ = Layer::Create();
- content_->SetBounds(gfx::Size(4, 4));
- layer_tree_host()->root_layer()->AddChild(content_);
+ layer_ = Layer::Create(layer_settings());
+ layer_->SetBounds(gfx::Size(4, 4));
+ layer_tree_host()->root_layer()->AddChild(layer_);
}
void BeginTest() override { PostSetNeedsCommitToMainThread(); }
@@ -952,7 +994,7 @@ class LayerTreeHostAnimationTestAddAnimationAfterAnimating
case 2:
// Second frame: add an animation to the content layer. The root layer
// animation has caused us to animate already during this frame.
- AddOpacityTransitionToLayer(content_.get(), 0.1, 5, 5, false);
+ AddOpacityTransitionToLayer(layer_.get(), 0.1, 5, 5, false);
break;
}
}
@@ -960,35 +1002,83 @@ class LayerTreeHostAnimationTestAddAnimationAfterAnimating
void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
// After both animations have started, verify that they have valid
// start times.
- num_swap_buffers_++;
+ if (host_impl->active_tree()->source_frame_number() < 2)
+ return;
AnimationRegistrar::AnimationControllerMap controllers_copy =
host_impl->animation_registrar()
->active_animation_controllers_for_testing();
- if (controllers_copy.size() == 2u) {
- EndTest();
- EXPECT_GE(num_swap_buffers_, 3);
- for (auto& it : controllers_copy) {
- int id = it.first;
- if (id == host_impl->RootLayer()->id()) {
- Animation* anim = it.second->GetAnimation(Animation::TRANSFORM);
- EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
- } else if (id == host_impl->RootLayer()->children()[0]->id()) {
- Animation* anim = it.second->GetAnimation(Animation::OPACITY);
- EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
- }
+ EXPECT_EQ(2u, controllers_copy.size());
+ for (auto& it : controllers_copy) {
+ int id = it.first;
+ if (id == host_impl->RootLayer()->id()) {
+ Animation* anim = it.second->GetAnimation(Animation::TRANSFORM);
+ EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
+ } else if (id == host_impl->RootLayer()->children()[0]->id()) {
+ Animation* anim = it.second->GetAnimation(Animation::OPACITY);
+ EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
}
+ EndTest();
}
}
void AfterTest() override {}
private:
- scoped_refptr<Layer> content_;
- int num_swap_buffers_;
+ scoped_refptr<Layer> layer_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostAnimationTestAddAnimationAfterAnimating);
+class LayerTreeHostAnimationTestNotifyAnimationFinished
+ : public LayerTreeHostAnimationTest {
+ public:
+ LayerTreeHostAnimationTestNotifyAnimationFinished()
+ : called_animation_started_(false), called_animation_finished_(false) {}
+
+ void SetupTree() override {
+ LayerTreeHostAnimationTest::SetupTree();
+ picture_ = FakePictureLayer::Create(layer_settings(), &client_);
+ picture_->SetBounds(gfx::Size(4, 4));
+ picture_->set_layer_animation_delegate(this);
+ layer_tree_host()->root_layer()->AddChild(picture_);
+ }
+
+ void BeginTest() override {
+ layer_tree_host()->SetViewportSize(gfx::Size());
+ PostAddLongAnimationToMainThread(picture_.get());
+ }
+
+ void NotifyAnimationStarted(base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property,
+ int group) override {
+ called_animation_started_ = true;
+ layer_tree_host()->AnimateLayers(
+ base::TimeTicks::FromInternalValue(std::numeric_limits<int64>::max()));
+ PostSetNeedsCommitToMainThread();
+ }
+
+ void NotifyAnimationFinished(base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property,
+ int group) override {
+ called_animation_finished_ = true;
+ EndTest();
+ }
+
+ void AfterTest() override {
+ EXPECT_TRUE(called_animation_started_);
+ EXPECT_TRUE(called_animation_finished_);
+ }
+
+ private:
+ bool called_animation_started_;
+ bool called_animation_finished_;
+ FakeContentLayerClient client_;
+ scoped_refptr<FakePictureLayer> picture_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostAnimationTestNotifyAnimationFinished);
+
} // namespace
} // namespace cc
diff --git a/chromium/cc/trees/layer_tree_host_unittest_animation_timelines.cc b/chromium/cc/trees/layer_tree_host_unittest_animation_timelines.cc
new file mode 100644
index 00000000000..4bf8e83d221
--- /dev/null
+++ b/chromium/cc/trees/layer_tree_host_unittest_animation_timelines.cc
@@ -0,0 +1,923 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/trees/layer_tree_host.h"
+
+#include "cc/animation/animation_curve.h"
+#include "cc/animation/animation_host.h"
+#include "cc/animation/animation_id_provider.h"
+#include "cc/animation/animation_player.h"
+#include "cc/animation/animation_timeline.h"
+#include "cc/animation/element_animations.h"
+#include "cc/animation/layer_animation_controller.h"
+#include "cc/animation/scroll_offset_animation_curve.h"
+#include "cc/animation/timing_function.h"
+#include "cc/base/time_util.h"
+#include "cc/layers/layer.h"
+#include "cc/layers/layer_impl.h"
+#include "cc/test/animation_test_common.h"
+#include "cc/test/fake_content_layer_client.h"
+#include "cc/test/fake_picture_layer.h"
+#include "cc/test/layer_tree_test.h"
+#include "cc/trees/layer_tree_impl.h"
+
+namespace cc {
+namespace {
+
+class LayerTreeHostTimelinesTest : public LayerTreeTest {
+ public:
+ LayerTreeHostTimelinesTest()
+ : timeline_id_(AnimationIdProvider::NextTimelineId()),
+ player_id_(AnimationIdProvider::NextPlayerId()),
+ player_child_id_(AnimationIdProvider::NextPlayerId()) {
+ timeline_ = AnimationTimeline::Create(timeline_id_);
+ player_ = AnimationPlayer::Create(player_id_);
+ player_child_ = AnimationPlayer::Create(player_child_id_);
+
+ player_->set_layer_animation_delegate(this);
+ }
+
+ void InitializeSettings(LayerTreeSettings* settings) override {
+ settings->use_compositor_animation_timelines = true;
+ }
+
+ void InitializeLayerSettings(LayerSettings* layer_settings) override {
+ layer_settings->use_compositor_animation_timelines = true;
+ }
+
+ void SetupTree() override { LayerTreeTest::SetupTree(); }
+
+ void AttachPlayersToTimeline() {
+ layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get());
+ timeline_->AttachPlayer(player_.get());
+ timeline_->AttachPlayer(player_child_.get());
+ }
+
+ protected:
+ scoped_refptr<AnimationTimeline> timeline_;
+ scoped_refptr<AnimationPlayer> player_;
+ scoped_refptr<AnimationPlayer> player_child_;
+
+ const int timeline_id_;
+ const int player_id_;
+ const int player_child_id_;
+};
+
+// Add a layer animation and confirm that
+// LayerTreeHostImpl::UpdateAnimationState does get called.
+// Evolved frome LayerTreeHostAnimationTestAddAnimation
+class LayerTreeHostTimelinesTestAddAnimation
+ : public LayerTreeHostTimelinesTest {
+ public:
+ LayerTreeHostTimelinesTestAddAnimation()
+ : update_animation_state_was_called_(false) {}
+
+ void BeginTest() override {
+ AttachPlayersToTimeline();
+ player_->AttachLayer(layer_tree_host()->root_layer()->id());
+ PostAddInstantAnimationToMainThreadPlayer(player_.get());
+ }
+
+ void UpdateAnimationState(LayerTreeHostImpl* host_impl,
+ bool has_unfinished_animation) override {
+ EXPECT_FALSE(has_unfinished_animation);
+ update_animation_state_was_called_ = true;
+ }
+
+ void NotifyAnimationStarted(base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property,
+ int group) override {
+ EXPECT_LT(base::TimeTicks(), monotonic_time);
+
+ LayerAnimationController* controller =
+ player_->element_animations()->layer_animation_controller();
+ Animation* animation = controller->GetAnimation(Animation::OPACITY);
+ if (animation)
+ player_->RemoveAnimation(animation->id());
+
+ EndTest();
+ }
+
+ void AfterTest() override { EXPECT_TRUE(update_animation_state_was_called_); }
+
+ private:
+ bool update_animation_state_was_called_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTimelinesTestAddAnimation);
+
+// Add a layer animation to a layer, but continually fail to draw. Confirm that
+// after a while, we do eventually force a draw.
+// Evolved from LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws.
+class LayerTreeHostTimelinesTestCheckerboardDoesNotStarveDraws
+ : public LayerTreeHostTimelinesTest {
+ public:
+ LayerTreeHostTimelinesTestCheckerboardDoesNotStarveDraws()
+ : started_animating_(false) {}
+
+ void BeginTest() override {
+ AttachPlayersToTimeline();
+ player_->AttachLayer(layer_tree_host()->root_layer()->id());
+ PostAddAnimationToMainThreadPlayer(player_.get());
+ }
+
+ void AnimateLayers(LayerTreeHostImpl* host_impl,
+ base::TimeTicks monotonic_time) override {
+ started_animating_ = true;
+ }
+
+ void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
+ if (started_animating_)
+ EndTest();
+ }
+
+ DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
+ LayerTreeHostImpl::FrameData* frame,
+ DrawResult draw_result) override {
+ return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
+ }
+
+ void AfterTest() override {}
+
+ private:
+ bool started_animating_;
+};
+
+// Starvation can only be an issue with the MT compositor.
+MULTI_THREAD_TEST_F(LayerTreeHostTimelinesTestCheckerboardDoesNotStarveDraws);
+
+// Ensures that animations eventually get deleted.
+// Evolved from LayerTreeHostAnimationTestAnimationsGetDeleted.
+class LayerTreeHostTimelinesTestAnimationsGetDeleted
+ : public LayerTreeHostTimelinesTest {
+ public:
+ LayerTreeHostTimelinesTestAnimationsGetDeleted()
+ : started_animating_(false) {}
+
+ void BeginTest() override {
+ AttachPlayersToTimeline();
+ player_->AttachLayer(layer_tree_host()->root_layer()->id());
+ PostAddAnimationToMainThreadPlayer(player_.get());
+ }
+
+ void AnimateLayers(LayerTreeHostImpl* host_impl,
+ base::TimeTicks monotonic_time) override {
+ bool have_animations = !host_impl->animation_host()
+ ->animation_registrar()
+ ->active_animation_controllers_for_testing()
+ .empty();
+ if (!started_animating_ && have_animations) {
+ started_animating_ = true;
+ return;
+ }
+
+ if (started_animating_ && !have_animations)
+ EndTest();
+ }
+
+ void NotifyAnimationFinished(base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property,
+ int group) override {
+ // Animations on the impl-side controller only get deleted during a commit,
+ // so we need to schedule a commit.
+ layer_tree_host()->SetNeedsCommit();
+ }
+
+ void AfterTest() override {}
+
+ private:
+ bool started_animating_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTimelinesTestAnimationsGetDeleted);
+
+// Ensure that an animation's timing function is respected.
+// Evolved from LayerTreeHostAnimationTestAddAnimationWithTimingFunction.
+class LayerTreeHostTimelinesTestAddAnimationWithTimingFunction
+ : public LayerTreeHostTimelinesTest {
+ public:
+ LayerTreeHostTimelinesTestAddAnimationWithTimingFunction() {}
+
+ void SetupTree() override {
+ LayerTreeHostTimelinesTest::SetupTree();
+ picture_ = FakePictureLayer::Create(layer_settings(), &client_);
+ picture_->SetBounds(gfx::Size(4, 4));
+ layer_tree_host()->root_layer()->AddChild(picture_);
+
+ AttachPlayersToTimeline();
+ player_child_->AttachLayer(picture_->id());
+ }
+
+ void BeginTest() override {
+ PostAddAnimationToMainThreadPlayer(player_child_.get());
+ }
+
+ void AnimateLayers(LayerTreeHostImpl* host_impl,
+ base::TimeTicks monotonic_time) override {
+ scoped_refptr<AnimationTimeline> timeline_impl =
+ host_impl->animation_host()->GetTimelineById(timeline_id_);
+ scoped_refptr<AnimationPlayer> player_child_impl =
+ timeline_impl->GetPlayerById(player_child_id_);
+
+ LayerAnimationController* controller_impl =
+ player_child_impl->element_animations()->layer_animation_controller();
+ if (!controller_impl)
+ return;
+
+ Animation* animation = controller_impl->GetAnimation(Animation::OPACITY);
+ if (!animation)
+ return;
+
+ const FloatAnimationCurve* curve =
+ animation->curve()->ToFloatAnimationCurve();
+ float start_opacity = curve->GetValue(base::TimeDelta());
+ float end_opacity = curve->GetValue(curve->Duration());
+ float linearly_interpolated_opacity =
+ 0.25f * end_opacity + 0.75f * start_opacity;
+ base::TimeDelta time = TimeUtil::Scale(curve->Duration(), 0.25f);
+ // If the linear timing function associated with this animation was not
+ // picked up, then the linearly interpolated opacity would be different
+ // because of the default ease timing function.
+ EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time));
+
+ EndTest();
+ }
+
+ void AfterTest() override {}
+
+ FakeContentLayerClient client_;
+ scoped_refptr<FakePictureLayer> picture_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostTimelinesTestAddAnimationWithTimingFunction);
+
+// Ensures that main thread animations have their start times synchronized with
+// impl thread animations.
+// Evolved from LayerTreeHostAnimationTestSynchronizeAnimationStartTimes.
+class LayerTreeHostTimelinesTestSynchronizeAnimationStartTimes
+ : public LayerTreeHostTimelinesTest {
+ public:
+ LayerTreeHostTimelinesTestSynchronizeAnimationStartTimes() {}
+
+ void SetupTree() override {
+ LayerTreeHostTimelinesTest::SetupTree();
+ picture_ = FakePictureLayer::Create(layer_settings(), &client_);
+ picture_->SetBounds(gfx::Size(4, 4));
+
+ layer_tree_host()->root_layer()->AddChild(picture_);
+
+ AttachPlayersToTimeline();
+ player_child_->set_layer_animation_delegate(this);
+ player_child_->AttachLayer(picture_->id());
+ }
+
+ void BeginTest() override {
+ PostAddAnimationToMainThreadPlayer(player_child_.get());
+ }
+
+ void NotifyAnimationStarted(base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property,
+ int group) override {
+ LayerAnimationController* controller =
+ player_child_->element_animations()->layer_animation_controller();
+ Animation* animation = controller->GetAnimation(Animation::OPACITY);
+ main_start_time_ = animation->start_time();
+ controller->RemoveAnimation(animation->id());
+ EndTest();
+ }
+
+ void UpdateAnimationState(LayerTreeHostImpl* impl_host,
+ bool has_unfinished_animation) override {
+ scoped_refptr<AnimationTimeline> timeline_impl =
+ impl_host->animation_host()->GetTimelineById(timeline_id_);
+ scoped_refptr<AnimationPlayer> player_child_impl =
+ timeline_impl->GetPlayerById(player_child_id_);
+
+ LayerAnimationController* controller =
+ player_child_impl->element_animations()->layer_animation_controller();
+ Animation* animation = controller->GetAnimation(Animation::OPACITY);
+ if (!animation)
+ return;
+
+ impl_start_time_ = animation->start_time();
+ }
+
+ void AfterTest() override {
+ EXPECT_EQ(impl_start_time_, main_start_time_);
+ EXPECT_LT(base::TimeTicks(), impl_start_time_);
+ }
+
+ private:
+ base::TimeTicks main_start_time_;
+ base::TimeTicks impl_start_time_;
+ FakeContentLayerClient client_;
+ scoped_refptr<FakePictureLayer> picture_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostTimelinesTestSynchronizeAnimationStartTimes);
+
+// Ensures that notify animation finished is called.
+// Evolved from LayerTreeHostAnimationTestAnimationFinishedEvents.
+class LayerTreeHostTimelinesTestAnimationFinishedEvents
+ : public LayerTreeHostTimelinesTest {
+ public:
+ LayerTreeHostTimelinesTestAnimationFinishedEvents() {}
+
+ void BeginTest() override {
+ AttachPlayersToTimeline();
+ player_->AttachLayer(layer_tree_host()->root_layer()->id());
+ PostAddInstantAnimationToMainThreadPlayer(player_.get());
+ }
+
+ void NotifyAnimationFinished(base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property,
+ int group) override {
+ LayerAnimationController* controller =
+ player_->element_animations()->layer_animation_controller();
+ Animation* animation = controller->GetAnimation(Animation::OPACITY);
+ if (animation)
+ controller->RemoveAnimation(animation->id());
+ EndTest();
+ }
+
+ void AfterTest() override {}
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostTimelinesTestAnimationFinishedEvents);
+
+// Ensures that when opacity is being animated, this value does not cause the
+// subtree to be skipped.
+// Evolved from LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity.
+class LayerTreeHostTimelinesTestDoNotSkipLayersWithAnimatedOpacity
+ : public LayerTreeHostTimelinesTest {
+ public:
+ LayerTreeHostTimelinesTestDoNotSkipLayersWithAnimatedOpacity()
+ : update_check_layer_(
+ FakePictureLayer::Create(layer_settings(), &client_)) {}
+
+ void SetupTree() override {
+ update_check_layer_->SetOpacity(0.f);
+ layer_tree_host()->SetRootLayer(update_check_layer_);
+ LayerTreeHostTimelinesTest::SetupTree();
+
+ AttachPlayersToTimeline();
+ player_->AttachLayer(update_check_layer_->id());
+ }
+
+ void BeginTest() override {
+ PostAddAnimationToMainThreadPlayer(player_.get());
+ }
+
+ void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
+ scoped_refptr<AnimationTimeline> timeline_impl =
+ host_impl->animation_host()->GetTimelineById(timeline_id_);
+ scoped_refptr<AnimationPlayer> player_impl =
+ timeline_impl->GetPlayerById(player_id_);
+
+ LayerAnimationController* controller_impl =
+ player_impl->element_animations()->layer_animation_controller();
+ Animation* animation_impl =
+ controller_impl->GetAnimation(Animation::OPACITY);
+ controller_impl->RemoveAnimation(animation_impl->id());
+ EndTest();
+ }
+
+ void AfterTest() override {
+ // Update() should have been called once, proving that the layer was not
+ // skipped.
+ EXPECT_EQ(1, update_check_layer_->update_count());
+
+ // clear update_check_layer_ so LayerTreeHost dies.
+ update_check_layer_ = NULL;
+ }
+
+ private:
+ FakeContentLayerClient client_;
+ scoped_refptr<FakePictureLayer> update_check_layer_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostTimelinesTestDoNotSkipLayersWithAnimatedOpacity);
+
+// Layers added to tree with existing active animations should have the
+// animation correctly recognized.
+// Evolved from LayerTreeHostAnimationTestLayerAddedWithAnimation.
+class LayerTreeHostTimelinesTestLayerAddedWithAnimation
+ : public LayerTreeHostTimelinesTest {
+ public:
+ LayerTreeHostTimelinesTestLayerAddedWithAnimation() {}
+
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ void DidCommit() override {
+ if (layer_tree_host()->source_frame_number() == 1) {
+ AttachPlayersToTimeline();
+
+ scoped_refptr<Layer> layer = Layer::Create(layer_settings());
+ player_->AttachLayer(layer->id());
+ player_->set_layer_animation_delegate(this);
+
+ // Any valid AnimationCurve will do here.
+ scoped_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve());
+ scoped_ptr<Animation> animation(
+ Animation::Create(curve.Pass(), 1, 1, Animation::OPACITY));
+ player_->AddAnimation(animation.Pass());
+
+ // We add the animation *before* attaching the layer to the tree.
+ layer_tree_host()->root_layer()->AddChild(layer);
+ }
+ }
+
+ void AnimateLayers(LayerTreeHostImpl* impl_host,
+ base::TimeTicks monotonic_time) override {
+ EndTest();
+ }
+
+ void AfterTest() override {}
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostTimelinesTestLayerAddedWithAnimation);
+
+// Make sure the main thread can still execute animations when CanDraw() is not
+// true.
+// Evolved from LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw
+class LayerTreeHostTimelinesTestRunAnimationWhenNotCanDraw
+ : public LayerTreeHostTimelinesTest {
+ public:
+ LayerTreeHostTimelinesTestRunAnimationWhenNotCanDraw() : started_times_(0) {}
+
+ void SetupTree() override {
+ LayerTreeHostTimelinesTest::SetupTree();
+ picture_ = FakePictureLayer::Create(layer_settings(), &client_);
+ picture_->SetBounds(gfx::Size(4, 4));
+ layer_tree_host()->root_layer()->AddChild(picture_);
+
+ AttachPlayersToTimeline();
+ player_child_->AttachLayer(picture_->id());
+ player_child_->set_layer_animation_delegate(this);
+ }
+
+ void BeginTest() override {
+ layer_tree_host()->SetViewportSize(gfx::Size());
+ PostAddAnimationToMainThreadPlayer(player_child_.get());
+ }
+
+ void NotifyAnimationStarted(base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property,
+ int group) override {
+ started_times_++;
+ }
+
+ void NotifyAnimationFinished(base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property,
+ int group) override {
+ EndTest();
+ }
+
+ void AfterTest() override { EXPECT_EQ(1, started_times_); }
+
+ private:
+ int started_times_;
+ FakeContentLayerClient client_;
+ scoped_refptr<FakePictureLayer> picture_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostTimelinesTestRunAnimationWhenNotCanDraw);
+
+// Animations should not be started when frames are being skipped due to
+// checkerboard.
+// Evolved from LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations.
+class LayerTreeHostTimelinesTestCheckerboardDoesntStartAnimations
+ : public LayerTreeHostTimelinesTest {
+ void SetupTree() override {
+ LayerTreeHostTimelinesTest::SetupTree();
+ picture_ = FakePictureLayer::Create(layer_settings(), &client_);
+ picture_->SetBounds(gfx::Size(4, 4));
+ layer_tree_host()->root_layer()->AddChild(picture_);
+
+ AttachPlayersToTimeline();
+ player_child_->AttachLayer(picture_->id());
+ player_child_->set_layer_animation_delegate(this);
+ }
+
+ void InitializeSettings(LayerTreeSettings* settings) override {
+ // Make sure that drawing many times doesn't cause a checkerboarded
+ // animation to start so we avoid flake in this test.
+ settings->timeout_and_draw_when_animation_checkerboards = false;
+ LayerTreeHostTimelinesTest::InitializeSettings(settings);
+ }
+
+ void BeginTest() override {
+ prevented_draw_ = 0;
+ added_animations_ = 0;
+ started_times_ = 0;
+
+ PostSetNeedsCommitToMainThread();
+ }
+
+ DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
+ LayerTreeHostImpl::FrameData* frame_data,
+ DrawResult draw_result) override {
+ if (added_animations_ < 2)
+ return draw_result;
+ if (TestEnded())
+ return draw_result;
+ // Act like there is checkerboard when the second animation wants to draw.
+ ++prevented_draw_;
+ if (prevented_draw_ > 2)
+ EndTest();
+ return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
+ }
+
+ void DidCommitAndDrawFrame() override {
+ switch (layer_tree_host()->source_frame_number()) {
+ case 1:
+ // The animation is longer than 1 BeginFrame interval.
+ AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 0.2f, 0.8f,
+ false);
+ added_animations_++;
+ break;
+ case 2:
+ // This second animation will not be drawn so it should not start.
+ AddAnimatedTransformToPlayer(player_child_.get(), 0.1, 5, 5);
+ added_animations_++;
+ break;
+ }
+ }
+
+ void NotifyAnimationStarted(base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property,
+ int group) override {
+ if (TestEnded())
+ return;
+ started_times_++;
+ }
+
+ void AfterTest() override {
+ // Make sure we tried to draw the second animation but failed.
+ EXPECT_LT(0, prevented_draw_);
+ // The first animation should be started, but the second should not because
+ // of checkerboard.
+ EXPECT_EQ(1, started_times_);
+ }
+
+ int prevented_draw_;
+ int added_animations_;
+ int started_times_;
+ FakeContentLayerClient client_;
+ scoped_refptr<FakePictureLayer> picture_;
+};
+
+MULTI_THREAD_TEST_F(
+ LayerTreeHostTimelinesTestCheckerboardDoesntStartAnimations);
+
+// Verifies that scroll offset animations are only accepted when impl-scrolling
+// is supported, and that when scroll offset animations are accepted,
+// scroll offset updates are sent back to the main thread.
+// Evolved from LayerTreeHostAnimationTestScrollOffsetChangesArePropagated
+class LayerTreeHostTimelinesTestScrollOffsetChangesArePropagated
+ : public LayerTreeHostTimelinesTest {
+ public:
+ LayerTreeHostTimelinesTestScrollOffsetChangesArePropagated() {}
+
+ void SetupTree() override {
+ LayerTreeHostTimelinesTest::SetupTree();
+
+ scroll_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
+ scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id());
+ scroll_layer_->SetBounds(gfx::Size(1000, 1000));
+ scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
+ layer_tree_host()->root_layer()->AddChild(scroll_layer_);
+
+ AttachPlayersToTimeline();
+ player_child_->AttachLayer(scroll_layer_->id());
+ }
+
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ void DidCommit() override {
+ switch (layer_tree_host()->source_frame_number()) {
+ case 1: {
+ scoped_ptr<ScrollOffsetAnimationCurve> curve(
+ ScrollOffsetAnimationCurve::Create(
+ gfx::ScrollOffset(500.f, 550.f),
+ EaseInOutTimingFunction::Create()));
+ scoped_ptr<Animation> animation(
+ Animation::Create(curve.Pass(), 1, 0, Animation::SCROLL_OFFSET));
+ animation->set_needs_synchronized_start_time(true);
+ bool impl_scrolling_supported =
+ layer_tree_host()->proxy()->SupportsImplScrolling();
+ if (impl_scrolling_supported)
+ player_child_->AddAnimation(animation.Pass());
+ else
+ EndTest();
+ break;
+ }
+ default:
+ if (scroll_layer_->scroll_offset().x() > 10 &&
+ scroll_layer_->scroll_offset().y() > 20)
+ EndTest();
+ }
+ }
+
+ void AfterTest() override {}
+
+ private:
+ FakeContentLayerClient client_;
+ scoped_refptr<FakePictureLayer> scroll_layer_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostTimelinesTestScrollOffsetChangesArePropagated);
+
+// Verifies that when the main thread removes a scroll animation and sets a new
+// scroll position, the active tree takes on exactly this new scroll position
+// after activation, and the main thread doesn't receive a spurious scroll
+// delta.
+// Evolved from LayerTreeHostAnimationTestScrollOffsetAnimationRemoval
+class LayerTreeHostTimelinesTestScrollOffsetAnimationRemoval
+ : public LayerTreeHostTimelinesTest {
+ public:
+ LayerTreeHostTimelinesTestScrollOffsetAnimationRemoval()
+ : final_postion_(50.0, 100.0) {}
+
+ void SetupTree() override {
+ LayerTreeHostTimelinesTest::SetupTree();
+
+ scroll_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
+ scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id());
+ scroll_layer_->SetBounds(gfx::Size(10000, 10000));
+ scroll_layer_->SetScrollOffset(gfx::ScrollOffset(100.0, 200.0));
+ layer_tree_host()->root_layer()->AddChild(scroll_layer_);
+
+ scoped_ptr<ScrollOffsetAnimationCurve> curve(
+ ScrollOffsetAnimationCurve::Create(gfx::ScrollOffset(6500.f, 7500.f),
+ EaseInOutTimingFunction::Create()));
+ scoped_ptr<Animation> animation(
+ Animation::Create(curve.Pass(), 1, 0, Animation::SCROLL_OFFSET));
+ animation->set_needs_synchronized_start_time(true);
+
+ AttachPlayersToTimeline();
+ player_child_->AttachLayer(scroll_layer_->id());
+ player_child_->AddAnimation(animation.Pass());
+ }
+
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ void BeginMainFrame(const BeginFrameArgs& args) override {
+ switch (layer_tree_host()->source_frame_number()) {
+ case 0:
+ break;
+ case 1: {
+ Animation* animation = player_child_->element_animations()
+ ->layer_animation_controller()
+ ->GetAnimation(Animation::SCROLL_OFFSET);
+ player_child_->RemoveAnimation(animation->id());
+ scroll_layer_->SetScrollOffset(final_postion_);
+ break;
+ }
+ default:
+ EXPECT_EQ(final_postion_, scroll_layer_->scroll_offset());
+ }
+ }
+
+ void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override {
+ host_impl->BlockNotifyReadyToActivateForTesting(true);
+ }
+
+ void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl,
+ const BeginFrameArgs& args) override {
+ if (!host_impl->pending_tree())
+ return;
+
+ if (!host_impl->active_tree()->root_layer()) {
+ host_impl->BlockNotifyReadyToActivateForTesting(false);
+ return;
+ }
+
+ scoped_refptr<AnimationTimeline> timeline_impl =
+ host_impl->animation_host()->GetTimelineById(timeline_id_);
+ scoped_refptr<AnimationPlayer> player_impl =
+ timeline_impl->GetPlayerById(player_child_id_);
+
+ LayerImpl* scroll_layer_impl =
+ host_impl->active_tree()->root_layer()->children()[0];
+ Animation* animation = player_impl->element_animations()
+ ->layer_animation_controller()
+ ->GetAnimation(Animation::SCROLL_OFFSET);
+
+ if (!animation || animation->run_state() != Animation::RUNNING) {
+ host_impl->BlockNotifyReadyToActivateForTesting(false);
+ return;
+ }
+
+ // Block activation until the running animation has a chance to produce a
+ // scroll delta.
+ gfx::Vector2dF scroll_delta = scroll_layer_impl->ScrollDelta();
+ if (scroll_delta.x() < 1.f || scroll_delta.y() < 1.f)
+ return;
+
+ host_impl->BlockNotifyReadyToActivateForTesting(false);
+ }
+
+ void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
+ if (host_impl->pending_tree()->source_frame_number() != 1)
+ return;
+ LayerImpl* scroll_layer_impl =
+ host_impl->pending_tree()->root_layer()->children()[0];
+ EXPECT_EQ(final_postion_, scroll_layer_impl->CurrentScrollOffset());
+ }
+
+ void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
+ if (host_impl->active_tree()->source_frame_number() != 1)
+ return;
+ LayerImpl* scroll_layer_impl =
+ host_impl->active_tree()->root_layer()->children()[0];
+ EXPECT_EQ(final_postion_, scroll_layer_impl->CurrentScrollOffset());
+ EndTest();
+ }
+
+ void AfterTest() override {
+ EXPECT_EQ(final_postion_, scroll_layer_->scroll_offset());
+ }
+
+ private:
+ FakeContentLayerClient client_;
+ scoped_refptr<FakePictureLayer> scroll_layer_;
+ const gfx::ScrollOffset final_postion_;
+};
+
+MULTI_THREAD_TEST_F(LayerTreeHostTimelinesTestScrollOffsetAnimationRemoval);
+
+// When animations are simultaneously added to an existing layer and to a new
+// layer, they should start at the same time, even when there's already a
+// running animation on the existing layer.
+// Evolved from LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers.
+class LayerTreeHostTimelinesTestAnimationsAddedToNewAndExistingLayers
+ : public LayerTreeHostTimelinesTest {
+ public:
+ LayerTreeHostTimelinesTestAnimationsAddedToNewAndExistingLayers()
+ : frame_count_with_pending_tree_(0) {}
+
+ void BeginTest() override {
+ AttachPlayersToTimeline();
+ PostSetNeedsCommitToMainThread();
+ }
+
+ void DidCommit() override {
+ if (layer_tree_host()->source_frame_number() == 1) {
+ player_->AttachLayer(layer_tree_host()->root_layer()->id());
+ AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1);
+ } else if (layer_tree_host()->source_frame_number() == 2) {
+ AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true);
+
+ scoped_refptr<Layer> layer = Layer::Create(layer_settings());
+ layer_tree_host()->root_layer()->AddChild(layer);
+ layer->SetBounds(gfx::Size(4, 4));
+
+ player_child_->AttachLayer(layer->id());
+ player_child_->set_layer_animation_delegate(this);
+ AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true);
+ }
+ }
+
+ void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override {
+ host_impl->BlockNotifyReadyToActivateForTesting(true);
+ }
+
+ void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
+ // For the commit that added animations to new and existing layers, keep
+ // blocking activation. We want to verify that even with activation blocked,
+ // the animation on the layer that's already in the active tree won't get a
+ // head start.
+ if (host_impl->pending_tree()->source_frame_number() != 2) {
+ host_impl->BlockNotifyReadyToActivateForTesting(false);
+ }
+ }
+
+ void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl,
+ const BeginFrameArgs& args) override {
+ if (!host_impl->pending_tree() ||
+ host_impl->pending_tree()->source_frame_number() != 2)
+ return;
+
+ frame_count_with_pending_tree_++;
+ if (frame_count_with_pending_tree_ == 2) {
+ host_impl->BlockNotifyReadyToActivateForTesting(false);
+ }
+ }
+
+ void UpdateAnimationState(LayerTreeHostImpl* host_impl,
+ bool has_unfinished_animation) override {
+ scoped_refptr<AnimationTimeline> timeline_impl =
+ host_impl->animation_host()->GetTimelineById(timeline_id_);
+ scoped_refptr<AnimationPlayer> player_impl =
+ timeline_impl->GetPlayerById(player_id_);
+ scoped_refptr<AnimationPlayer> player_child_impl =
+ timeline_impl->GetPlayerById(player_child_id_);
+
+ // wait for tree activation.
+ if (!player_impl->element_animations())
+ return;
+
+ LayerAnimationController* root_controller_impl =
+ player_impl->element_animations()->layer_animation_controller();
+ Animation* root_animation =
+ root_controller_impl->GetAnimation(Animation::OPACITY);
+ if (!root_animation || root_animation->run_state() != Animation::RUNNING)
+ return;
+
+ LayerAnimationController* child_controller_impl =
+ player_child_impl->element_animations()->layer_animation_controller();
+ Animation* child_animation =
+ child_controller_impl->GetAnimation(Animation::OPACITY);
+ EXPECT_EQ(Animation::RUNNING, child_animation->run_state());
+ EXPECT_EQ(root_animation->start_time(), child_animation->start_time());
+ root_controller_impl->AbortAnimations(Animation::OPACITY);
+ root_controller_impl->AbortAnimations(Animation::TRANSFORM);
+ child_controller_impl->AbortAnimations(Animation::OPACITY);
+ EndTest();
+ }
+
+ void AfterTest() override {}
+
+ private:
+ int frame_count_with_pending_tree_;
+};
+
+// This test blocks activation which is not supported for single thread mode.
+MULTI_THREAD_BLOCKNOTIFY_TEST_F(
+ LayerTreeHostTimelinesTestAnimationsAddedToNewAndExistingLayers);
+
+// Evolved from LayerTreeHostAnimationTestAddAnimationAfterAnimating.
+class LayerTreeHostTimelinesTestAddAnimationAfterAnimating
+ : public LayerTreeHostTimelinesTest {
+ public:
+ void SetupTree() override {
+ LayerTreeHostTimelinesTest::SetupTree();
+ content_ = Layer::Create(layer_settings());
+ content_->SetBounds(gfx::Size(4, 4));
+ layer_tree_host()->root_layer()->AddChild(content_);
+
+ AttachPlayersToTimeline();
+
+ player_->AttachLayer(layer_tree_host()->root_layer()->id());
+ player_child_->AttachLayer(content_->id());
+ }
+
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ void DidCommit() override {
+ switch (layer_tree_host()->source_frame_number()) {
+ case 1:
+ // First frame: add an animation to the root layer.
+ AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5);
+ break;
+ case 2:
+ // Second frame: add an animation to the content layer. The root layer
+ // animation has caused us to animate already during this frame.
+ AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 5, 5, false);
+ break;
+ }
+ }
+
+ void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
+ // After both animations have started, verify that they have valid
+ // start times.
+ if (host_impl->active_tree()->source_frame_number() < 2)
+ return;
+ AnimationRegistrar::AnimationControllerMap controllers_copy =
+ host_impl->animation_host()
+ ->animation_registrar()
+ ->active_animation_controllers_for_testing();
+ EXPECT_EQ(2u, controllers_copy.size());
+ for (auto& it : controllers_copy) {
+ int id = it.first;
+ if (id == host_impl->RootLayer()->id()) {
+ Animation* anim = it.second->GetAnimation(Animation::TRANSFORM);
+ EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
+ } else if (id == host_impl->RootLayer()->children()[0]->id()) {
+ Animation* anim = it.second->GetAnimation(Animation::OPACITY);
+ EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
+ }
+ EndTest();
+ }
+ }
+
+ void AfterTest() override {}
+
+ private:
+ scoped_refptr<Layer> content_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostTimelinesTestAddAnimationAfterAnimating);
+
+} // namespace
+} // namespace cc
diff --git a/chromium/cc/trees/layer_tree_host_unittest_context.cc b/chromium/cc/trees/layer_tree_host_unittest_context.cc
index 82e47b89b0e..d25d047d0a7 100644
--- a/chromium/cc/trees/layer_tree_host_unittest_context.cc
+++ b/chromium/cc/trees/layer_tree_host_unittest_context.cc
@@ -5,7 +5,6 @@
#include "cc/trees/layer_tree_host.h"
#include "base/basictypes.h"
-#include "cc/layers/content_layer.h"
#include "cc/layers/delegated_frame_provider.h"
#include "cc/layers/delegated_frame_resource_collection.h"
#include "cc/layers/heads_up_display_layer.h"
@@ -20,9 +19,7 @@
#include "cc/output/filter_operations.h"
#include "cc/resources/single_release_callback.h"
#include "cc/test/failure_output_surface.h"
-#include "cc/test/fake_content_layer.h"
#include "cc/test/fake_content_layer_client.h"
-#include "cc/test/fake_content_layer_impl.h"
#include "cc/test/fake_delegated_renderer_layer.h"
#include "cc/test/fake_delegated_renderer_layer_impl.h"
#include "cc/test/fake_layer_tree_host_client.h"
@@ -31,6 +28,7 @@
#include "cc/test/fake_painted_scrollbar_layer.h"
#include "cc/test/fake_picture_layer.h"
#include "cc/test/fake_picture_layer_impl.h"
+#include "cc/test/fake_resource_provider.h"
#include "cc/test/fake_scoped_ui_resource.h"
#include "cc/test/fake_scrollbar.h"
#include "cc/test/fake_video_frame_provider.h"
@@ -70,6 +68,9 @@ class LayerTreeHostContextTest : public LayerTreeTest {
}
void LoseContext() {
+ // CreateFakeOutputSurface happens on a different thread, so lock context3d_
+ // to make sure we don't set it to null after recreating it there.
+ base::AutoLock lock(context3d_lock_);
// For sanity-checking tests, they should only call this when the
// context is not lost.
CHECK(context3d_);
@@ -90,6 +91,7 @@ class LayerTreeHostContextTest : public LayerTreeTest {
}
scoped_ptr<TestWebGraphicsContext3D> context3d = CreateContext3d();
+ base::AutoLock lock(context3d_lock_);
context3d_ = context3d.get();
if (context_should_support_io_surface_) {
@@ -107,10 +109,9 @@ class LayerTreeHostContextTest : public LayerTreeTest {
LayerTreeHostImpl::FrameData* frame,
DrawResult draw_result) override {
if (draw_result == DRAW_ABORTED_MISSING_HIGH_RES_CONTENT) {
- // Only valid for single-threaded impl-side painting, which activates
+ // Only valid for single-threaded compositing, which activates
// immediately and will try to draw again when content has finished.
DCHECK(!host_impl->proxy()->HasImplThread());
- DCHECK(host_impl->settings().impl_side_painting);
return draw_result;
}
EXPECT_EQ(DRAW_SUCCESS, draw_result);
@@ -148,7 +149,11 @@ class LayerTreeHostContextTest : public LayerTreeTest {
void ExpectCreateToFail() { ++times_to_expect_create_failed_; }
protected:
+ // Protects use of context3d_ so LoseContext and CreateFakeOutputSurface
+ // can both use it on different threads.
+ base::Lock context3d_lock_;
TestWebGraphicsContext3D* context3d_;
+
int times_to_fail_create_;
int times_to_lose_during_commit_;
int times_to_lose_during_draw_;
@@ -385,6 +390,8 @@ class MultipleCompositeDoesNotCreateOutputSurface
void InitializeSettings(LayerTreeSettings* settings) override {
settings->single_thread_proxy_scheduler = false;
+ settings->use_zero_copy = true;
+ settings->use_one_copy = false;
}
void RequestNewOutputSurface() override {
@@ -393,8 +400,8 @@ class MultipleCompositeDoesNotCreateOutputSurface
}
void BeginTest() override {
- layer_tree_host()->Composite(base::TimeTicks());
- layer_tree_host()->Composite(base::TimeTicks());
+ layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(1));
+ layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(2));
}
scoped_ptr<OutputSurface> CreateOutputSurface() override {
@@ -409,7 +416,8 @@ class MultipleCompositeDoesNotCreateOutputSurface
int request_count_;
};
-SINGLE_THREAD_NOIMPL_TEST_F(MultipleCompositeDoesNotCreateOutputSurface);
+// This test uses Composite() which only exists for single thread.
+SINGLE_THREAD_TEST_F(MultipleCompositeDoesNotCreateOutputSurface);
// This test makes sure that once a SingleThreadProxy issues a
// DidFailToInitializeOutputSurface, that future Composite calls will not
@@ -422,6 +430,8 @@ class FailedCreateDoesNotCreateExtraOutputSurface
void InitializeSettings(LayerTreeSettings* settings) override {
settings->single_thread_proxy_scheduler = false;
+ settings->use_zero_copy = true;
+ settings->use_one_copy = false;
}
void RequestNewOutputSurface() override {
@@ -439,12 +449,12 @@ class FailedCreateDoesNotCreateExtraOutputSurface
void BeginTest() override {
// First composite tries to create a surface.
- layer_tree_host()->Composite(base::TimeTicks());
+ layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(1));
EXPECT_EQ(num_requests_, 2);
EXPECT_TRUE(has_failed_);
// Second composite should not request or fail.
- layer_tree_host()->Composite(base::TimeTicks());
+ layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(2));
EXPECT_EQ(num_requests_, 2);
EndTest();
}
@@ -463,7 +473,8 @@ class FailedCreateDoesNotCreateExtraOutputSurface
bool has_failed_;
};
-SINGLE_THREAD_NOIMPL_TEST_F(FailedCreateDoesNotCreateExtraOutputSurface);
+// This test uses Composite() which only exists for single thread.
+SINGLE_THREAD_TEST_F(FailedCreateDoesNotCreateExtraOutputSurface);
class LayerTreeHostContextTestCommitAfterDelayedOutputSurface
: public LayerTreeHostContextTest {
@@ -473,6 +484,8 @@ class LayerTreeHostContextTestCommitAfterDelayedOutputSurface
void InitializeSettings(LayerTreeSettings* settings) override {
settings->single_thread_proxy_scheduler = false;
+ settings->use_zero_copy = true;
+ settings->use_one_copy = false;
}
void RequestNewOutputSurface() override {
@@ -489,7 +502,9 @@ class LayerTreeHostContextTestCommitAfterDelayedOutputSurface
LayerTreeHostContextTest::CreateOutputSurface());
}
- void BeginTest() override { layer_tree_host()->Composite(base::TimeTicks()); }
+ void BeginTest() override {
+ layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(1));
+ }
void ScheduleComposite() override {
if (creating_output_)
@@ -501,8 +516,8 @@ class LayerTreeHostContextTestCommitAfterDelayedOutputSurface
bool creating_output_;
};
-SINGLE_THREAD_NOIMPL_TEST_F(
- LayerTreeHostContextTestCommitAfterDelayedOutputSurface);
+// This test uses Composite() which only exists for single thread.
+SINGLE_THREAD_TEST_F(LayerTreeHostContextTestCommitAfterDelayedOutputSurface);
class LayerTreeHostContextTestAvoidUnnecessaryComposite
: public LayerTreeHostContextTest {
@@ -512,6 +527,8 @@ class LayerTreeHostContextTestAvoidUnnecessaryComposite
void InitializeSettings(LayerTreeSettings* settings) override {
settings->single_thread_proxy_scheduler = false;
+ settings->use_zero_copy = true;
+ settings->use_one_copy = false;
}
void RequestNewOutputSurface() override {
@@ -522,7 +539,7 @@ class LayerTreeHostContextTestAvoidUnnecessaryComposite
void BeginTest() override {
in_composite_ = true;
- layer_tree_host()->Composite(base::TimeTicks());
+ layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(1));
in_composite_ = false;
}
@@ -533,13 +550,15 @@ class LayerTreeHostContextTestAvoidUnnecessaryComposite
bool in_composite_;
};
-SINGLE_THREAD_NOIMPL_TEST_F(LayerTreeHostContextTestAvoidUnnecessaryComposite);
+// This test uses Composite() which only exists for single thread.
+SINGLE_THREAD_TEST_F(LayerTreeHostContextTestAvoidUnnecessaryComposite);
+// This test uses PictureLayer to check for a working context.
class LayerTreeHostContextTestLostContextSucceedsWithContent
: public LayerTreeHostContextTestLostContextSucceeds {
public:
void SetupTree() override {
- root_ = Layer::Create();
+ root_ = Layer::Create(layer_settings());
root_->SetBounds(gfx::Size(10, 10));
root_->SetIsDrawable(true);
@@ -548,10 +567,7 @@ class LayerTreeHostContextTestLostContextSucceedsWithContent
paint.setColor(SkColorSetARGB(100, 80, 200, 200));
client_.add_draw_rect(gfx::Rect(0, 0, 5, 5), paint);
- if (layer_tree_host()->settings().impl_side_painting)
- layer_ = FakePictureLayer::Create(&client_);
- else
- layer_ = FakeContentLayer::Create(&client_);
+ layer_ = FakePictureLayer::Create(layer_settings(), &client_);
layer_->SetBounds(gfx::Size(10, 10));
layer_->SetIsDrawable(true);
@@ -570,21 +586,12 @@ class LayerTreeHostContextTestLostContextSucceedsWithContent
}
void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
- if (!host_impl->settings().impl_side_painting) {
- FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>(
- host_impl->active_tree()->root_layer()->children()[0]);
- // Even though the context was lost, we should have a resource. The
- // TestWebGraphicsContext3D ensures that this resource is created with
- // the active context.
- EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0));
- } else {
- FakePictureLayerImpl* picture_impl = static_cast<FakePictureLayerImpl*>(
- host_impl->active_tree()->root_layer()->children()[0]);
- EXPECT_TRUE(picture_impl->HighResTiling()
- ->TileAt(0, 0)
- ->draw_info()
- .IsReadyToDraw());
- }
+ FakePictureLayerImpl* picture_impl = static_cast<FakePictureLayerImpl*>(
+ host_impl->active_tree()->root_layer()->children()[0]);
+ EXPECT_TRUE(picture_impl->HighResTiling()
+ ->TileAt(0, 0)
+ ->draw_info()
+ .IsReadyToDraw());
}
protected:
@@ -593,7 +600,6 @@ class LayerTreeHostContextTestLostContextSucceedsWithContent
scoped_refptr<Layer> layer_;
};
-// This test uses TiledLayer and PictureLayer to check for a working context.
SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostContextTestLostContextSucceedsWithContent);
@@ -639,15 +645,10 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
paint.setColor(SkColorSetARGB(100, 80, 200, 200));
client_.add_draw_rect(gfx::Rect(0, 0, 5, 5), paint);
- if (layer_tree_host()->settings().impl_side_painting) {
- picture_layer_ = FakePictureLayer::Create(&client_);
- picture_layer_->SetBounds(gfx::Size(10, 20));
- layer_tree_host()->SetRootLayer(picture_layer_);
- } else {
- content_layer_ = FakeContentLayer::Create(&client_);
- content_layer_->SetBounds(gfx::Size(10, 20));
- layer_tree_host()->SetRootLayer(content_layer_);
- }
+ scoped_refptr<FakePictureLayer> picture_layer =
+ FakePictureLayer::Create(layer_settings(), &client_);
+ picture_layer->SetBounds(gfx::Size(10, 20));
+ layer_tree_host()->SetRootLayer(picture_layer);
LayerTreeHostContextTest::SetupTree();
}
@@ -679,9 +680,6 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
void DidCommitAndDrawFrame() override {
if (num_commits_ > 1)
return;
- if (!layer_tree_host()->settings().impl_side_painting) {
- EXPECT_TRUE(content_layer_->HaveBackingAt(0, 0));
- }
PostEvictTextures();
}
@@ -697,18 +695,12 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
}
void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
- if (impl->settings().impl_side_painting) {
- FakePictureLayerImpl* picture_impl =
- static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer());
- EXPECT_TRUE(picture_impl->HighResTiling()
- ->TileAt(0, 0)
- ->draw_info()
- .IsReadyToDraw());
- } else {
- FakeContentLayerImpl* content_impl =
- static_cast<FakeContentLayerImpl*>(impl->active_tree()->root_layer());
- EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0));
- }
+ FakePictureLayerImpl* picture_impl =
+ static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer());
+ EXPECT_TRUE(picture_impl->HighResTiling()
+ ->TileAt(0, 0)
+ ->draw_info()
+ .IsReadyToDraw());
impl_host_ = impl;
if (lost_context_)
@@ -722,8 +714,6 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
protected:
bool lose_after_evict_;
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> content_layer_;
- scoped_refptr<FakePictureLayer> picture_layer_;
LayerTreeHostImpl* impl_host_;
int num_commits_;
bool lost_context_;
@@ -732,143 +722,60 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
LoseAfterEvict_SingleThread_DirectRenderer) {
lose_after_evict_ = true;
- RunTest(false, false, false);
+ RunTest(false, false);
}
TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
LoseAfterEvict_SingleThread_DelegatingRenderer) {
lose_after_evict_ = true;
- RunTest(false, true, false);
+ RunTest(false, true);
}
TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
- LoseAfterEvict_MultiThread_DirectRenderer_MainThreadPaint) {
+ LoseAfterEvict_MultiThread_DirectRenderer) {
lose_after_evict_ = true;
- RunTest(true, false, false);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
- LoseAfterEvict_MultiThread_DelegatingRenderer_MainThreadPaint) {
+ LoseAfterEvict_MultiThread_DelegatingRenderer) {
lose_after_evict_ = true;
- RunTest(true, true, false);
-}
-
-// Flaky on all platforms, http://crbug.com/310979
-TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
- DISABLED_LoseAfterEvict_MultiThread_DelegatingRenderer_ImplSidePaint) {
- lose_after_evict_ = true;
- RunTest(true, true, true);
+ RunTest(true, true);
}
TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
LoseBeforeEvict_SingleThread_DirectRenderer) {
lose_after_evict_ = false;
- RunTest(false, false, false);
+ RunTest(false, false);
}
TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
LoseBeforeEvict_SingleThread_DelegatingRenderer) {
lose_after_evict_ = false;
- RunTest(false, true, false);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
- LoseBeforeEvict_MultiThread_DirectRenderer_MainThreadPaint) {
- lose_after_evict_ = false;
- RunTest(true, false, false);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
- LoseBeforeEvict_MultiThread_DirectRenderer_ImplSidePaint) {
- lose_after_evict_ = false;
- RunTest(true, false, true);
+ RunTest(false, true);
}
TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
- LoseBeforeEvict_MultiThread_DelegatingRenderer_MainThreadPaint) {
+ LoseBeforeEvict_MultiThread_DirectRenderer) {
lose_after_evict_ = false;
- RunTest(true, true, false);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
- LoseBeforeEvict_MultiThread_DelegatingRenderer_ImplSidePaint) {
+ LoseBeforeEvict_MultiThread_DelegatingRenderer) {
lose_after_evict_ = false;
- RunTest(true, true, true);
+ RunTest(true, true);
}
-class LayerTreeHostContextTestLostContextWhileUpdatingResources
- : public LayerTreeHostContextTest {
- public:
- LayerTreeHostContextTestLostContextWhileUpdatingResources()
- : num_children_(50), times_to_lose_on_end_query_(3) {}
-
- scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() override {
- scoped_ptr<TestWebGraphicsContext3D> context =
- LayerTreeHostContextTest::CreateContext3d();
- if (times_to_lose_on_end_query_) {
- --times_to_lose_on_end_query_;
- context->set_times_end_query_succeeds(5);
- }
- return context.Pass();
- }
-
- void SetupTree() override {
- if (layer_tree_host()->settings().impl_side_painting)
- parent_ = FakePictureLayer::Create(&client_);
- else
- parent_ = FakeContentLayer::Create(&client_);
-
- parent_->SetBounds(gfx::Size(num_children_, 1));
-
- for (int i = 0; i < num_children_; i++) {
- scoped_refptr<Layer> child;
- if (layer_tree_host()->settings().impl_side_painting)
- child = FakePictureLayer::Create(&client_);
- else
- child = FakeContentLayer::Create(&client_);
- child->SetPosition(gfx::PointF(i, 0.f));
- child->SetBounds(gfx::Size(1, 1));
- parent_->AddChild(child);
- }
-
- layer_tree_host()->SetRootLayer(parent_);
- LayerTreeHostContextTest::SetupTree();
- }
-
- void BeginTest() override { PostSetNeedsCommitToMainThread(); }
-
- void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
- EXPECT_EQ(0, times_to_lose_on_end_query_);
- EndTest();
- }
-
- void AfterTest() override { EXPECT_EQ(0, times_to_lose_on_end_query_); }
-
- private:
- FakeContentLayerClient client_;
- scoped_refptr<Layer> parent_;
- int num_children_;
- int times_to_lose_on_end_query_;
-};
-
-SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(
- LayerTreeHostContextTestLostContextWhileUpdatingResources);
-
class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest {
public:
LayerTreeHostContextTestLayersNotified()
: LayerTreeHostContextTest(), num_commits_(0) {}
void SetupTree() override {
- if (layer_tree_host()->settings().impl_side_painting) {
- root_ = FakePictureLayer::Create(&client_);
- child_ = FakePictureLayer::Create(&client_);
- grandchild_ = FakePictureLayer::Create(&client_);
- } else {
- root_ = FakeContentLayer::Create(&client_);
- child_ = FakeContentLayer::Create(&client_);
- grandchild_ = FakeContentLayer::Create(&client_);
- }
+ root_ = FakePictureLayer::Create(layer_settings(), &client_);
+ child_ = FakePictureLayer::Create(layer_settings(), &client_);
+ grandchild_ = FakePictureLayer::Create(layer_settings(), &client_);
root_->AddChild(child_);
child_->AddChild(grandchild_);
@@ -885,54 +792,29 @@ class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest {
FakePictureLayerImpl* root_picture = NULL;
FakePictureLayerImpl* child_picture = NULL;
FakePictureLayerImpl* grandchild_picture = NULL;
- FakeContentLayerImpl* root_content = NULL;
- FakeContentLayerImpl* child_content = NULL;
- FakeContentLayerImpl* grandchild_content = NULL;
-
- if (host_impl->settings().impl_side_painting) {
- root_picture = static_cast<FakePictureLayerImpl*>(
- host_impl->active_tree()->root_layer());
- child_picture =
- static_cast<FakePictureLayerImpl*>(root_picture->children()[0]);
- grandchild_picture =
- static_cast<FakePictureLayerImpl*>(child_picture->children()[0]);
- } else {
- root_content = static_cast<FakeContentLayerImpl*>(
- host_impl->active_tree()->root_layer());
- child_content =
- static_cast<FakeContentLayerImpl*>(root_content->children()[0]);
- grandchild_content =
- static_cast<FakeContentLayerImpl*>(child_content->children()[0]);
- }
+ root_picture = static_cast<FakePictureLayerImpl*>(
+ host_impl->active_tree()->root_layer());
+ child_picture =
+ static_cast<FakePictureLayerImpl*>(root_picture->children()[0]);
+ grandchild_picture =
+ static_cast<FakePictureLayerImpl*>(child_picture->children()[0]);
++num_commits_;
switch (num_commits_) {
case 1:
- if (host_impl->settings().impl_side_painting) {
- EXPECT_EQ(0u, root_picture->release_resources_count());
- EXPECT_EQ(0u, child_picture->release_resources_count());
- EXPECT_EQ(0u, grandchild_picture->release_resources_count());
- } else {
- EXPECT_EQ(0u, root_content->lost_output_surface_count());
- EXPECT_EQ(0u, child_content->lost_output_surface_count());
- EXPECT_EQ(0u, grandchild_content->lost_output_surface_count());
- }
+ EXPECT_EQ(0u, root_picture->release_resources_count());
+ EXPECT_EQ(0u, child_picture->release_resources_count());
+ EXPECT_EQ(0u, grandchild_picture->release_resources_count());
// Lose the context and struggle to recreate it.
LoseContext();
times_to_fail_create_ = 1;
break;
case 2:
- if (host_impl->settings().impl_side_painting) {
- EXPECT_TRUE(root_picture->release_resources_count());
- EXPECT_TRUE(child_picture->release_resources_count());
- EXPECT_TRUE(grandchild_picture->release_resources_count());
- } else {
- EXPECT_TRUE(root_content->lost_output_surface_count());
- EXPECT_TRUE(child_content->lost_output_surface_count());
- EXPECT_TRUE(grandchild_content->lost_output_surface_count());
- }
+ EXPECT_TRUE(root_picture->release_resources_count());
+ EXPECT_TRUE(child_picture->release_resources_count());
+ EXPECT_TRUE(grandchild_picture->release_resources_count());
EndTest();
break;
@@ -963,14 +845,8 @@ class LayerTreeHostContextTestDontUseLostResources
child_output_surface_ = FakeOutputSurface::Create3d();
child_output_surface_->BindToClient(&output_surface_client_);
shared_bitmap_manager_.reset(new TestSharedBitmapManager());
- child_resource_provider_ =
- ResourceProvider::Create(child_output_surface_.get(),
- shared_bitmap_manager_.get(),
- NULL,
- NULL,
- 0,
- false,
- 1);
+ child_resource_provider_ = FakeResourceProvider::Create(
+ child_output_surface_.get(), shared_bitmap_manager_.get());
}
static void EmptyReleaseCallback(unsigned sync_point, bool lost) {}
@@ -1004,10 +880,9 @@ class LayerTreeHostContextTestDontUseLostResources
delegated_frame_provider_ = new DelegatedFrameProvider(
delegated_resource_collection_.get(), frame_data.Pass());
- ResourceProvider::ResourceId resource =
- child_resource_provider_->CreateResource(
- gfx::Size(4, 4), GL_CLAMP_TO_EDGE,
- ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888);
+ ResourceId resource = child_resource_provider_->CreateResource(
+ gfx::Size(4, 4), GL_CLAMP_TO_EDGE,
+ ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888);
ResourceProvider::ScopedWriteLockGL lock(child_resource_provider_.get(),
resource);
@@ -1015,26 +890,25 @@ class LayerTreeHostContextTestDontUseLostResources
gl->GenMailboxCHROMIUM(mailbox.name);
GLuint sync_point = gl->InsertSyncPointCHROMIUM();
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(gfx::Size(10, 10));
root->SetIsDrawable(true);
scoped_refptr<FakeDelegatedRendererLayer> delegated =
- FakeDelegatedRendererLayer::Create(delegated_frame_provider_.get());
+ FakeDelegatedRendererLayer::Create(layer_settings(),
+ delegated_frame_provider_.get());
delegated->SetBounds(gfx::Size(10, 10));
delegated->SetIsDrawable(true);
root->AddChild(delegated);
- scoped_refptr<Layer> layer;
- if (layer_tree_host()->settings().impl_side_painting)
- layer = PictureLayer::Create(&client_);
- else
- layer = ContentLayer::Create(&client_);
+ scoped_refptr<PictureLayer> layer =
+ PictureLayer::Create(layer_settings(), &client_);
layer->SetBounds(gfx::Size(10, 10));
layer->SetIsDrawable(true);
root->AddChild(layer);
- scoped_refptr<TextureLayer> texture = TextureLayer::CreateForMailbox(NULL);
+ scoped_refptr<TextureLayer> texture =
+ TextureLayer::CreateForMailbox(layer_settings_, NULL);
texture->SetBounds(gfx::Size(10, 10));
texture->SetIsDrawable(true);
texture->SetTextureMailbox(
@@ -1044,37 +918,31 @@ class LayerTreeHostContextTestDontUseLostResources
EmptyReleaseCallback)));
root->AddChild(texture);
- scoped_refptr<Layer> mask;
- if (layer_tree_host()->settings().impl_side_painting)
- mask = PictureLayer::Create(&client_);
- else
- mask = ContentLayer::Create(&client_);
+ scoped_refptr<PictureLayer> mask =
+ PictureLayer::Create(layer_settings_, &client_);
mask->SetBounds(gfx::Size(10, 10));
- scoped_refptr<Layer> layer_with_mask;
- if (layer_tree_host()->settings().impl_side_painting)
- layer_with_mask = PictureLayer::Create(&client_);
- else
- layer_with_mask = ContentLayer::Create(&client_);
+ scoped_refptr<PictureLayer> layer_with_mask =
+ PictureLayer::Create(layer_settings_, &client_);
layer_with_mask->SetBounds(gfx::Size(10, 10));
layer_with_mask->SetIsDrawable(true);
layer_with_mask->SetMaskLayer(mask.get());
root->AddChild(layer_with_mask);
- scoped_refptr<VideoLayer> video_color =
- VideoLayer::Create(&color_frame_provider_, media::VIDEO_ROTATION_0);
+ scoped_refptr<VideoLayer> video_color = VideoLayer::Create(
+ layer_settings_, &color_frame_provider_, media::VIDEO_ROTATION_0);
video_color->SetBounds(gfx::Size(10, 10));
video_color->SetIsDrawable(true);
root->AddChild(video_color);
- scoped_refptr<VideoLayer> video_hw =
- VideoLayer::Create(&hw_frame_provider_, media::VIDEO_ROTATION_0);
+ scoped_refptr<VideoLayer> video_hw = VideoLayer::Create(
+ layer_settings_, &hw_frame_provider_, media::VIDEO_ROTATION_0);
video_hw->SetBounds(gfx::Size(10, 10));
video_hw->SetIsDrawable(true);
root->AddChild(video_hw);
- scoped_refptr<VideoLayer> video_scaled_hw =
- VideoLayer::Create(&scaled_hw_frame_provider_, media::VIDEO_ROTATION_0);
+ scoped_refptr<VideoLayer> video_scaled_hw = VideoLayer::Create(
+ layer_settings_, &scaled_hw_frame_provider_, media::VIDEO_ROTATION_0);
video_scaled_hw->SetBounds(gfx::Size(10, 10));
video_scaled_hw->SetIsDrawable(true);
root->AddChild(video_scaled_hw);
@@ -1082,28 +950,26 @@ class LayerTreeHostContextTestDontUseLostResources
color_video_frame_ = VideoFrame::CreateColorFrame(
gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta());
hw_video_frame_ = VideoFrame::WrapNativeTexture(
+ media::VideoFrame::ARGB,
gpu::MailboxHolder(mailbox, GL_TEXTURE_2D, sync_point),
media::VideoFrame::ReleaseMailboxCB(), gfx::Size(4, 4),
- gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeDelta(),
- false /* allow_overlay */, true /* has_alpha */);
+ gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeDelta());
scaled_hw_video_frame_ = VideoFrame::WrapNativeTexture(
+ media::VideoFrame::ARGB,
gpu::MailboxHolder(mailbox, GL_TEXTURE_2D, sync_point),
media::VideoFrame::ReleaseMailboxCB(), gfx::Size(4, 4),
- gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), base::TimeDelta(),
- false /* allow_overlay */, true /* has_alpha */);
+ gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), base::TimeDelta());
color_frame_provider_.set_frame(color_video_frame_);
hw_frame_provider_.set_frame(hw_video_frame_);
scaled_hw_frame_provider_.set_frame(scaled_hw_video_frame_);
- if (!delegating_renderer()) {
- // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335
- scoped_refptr<IOSurfaceLayer> io_surface = IOSurfaceLayer::Create();
- io_surface->SetBounds(gfx::Size(10, 10));
- io_surface->SetIsDrawable(true);
- io_surface->SetIOSurfaceProperties(1, gfx::Size(10, 10));
- root->AddChild(io_surface);
- }
+ scoped_refptr<IOSurfaceLayer> io_surface =
+ IOSurfaceLayer::Create(layer_settings_);
+ io_surface->SetBounds(gfx::Size(10, 10));
+ io_surface->SetIsDrawable(true);
+ io_surface->SetIOSurfaceProperties(1, gfx::Size(10, 10));
+ root->AddChild(io_surface);
// Enable the hud.
LayerTreeDebugState debug_state;
@@ -1112,7 +978,8 @@ class LayerTreeHostContextTestDontUseLostResources
scoped_refptr<PaintedScrollbarLayer> scrollbar =
PaintedScrollbarLayer::Create(
- scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), layer->id());
+ layer_settings_, scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(),
+ layer->id());
scrollbar->SetBounds(gfx::Size(10, 10));
scrollbar->SetIsDrawable(true);
root->AddChild(scrollbar);
@@ -1189,27 +1056,22 @@ class LayerTreeHostContextTestDontUseLostResources
FakeVideoFrameProvider color_frame_provider_;
FakeVideoFrameProvider hw_frame_provider_;
FakeVideoFrameProvider scaled_hw_frame_provider_;
+
+ LayerSettings layer_settings_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestDontUseLostResources);
-class ImplSidePaintingLayerTreeHostContextTest
- : public LayerTreeHostContextTest {
- public:
- void InitializeSettings(LayerTreeSettings* settings) override {
- settings->impl_side_painting = true;
- }
-};
-
class LayerTreeHostContextTestImplSidePainting
- : public ImplSidePaintingLayerTreeHostContextTest {
+ : public LayerTreeHostContextTest {
public:
void SetupTree() override {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(gfx::Size(10, 10));
root->SetIsDrawable(true);
- scoped_refptr<PictureLayer> picture = PictureLayer::Create(&client_);
+ scoped_refptr<PictureLayer> picture =
+ PictureLayer::Create(layer_settings(), &client_);
picture->SetBounds(gfx::Size(10, 10));
picture->SetIsDrawable(true);
root->AddChild(picture);
@@ -1231,16 +1093,16 @@ class LayerTreeHostContextTestImplSidePainting
FakeContentLayerClient client_;
};
-MULTI_THREAD_TEST_F(LayerTreeHostContextTestImplSidePainting);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestImplSidePainting);
class ScrollbarLayerLostContext : public LayerTreeHostContextTest {
public:
ScrollbarLayerLostContext() : commits_(0) {}
void BeginTest() override {
- scoped_refptr<Layer> scroll_layer = Layer::Create();
- scrollbar_layer_ =
- FakePaintedScrollbarLayer::Create(false, true, scroll_layer->id());
+ scoped_refptr<Layer> scroll_layer = Layer::Create(layer_settings());
+ scrollbar_layer_ = FakePaintedScrollbarLayer::Create(
+ layer_settings(), false, true, scroll_layer->id());
scrollbar_layer_->SetBounds(gfx::Size(10, 100));
layer_tree_host()->root_layer()->AddChild(scrollbar_layer_);
layer_tree_host()->root_layer()->AddChild(scroll_layer);
@@ -1328,24 +1190,13 @@ class UIResourceLostTest : public LayerTreeHostContextTest {
class UIResourceLostTestSimple : public UIResourceLostTest {
public:
- // This is called when the commit is complete and the new layer tree has been
- // activated.
+ // This is called when the new layer tree has been activated.
virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) = 0;
- void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
- if (!impl->settings().impl_side_painting) {
- StepCompleteOnImplThread(impl);
- PostStepCompleteToMainThread();
- ++time_step_;
- }
- }
-
void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
- if (impl->settings().impl_side_painting) {
- StepCompleteOnImplThread(impl);
- PostStepCompleteToMainThread();
- ++time_step_;
- }
+ StepCompleteOnImplThread(impl);
+ PostStepCompleteToMainThread();
+ ++time_step_;
}
};
@@ -1585,15 +1436,7 @@ class UIResourceLostBeforeActivateTree : public UIResourceLostTest {
UIResourceId test_id_;
};
-TEST_F(UIResourceLostBeforeActivateTree,
- RunMultiThread_DirectRenderer_ImplSidePaint) {
- RunTest(true, false, true);
-}
-
-TEST_F(UIResourceLostBeforeActivateTree,
- RunMultiThread_DelegatingRenderer_ImplSidePaint) {
- RunTest(true, true, true);
-}
+SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostBeforeActivateTree);
// Resources evicted explicitly and by visibility changes.
class UIResourceLostEviction : public UIResourceLostTestSimple {
@@ -1685,15 +1528,9 @@ class LayerTreeHostContextTestSurfaceCreateCallback
: LayerTreeHostContextTest() {}
void SetupTree() override {
- if (layer_tree_host()->settings().impl_side_painting) {
- picture_layer_ = FakePictureLayer::Create(&client_);
- picture_layer_->SetBounds(gfx::Size(10, 20));
- layer_tree_host()->SetRootLayer(picture_layer_);
- } else {
- content_layer_ = FakeContentLayer::Create(&client_);
- content_layer_->SetBounds(gfx::Size(10, 20));
- layer_tree_host()->SetRootLayer(content_layer_);
- }
+ picture_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
+ picture_layer_->SetBounds(gfx::Size(10, 20));
+ layer_tree_host()->SetRootLayer(picture_layer_);
LayerTreeHostContextTest::SetupTree();
}
@@ -1703,30 +1540,18 @@ class LayerTreeHostContextTestSurfaceCreateCallback
void DidCommit() override {
switch (layer_tree_host()->source_frame_number()) {
case 1:
- if (layer_tree_host()->settings().impl_side_painting)
- EXPECT_EQ(1u, picture_layer_->output_surface_created_count());
- else
- EXPECT_EQ(1u, content_layer_->output_surface_created_count());
+ EXPECT_EQ(1u, picture_layer_->output_surface_created_count());
layer_tree_host()->SetNeedsCommit();
break;
case 2:
- if (layer_tree_host()->settings().impl_side_painting)
- EXPECT_EQ(1u, picture_layer_->output_surface_created_count());
- else
- EXPECT_EQ(1u, content_layer_->output_surface_created_count());
+ EXPECT_EQ(1u, picture_layer_->output_surface_created_count());
layer_tree_host()->SetNeedsCommit();
break;
case 3:
- if (layer_tree_host()->settings().impl_side_painting)
- EXPECT_EQ(1u, picture_layer_->output_surface_created_count());
- else
- EXPECT_EQ(1u, content_layer_->output_surface_created_count());
+ EXPECT_EQ(1u, picture_layer_->output_surface_created_count());
break;
case 4:
- if (layer_tree_host()->settings().impl_side_painting)
- EXPECT_EQ(2u, picture_layer_->output_surface_created_count());
- else
- EXPECT_EQ(2u, content_layer_->output_surface_created_count());
+ EXPECT_EQ(2u, picture_layer_->output_surface_created_count());
layer_tree_host()->SetNeedsCommit();
break;
}
@@ -1753,7 +1578,6 @@ class LayerTreeHostContextTestSurfaceCreateCallback
protected:
FakeContentLayerClient client_;
scoped_refptr<FakePictureLayer> picture_layer_;
- scoped_refptr<FakeContentLayer> content_layer_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback);
diff --git a/chromium/cc/trees/layer_tree_host_unittest_copyrequest.cc b/chromium/cc/trees/layer_tree_host_unittest_copyrequest.cc
index 5766a192106..e29cb21333e 100644
--- a/chromium/cc/trees/layer_tree_host_unittest_copyrequest.cc
+++ b/chromium/cc/trees/layer_tree_host_unittest_copyrequest.cc
@@ -5,9 +5,9 @@
#include "cc/layers/layer_iterator.h"
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
-#include "cc/test/fake_content_layer.h"
#include "cc/test/fake_content_layer_client.h"
#include "cc/test/fake_output_surface.h"
+#include "cc/test/fake_picture_layer.h"
#include "cc/test/layer_tree_test.h"
#include "cc/trees/layer_tree_impl.h"
#include "gpu/GLES2/gl2extchromium.h"
@@ -23,10 +23,10 @@ class LayerTreeHostCopyRequestTestMultipleRequests
: public LayerTreeHostCopyRequestTest {
protected:
void SetupTree() override {
- root = FakeContentLayer::Create(&client_);
+ root = FakePictureLayer::Create(layer_settings(), &client_);
root->SetBounds(gfx::Size(20, 20));
- child = FakeContentLayer::Create(&client_);
+ child = FakePictureLayer::Create(layer_settings(), &client_);
child->SetBounds(gfx::Size(10, 10));
root->AddChild(child);
@@ -114,48 +114,47 @@ class LayerTreeHostCopyRequestTestMultipleRequests
bool use_gl_renderer_;
std::vector<gfx::Size> callbacks_;
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> root;
- scoped_refptr<FakeContentLayer> child;
+ scoped_refptr<FakePictureLayer> root;
+ scoped_refptr<FakePictureLayer> child;
};
// Readback can't be done with a delegating renderer.
-// Disabled due to flake: http://crbug.com/448521
TEST_F(LayerTreeHostCopyRequestTestMultipleRequests,
- DISABLED_GLRenderer_RunSingleThread) {
+ GLRenderer_RunSingleThread) {
use_gl_renderer_ = true;
- RunTest(false, false, false);
+ RunTest(false, false);
}
TEST_F(LayerTreeHostCopyRequestTestMultipleRequests,
- GLRenderer_RunMultiThread_MainThreadPainting) {
+ GLRenderer_RunMultiThread) {
use_gl_renderer_ = true;
- RunTest(true, false, false);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostCopyRequestTestMultipleRequests,
SoftwareRenderer_RunSingleThread) {
use_gl_renderer_ = false;
- RunTest(false, false, false);
+ RunTest(false, false);
}
TEST_F(LayerTreeHostCopyRequestTestMultipleRequests,
- SoftwareRenderer_RunMultiThread_MainThreadPainting) {
+ SoftwareRenderer_RunMultiThread) {
use_gl_renderer_ = false;
- RunTest(true, false, false);
+ RunTest(true, false);
}
class LayerTreeHostCopyRequestTestLayerDestroyed
: public LayerTreeHostCopyRequestTest {
protected:
void SetupTree() override {
- root_ = FakeContentLayer::Create(&client_);
+ root_ = FakePictureLayer::Create(layer_settings(), &client_);
root_->SetBounds(gfx::Size(20, 20));
- main_destroyed_ = FakeContentLayer::Create(&client_);
+ main_destroyed_ = FakePictureLayer::Create(layer_settings(), &client_);
main_destroyed_->SetBounds(gfx::Size(15, 15));
root_->AddChild(main_destroyed_);
- impl_destroyed_ = FakeContentLayer::Create(&client_);
+ impl_destroyed_ = FakePictureLayer::Create(layer_settings(), &client_);
impl_destroyed_->SetBounds(gfx::Size(10, 10));
root_->AddChild(impl_destroyed_);
@@ -229,9 +228,9 @@ class LayerTreeHostCopyRequestTestLayerDestroyed
int callback_count_;
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> root_;
- scoped_refptr<FakeContentLayer> main_destroyed_;
- scoped_refptr<FakeContentLayer> impl_destroyed_;
+ scoped_refptr<FakePictureLayer> root_;
+ scoped_refptr<FakePictureLayer> main_destroyed_;
+ scoped_refptr<FakePictureLayer> impl_destroyed_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostCopyRequestTestLayerDestroyed);
@@ -240,20 +239,20 @@ class LayerTreeHostCopyRequestTestInHiddenSubtree
: public LayerTreeHostCopyRequestTest {
protected:
void SetupTree() override {
- root_ = FakeContentLayer::Create(&client_);
+ root_ = FakePictureLayer::Create(layer_settings(), &client_);
root_->SetBounds(gfx::Size(20, 20));
- grand_parent_layer_ = FakeContentLayer::Create(&client_);
+ grand_parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
grand_parent_layer_->SetBounds(gfx::Size(15, 15));
root_->AddChild(grand_parent_layer_);
// parent_layer_ owns a render surface.
- parent_layer_ = FakeContentLayer::Create(&client_);
+ parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
parent_layer_->SetBounds(gfx::Size(15, 15));
parent_layer_->SetForceRenderSurface(true);
grand_parent_layer_->AddChild(parent_layer_);
- copy_layer_ = FakeContentLayer::Create(&client_);
+ copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
copy_layer_->SetBounds(gfx::Size(10, 10));
parent_layer_->AddChild(copy_layer_);
@@ -326,34 +325,34 @@ class LayerTreeHostCopyRequestTestInHiddenSubtree
int callback_count_;
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> root_;
- scoped_refptr<FakeContentLayer> grand_parent_layer_;
- scoped_refptr<FakeContentLayer> parent_layer_;
- scoped_refptr<FakeContentLayer> copy_layer_;
+ scoped_refptr<FakePictureLayer> root_;
+ scoped_refptr<FakePictureLayer> grand_parent_layer_;
+ scoped_refptr<FakePictureLayer> parent_layer_;
+ scoped_refptr<FakePictureLayer> copy_layer_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F(
+SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
LayerTreeHostCopyRequestTestInHiddenSubtree);
class LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest
: public LayerTreeHostCopyRequestTest {
protected:
void SetupTree() override {
- root_ = FakeContentLayer::Create(&client_);
+ root_ = FakePictureLayer::Create(layer_settings(), &client_);
root_->SetBounds(gfx::Size(20, 20));
- grand_parent_layer_ = FakeContentLayer::Create(&client_);
+ grand_parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
grand_parent_layer_->SetBounds(gfx::Size(15, 15));
grand_parent_layer_->SetHideLayerAndSubtree(true);
root_->AddChild(grand_parent_layer_);
// parent_layer_ owns a render surface.
- parent_layer_ = FakeContentLayer::Create(&client_);
+ parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
parent_layer_->SetBounds(gfx::Size(15, 15));
parent_layer_->SetForceRenderSurface(true);
grand_parent_layer_->AddChild(parent_layer_);
- copy_layer_ = FakeContentLayer::Create(&client_);
+ copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
copy_layer_->SetBounds(gfx::Size(10, 10));
parent_layer_->AddChild(copy_layer_);
@@ -403,10 +402,10 @@ class LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest
FakeContentLayerClient client_;
bool did_draw_;
- scoped_refptr<FakeContentLayer> root_;
- scoped_refptr<FakeContentLayer> grand_parent_layer_;
- scoped_refptr<FakeContentLayer> parent_layer_;
- scoped_refptr<FakeContentLayer> copy_layer_;
+ scoped_refptr<FakePictureLayer> root_;
+ scoped_refptr<FakePictureLayer> grand_parent_layer_;
+ scoped_refptr<FakePictureLayer> parent_layer_;
+ scoped_refptr<FakePictureLayer> copy_layer_;
};
// No output to copy for delegated renderers.
@@ -417,15 +416,15 @@ class LayerTreeHostCopyRequestTestClippedOut
: public LayerTreeHostCopyRequestTest {
protected:
void SetupTree() override {
- root_ = FakeContentLayer::Create(&client_);
+ root_ = FakePictureLayer::Create(layer_settings(), &client_);
root_->SetBounds(gfx::Size(20, 20));
- parent_layer_ = FakeContentLayer::Create(&client_);
+ parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
parent_layer_->SetBounds(gfx::Size(15, 15));
parent_layer_->SetMasksToBounds(true);
root_->AddChild(parent_layer_);
- copy_layer_ = FakeContentLayer::Create(&client_);
+ copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
copy_layer_->SetPosition(gfx::Point(15, 15));
copy_layer_->SetBounds(gfx::Size(10, 10));
parent_layer_->AddChild(copy_layer_);
@@ -453,9 +452,9 @@ class LayerTreeHostCopyRequestTestClippedOut
void AfterTest() override {}
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> root_;
- scoped_refptr<FakeContentLayer> parent_layer_;
- scoped_refptr<FakeContentLayer> copy_layer_;
+ scoped_refptr<FakePictureLayer> root_;
+ scoped_refptr<FakePictureLayer> parent_layer_;
+ scoped_refptr<FakePictureLayer> copy_layer_;
};
SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
@@ -465,10 +464,10 @@ class LayerTreeHostTestAsyncTwoReadbacksWithoutDraw
: public LayerTreeHostCopyRequestTest {
protected:
void SetupTree() override {
- root_ = FakeContentLayer::Create(&client_);
+ root_ = FakePictureLayer::Create(layer_settings(), &client_);
root_->SetBounds(gfx::Size(20, 20));
- copy_layer_ = FakeContentLayer::Create(&client_);
+ copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
copy_layer_->SetBounds(gfx::Size(10, 10));
root_->AddChild(copy_layer_);
@@ -513,11 +512,24 @@ class LayerTreeHostTestAsyncTwoReadbacksWithoutDraw
void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {
EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread());
- EXPECT_EQ(copy_layer_->bounds().ToString(), result->size().ToString());
- ++callback_count_;
- if (callback_count_ == 2)
- EndTest();
+ // The first frame can't be drawn.
+ switch (callback_count_) {
+ case 0:
+ EXPECT_TRUE(result->IsEmpty());
+ EXPECT_EQ(gfx::Size(), result->size());
+ break;
+ case 1:
+ EXPECT_FALSE(result->IsEmpty());
+ EXPECT_EQ(copy_layer_->bounds().ToString(), result->size().ToString());
+ EndTest();
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+
+ ++callback_count_;
}
void AfterTest() override { EXPECT_TRUE(saw_copy_request_); }
@@ -525,11 +537,11 @@ class LayerTreeHostTestAsyncTwoReadbacksWithoutDraw
bool saw_copy_request_;
int callback_count_;
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> root_;
- scoped_refptr<FakeContentLayer> copy_layer_;
+ scoped_refptr<FakePictureLayer> root_;
+ scoped_refptr<FakePictureLayer> copy_layer_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F(
+SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
LayerTreeHostTestAsyncTwoReadbacksWithoutDraw);
class LayerTreeHostCopyRequestTestLostOutputSurface
@@ -547,10 +559,10 @@ class LayerTreeHostCopyRequestTestLostOutputSurface
}
void SetupTree() override {
- root_ = FakeContentLayer::Create(&client_);
+ root_ = FakePictureLayer::Create(layer_settings(), &client_);
root_->SetBounds(gfx::Size(20, 20));
- copy_layer_ = FakeContentLayer::Create(&client_);
+ copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
copy_layer_->SetBounds(gfx::Size(10, 10));
root_->AddChild(copy_layer_);
@@ -652,12 +664,12 @@ class LayerTreeHostCopyRequestTestLostOutputSurface
size_t num_textures_without_readback_;
size_t num_textures_after_loss_;
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> root_;
- scoped_refptr<FakeContentLayer> copy_layer_;
+ scoped_refptr<FakePictureLayer> root_;
+ scoped_refptr<FakePictureLayer> copy_layer_;
scoped_ptr<CopyOutputResult> result_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F(
+SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
LayerTreeHostCopyRequestTestLostOutputSurface);
class LayerTreeHostCopyRequestTestCountTextures
@@ -669,10 +681,12 @@ class LayerTreeHostCopyRequestTestCountTextures
}
void SetupTree() override {
- root_ = FakeContentLayer::Create(&client_);
+ client_.set_fill_with_nonsolid_color(true);
+
+ root_ = FakePictureLayer::Create(layer_settings(), &client_);
root_->SetBounds(gfx::Size(20, 20));
- copy_layer_ = FakeContentLayer::Create(&client_);
+ copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
copy_layer_->SetBounds(gfx::Size(10, 10));
root_->AddChild(copy_layer_);
@@ -728,8 +742,8 @@ class LayerTreeHostCopyRequestTestCountTextures
size_t num_textures_with_readback_;
unsigned waited_sync_point_after_readback_;
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> root_;
- scoped_refptr<FakeContentLayer> copy_layer_;
+ scoped_refptr<FakePictureLayer> root_;
+ scoped_refptr<FakePictureLayer> copy_layer_;
};
class LayerTreeHostCopyRequestTestCreatesTexture
@@ -763,7 +777,7 @@ class LayerTreeHostCopyRequestTestCreatesTexture
}
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F(
+SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
LayerTreeHostCopyRequestTestCreatesTexture);
class LayerTreeHostCopyRequestTestProvideTexture
@@ -816,17 +830,17 @@ class LayerTreeHostCopyRequestTestProvideTexture
unsigned sync_point_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F(
+SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
LayerTreeHostCopyRequestTestProvideTexture);
class LayerTreeHostCopyRequestTestDestroyBeforeCopy
: public LayerTreeHostCopyRequestTest {
protected:
void SetupTree() override {
- root_ = FakeContentLayer::Create(&client_);
+ root_ = FakePictureLayer::Create(layer_settings(), &client_);
root_->SetBounds(gfx::Size(20, 20));
- copy_layer_ = FakeContentLayer::Create(&client_);
+ copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
copy_layer_->SetBounds(gfx::Size(10, 10));
root_->AddChild(copy_layer_);
@@ -889,8 +903,8 @@ class LayerTreeHostCopyRequestTestDestroyBeforeCopy
int callback_count_;
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> root_;
- scoped_refptr<FakeContentLayer> copy_layer_;
+ scoped_refptr<FakePictureLayer> root_;
+ scoped_refptr<FakePictureLayer> copy_layer_;
};
SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
@@ -900,10 +914,10 @@ class LayerTreeHostCopyRequestTestShutdownBeforeCopy
: public LayerTreeHostCopyRequestTest {
protected:
void SetupTree() override {
- root_ = FakeContentLayer::Create(&client_);
+ root_ = FakePictureLayer::Create(layer_settings(), &client_);
root_->SetBounds(gfx::Size(20, 20));
- copy_layer_ = FakeContentLayer::Create(&client_);
+ copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
copy_layer_->SetBounds(gfx::Size(10, 10));
root_->AddChild(copy_layer_);
@@ -960,8 +974,8 @@ class LayerTreeHostCopyRequestTestShutdownBeforeCopy
int callback_count_;
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> root_;
- scoped_refptr<FakeContentLayer> copy_layer_;
+ scoped_refptr<FakePictureLayer> root_;
+ scoped_refptr<FakePictureLayer> copy_layer_;
};
SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
@@ -971,10 +985,11 @@ class LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest
: public LayerTreeHostCopyRequestTest {
protected:
void SetupTree() override {
- scoped_refptr<FakeContentLayer> root = FakeContentLayer::Create(&client_);
+ scoped_refptr<FakePictureLayer> root =
+ FakePictureLayer::Create(layer_settings(), &client_);
root->SetBounds(gfx::Size(20, 20));
- child_ = FakeContentLayer::Create(&client_);
+ child_ = FakePictureLayer::Create(layer_settings(), &client_);
child_->SetBounds(gfx::Size(10, 10));
root->AddChild(child_);
child_->SetHideLayerAndSubtree(true);
@@ -1009,10 +1024,9 @@ class LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest
bool saw_root = false;
bool saw_child = false;
- for (LayerIterator<LayerImpl> it = LayerIterator<LayerImpl>::Begin(
- frame_data->render_surface_layer_list);
- it != LayerIterator<LayerImpl>::End(
- frame_data->render_surface_layer_list);
+ for (LayerIterator it =
+ LayerIterator::Begin(frame_data->render_surface_layer_list);
+ it != LayerIterator::End(frame_data->render_surface_layer_list);
++it) {
if (it.represents_itself()) {
if (*it == root)
@@ -1073,7 +1087,7 @@ class LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest
void AfterTest() override {}
- scoped_refptr<FakeContentLayer> child_;
+ scoped_refptr<FakePictureLayer> child_;
FakeContentLayerClient client_;
int num_draws_;
bool copy_happened_;
diff --git a/chromium/cc/trees/layer_tree_host_unittest_damage.cc b/chromium/cc/trees/layer_tree_host_unittest_damage.cc
index daff40beb2d..fc5cacf087e 100644
--- a/chromium/cc/trees/layer_tree_host_unittest_damage.cc
+++ b/chromium/cc/trees/layer_tree_host_unittest_damage.cc
@@ -7,9 +7,8 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/location.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/time/time.h"
-#include "cc/test/fake_content_layer.h"
+#include "cc/layers/solid_color_layer.h"
#include "cc/test/fake_content_layer_client.h"
#include "cc/test/fake_painted_scrollbar_layer.h"
#include "cc/test/fake_picture_layer.h"
@@ -28,7 +27,8 @@ class LayerTreeHostDamageTestSetNeedsRedraw
: public LayerTreeHostDamageTest {
void SetupTree() override {
// Viewport is 10x10.
- scoped_refptr<FakeContentLayer> root = FakeContentLayer::Create(&client_);
+ scoped_refptr<FakePictureLayer> root =
+ FakePictureLayer::Create(layer_settings(), &client_);
root->SetBounds(gfx::Size(10, 10));
layer_tree_host()->SetRootLayer(root);
@@ -89,7 +89,8 @@ class LayerTreeHostDamageTestSetViewportSize
: public LayerTreeHostDamageTest {
void SetupTree() override {
// Viewport is 10x10.
- scoped_refptr<FakeContentLayer> root = FakeContentLayer::Create(&client_);
+ scoped_refptr<FakePictureLayer> root =
+ FakePictureLayer::Create(layer_settings(), &client_);
root->SetBounds(gfx::Size(10, 10));
layer_tree_host()->SetRootLayer(root);
@@ -155,11 +156,12 @@ class LayerTreeHostDamageTestNoDamageDoesNotSwap
}
void SetupTree() override {
- scoped_refptr<FakeContentLayer> root = FakeContentLayer::Create(&client_);
+ scoped_refptr<FakePictureLayer> root =
+ FakePictureLayer::Create(layer_settings(), &client_);
root->SetBounds(gfx::Size(10, 10));
// Most of the layer isn't visible.
- content_ = FakeContentLayer::Create(&client_);
+ content_ = FakePictureLayer::Create(layer_settings(), &client_);
content_->SetBounds(gfx::Size(2000, 100));
root->AddChild(content_);
@@ -227,21 +229,20 @@ class LayerTreeHostDamageTestNoDamageDoesNotSwap
}
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> content_;
+ scoped_refptr<FakePictureLayer> content_;
int expect_swap_and_succeed_;
int did_swaps_;
int did_swap_and_succeed_;
};
-SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(
- LayerTreeHostDamageTestNoDamageDoesNotSwap);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestNoDamageDoesNotSwap);
class LayerTreeHostDamageTestForcedFullDamage : public LayerTreeHostDamageTest {
void BeginTest() override { PostSetNeedsCommitToMainThread(); }
void SetupTree() override {
- root_ = FakeContentLayer::Create(&client_);
- child_ = FakeContentLayer::Create(&client_);
+ root_ = FakePictureLayer::Create(layer_settings(), &client_);
+ child_ = FakePictureLayer::Create(layer_settings(), &client_);
root_->SetBounds(gfx::Size(500, 500));
child_->SetPosition(gfx::Point(100, 100));
@@ -293,21 +294,6 @@ class LayerTreeHostDamageTestForcedFullDamage : public LayerTreeHostDamageTest {
// should match the invalidation.
EXPECT_EQ(gfx::RectF(100+10, 100+11, 12, 13).ToString(),
root_damage.ToString());
-
- // TODO(danakj): Remove this when impl side painting is always on.
- if (delegating_renderer() ||
- host_impl->settings().impl_side_painting) {
- // When using a delegating renderer, or using impl side painting, the
- // entire child is considered damaged as we need to replace its
- // resources with newly created ones. The damaged area is kept as it
- // is, but entire child is painted.
-
- // The paint rect should match the layer bounds.
- gfx::RectF paint_rect = child_->LastPaintRect();
- paint_rect.set_origin(child_->position());
- EXPECT_EQ(gfx::RectF(100, 100, 30, 30).ToString(),
- paint_rect.ToString());
- }
EXPECT_FALSE(frame_data->has_no_damage);
// If we damage part of the frame, but also damage the full
@@ -340,33 +326,35 @@ class LayerTreeHostDamageTestForcedFullDamage : public LayerTreeHostDamageTest {
void AfterTest() override {}
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> root_;
- scoped_refptr<FakeContentLayer> child_;
+ scoped_refptr<FakePictureLayer> root_;
+ scoped_refptr<FakePictureLayer> child_;
gfx::Rect child_damage_rect_;
};
-SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostDamageTestForcedFullDamage);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestForcedFullDamage);
class LayerTreeHostScrollbarDamageTest : public LayerTreeHostDamageTest {
void SetupTree() override {
- scoped_refptr<Layer> root_layer = Layer::Create();
+ scoped_refptr<Layer> root_layer = Layer::Create(layer_settings());
root_layer->SetBounds(gfx::Size(400, 400));
root_layer->SetMasksToBounds(true);
layer_tree_host()->SetRootLayer(root_layer);
- scoped_refptr<Layer> scroll_clip_layer = Layer::Create();
- scoped_refptr<Layer> content_layer = FakeContentLayer::Create(&client_);
+ scoped_refptr<Layer> scroll_clip_layer = Layer::Create(layer_settings());
+ scoped_refptr<Layer> content_layer =
+ FakePictureLayer::Create(layer_settings(), &client_);
content_layer->SetScrollClipLayerId(scroll_clip_layer->id());
content_layer->SetScrollOffset(gfx::ScrollOffset(10, 20));
content_layer->SetBounds(gfx::Size(100, 200));
+ content_layer->SetIsDrawable(true);
scroll_clip_layer->SetBounds(
gfx::Size(content_layer->bounds().width() - 30,
content_layer->bounds().height() - 50));
scroll_clip_layer->AddChild(content_layer);
root_layer->AddChild(scroll_clip_layer);
- scoped_refptr<Layer> scrollbar_layer =
- FakePaintedScrollbarLayer::Create(false, true, content_layer->id());
+ scoped_refptr<Layer> scrollbar_layer = FakePaintedScrollbarLayer::Create(
+ layer_settings(), false, true, content_layer->id());
scrollbar_layer->SetPosition(gfx::Point(300, 300));
scrollbar_layer->SetBounds(gfx::Size(10, 100));
scrollbar_layer->ToScrollbarLayer()->SetClipLayer(scroll_clip_layer->id());
@@ -443,13 +431,25 @@ class LayerTreeHostDamageTestScrollbarDoesDamage
host_impl->SetNeedsRedraw();
break;
case 3:
- scroll_layer->SetBounds(gfx::Size(root->bounds().width() + 60,
- root->bounds().height() + 100));
- host_impl->SetNeedsRedraw();
+ // We will resize the content layer, on the main thread.
+ MainThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &LayerTreeHostDamageTestScrollbarDoesDamage::ResizeScrollLayer,
+ base::Unretained(this)));
break;
}
}
+ void ResizeScrollLayer() {
+ EXPECT_EQ(3, did_swaps_);
+ Layer* root = layer_tree_host()->root_layer();
+ Layer* scroll_clip_layer = root->child_at(0);
+ Layer* scroll_layer = scroll_clip_layer->child_at(0);
+ scroll_layer->SetBounds(
+ gfx::Size(root->bounds().width() + 60, root->bounds().height() + 100));
+ }
+
void AfterTest() override { EXPECT_EQ(4, did_swaps_); }
int did_swaps_;
diff --git a/chromium/cc/trees/layer_tree_host_unittest_delegated.cc b/chromium/cc/trees/layer_tree_host_unittest_delegated.cc
index 2864eb82ad6..2ebb337e807 100644
--- a/chromium/cc/trees/layer_tree_host_unittest_delegated.cc
+++ b/chromium/cc/trees/layer_tree_host_unittest_delegated.cc
@@ -135,7 +135,7 @@ class LayerTreeHostDelegatedTest : public LayerTreeTest {
}
void AddTransferableResource(DelegatedFrameData* frame,
- ResourceProvider::ResourceId resource_id) {
+ ResourceId resource_id) {
TransferableResource resource;
resource.id = resource_id;
resource.mailbox_holder.texture_target = GL_TEXTURE_2D;
@@ -147,8 +147,7 @@ class LayerTreeHostDelegatedTest : public LayerTreeTest {
frame->resource_list.push_back(resource);
}
- void AddTextureQuad(DelegatedFrameData* frame,
- ResourceProvider::ResourceId resource_id) {
+ void AddTextureQuad(DelegatedFrameData* frame, ResourceId resource_id) {
RenderPass* render_pass = frame->render_pass_list[0];
SharedQuadState* sqs = render_pass->CreateAndAppendSharedQuadState();
TextureDrawQuad* quad =
@@ -201,9 +200,9 @@ class LayerTreeHostDelegatedTest : public LayerTreeTest {
background_filters);
}
- static ResourceProvider::ResourceId AppendResourceId(
- std::vector<ResourceProvider::ResourceId>* resources_in_last_sent_frame,
- ResourceProvider::ResourceId resource_id) {
+ static ResourceId AppendResourceId(
+ std::vector<ResourceId>* resources_in_last_sent_frame,
+ ResourceId resource_id) {
resources_in_last_sent_frame->push_back(resource_id);
return resource_id;
}
@@ -214,19 +213,18 @@ class LayerTreeHostDelegatedTest : public LayerTreeTest {
if (!delegated_frame_data)
return;
- std::vector<ResourceProvider::ResourceId> resources_in_last_sent_frame;
+ std::vector<ResourceId> resources_in_last_sent_frame;
for (size_t i = 0; i < delegated_frame_data->resource_list.size(); ++i) {
resources_in_last_sent_frame.push_back(
delegated_frame_data->resource_list[i].id);
}
- std::vector<ResourceProvider::ResourceId> resources_to_return;
+ std::vector<ResourceId> resources_to_return;
const TransferableResourceArray& resources_held_by_parent =
output_surface()->resources_held_by_parent();
for (size_t i = 0; i < resources_held_by_parent.size(); ++i) {
- ResourceProvider::ResourceId resource_in_parent =
- resources_held_by_parent[i].id;
+ ResourceId resource_in_parent = resources_held_by_parent[i].id;
bool resource_in_parent_is_not_part_of_frame =
std::find(resources_in_last_sent_frame.begin(),
resources_in_last_sent_frame.end(),
@@ -274,7 +272,7 @@ class LayerTreeHostDelegatedTestCaseSingleDelegatedLayer
}
void SetupTree() override {
- root_ = Layer::Create();
+ root_ = Layer::Create(layer_settings());
root_->SetBounds(gfx::Size(15, 15));
layer_tree_host()->SetRootLayer(root_);
@@ -310,7 +308,7 @@ class LayerTreeHostDelegatedTestCaseSingleDelegatedLayer
scoped_refptr<DelegatedRendererLayer> CreateDelegatedLayer(
DelegatedFrameProvider* frame_provider) {
scoped_refptr<DelegatedRendererLayer> delegated =
- FakeDelegatedRendererLayer::Create(frame_provider);
+ FakeDelegatedRendererLayer::Create(layer_settings(), frame_provider);
delegated->SetBounds(gfx::Size(10, 10));
delegated->SetIsDrawable(true);
@@ -432,7 +430,7 @@ class LayerTreeHostDelegatedTestDontUseLostChildIdAfterCommit
}
};
-MULTI_THREAD_IMPL_TEST_F(
+SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostDelegatedTestDontUseLostChildIdAfterCommit);
// Test that we can gracefully handle invalid frames after the context was lost.
@@ -804,18 +802,18 @@ class LayerTreeHostDelegatedTestRemapResourcesInQuads
EXPECT_EQ(1u, map.count(999));
EXPECT_EQ(1u, map.count(555));
- ResourceProvider::ResourceId parent_resource_id1 = map.find(999)->second;
+ ResourceId parent_resource_id1 = map.find(999)->second;
EXPECT_NE(parent_resource_id1, 999u);
- ResourceProvider::ResourceId parent_resource_id2 = map.find(555)->second;
+ ResourceId parent_resource_id2 = map.find(555)->second;
EXPECT_NE(parent_resource_id2, 555u);
// The resources in the quads should be remapped to the parent's namespace.
const TextureDrawQuad* quad1 = TextureDrawQuad::MaterialCast(
delegated_impl->RenderPassesInDrawOrder()[0]->quad_list.ElementAt(0));
- EXPECT_EQ(parent_resource_id1, quad1->resource_id);
+ EXPECT_EQ(parent_resource_id1, quad1->resource_id());
const TextureDrawQuad* quad2 = TextureDrawQuad::MaterialCast(
delegated_impl->RenderPassesInDrawOrder()[0]->quad_list.ElementAt(1));
- EXPECT_EQ(parent_resource_id2, quad2->resource_id);
+ EXPECT_EQ(parent_resource_id2, quad2->resource_id());
EndTest();
}
@@ -1057,7 +1055,7 @@ class LayerTreeHostDelegatedTestFrameBeforeAck
EXPECT_EQ(1u, pass->quad_list.size());
const TextureDrawQuad* quad =
TextureDrawQuad::MaterialCast(pass->quad_list.front());
- EXPECT_EQ(map.find(999)->second, quad->resource_id);
+ EXPECT_EQ(map.find(999)->second, quad->resource_id());
EndTest();
}
@@ -1169,13 +1167,13 @@ class LayerTreeHostDelegatedTestFrameBeforeTakeResources
EXPECT_EQ(3u, pass->quad_list.size());
const TextureDrawQuad* quad1 =
TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(0));
- EXPECT_EQ(map.find(999)->second, quad1->resource_id);
+ EXPECT_EQ(map.find(999)->second, quad1->resource_id());
const TextureDrawQuad* quad2 =
TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(1));
- EXPECT_EQ(map.find(555)->second, quad2->resource_id);
+ EXPECT_EQ(map.find(555)->second, quad2->resource_id());
const TextureDrawQuad* quad3 =
TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(2));
- EXPECT_EQ(map.find(444)->second, quad3->resource_id);
+ EXPECT_EQ(map.find(444)->second, quad3->resource_id());
}
void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
@@ -1288,10 +1286,10 @@ class LayerTreeHostDelegatedTestBadFrame
EXPECT_EQ(2u, pass->quad_list.size());
const TextureDrawQuad* quad1 =
TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(0));
- EXPECT_EQ(map.find(999)->second, quad1->resource_id);
+ EXPECT_EQ(map.find(999)->second, quad1->resource_id());
const TextureDrawQuad* quad2 =
TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(1));
- EXPECT_EQ(map.find(555)->second, quad2->resource_id);
+ EXPECT_EQ(map.find(555)->second, quad2->resource_id());
break;
}
case 2: {
@@ -1310,10 +1308,10 @@ class LayerTreeHostDelegatedTestBadFrame
EXPECT_EQ(2u, pass->quad_list.size());
const TextureDrawQuad* quad1 =
TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(0));
- EXPECT_EQ(map.find(999)->second, quad1->resource_id);
+ EXPECT_EQ(map.find(999)->second, quad1->resource_id());
const TextureDrawQuad* quad2 =
TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(1));
- EXPECT_EQ(map.find(555)->second, quad2->resource_id);
+ EXPECT_EQ(map.find(555)->second, quad2->resource_id());
break;
}
case 3: {
@@ -1328,7 +1326,7 @@ class LayerTreeHostDelegatedTestBadFrame
EXPECT_EQ(1u, pass->quad_list.size());
const TextureDrawQuad* quad1 =
TextureDrawQuad::MaterialCast(pass->quad_list.front());
- EXPECT_EQ(map.find(999)->second, quad1->resource_id);
+ EXPECT_EQ(map.find(999)->second, quad1->resource_id());
break;
}
}
@@ -2288,7 +2286,8 @@ class LayerTreeHostDelegatedTestActiveFrameIsValid
bool drew_with_pending_tree_;
};
-MULTI_THREAD_IMPL_TEST_F(LayerTreeHostDelegatedTestActiveFrameIsValid);
+// This test blocks activation which is not supported for single thread mode.
+MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostDelegatedTestActiveFrameIsValid);
} // namespace
} // namespace cc
diff --git a/chromium/cc/trees/layer_tree_host_unittest_no_message_loop.cc b/chromium/cc/trees/layer_tree_host_unittest_no_message_loop.cc
deleted file mode 100644
index ef948f70240..00000000000
--- a/chromium/cc/trees/layer_tree_host_unittest_no_message_loop.cc
+++ /dev/null
@@ -1,248 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/thread_task_runner_handle.h"
-#include "base/threading/simple_thread.h"
-#include "cc/layers/delegated_frame_provider.h"
-#include "cc/layers/delegated_frame_resource_collection.h"
-#include "cc/layers/delegated_renderer_layer.h"
-#include "cc/layers/layer.h"
-#include "cc/layers/solid_color_layer.h"
-#include "cc/output/delegated_frame_data.h"
-#include "cc/output/output_surface.h"
-#include "cc/output/output_surface_client.h"
-#include "cc/resources/resource_provider.h"
-#include "cc/scheduler/begin_frame_source.h"
-#include "cc/test/fake_delegated_renderer_layer.h"
-#include "cc/test/test_context_provider.h"
-#include "cc/trees/layer_tree_host.h"
-#include "cc/trees/layer_tree_host_client.h"
-#include "cc/trees/layer_tree_host_single_thread_client.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "ui/gfx/frame_time.h"
-
-namespace cc {
-namespace {
-
-class NoMessageLoopOutputSurface : public OutputSurface {
- public:
- NoMessageLoopOutputSurface() : OutputSurface(TestContextProvider::Create()) {}
- ~NoMessageLoopOutputSurface() override {}
-
- // OutputSurface overrides.
- void SwapBuffers(CompositorFrame* frame) override {
- DCHECK(client_);
- client_->DidSwapBuffers();
- client_->DidSwapBuffersComplete();
- }
-};
-
-class LayerTreeHostNoMessageLoopTest
- : public testing::Test,
- public base::DelegateSimpleThread::Delegate,
- public LayerTreeHostClient,
- public LayerTreeHostSingleThreadClient {
- public:
- LayerTreeHostNoMessageLoopTest()
- : did_initialize_output_surface_(false),
- did_commit_(false),
- did_commit_and_draw_frame_(false),
- size_(100, 100),
- no_loop_thread_(this, "LayerTreeHostNoMessageLoopTest") {}
- ~LayerTreeHostNoMessageLoopTest() override {}
-
- // LayerTreeHostClient overrides.
- void WillBeginMainFrame() override {}
- void BeginMainFrame(const BeginFrameArgs& args) override {}
- void BeginMainFrameNotExpectedSoon() override {}
- void DidBeginMainFrame() override {}
- void Layout() override {}
- void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
- const gfx::Vector2dF& outer_delta,
- const gfx::Vector2dF& elastic_overscroll_delta,
- float page_scale,
- float top_controls_delta) override {}
- void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
- float page_scale,
- float top_controls_delta) override {}
- void RequestNewOutputSurface() override {
- layer_tree_host_->SetOutputSurface(
- make_scoped_ptr<OutputSurface>(new NoMessageLoopOutputSurface));
- }
- void DidInitializeOutputSurface() override {
- did_initialize_output_surface_ = true;
- }
- void DidFailToInitializeOutputSurface() override {}
- void WillCommit() override {}
- void DidCommit() override { did_commit_ = true; }
- void DidCommitAndDrawFrame() override { did_commit_and_draw_frame_ = true; }
- void DidCompleteSwapBuffers() override {}
- void DidCompletePageScaleAnimation() override {}
-
- // LayerTreeHostSingleThreadClient overrides.
- void DidPostSwapBuffers() override {}
- void DidAbortSwapBuffers() override {}
-
- void RunTest() {
- no_loop_thread_.Start();
- no_loop_thread_.Join();
- }
-
- // base::DelegateSimpleThread::Delegate override.
- void Run() override {
- ASSERT_FALSE(base::ThreadTaskRunnerHandle::IsSet());
- RunTestWithoutMessageLoop();
- EXPECT_FALSE(base::ThreadTaskRunnerHandle::IsSet());
- }
-
- protected:
- virtual void RunTestWithoutMessageLoop() = 0;
-
- void SetupLayerTreeHost() {
- LayerTreeSettings settings;
- settings.single_thread_proxy_scheduler = false;
- settings.verify_property_trees = true;
- settings.raster_enabled = false;
-
- LayerTreeHost::InitParams params;
- params.client = this;
- params.settings = &settings;
- layer_tree_host_ = LayerTreeHost::CreateSingleThreaded(this, &params);
- layer_tree_host_->SetViewportSize(size_);
- layer_tree_host_->SetRootLayer(root_layer_);
- }
-
- void Composite() {
- did_commit_ = false;
- did_commit_and_draw_frame_ = false;
- layer_tree_host_->Composite(gfx::FrameTime::Now());
- EXPECT_TRUE(did_initialize_output_surface_);
- EXPECT_TRUE(did_commit_);
- EXPECT_TRUE(did_commit_and_draw_frame_);
- }
-
- void TearDownLayerTreeHost() {
- // Explicit teardown to make failures easier to debug.
- layer_tree_host_ = nullptr;
- root_layer_ = nullptr;
- }
-
- // All protected member variables are accessed only on |no_loop_thread_|.
- scoped_ptr<LayerTreeHost> layer_tree_host_;
- scoped_refptr<Layer> root_layer_;
-
- bool did_initialize_output_surface_;
- bool did_commit_;
- bool did_commit_and_draw_frame_;
- gfx::Size size_;
-
- private:
- base::DelegateSimpleThread no_loop_thread_;
-};
-
-class LayerTreeHostNoMessageLoopSmokeTest
- : public LayerTreeHostNoMessageLoopTest {
- protected:
- void RunTestWithoutMessageLoop() override {
- gfx::Size size(100, 100);
-
- // Set up root layer.
- {
- scoped_refptr<SolidColorLayer> solid_color_layer =
- SolidColorLayer::Create();
- solid_color_layer->SetBackgroundColor(SK_ColorRED);
- solid_color_layer->SetBounds(size_);
- solid_color_layer->SetIsDrawable(true);
- root_layer_ = solid_color_layer;
- }
-
- SetupLayerTreeHost();
- Composite();
- TearDownLayerTreeHost();
- }
-};
-
-TEST_F(LayerTreeHostNoMessageLoopSmokeTest, SmokeTest) {
- RunTest();
-}
-
-class LayerTreeHostNoMessageLoopDelegatedLayer
- : public LayerTreeHostNoMessageLoopTest,
- public DelegatedFrameResourceCollectionClient {
- protected:
- void RunTestWithoutMessageLoop() override {
- resource_collection_ = new DelegatedFrameResourceCollection;
- frame_provider_ = new DelegatedFrameProvider(
- resource_collection_.get(), CreateFrameDataWithResource(998));
-
- root_layer_ = Layer::Create();
- delegated_layer_ =
- FakeDelegatedRendererLayer::Create(frame_provider_.get());
- delegated_layer_->SetBounds(size_);
- delegated_layer_->SetIsDrawable(true);
- root_layer_->AddChild(delegated_layer_);
-
- SetupLayerTreeHost();
-
- // Draw first frame.
- Composite();
-
- // Prepare and draw second frame.
- frame_provider_->SetFrameData(CreateFrameDataWithResource(999));
- Composite();
-
- // Resource from first frame should be returned.
- CheckReturnedResource(1u);
-
- TearDownLayerTreeHost();
- delegated_layer_ = NULL;
- frame_provider_ = NULL;
-
- // Resource from second frame should be returned.
- CheckReturnedResource(1u);
- resource_collection_ = NULL;
- }
-
- // DelegatedFrameResourceCollectionClient overrides.
- void UnusedResourcesAreAvailable() override {}
-
- private:
- scoped_ptr<DelegatedFrameData> CreateFrameDataWithResource(
- ResourceProvider::ResourceId resource_id) {
- scoped_ptr<DelegatedFrameData> frame(new DelegatedFrameData);
- gfx::Rect frame_rect(size_);
-
- scoped_ptr<RenderPass> root_pass(RenderPass::Create());
- root_pass->SetNew(
- RenderPassId(1, 1), frame_rect, frame_rect, gfx::Transform());
- frame->render_pass_list.push_back(root_pass.Pass());
-
- TransferableResource resource;
- resource.id = resource_id;
- resource.mailbox_holder.texture_target = GL_TEXTURE_2D;
- resource.mailbox_holder.mailbox = gpu::Mailbox::Generate();
- frame->resource_list.push_back(resource);
-
- return frame.Pass();
- }
-
- void CheckReturnedResource(size_t expected_num) {
- ReturnedResourceArray returned_resources;
- resource_collection_->TakeUnusedResourcesForChildCompositor(
- &returned_resources);
- EXPECT_EQ(expected_num, returned_resources.size());
- }
-
- scoped_refptr<DelegatedFrameResourceCollection> resource_collection_;
- scoped_refptr<DelegatedFrameProvider> frame_provider_;
- scoped_refptr<DelegatedRendererLayer> delegated_layer_;
-};
-
-TEST_F(LayerTreeHostNoMessageLoopDelegatedLayer, SingleDelegatedLayer) {
- RunTest();
-}
-
-} // namespace
-} // namespace cc
diff --git a/chromium/cc/trees/layer_tree_host_unittest_occlusion.cc b/chromium/cc/trees/layer_tree_host_unittest_occlusion.cc
index 9974ae4066b..37c56d1e74a 100644
--- a/chromium/cc/trees/layer_tree_host_unittest_occlusion.cc
+++ b/chromium/cc/trees/layer_tree_host_unittest_occlusion.cc
@@ -30,11 +30,11 @@ class LayerTreeHostOcclusionTestDrawPropertiesOnLayer
: public LayerTreeHostOcclusionTest {
public:
void SetupTree() override {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(gfx::Size(100, 100));
root->SetIsDrawable(true);
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
child->SetBounds(gfx::Size(50, 60));
child->SetPosition(gfx::PointF(10.f, 5.5f));
child->SetContentsOpaque(true);
@@ -76,18 +76,18 @@ class LayerTreeHostOcclusionTestDrawPropertiesOnSurface
: public LayerTreeHostOcclusionTest {
public:
void SetupTree() override {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(gfx::Size(100, 100));
root->SetIsDrawable(true);
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
child->SetBounds(gfx::Size(1, 1));
child->SetPosition(gfx::PointF(10.f, 5.5f));
child->SetIsDrawable(true);
child->SetForceRenderSurface(true);
root->AddChild(child);
- scoped_refptr<Layer> child2 = Layer::Create();
+ scoped_refptr<Layer> child2 = Layer::Create(layer_settings());
child2->SetBounds(gfx::Size(10, 12));
child2->SetPosition(gfx::PointF(13.f, 8.5f));
child2->SetContentsOpaque(true);
@@ -128,28 +128,29 @@ class LayerTreeHostOcclusionTestDrawPropertiesOnMask
: public LayerTreeHostOcclusionTest {
public:
void SetupTree() override {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(gfx::Size(100, 100));
root->SetIsDrawable(true);
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
child->SetBounds(gfx::Size(30, 40));
child->SetPosition(gfx::PointF(10.f, 5.5f));
child->SetIsDrawable(true);
root->AddChild(child);
- scoped_refptr<Layer> make_surface_bigger = Layer::Create();
+ scoped_refptr<Layer> make_surface_bigger = Layer::Create(layer_settings());
make_surface_bigger->SetBounds(gfx::Size(100, 100));
make_surface_bigger->SetPosition(gfx::PointF(-10.f, -15.f));
make_surface_bigger->SetIsDrawable(true);
child->AddChild(make_surface_bigger);
- scoped_refptr<Layer> mask = PictureLayer::Create(&client_);
+ scoped_refptr<Layer> mask =
+ PictureLayer::Create(layer_settings(), &client_);
mask->SetBounds(gfx::Size(30, 40));
mask->SetIsDrawable(true);
child->SetMaskLayer(mask.get());
- scoped_refptr<Layer> child2 = Layer::Create();
+ scoped_refptr<Layer> child2 = Layer::Create(layer_settings());
child2->SetBounds(gfx::Size(10, 12));
child2->SetPosition(gfx::PointF(13.f, 8.5f));
child2->SetContentsOpaque(true);
@@ -198,29 +199,30 @@ class LayerTreeHostOcclusionTestDrawPropertiesInsideReplica
: public LayerTreeHostOcclusionTest {
public:
void SetupTree() override {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(gfx::Size(100, 100));
root->SetIsDrawable(true);
- scoped_refptr<Layer> child = Layer::Create();
+ scoped_refptr<Layer> child = Layer::Create(layer_settings());
child->SetBounds(gfx::Size(1, 1));
child->SetPosition(gfx::PointF(10.f, 5.5f));
child->SetIsDrawable(true);
child->SetForceRenderSurface(true);
root->AddChild(child);
- scoped_refptr<Layer> replica = Layer::Create();
+ scoped_refptr<Layer> replica = Layer::Create(layer_settings());
gfx::Transform translate;
translate.Translate(20.f, 4.f);
replica->SetTransform(translate);
child->SetReplicaLayer(replica.get());
- scoped_refptr<Layer> mask = PictureLayer::Create(&client_);
+ scoped_refptr<Layer> mask =
+ PictureLayer::Create(layer_settings(), &client_);
mask->SetBounds(gfx::Size(30, 40));
mask->SetIsDrawable(true);
child->SetMaskLayer(mask.get());
- scoped_refptr<Layer> child2 = Layer::Create();
+ scoped_refptr<Layer> child2 = Layer::Create(layer_settings());
child2->SetBounds(gfx::Size(10, 12));
child2->SetPosition(gfx::PointF(13.f, 8.5f));
child2->SetContentsOpaque(true);
diff --git a/chromium/cc/trees/layer_tree_host_unittest_picture.cc b/chromium/cc/trees/layer_tree_host_unittest_picture.cc
index 6f222f71e71..7a0d7bfa520 100644
--- a/chromium/cc/trees/layer_tree_host_unittest_picture.cc
+++ b/chromium/cc/trees/layer_tree_host_unittest_picture.cc
@@ -17,10 +17,10 @@ namespace {
class LayerTreeHostPictureTest : public LayerTreeTest {
protected:
void SetupTreeWithSinglePictureLayer(const gfx::Size& size) {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(size);
- root_picture_layer_ = FakePictureLayer::Create(&client_);
+ root_picture_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
root_picture_layer_->SetBounds(size);
root->AddChild(root_picture_layer_);
@@ -57,7 +57,7 @@ class LayerTreeHostPictureTestTwinLayer
// Add a new picture layer so the activate will have a pending layer
// without an active twin.
scoped_refptr<FakePictureLayer> picture =
- FakePictureLayer::Create(&client_);
+ FakePictureLayer::Create(layer_settings(), &client_);
layer_tree_host()->root_layer()->AddChild(picture);
break;
}
@@ -107,24 +107,16 @@ class LayerTreeHostPictureTestTwinLayer
active_picture_impl->GetPendingOrActiveTwinLayer());
EXPECT_EQ(active_picture_impl,
pending_picture_impl->GetPendingOrActiveTwinLayer());
- EXPECT_EQ(nullptr, active_picture_impl->GetRecycledTwinLayer());
}
void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
LayerImpl* active_root_impl = impl->active_tree()->root_layer();
- LayerImpl* recycle_root_impl = impl->recycle_tree()->root_layer();
-
if (active_root_impl->children().empty()) {
EXPECT_EQ(2, activates_);
} else {
FakePictureLayerImpl* active_picture_impl =
static_cast<FakePictureLayerImpl*>(active_root_impl->children()[0]);
- FakePictureLayerImpl* recycle_picture_impl =
- static_cast<FakePictureLayerImpl*>(recycle_root_impl->children()[0]);
-
EXPECT_EQ(nullptr, active_picture_impl->GetPendingOrActiveTwinLayer());
- EXPECT_EQ(recycle_picture_impl,
- active_picture_impl->GetRecycledTwinLayer());
}
++activates_;
@@ -136,7 +128,7 @@ class LayerTreeHostPictureTestTwinLayer
};
// There is no pending layers in single thread mode.
-MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestTwinLayer);
+MULTI_THREAD_TEST_F(LayerTreeHostPictureTestTwinLayer);
class LayerTreeHostPictureTestResizeViewportWithGpuRaster
: public LayerTreeHostPictureTest {
@@ -145,11 +137,11 @@ class LayerTreeHostPictureTestResizeViewportWithGpuRaster
}
void SetupTree() override {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(gfx::Size(768, 960));
client_.set_fill_with_nonsolid_color(true);
- picture_ = FakePictureLayer::Create(&client_);
+ picture_ = FakePictureLayer::Create(layer_settings(), &client_);
picture_->SetBounds(gfx::Size(768, 960));
root->AddChild(picture_);
@@ -199,7 +191,7 @@ class LayerTreeHostPictureTestResizeViewportWithGpuRaster
scoped_refptr<FakePictureLayer> picture_;
};
-SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(
+SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostPictureTestResizeViewportWithGpuRaster);
class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree
@@ -208,13 +200,13 @@ class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree
frame_ = 0;
did_post_commit_ = false;
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(gfx::Size(100, 100));
// The layer is big enough that the live tiles rect won't cover the full
// layer.
client_.set_fill_with_nonsolid_color(true);
- picture_ = FakePictureLayer::Create(&client_);
+ picture_ = FakePictureLayer::Create(layer_settings(), &client_);
picture_->SetBounds(gfx::Size(100, 100000));
root->AddChild(picture_);
@@ -228,13 +220,9 @@ class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree
LayerImpl* child = impl->active_tree()->root_layer()->children()[0];
FakePictureLayerImpl* picture_impl =
static_cast<FakePictureLayerImpl*>(child);
- FakePictureLayerImpl* recycled_impl = static_cast<FakePictureLayerImpl*>(
- picture_impl->GetRecycledTwinLayer());
-
switch (++frame_) {
case 1: {
PictureLayerTiling* tiling = picture_impl->HighResTiling();
- PictureLayerTiling* recycled_tiling = recycled_impl->HighResTiling();
int num_tiles_y = tiling->TilingDataForTesting().num_tiles_y();
// There should be tiles at the top of the picture layer but not at the
@@ -242,52 +230,34 @@ class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree
EXPECT_TRUE(tiling->TileAt(0, 0));
EXPECT_FALSE(tiling->TileAt(0, num_tiles_y));
- // The recycled tiling has no tiles.
- EXPECT_FALSE(recycled_tiling->TileAt(0, 0));
- EXPECT_FALSE(recycled_tiling->TileAt(0, num_tiles_y));
-
- // The live tiles rect matches on the recycled tree.
- EXPECT_EQ(tiling->live_tiles_rect(),
- recycled_tiling->live_tiles_rect());
-
// Make the bottom of the layer visible.
- picture_impl->SetPosition(gfx::PointF(0.f, -100000.f + 100.f));
+ gfx::Transform transform;
+ transform.Translate(0.f, -100000.f + 100.f);
+ picture_impl->SetTransform(transform);
+ picture_impl->UpdatePropertyTreeTransform();
impl->SetNeedsRedraw();
break;
}
case 2: {
PictureLayerTiling* tiling = picture_impl->HighResTiling();
- PictureLayerTiling* recycled_tiling = recycled_impl->HighResTiling();
// There not be tiles at the top of the layer now.
EXPECT_FALSE(tiling->TileAt(0, 0));
- // The recycled twin tiling should not have unshared tiles at the top
- // either.
- EXPECT_FALSE(recycled_tiling->TileAt(0, 0));
-
// Make the top of the layer visible again.
- picture_impl->SetPosition(gfx::PointF());
+ picture_impl->SetTransform(gfx::Transform());
+ picture_impl->UpdatePropertyTreeTransform();
impl->SetNeedsRedraw();
break;
}
case 3: {
PictureLayerTiling* tiling = picture_impl->HighResTiling();
- PictureLayerTiling* recycled_tiling = recycled_impl->HighResTiling();
int num_tiles_y = tiling->TilingDataForTesting().num_tiles_y();
// There should be tiles at the top of the picture layer again.
EXPECT_TRUE(tiling->TileAt(0, 0));
EXPECT_FALSE(tiling->TileAt(0, num_tiles_y));
- // The recycled tiling should have no tiles.
- EXPECT_FALSE(recycled_tiling->TileAt(0, 0));
- EXPECT_FALSE(recycled_tiling->TileAt(0, num_tiles_y));
-
- // The live tiles rect matches on the recycled tree.
- EXPECT_EQ(tiling->live_tiles_rect(),
- recycled_tiling->live_tiles_rect());
-
// Make a new main frame without changing the picture layer at all, so
// it won't need to update or push properties.
did_post_commit_ = true;
@@ -328,20 +298,19 @@ class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree
};
// Multi-thread only since there is no recycle tree in single thread.
-MULTI_THREAD_IMPL_TEST_F(
- LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree);
+MULTI_THREAD_TEST_F(LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree);
class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest {
void SetupTree() override {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(gfx::Size(100, 100));
- child_ = Layer::Create();
+ child_ = Layer::Create(layer_settings());
root->AddChild(child_);
// Don't be solid color so the layer has tilings/tiles.
client_.set_fill_with_nonsolid_color(true);
- picture_ = FakePictureLayer::Create(&client_);
+ picture_ = FakePictureLayer::Create(layer_settings(), &client_);
picture_->SetBounds(gfx::Size(100, 100));
child_->AddChild(picture_);
@@ -417,15 +386,15 @@ class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest {
scoped_refptr<FakePictureLayer> picture_;
};
-SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembership);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostPictureTestRSLLMembership);
class LayerTreeHostPictureTestRSLLMembershipWithScale
: public LayerTreeHostPictureTest {
void SetupTree() override {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(gfx::Size(100, 100));
- pinch_ = Layer::Create();
+ pinch_ = Layer::Create(layer_settings());
pinch_->SetBounds(gfx::Size(500, 500));
pinch_->SetScrollClipLayerId(root->id());
pinch_->SetIsContainerForFixedPositionLayers(true);
@@ -433,7 +402,7 @@ class LayerTreeHostPictureTestRSLLMembershipWithScale
// Don't be solid color so the layer has tilings/tiles.
client_.set_fill_with_nonsolid_color(true);
- picture_ = FakePictureLayer::Create(&client_);
+ picture_ = FakePictureLayer::Create(layer_settings(), &client_);
picture_->SetBounds(gfx::Size(100, 100));
pinch_->AddChild(picture_);
@@ -568,7 +537,7 @@ class LayerTreeHostPictureTestRSLLMembershipWithScale
// Multi-thread only because in single thread you can't pinch zoom on the
// compositor thread.
// Disabled due to flakiness. See http://crbug.com/460581
-// MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale);
+// MULTI_THREAD_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale);
} // namespace
} // namespace cc
diff --git a/chromium/cc/trees/layer_tree_host_unittest_proxy.cc b/chromium/cc/trees/layer_tree_host_unittest_proxy.cc
index 313510371e7..66340e7bbff 100644
--- a/chromium/cc/trees/layer_tree_host_unittest_proxy.cc
+++ b/chromium/cc/trees/layer_tree_host_unittest_proxy.cc
@@ -7,16 +7,8 @@
#include "cc/test/layer_tree_test.h"
#include "cc/trees/thread_proxy.h"
-#define THREAD_PROXY_NO_IMPL_TEST_F(TEST_FIXTURE_NAME) \
- TEST_F(TEST_FIXTURE_NAME, Run_MainThreadPaint) { \
- Run(true, false); \
- }
-
-#define THREAD_PROXY_TEST_F(TEST_FIXTURE_NAME) \
- THREAD_PROXY_NO_IMPL_TEST_F(TEST_FIXTURE_NAME); \
- TEST_F(TEST_FIXTURE_NAME, Run_ImplSidePaint) { \
- Run(true, true); \
- }
+#define THREAD_PROXY_TEST_F(TEST_FIXTURE_NAME) \
+ TEST_F(TEST_FIXTURE_NAME, MultiThread) { Run(true); }
// Do common tests for single thread proxy and thread proxy.
// TODO(simonhong): Add SINGLE_THREAD_PROXY_TEST_F
@@ -30,11 +22,11 @@ class ProxyTest : public LayerTreeTest {
ProxyTest() {}
~ProxyTest() override {}
- void Run(bool threaded, bool impl_side_painting) {
+ void Run(bool threaded) {
// We don't need to care about delegating mode.
bool delegating_renderer = true;
- RunTest(threaded, delegating_renderer, impl_side_painting);
+ RunTest(threaded, delegating_renderer);
}
void BeginTest() override {}
diff --git a/chromium/cc/trees/layer_tree_host_unittest_scroll.cc b/chromium/cc/trees/layer_tree_host_unittest_scroll.cc
index 4e77a2d245f..dc075b563cf 100644
--- a/chromium/cc/trees/layer_tree_host_unittest_scroll.cc
+++ b/chromium/cc/trees/layer_tree_host_unittest_scroll.cc
@@ -19,6 +19,7 @@
#include "cc/test/geometry_test_utils.h"
#include "cc/test/layer_tree_test.h"
#include "cc/test/test_shared_bitmap_manager.h"
+#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_impl.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
@@ -39,7 +40,7 @@ class LayerTreeHostScrollTestScrollSimple : public LayerTreeHostScrollTest {
void BeginTest() override {
Layer* root_layer = layer_tree_host()->root_layer();
- scoped_refptr<Layer> scroll_layer = Layer::Create();
+ scoped_refptr<Layer> scroll_layer = Layer::Create(layer_settings());
root_layer->AddChild(scroll_layer);
// Create an effective max_scroll_offset of (100, 100).
scroll_layer->SetBounds(gfx::Size(root_layer->bounds().width() + 100,
@@ -92,7 +93,9 @@ class LayerTreeHostScrollTestScrollSimple : public LayerTreeHostScrollTest {
}
}
- void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
+ void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
+ const gfx::Vector2dF& outer_delta,
+ const gfx::Vector2dF& elastic_overscroll_delta,
float scale,
float top_controls_delta) override {
num_scrolls_++;
@@ -117,7 +120,7 @@ class LayerTreeHostScrollTestScrollMultipleRedraw
void BeginTest() override {
Layer* root_layer = layer_tree_host()->root_layer();
- scroll_layer_ = Layer::Create();
+ scroll_layer_ = Layer::Create(layer_settings());
root_layer->AddChild(scroll_layer_);
// Create an effective max_scroll_offset of (100, 100).
scroll_layer_->SetBounds(gfx::Size(root_layer->bounds().width() + 100,
@@ -154,7 +157,7 @@ class LayerTreeHostScrollTestScrollMultipleRedraw
LayerImpl* scroll_layer =
impl->active_tree()->LayerById(scroll_layer_->id());
if (impl->active_tree()->source_frame_number() == 0 &&
- impl->SourceAnimationFrameNumber() == 1) {
+ impl->SourceAnimationFrameNumberForTesting() == 1) {
// First draw after first commit.
EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d());
scroll_layer->ScrollBy(scroll_amount_);
@@ -163,7 +166,7 @@ class LayerTreeHostScrollTestScrollMultipleRedraw
EXPECT_VECTOR_EQ(scroll_layer->BaseScrollOffset(), initial_scroll_);
PostSetNeedsRedrawToMainThread();
} else if (impl->active_tree()->source_frame_number() == 0 &&
- impl->SourceAnimationFrameNumber() == 2) {
+ impl->SourceAnimationFrameNumberForTesting() == 2) {
// Second draw after first commit.
EXPECT_EQ(scroll_layer->ScrollDelta(), scroll_amount_);
scroll_layer->ScrollBy(scroll_amount_);
@@ -174,7 +177,7 @@ class LayerTreeHostScrollTestScrollMultipleRedraw
PostSetNeedsCommitToMainThread();
} else if (impl->active_tree()->source_frame_number() == 1) {
// Third or later draw after second commit.
- EXPECT_GE(impl->SourceAnimationFrameNumber(), 3);
+ EXPECT_GE(impl->SourceAnimationFrameNumberForTesting(), 3u);
EXPECT_VECTOR_EQ(scroll_layer_->ScrollDelta(), gfx::Vector2d());
EXPECT_VECTOR_EQ(
scroll_layer_->scroll_offset(),
@@ -184,7 +187,9 @@ class LayerTreeHostScrollTestScrollMultipleRedraw
}
}
- void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
+ void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
+ const gfx::Vector2dF& outer_delta,
+ const gfx::Vector2dF& elastic_overscroll_delta,
float scale,
float top_controls_delta) override {
num_scrolls_++;
@@ -221,7 +226,7 @@ class LayerTreeHostScrollTestScrollAbortedCommit
void SetupTree() override {
LayerTreeHostScrollTest::SetupTree();
Layer* root_layer = layer_tree_host()->root_layer();
- scoped_refptr<Layer> root_scroll_layer = Layer::Create();
+ scoped_refptr<Layer> root_scroll_layer = Layer::Create(layer_settings());
root_scroll_layer->SetScrollClipLayerId(root_layer->id());
root_scroll_layer->SetScrollOffset(initial_scroll_);
root_scroll_layer->SetBounds(gfx::Size(200, 200));
@@ -301,7 +306,7 @@ class LayerTreeHostScrollTestScrollAbortedCommit
impl->active_tree()->root_layer()->children()[0];
if (impl->active_tree()->source_frame_number() == 0 &&
- impl->SourceAnimationFrameNumber() == 1) {
+ impl->SourceAnimationFrameNumberForTesting() == 1) {
// First draw
EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d());
root_scroll_layer->ScrollBy(impl_scroll_);
@@ -317,7 +322,7 @@ class LayerTreeHostScrollTestScrollAbortedCommit
// To simplify the testing flow, don't redraw here, just commit.
impl->SetNeedsCommit();
} else if (impl->active_tree()->source_frame_number() == 0 &&
- impl->SourceAnimationFrameNumber() == 2) {
+ impl->SourceAnimationFrameNumberForTesting() == 2) {
// Test a second draw after an aborted commit.
// The scroll/scale values should be baked into the offset/scale factor
// since the main thread consumed but aborted the begin frame.
@@ -340,7 +345,7 @@ class LayerTreeHostScrollTestScrollAbortedCommit
// Commit for source frame 1 is aborted.
NOTREACHED();
} else if (impl->active_tree()->source_frame_number() == 2 &&
- impl->SourceAnimationFrameNumber() == 3) {
+ impl->SourceAnimationFrameNumberForTesting() == 3) {
// Third draw after the second full commit.
EXPECT_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d());
root_scroll_layer->ScrollBy(impl_scroll_);
@@ -350,7 +355,7 @@ class LayerTreeHostScrollTestScrollAbortedCommit
EXPECT_VECTOR_EQ(root_scroll_layer->BaseScrollOffset(),
gfx::ScrollOffsetWithDelta(initial_scroll_, delta));
} else if (impl->active_tree()->source_frame_number() == 2 &&
- impl->SourceAnimationFrameNumber() == 4) {
+ impl->SourceAnimationFrameNumberForTesting() == 4) {
// Final draw after the second aborted commit.
EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d());
gfx::Vector2dF delta =
@@ -364,7 +369,9 @@ class LayerTreeHostScrollTestScrollAbortedCommit
}
}
- void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
+ void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
+ const gfx::Vector2dF& outer_delta,
+ const gfx::Vector2dF& elastic_overscroll_delta,
float scale,
float top_controls_delta) override {
num_impl_scrolls_++;
@@ -403,7 +410,7 @@ class LayerTreeHostScrollTestFractionalScroll : public LayerTreeHostScrollTest {
void SetupTree() override {
LayerTreeHostScrollTest::SetupTree();
Layer* root_layer = layer_tree_host()->root_layer();
- scoped_refptr<Layer> root_scroll_layer = Layer::Create();
+ scoped_refptr<Layer> root_scroll_layer = Layer::Create(layer_settings());
root_scroll_layer->SetScrollClipLayerId(root_layer->id());
root_scroll_layer->SetBounds(
gfx::Size(root_layer->bounds().width() + 100,
@@ -470,10 +477,11 @@ class LayerTreeHostScrollTestCaseWithChild : public LayerTreeHostScrollTest {
void SetupTree() override {
layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_);
- scoped_refptr<Layer> root_layer = Layer::Create();
+ scoped_refptr<Layer> root_layer = Layer::Create(layer_settings());
root_layer->SetBounds(gfx::Size(10, 10));
- root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_);
+ root_scroll_layer_ =
+ FakePictureLayer::Create(layer_settings(), &fake_content_layer_client_);
root_scroll_layer_->SetBounds(gfx::Size(110, 110));
root_scroll_layer_->SetPosition(gfx::Point());
@@ -483,7 +491,8 @@ class LayerTreeHostScrollTestCaseWithChild : public LayerTreeHostScrollTest {
root_scroll_layer_->SetIsContainerForFixedPositionLayers(true);
root_layer->AddChild(root_scroll_layer_);
- child_layer_ = FakePictureLayer::Create(&fake_content_layer_client_);
+ child_layer_ =
+ FakePictureLayer::Create(layer_settings(), &fake_content_layer_client_);
child_layer_->set_did_scroll_callback(
base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll,
base::Unretained(this)));
@@ -534,7 +543,9 @@ class LayerTreeHostScrollTestCaseWithChild : public LayerTreeHostScrollTest {
final_scroll_offset_ = expected_scroll_layer_->scroll_offset();
}
- void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
+ void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
+ const gfx::Vector2dF& outer_delta,
+ const gfx::Vector2dF& elastic_overscroll_delta,
float scale,
float top_controls_delta) override {
num_scrolls_++;
@@ -670,101 +681,89 @@ TEST_F(LayerTreeHostScrollTestCaseWithChild,
DeviceScaleFactor1_ScrollChild_DirectRenderer) {
device_scale_factor_ = 1.f;
scroll_child_layer_ = true;
- RunTest(true, false, true);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostScrollTestCaseWithChild,
DeviceScaleFactor1_ScrollChild_DelegatingRenderer) {
device_scale_factor_ = 1.f;
scroll_child_layer_ = true;
- RunTest(true, true, true);
+ RunTest(true, true);
}
TEST_F(LayerTreeHostScrollTestCaseWithChild,
DeviceScaleFactor15_ScrollChild_DirectRenderer) {
device_scale_factor_ = 1.5f;
scroll_child_layer_ = true;
- RunTest(true, false, true);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostScrollTestCaseWithChild,
DeviceScaleFactor15_ScrollChild_DelegatingRenderer) {
device_scale_factor_ = 1.5f;
scroll_child_layer_ = true;
- RunTest(true, true, true);
+ RunTest(true, true);
}
TEST_F(LayerTreeHostScrollTestCaseWithChild,
DeviceScaleFactor2_ScrollChild_DirectRenderer) {
device_scale_factor_ = 2.f;
scroll_child_layer_ = true;
- RunTest(true, false, true);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostScrollTestCaseWithChild,
DeviceScaleFactor2_ScrollChild_DelegatingRenderer) {
device_scale_factor_ = 2.f;
scroll_child_layer_ = true;
- RunTest(true, true, true);
+ RunTest(true, true);
}
TEST_F(LayerTreeHostScrollTestCaseWithChild,
DeviceScaleFactor1_ScrollRootScrollLayer_DirectRenderer) {
device_scale_factor_ = 1.f;
scroll_child_layer_ = false;
- RunTest(true, false, true);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostScrollTestCaseWithChild,
DeviceScaleFactor1_ScrollRootScrollLayer_DelegatingRenderer) {
device_scale_factor_ = 1.f;
scroll_child_layer_ = false;
- RunTest(true, true, true);
+ RunTest(true, true);
}
TEST_F(LayerTreeHostScrollTestCaseWithChild,
DeviceScaleFactor15_ScrollRootScrollLayer_DirectRenderer) {
device_scale_factor_ = 1.5f;
scroll_child_layer_ = false;
- RunTest(true, false, true);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostScrollTestCaseWithChild,
DeviceScaleFactor15_ScrollRootScrollLayer_DelegatingRenderer) {
device_scale_factor_ = 1.5f;
scroll_child_layer_ = false;
- RunTest(true, true, true);
+ RunTest(true, true);
}
TEST_F(LayerTreeHostScrollTestCaseWithChild,
DeviceScaleFactor2_ScrollRootScrollLayer_DirectRenderer) {
device_scale_factor_ = 2.f;
scroll_child_layer_ = false;
- RunTest(true, false, true);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostScrollTestCaseWithChild,
DeviceScaleFactor2_ScrollRootScrollLayer_DelegatingRenderer) {
device_scale_factor_ = 2.f;
scroll_child_layer_ = false;
- RunTest(true, true, true);
+ RunTest(true, true);
}
-class ImplSidePaintingScrollTest : public LayerTreeHostScrollTest {
+class LayerTreeHostScrollTestSimple : public LayerTreeHostScrollTest {
public:
- void InitializeSettings(LayerTreeSettings* settings) override {
- settings->impl_side_painting = true;
- }
-
- void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
- if (impl->pending_tree())
- impl->SetNeedsRedraw();
- }
-};
-
-class ImplSidePaintingScrollTestSimple : public ImplSidePaintingScrollTest {
- public:
- ImplSidePaintingScrollTestSimple()
+ LayerTreeHostScrollTestSimple()
: initial_scroll_(10, 20),
main_thread_scroll_(40, 5),
impl_thread_scroll1_(2, -1),
@@ -774,7 +773,7 @@ class ImplSidePaintingScrollTestSimple : public ImplSidePaintingScrollTest {
void SetupTree() override {
LayerTreeHostScrollTest::SetupTree();
Layer* root_layer = layer_tree_host()->root_layer();
- scoped_refptr<Layer> root_scroll_layer = Layer::Create();
+ scoped_refptr<Layer> root_scroll_layer = Layer::Create(layer_settings());
root_scroll_layer->SetScrollClipLayerId(root_layer->id());
root_scroll_layer->SetScrollOffset(initial_scroll_);
root_scroll_layer->SetBounds(
@@ -817,7 +816,8 @@ class ImplSidePaintingScrollTestSimple : public ImplSidePaintingScrollTest {
}
void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
- ImplSidePaintingScrollTest::DrawLayersOnThread(impl);
+ if (impl->pending_tree())
+ impl->SetNeedsRedraw();
LayerImpl* root = impl->active_tree()->root_layer();
LayerImpl* scroll_layer = root->children()[0];
@@ -868,7 +868,9 @@ class ImplSidePaintingScrollTestSimple : public ImplSidePaintingScrollTest {
}
}
- void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
+ void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
+ const gfx::Vector2dF& outer_delta,
+ const gfx::Vector2dF& elastic_overscroll_delta,
float scale,
float top_controls_delta) override {
num_scrolls_++;
@@ -884,22 +886,22 @@ class ImplSidePaintingScrollTestSimple : public ImplSidePaintingScrollTest {
int num_scrolls_;
};
-MULTI_THREAD_TEST_F(ImplSidePaintingScrollTestSimple);
+// This tests scrolling on the impl side which is only possible with a thread.
+MULTI_THREAD_TEST_F(LayerTreeHostScrollTestSimple);
// This test makes sure that layers pick up scrolls that occur between
// beginning a commit and finishing a commit (aka scroll deltas not
// included in sent scroll delta) still apply to layers that don't
// push properties.
-class ImplSidePaintingScrollTestImplOnlyScroll
- : public ImplSidePaintingScrollTest {
+class LayerTreeHostScrollTestImplOnlyScroll : public LayerTreeHostScrollTest {
public:
- ImplSidePaintingScrollTestImplOnlyScroll()
+ LayerTreeHostScrollTestImplOnlyScroll()
: initial_scroll_(20, 10), impl_thread_scroll_(-2, 3), impl_scale_(2.f) {}
void SetupTree() override {
LayerTreeHostScrollTest::SetupTree();
Layer* root_layer = layer_tree_host()->root_layer();
- scoped_refptr<Layer> root_scroll_layer = Layer::Create();
+ scoped_refptr<Layer> root_scroll_layer = Layer::Create(layer_settings());
root_scroll_layer->SetScrollClipLayerId(root_layer->id());
root_scroll_layer->SetScrollOffset(initial_scroll_);
root_scroll_layer->SetBounds(
@@ -986,7 +988,8 @@ class ImplSidePaintingScrollTestImplOnlyScroll
}
void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
- ImplSidePaintingScrollTest::DrawLayersOnThread(impl);
+ if (impl->pending_tree())
+ impl->SetNeedsRedraw();
LayerImpl* root = impl->active_tree()->root_layer();
LayerImpl* scroll_layer = root->children()[0];
@@ -1024,7 +1027,8 @@ class ImplSidePaintingScrollTestImplOnlyScroll
float impl_scale_;
};
-MULTI_THREAD_TEST_F(ImplSidePaintingScrollTestImplOnlyScroll);
+// This tests scrolling on the impl side which is only possible with a thread.
+MULTI_THREAD_TEST_F(LayerTreeHostScrollTestImplOnlyScroll);
class LayerTreeHostScrollTestScrollZeroMaxScrollOffset
: public LayerTreeHostScrollTest {
@@ -1033,7 +1037,7 @@ class LayerTreeHostScrollTestScrollZeroMaxScrollOffset
void SetupTree() override {
LayerTreeTest::SetupTree();
- scoped_refptr<Layer> scroll_layer = Layer::Create();
+ scoped_refptr<Layer> scroll_layer = Layer::Create(layer_settings());
layer_tree_host()->root_layer()->AddChild(scroll_layer);
}
@@ -1126,13 +1130,14 @@ TEST(LayerTreeHostFlingTest, DidStopFlingingThread) {
impl_thread.task_runner().get(), &received_stop_flinging);
FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
- ASSERT_TRUE(impl_thread.task_runner().get());
- scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
- new TestSharedBitmapManager());
+ ASSERT_TRUE(impl_thread.task_runner());
+ TestSharedBitmapManager shared_bitmap_manager;
+ TestTaskGraphRunner task_graph_runner;
LayerTreeHost::InitParams params;
params.client = &client;
- params.shared_bitmap_manager = shared_bitmap_manager.get();
+ params.shared_bitmap_manager = &shared_bitmap_manager;
+ params.task_graph_runner = &task_graph_runner;
params.settings = &settings;
params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
scoped_ptr<LayerTreeHost> layer_tree_host =
@@ -1156,7 +1161,7 @@ class LayerTreeHostScrollTestLayerStructureChange
: scroll_destroy_whole_tree_(false) {}
void SetupTree() override {
- scoped_refptr<Layer> root_layer = Layer::Create();
+ scoped_refptr<Layer> root_layer = Layer::Create(layer_settings());
root_layer->SetBounds(gfx::Size(10, 10));
Layer* root_scroll_layer =
@@ -1208,7 +1213,7 @@ class LayerTreeHostScrollTestLayerStructureChange
Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) {
scoped_refptr<PictureLayer> scroll_layer =
- PictureLayer::Create(&fake_content_layer_client_);
+ PictureLayer::Create(layer_settings(), &fake_content_layer_client_);
scroll_layer->SetBounds(gfx::Size(110, 110));
scroll_layer->SetPosition(gfx::Point(0, 0));
scroll_layer->SetIsDrawable(true);
@@ -1233,12 +1238,12 @@ class LayerTreeHostScrollTestLayerStructureChange
};
TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyLayer) {
- RunTest(true, false, true);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) {
scroll_destroy_whole_tree_ = true;
- RunTest(true, false, true);
+ RunTest(true, false);
}
} // namespace
diff --git a/chromium/cc/trees/layer_tree_host_unittest_video.cc b/chromium/cc/trees/layer_tree_host_unittest_video.cc
index ffeda727fe3..31854ac68a9 100644
--- a/chromium/cc/trees/layer_tree_host_unittest_video.cc
+++ b/chromium/cc/trees/layer_tree_host_unittest_video.cc
@@ -23,12 +23,12 @@ class LayerTreeHostVideoTestSetNeedsDisplay
: public LayerTreeHostVideoTest {
public:
void SetupTree() override {
- scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> root = Layer::Create(layer_settings());
root->SetBounds(gfx::Size(10, 10));
root->SetIsDrawable(true);
- scoped_refptr<VideoLayer> video =
- VideoLayer::Create(&video_frame_provider_, media::VIDEO_ROTATION_90);
+ scoped_refptr<VideoLayer> video = VideoLayer::Create(
+ layer_settings(), &video_frame_provider_, media::VIDEO_ROTATION_90);
video->SetPosition(gfx::PointF(3.f, 3.f));
video->SetBounds(gfx::Size(4, 5));
video->SetIsDrawable(true);
diff --git a/chromium/cc/trees/layer_tree_impl.cc b/chromium/cc/trees/layer_tree_impl.cc
index 01a4cfd19ec..d4d2dee7f23 100644
--- a/chromium/cc/trees/layer_tree_impl.cc
+++ b/chromium/cc/trees/layer_tree_impl.cc
@@ -10,13 +10,13 @@
#include "base/trace_event/trace_event.h"
#include "base/trace_event/trace_event_argument.h"
+#include "cc/animation/animation_host.h"
#include "cc/animation/keyframed_animation_curve.h"
#include "cc/animation/scrollbar_animation_controller.h"
#include "cc/animation/scrollbar_animation_controller_linear_fade.h"
#include "cc/animation/scrollbar_animation_controller_thinning.h"
#include "cc/base/math_util.h"
#include "cc/base/synced_property.h"
-#include "cc/base/util.h"
#include "cc/debug/devtools_instrumentation.h"
#include "cc/debug/traced_value.h"
#include "cc/input/layer_scroll_offset_delegate.h"
@@ -30,6 +30,9 @@
#include "cc/trees/layer_tree_host_common.h"
#include "cc/trees/layer_tree_host_impl.h"
#include "cc/trees/occlusion_tracker.h"
+#include "cc/trees/property_tree.h"
+#include "cc/trees/property_tree_builder.h"
+#include "ui/gfx/geometry/box_f.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
@@ -57,7 +60,6 @@ LayerTreeImpl::LayerTreeImpl(
max_page_scale_factor_(0),
elastic_overscroll_(elastic_overscroll),
scrolling_layer_id_from_previous_tree_(0),
- contents_textures_purged_(false),
viewport_size_invalid_(false),
needs_update_draw_properties_(true),
needs_full_tree_sync_(true),
@@ -112,9 +114,9 @@ void LayerTreeImpl::GatherFrameTimingRequestIds(
});
}
-bool LayerTreeImpl::IsExternalFlingActive() const {
+bool LayerTreeImpl::IsExternalScrollActive() const {
return root_layer_scroll_offset_delegate_ &&
- root_layer_scroll_offset_delegate_->IsExternalFlingActive();
+ root_layer_scroll_offset_delegate_->IsExternalScrollActive();
}
void LayerTreeImpl::DidUpdateScrollOffset(int layer_id) {
@@ -189,6 +191,40 @@ scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() {
return root_layer_.Pass();
}
+static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer,
+ ClipTree* clip_tree) {
+ if (layer && layer->masks_to_bounds()) {
+ ClipNode* clip_node = clip_tree->Node(layer->clip_tree_index());
+ if (clip_node) {
+ DCHECK_EQ(layer->id(), clip_node->owner_id);
+ gfx::Size bounds = layer->bounds();
+ if (clip_node->data.clip.size() != bounds) {
+ clip_node->data.clip.set_size(bounds);
+ clip_tree->set_needs_update(true);
+ }
+ }
+ }
+}
+
+void LayerTreeImpl::UpdatePropertyTreesForBoundsDelta() {
+ DCHECK(IsActiveTree());
+ LayerImpl* inner_container = InnerViewportContainerLayer();
+ LayerImpl* outer_container = OuterViewportContainerLayer();
+
+ UpdateClipTreeForBoundsDeltaOnLayer(inner_container,
+ &property_trees_.clip_tree);
+ UpdateClipTreeForBoundsDeltaOnLayer(InnerViewportScrollLayer(),
+ &property_trees_.clip_tree);
+ UpdateClipTreeForBoundsDeltaOnLayer(outer_container,
+ &property_trees_.clip_tree);
+
+ TransformTree& transform_tree = property_trees_.transform_tree;
+ if (inner_container)
+ transform_tree.SetInnerViewportBoundsDelta(inner_container->bounds_delta());
+ if (outer_container)
+ transform_tree.SetOuterViewportBoundsDelta(outer_container->bounds_delta());
+}
+
void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) {
// The request queue should have been processed and does not require a push.
DCHECK_EQ(ui_resource_request_queue_.size(), 0u);
@@ -235,11 +271,6 @@ void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) {
target_tree->set_background_color(background_color());
target_tree->set_has_transparent_background(has_transparent_background());
- if (ContentsTexturesPurged())
- target_tree->SetContentsTexturesPurged();
- else
- target_tree->ResetContentsTexturesPurged();
-
if (ViewportSizeInvalid())
target_tree->SetViewportSizeInvalid();
else
@@ -313,6 +344,21 @@ float LayerTreeImpl::ClampPageScaleFactorToLimits(
return page_scale_factor;
}
+void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() {
+ // TODO(enne): This should get replaced by pulling out scrolling and
+ // animations into their own trees. Then scrolls and animations would have
+ // their own ways of synchronizing across commits. This occurs to push
+ // updates from scrolling deltas on the compositor thread that have occurred
+ // after begin frame and updates from animations that have ticked since begin
+ // frame to a newly-committed property tree.
+ if (!root_layer())
+ return;
+ LayerTreeHostCommon::CallFunctionForSubtree(
+ root_layer(), [](LayerImpl* layer) {
+ layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded();
+ });
+}
+
void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) {
DCHECK(IsActiveTree());
if (page_scale_factor()->SetCurrent(
@@ -334,11 +380,21 @@ void LayerTreeImpl::PushPageScaleFactorAndLimits(const float* page_scale_factor,
bool changed_page_scale = false;
if (page_scale_factor) {
DCHECK(!IsActiveTree() || !layer_tree_host_impl_->pending_tree());
+ changed_page_scale |= page_scale_factor_->Delta() != 1.f;
+ // TODO(enne): Once CDP goes away, ignore this call below. The only time
+ // the property trees will differ is if there's been a page scale on the
+ // compositor thread after the begin frame, which is the delta check above.
changed_page_scale |=
page_scale_factor_->PushFromMainThread(*page_scale_factor);
}
- if (IsActiveTree())
+ if (IsActiveTree()) {
+ // TODO(enne): Pushing from pending to active should never require
+ // DidUpdatePageScale. The values should already be set by the fully
+ // computed property trees being synced from one tree to another. Remove
+ // this once CDP goes away.
changed_page_scale |= page_scale_factor_->PushPendingToActive();
+ }
+
changed_page_scale |=
SetPageScaleFactorLimits(min_page_scale_factor, max_page_scale_factor);
@@ -414,6 +470,21 @@ void LayerTreeImpl::DidUpdatePageScale() {
max_page_scale_factor_);
}
+ if (page_scale_layer() && page_scale_layer()->transform_tree_index() != -1) {
+ TransformNode* node = property_trees_.transform_tree.Node(
+ page_scale_layer()->transform_tree_index());
+ node->data.post_local_scale_factor = current_page_scale_factor();
+ node->data.needs_local_transform_update = true;
+ // TODO(enne): property trees can't ask the layer these things, but
+ // the page scale layer should *just* be the page scale.
+ DCHECK_EQ(page_scale_layer()->position().ToString(),
+ gfx::PointF().ToString());
+ DCHECK_EQ(page_scale_layer()->transform_origin().ToString(),
+ gfx::Point3F().ToString());
+ node->data.update_post_local_transform(gfx::PointF(), gfx::Point3F());
+ property_trees_.transform_tree.set_needs_update(true);
+ }
+
ForceScrollbarParameterUpdateAfterScaleChange(page_scale_layer());
HideInnerViewportScrollbarsIfNearMinimumScale();
@@ -464,7 +535,7 @@ gfx::Rect LayerTreeImpl::RootScrollLayerDeviceViewportBounds() const {
return gfx::Rect();
LayerImpl* layer = root_scroll_layer->children()[0];
return MathUtil::MapEnclosingClippedRect(layer->screen_space_transform(),
- gfx::Rect(layer->content_bounds()));
+ gfx::Rect(layer->bounds()));
}
void LayerTreeImpl::ApplySentScrollAndScaleDeltasFromAbortedCommit() {
@@ -547,6 +618,7 @@ bool LayerTreeImpl::UpdateDrawProperties(bool update_lcd_text) {
root_layer(), DrawViewportSize(),
layer_tree_host_impl_->DrawTransform(), device_scale_factor(),
current_page_scale_factor(), page_scale_layer,
+ inner_viewport_scroll_layer_, outer_viewport_scroll_layer_,
elastic_overscroll()->Current(IsActiveTree()),
overscroll_elasticity_layer_, resource_provider()->max_texture_size(),
settings().can_use_lcd_text, settings().layers_always_allowed_lcd_text,
@@ -561,7 +633,7 @@ bool LayerTreeImpl::UpdateDrawProperties(bool update_lcd_text) {
TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion",
"IsActive", IsActiveTree(), "SourceFrameNumber",
source_frame_number_);
- OcclusionTracker<LayerImpl> occlusion_tracker(
+ OcclusionTracker occlusion_tracker(
root_layer()->render_surface()->content_rect());
occlusion_tracker.set_minimum_tracking_size(
settings().minimum_occlusion_tracking_size);
@@ -569,8 +641,8 @@ bool LayerTreeImpl::UpdateDrawProperties(bool update_lcd_text) {
// LayerIterator is used here instead of CallFunctionForSubtree to only
// UpdateTilePriorities on layers that will be visible (and thus have valid
// draw properties) and not because any ordering is required.
- auto end = LayerIterator<LayerImpl>::End(&render_surface_layer_list_);
- for (auto it = LayerIterator<LayerImpl>::Begin(&render_surface_layer_list_);
+ LayerIterator end = LayerIterator::End(&render_surface_layer_list_);
+ for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_);
it != end; ++it) {
occlusion_tracker.EnterLayer(it);
@@ -678,6 +750,14 @@ bool LayerTreeImpl::UpdateDrawProperties(bool update_lcd_text) {
return true;
}
+void LayerTreeImpl::BuildPropertyTreesForTesting() {
+ PropertyTreeBuilder::BuildPropertyTrees(
+ root_layer_.get(), page_scale_layer_, inner_viewport_scroll_layer_,
+ outer_viewport_scroll_layer_, current_page_scale_factor(),
+ device_scale_factor(), gfx::Rect(DrawViewportSize()),
+ layer_tree_host_impl_->DrawTransform(), &property_trees_);
+}
+
const LayerImplList& LayerTreeImpl::RenderSurfaceLayerList() const {
// If this assert triggers, then the list is dirty.
DCHECK(!needs_update_draw_properties_);
@@ -700,18 +780,26 @@ gfx::Size LayerTreeImpl::ScrollableSize() const {
return root_scroll_layer->children()[0]->bounds();
}
-LayerImpl* LayerTreeImpl::LayerById(int id) {
- LayerIdMap::iterator iter = layer_id_map_.find(id);
+LayerImpl* LayerTreeImpl::LayerById(int id) const {
+ LayerIdMap::const_iterator iter = layer_id_map_.find(id);
return iter != layer_id_map_.end() ? iter->second : NULL;
}
void LayerTreeImpl::RegisterLayer(LayerImpl* layer) {
DCHECK(!LayerById(layer->id()));
layer_id_map_[layer->id()] = layer;
+ if (layer_tree_host_impl_->animation_host())
+ layer_tree_host_impl_->animation_host()->RegisterLayer(
+ layer->id(),
+ IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING);
}
void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) {
DCHECK(LayerById(layer->id()));
+ if (layer_tree_host_impl_->animation_host())
+ layer_tree_host_impl_->animation_host()->UnregisterLayer(
+ layer->id(),
+ IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING);
layer_id_map_.erase(layer->id());
}
@@ -751,24 +839,6 @@ void LayerTreeImpl::DidBecomeActive() {
source_frame_number_);
}
-bool LayerTreeImpl::ContentsTexturesPurged() const {
- return contents_textures_purged_;
-}
-
-void LayerTreeImpl::SetContentsTexturesPurged() {
- if (contents_textures_purged_)
- return;
- contents_textures_purged_ = true;
- layer_tree_host_impl_->OnCanDrawStateChangedForTree();
-}
-
-void LayerTreeImpl::ResetContentsTexturesPurged() {
- if (!contents_textures_purged_)
- return;
- contents_textures_purged_ = false;
- layer_tree_host_impl_->OnCanDrawStateChangedForTree();
-}
-
bool LayerTreeImpl::RequiresHighResToDraw() const {
return layer_tree_host_impl_->RequiresHighResToDraw();
}
@@ -881,8 +951,8 @@ BeginFrameArgs LayerTreeImpl::CurrentBeginFrameArgs() const {
return layer_tree_host_impl_->CurrentBeginFrameArgs();
}
-base::TimeDelta LayerTreeImpl::begin_impl_frame_interval() const {
- return layer_tree_host_impl_->begin_impl_frame_interval();
+base::TimeDelta LayerTreeImpl::CurrentBeginFrameInterval() const {
+ return layer_tree_host_impl_->CurrentBeginFrameInterval();
}
void LayerTreeImpl::SetNeedsCommit() {
@@ -960,12 +1030,9 @@ AnimationRegistrar* LayerTreeImpl::GetAnimationRegistrar() const {
void LayerTreeImpl::GetAllPrioritizedTilesForTracing(
std::vector<PrioritizedTile>* prioritized_tiles) const {
- typedef LayerIterator<LayerImpl> LayerIteratorType;
- LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_);
- for (LayerIteratorType it =
- LayerIteratorType::Begin(&render_surface_layer_list_);
- it != end;
- ++it) {
+ LayerIterator end = LayerIterator::End(&render_surface_layer_list_);
+ for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_);
+ it != end; ++it) {
if (!it.represents_itself())
continue;
LayerImpl* layer_impl = *it;
@@ -982,10 +1049,9 @@ void LayerTreeImpl::AsValueInto(base::trace_event::TracedValue* state) const {
state->EndDictionary();
state->BeginArray("render_surface_layer_list");
- typedef LayerIterator<LayerImpl> LayerIteratorType;
- LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_);
- for (LayerIteratorType it = LayerIteratorType::Begin(
- &render_surface_layer_list_); it != end; ++it) {
+ LayerIterator end = LayerIterator::End(&render_surface_layer_list_);
+ for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_);
+ it != end; ++it) {
if (!it.represents_itself())
continue;
TracedValue::AppendIDRef(*it, state);
@@ -1075,9 +1141,9 @@ void LayerTreeImpl::QueueSwapPromise(scoped_ptr<SwapPromise> swap_promise) {
void LayerTreeImpl::PassSwapPromises(
ScopedPtrVector<SwapPromise>* new_swap_promise) {
- // Any left over promises have failed to swap before the next frame.
- BreakSwapPromises(SwapPromise::SWAP_FAILS);
- swap_promise_list_.swap(*new_swap_promise);
+ swap_promise_list_.insert_and_take(swap_promise_list_.end(),
+ new_swap_promise);
+ new_swap_promise->clear();
}
void LayerTreeImpl::FinishSwapPromises(CompositorFrameMetadata* metadata) {
@@ -1101,8 +1167,7 @@ void LayerTreeImpl::set_ui_resource_request_queue(
ui_resource_request_queue_ = queue;
}
-ResourceProvider::ResourceId LayerTreeImpl::ResourceIdForUIResource(
- UIResourceId uid) const {
+ResourceId LayerTreeImpl::ResourceIdForUIResource(UIResourceId uid) const {
return layer_tree_host_impl_->ResourceIdForUIResource(uid);
}
@@ -1238,9 +1303,7 @@ static bool PointHitsRect(
static bool PointHitsRegion(const gfx::PointF& screen_space_point,
const gfx::Transform& screen_space_transform,
- const Region& layer_space_region,
- float layer_content_scale_x,
- float layer_content_scale_y) {
+ const Region& layer_space_region) {
// If the transform is not invertible, then assume that this point doesn't hit
// this region.
gfx::Transform inverse_screen_space_transform(
@@ -1251,12 +1314,8 @@ static bool PointHitsRegion(const gfx::PointF& screen_space_point,
// Transform the hit test point from screen space to the local space of the
// given region.
bool clipped = false;
- gfx::PointF hit_test_point_in_content_space = MathUtil::ProjectPoint(
+ gfx::PointF hit_test_point_in_layer_space = MathUtil::ProjectPoint(
inverse_screen_space_transform, screen_space_point, &clipped);
- gfx::PointF hit_test_point_in_layer_space =
- gfx::ScalePoint(hit_test_point_in_content_space,
- 1.f / layer_content_scale_x,
- 1.f / layer_content_scale_y);
// If ProjectPoint could not project to a valid value, then we assume that
// this point doesn't hit this region.
@@ -1289,10 +1348,8 @@ static bool PointIsClippedBySurfaceOrClipRect(
return true;
if (LayerClipsSubtree(layer) &&
- !PointHitsRect(screen_space_point,
- layer->screen_space_transform(),
- gfx::Rect(layer->content_bounds()),
- NULL))
+ !PointHitsRect(screen_space_point, layer->screen_space_transform(),
+ gfx::Rect(layer->bounds()), NULL))
return true;
}
@@ -1304,7 +1361,7 @@ static bool PointIsClippedBySurfaceOrClipRect(
static bool PointHitsLayer(const LayerImpl* layer,
const gfx::PointF& screen_space_point,
float* distance_to_intersection) {
- gfx::RectF content_rect(layer->content_bounds());
+ gfx::RectF content_rect(layer->bounds());
if (!PointHitsRect(screen_space_point,
layer->screen_space_transform(),
content_rect,
@@ -1340,9 +1397,11 @@ static void FindClosestMatchingLayer(
LayerImpl* layer,
const Functor& func,
FindClosestMatchingLayerDataForRecursion* data_for_recursion) {
- for (int i = layer->children().size() - 1; i >= 0; --i) {
- FindClosestMatchingLayer(
- screen_space_point, layer->children()[i], func, data_for_recursion);
+ size_t children_size = layer->children().size();
+ for (size_t i = 0; i < children_size; ++i) {
+ size_t index = children_size - 1 - i;
+ FindClosestMatchingLayer(screen_space_point, layer->children()[index], func,
+ data_for_recursion);
}
float distance_to_intersection = 0.f;
@@ -1358,7 +1417,7 @@ static void FindClosestMatchingLayer(
static bool ScrollsAnyDrawnRenderSurfaceLayerListMember(LayerImpl* layer) {
if (!layer->scrollable())
return false;
- if (layer->draw_properties().layer_or_descendant_is_drawn)
+ if (layer->layer_or_descendant_is_drawn())
return true;
if (!layer->scroll_children())
@@ -1367,7 +1426,7 @@ static bool ScrollsAnyDrawnRenderSurfaceLayerListMember(LayerImpl* layer) {
layer->scroll_children()->begin();
it != layer->scroll_children()->end();
++it) {
- if ((*it)->draw_properties().layer_or_descendant_is_drawn)
+ if ((*it)->layer_or_descendant_is_drawn())
return true;
}
return false;
@@ -1418,11 +1477,8 @@ static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point,
if (layer_impl->touch_event_handler_region().IsEmpty())
return false;
- if (!PointHitsRegion(screen_space_point,
- layer_impl->screen_space_transform(),
- layer_impl->touch_event_handler_region(),
- layer_impl->contents_scale_x(),
- layer_impl->contents_scale_y()))
+ if (!PointHitsRegion(screen_space_point, layer_impl->screen_space_transform(),
+ layer_impl->touch_event_handler_region()))
return false;
// At this point, we think the point does hit the touch event handler region
@@ -1490,18 +1546,14 @@ static ViewportSelectionBound ComputeViewportSelectionBound(
if (!layer || layer_bound.type == SELECTION_BOUND_EMPTY)
return viewport_bound;
- gfx::PointF layer_scaled_top = gfx::ScalePoint(layer_bound.edge_top,
- layer->contents_scale_x(),
- layer->contents_scale_y());
- gfx::PointF layer_scaled_bottom = gfx::ScalePoint(layer_bound.edge_bottom,
- layer->contents_scale_x(),
- layer->contents_scale_y());
+ gfx::PointF layer_top = layer_bound.edge_top;
+ gfx::PointF layer_bottom = layer_bound.edge_bottom;
bool clipped = false;
- gfx::PointF screen_top = MathUtil::MapPoint(
- layer->screen_space_transform(), layer_scaled_top, &clipped);
+ gfx::PointF screen_top =
+ MathUtil::MapPoint(layer->screen_space_transform(), layer_top, &clipped);
gfx::PointF screen_bottom = MathUtil::MapPoint(
- layer->screen_space_transform(), layer_scaled_bottom, &clipped);
+ layer->screen_space_transform(), layer_bottom, &clipped);
const float inv_scale = 1.f / device_scale_factor;
viewport_bound.edge_top = gfx::ScalePoint(screen_top, inv_scale);
@@ -1512,9 +1564,9 @@ static ViewportSelectionBound ComputeViewportSelectionBound(
// Shifting the visibility point fractionally inward ensures that neighboring
// or logically coincident layers aligned to integral DPI coordinates will not
// spuriously occlude the bound.
- gfx::Vector2dF visibility_offset = layer_scaled_top - layer_scaled_bottom;
+ gfx::Vector2dF visibility_offset = layer_top - layer_bottom;
visibility_offset.Scale(device_scale_factor / visibility_offset.Length());
- gfx::PointF visibility_point = layer_scaled_bottom + visibility_offset;
+ gfx::PointF visibility_point = layer_bottom + visibility_offset;
if (visibility_point.x() <= 0)
visibility_point.set_x(visibility_point.x() + device_scale_factor);
visibility_point = MathUtil::MapPoint(
@@ -1574,4 +1626,131 @@ scoped_ptr<PendingPageScaleAnimation>
return pending_page_scale_animation_.Pass();
}
+bool LayerTreeImpl::IsAnimatingFilterProperty(const LayerImpl* layer) const {
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()
+ ->IsAnimatingFilterProperty(layer->id())
+ : false;
+}
+
+bool LayerTreeImpl::IsAnimatingOpacityProperty(const LayerImpl* layer) const {
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()
+ ->IsAnimatingOpacityProperty(layer->id())
+ : false;
+}
+
+bool LayerTreeImpl::IsAnimatingTransformProperty(const LayerImpl* layer) const {
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()
+ ->IsAnimatingTransformProperty(layer->id())
+ : false;
+}
+
+bool LayerTreeImpl::HasPotentiallyRunningOpacityAnimation(
+ const LayerImpl* layer) const {
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()
+ ->HasPotentiallyRunningOpacityAnimation(layer->id())
+ : false;
+}
+
+bool LayerTreeImpl::HasPotentiallyRunningTransformAnimation(
+ const LayerImpl* layer) const {
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()
+ ->HasPotentiallyRunningTransformAnimation(layer->id())
+ : false;
+}
+
+bool LayerTreeImpl::FilterIsAnimatingOnImplOnly(const LayerImpl* layer) const {
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()
+ ->FilterIsAnimatingOnImplOnly(layer->id())
+ : false;
+}
+
+bool LayerTreeImpl::OpacityIsAnimatingOnImplOnly(const LayerImpl* layer) const {
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()
+ ->OpacityIsAnimatingOnImplOnly(layer->id())
+ : false;
+}
+
+bool LayerTreeImpl::TransformIsAnimatingOnImplOnly(
+ const LayerImpl* layer) const {
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()
+ ->TransformIsAnimatingOnImplOnly(layer->id())
+ : false;
+}
+
+bool LayerTreeImpl::HasOnlyTranslationTransforms(const LayerImpl* layer) const {
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()
+ ->HasOnlyTranslationTransforms(layer->id())
+ : true;
+}
+
+bool LayerTreeImpl::MaximumTargetScale(const LayerImpl* layer,
+ float* max_scale) const {
+ *max_scale = 0.f;
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()->MaximumTargetScale(
+ layer->id(), max_scale)
+ : true;
+}
+
+bool LayerTreeImpl::AnimationStartScale(const LayerImpl* layer,
+ float* start_scale) const {
+ *start_scale = 0.f;
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()->AnimationStartScale(
+ layer->id(), start_scale)
+ : true;
+}
+
+bool LayerTreeImpl::HasFilterAnimationThatInflatesBounds(
+ const LayerImpl* layer) const {
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()
+ ->HasFilterAnimationThatInflatesBounds(layer->id())
+ : false;
+}
+
+bool LayerTreeImpl::HasTransformAnimationThatInflatesBounds(
+ const LayerImpl* layer) const {
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()
+ ->HasTransformAnimationThatInflatesBounds(layer->id())
+ : false;
+}
+
+bool LayerTreeImpl::HasAnimationThatInflatesBounds(
+ const LayerImpl* layer) const {
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()
+ ->HasAnimationThatInflatesBounds(layer->id())
+ : false;
+}
+
+bool LayerTreeImpl::FilterAnimationBoundsForBox(const LayerImpl* layer,
+ const gfx::BoxF& box,
+ gfx::BoxF* bounds) const {
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()
+ ->FilterAnimationBoundsForBox(layer->id(), box, bounds)
+ : false;
+}
+
+bool LayerTreeImpl::TransformAnimationBoundsForBox(const LayerImpl* layer,
+ const gfx::BoxF& box,
+ gfx::BoxF* bounds) const {
+ *bounds = gfx::BoxF();
+ return layer_tree_host_impl_->animation_host()
+ ? layer_tree_host_impl_->animation_host()
+ ->TransformAnimationBoundsForBox(layer->id(), box, bounds)
+ : true;
+}
+
} // namespace cc
diff --git a/chromium/cc/trees/layer_tree_impl.h b/chromium/cc/trees/layer_tree_impl.h
index 9c1b5b942db..973df977733 100644
--- a/chromium/cc/trees/layer_tree_impl.h
+++ b/chromium/cc/trees/layer_tree_impl.h
@@ -96,7 +96,7 @@ class CC_EXPORT LayerTreeImpl {
LayerImpl* FindPendingTreeLayerById(int id);
bool PinchGestureActive() const;
BeginFrameArgs CurrentBeginFrameArgs() const;
- base::TimeDelta begin_impl_frame_interval() const;
+ base::TimeDelta CurrentBeginFrameInterval() const;
void SetNeedsCommit();
gfx::Rect DeviceViewport() const;
gfx::Size DrawViewportSize() const;
@@ -131,7 +131,11 @@ class CC_EXPORT LayerTreeImpl {
void SetPropertyTrees(const PropertyTrees& property_trees) {
property_trees_ = property_trees;
+ property_trees_.transform_tree.set_source_to_parent_updates_allowed(false);
}
+ PropertyTrees* property_trees() { return &property_trees_; }
+
+ void UpdatePropertyTreesForBoundsDelta();
void PushPropertiesTo(LayerTreeImpl* tree_impl);
@@ -178,6 +182,7 @@ class CC_EXPORT LayerTreeImpl {
has_transparent_background_ = transparent;
}
+ void UpdatePropertyTreeScrollingAndAnimationFromMainThread();
void SetPageScaleOnActiveTree(float active_page_scale);
void PushPageScaleFromMainThread(float page_scale_factor,
float min_page_scale_factor,
@@ -211,6 +216,7 @@ class CC_EXPORT LayerTreeImpl {
// priorities. Returns false if it was unable to update. Updating lcd
// text may cause invalidations, so should only be done after a commit.
bool UpdateDrawProperties(bool update_lcd_text);
+ void BuildPropertyTreesForTesting();
void set_needs_update_draw_properties() {
needs_update_draw_properties_ = true;
@@ -241,7 +247,7 @@ class CC_EXPORT LayerTreeImpl {
gfx::Rect RootScrollLayerDeviceViewportBounds() const;
- LayerImpl* LayerById(int id);
+ LayerImpl* LayerById(int id) const;
// These should be called by LayerImpl's ctor/dtor.
void RegisterLayer(LayerImpl* layer);
@@ -255,10 +261,6 @@ class CC_EXPORT LayerTreeImpl {
void DidBecomeActive();
- bool ContentsTexturesPurged() const;
- void SetContentsTexturesPurged();
- void ResetContentsTexturesPurged();
-
// Set on the active tree when the viewport size recently changed
// and the active tree's size is now out of date.
bool ViewportSizeInvalid() const;
@@ -286,7 +288,7 @@ class CC_EXPORT LayerTreeImpl {
void DidModifyTilePriorities();
- ResourceProvider::ResourceId ResourceIdForUIResource(UIResourceId uid) const;
+ ResourceId ResourceIdForUIResource(UIResourceId uid) const;
void ProcessUIResourceRequestQueue();
bool IsUIResourceOpaque(UIResourceId uid) const;
@@ -340,9 +342,36 @@ class CC_EXPORT LayerTreeImpl {
void GatherFrameTimingRequestIds(std::vector<int64_t>* request_ids);
- bool IsExternalFlingActive() const;
+ bool IsExternalScrollActive() const;
void DidUpdateScrollOffset(int layer_id);
+ bool IsAnimatingFilterProperty(const LayerImpl* layer) const;
+ bool IsAnimatingOpacityProperty(const LayerImpl* layer) const;
+ bool IsAnimatingTransformProperty(const LayerImpl* layer) const;
+
+ bool HasPotentiallyRunningOpacityAnimation(const LayerImpl* layer) const;
+ bool HasPotentiallyRunningTransformAnimation(const LayerImpl* layer) const;
+
+ bool FilterIsAnimatingOnImplOnly(const LayerImpl* layer) const;
+ bool OpacityIsAnimatingOnImplOnly(const LayerImpl* layer) const;
+ bool TransformIsAnimatingOnImplOnly(const LayerImpl* layer) const;
+
+ bool HasOnlyTranslationTransforms(const LayerImpl* layer) const;
+
+ bool MaximumTargetScale(const LayerImpl* layer, float* max_scale) const;
+ bool AnimationStartScale(const LayerImpl* layer, float* start_scale) const;
+
+ bool HasFilterAnimationThatInflatesBounds(const LayerImpl* layer) const;
+ bool HasTransformAnimationThatInflatesBounds(const LayerImpl* layer) const;
+ bool HasAnimationThatInflatesBounds(const LayerImpl* layer) const;
+
+ bool FilterAnimationBoundsForBox(const LayerImpl* layer,
+ const gfx::BoxF& box,
+ gfx::BoxF* bounds) const;
+ bool TransformAnimationBoundsForBox(const LayerImpl* layer,
+ const gfx::BoxF& box,
+ gfx::BoxF* bounds) const;
+
protected:
explicit LayerTreeImpl(
LayerTreeHostImpl* layer_tree_host_impl,
@@ -396,7 +425,6 @@ class CC_EXPORT LayerTreeImpl {
// would not be fully covered by opaque content.
Region unoccluded_screen_space_region_;
- bool contents_textures_purged_;
bool viewport_size_invalid_;
bool needs_update_draw_properties_;
diff --git a/chromium/cc/trees/layer_tree_impl_unittest.cc b/chromium/cc/trees/layer_tree_impl_unittest.cc
index 04c108f1bdf..81a566fe7f3 100644
--- a/chromium/cc/trees/layer_tree_impl_unittest.cc
+++ b/chromium/cc/trees/layer_tree_impl_unittest.cc
@@ -380,87 +380,6 @@ TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) {
EXPECT_EQ(12345, result_layer->id());
}
-TEST_F(LayerTreeImplTest, HitTestingForSingleLayerWithScaledContents) {
- // A layer's visible content rect is actually in the layer's content space.
- // The screen space transform converts from the layer's origin space to screen
- // space. This test makes sure that hit testing works correctly accounts for
- // the contents scale. A contents scale that is not 1 effectively forces a
- // non-identity transform between layer's content space and layer's origin
- // space. The hit testing code must take this into account.
- //
- // To test this, the layer is positioned at (25, 25), and is size (50, 50). If
- // contents scale is ignored, then hit testing will mis-interpret the visible
- // content rect as being larger than the actual bounds of the layer.
- //
- scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1);
-
- gfx::Transform identity_matrix;
- gfx::Point3F transform_origin;
-
- SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
- gfx::PointF(), gfx::Size(100, 100), true, false,
- true);
- {
- gfx::PointF position(25.f, 25.f);
- gfx::Size bounds(50, 50);
- scoped_ptr<LayerImpl> test_layer =
- LayerImpl::Create(host_impl().active_tree(), 12345);
- SetLayerPropertiesForTesting(test_layer.get(), identity_matrix,
- transform_origin, position, bounds, true,
- false, false);
-
- // override content bounds and contents scale
- test_layer->SetContentBounds(gfx::Size(100, 100));
- test_layer->SetContentsScale(2, 2);
-
- test_layer->SetDrawsContent(true);
- root->AddChild(test_layer.Pass());
- }
-
- host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
-
- // Sanity check the scenario we just created.
- // The visible content rect for test_layer is actually 100x100, even though
- // its layout size is 50x50, positioned at 25x25.
- LayerImpl* test_layer =
- host_impl().active_tree()->root_layer()->children()[0];
- EXPECT_EQ(gfx::Rect(0, 0, 100, 100), test_layer->visible_content_rect());
- ASSERT_EQ(1u, RenderSurfaceLayerList().size());
- ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
-
- // Hit testing for a point outside the layer should return a null pointer (the
- // root layer does not draw content, so it will not be hit tested either).
- gfx::Point test_point(101, 101);
- LayerImpl* result_layer =
- host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
- EXPECT_FALSE(result_layer);
-
- test_point = gfx::Point(24, 24);
- result_layer =
- host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
- EXPECT_FALSE(result_layer);
-
- test_point = gfx::Point(76, 76);
- result_layer =
- host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
- EXPECT_FALSE(result_layer);
-
- // Hit testing for a point inside should return the test layer.
- test_point = gfx::Point(26, 26);
- result_layer =
- host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
- ASSERT_TRUE(result_layer);
- EXPECT_EQ(12345, result_layer->id());
-
- test_point = gfx::Point(74, 74);
- result_layer =
- host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
- ASSERT_TRUE(result_layer);
- EXPECT_EQ(12345, result_layer->id());
-}
-
TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) {
// Test that hit-testing will only work for the visible portion of a layer,
// and not the entire layer bounds. Here we just test the simple axis-aligned
@@ -1500,110 +1419,6 @@ TEST_F(LayerTreeImplTest,
}
TEST_F(LayerTreeImplTest,
- HitCheckingTouchHandlerRegionsForSingleLayerWithScaledContents) {
- // A layer's visible content rect is actually in the layer's content space.
- // The screen space transform converts from the layer's origin space to screen
- // space. This test makes sure that hit testing works correctly accounts for
- // the contents scale. A contents scale that is not 1 effectively forces a
- // non-identity transform between layer's content space and layer's origin
- // space. The hit testing code must take this into account.
- //
- // To test this, the layer is positioned at (25, 25), and is size (50, 50). If
- // contents scale is ignored, then hit checking will mis-interpret the visible
- // content rect as being larger than the actual bounds of the layer.
- //
- scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1);
-
- gfx::Transform identity_matrix;
- gfx::Point3F transform_origin;
-
- SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
- gfx::PointF(), gfx::Size(100, 100), true, false,
- true);
- {
- Region touch_handler_region(gfx::Rect(10, 10, 30, 30));
- gfx::PointF position(25.f, 25.f);
- gfx::Size bounds(50, 50);
- scoped_ptr<LayerImpl> test_layer =
- LayerImpl::Create(host_impl().active_tree(), 12345);
- SetLayerPropertiesForTesting(test_layer.get(), identity_matrix,
- transform_origin, position, bounds, true,
- false, false);
-
- // override content bounds and contents scale
- test_layer->SetContentBounds(gfx::Size(100, 100));
- test_layer->SetContentsScale(2, 2);
-
- test_layer->SetDrawsContent(true);
- test_layer->SetTouchEventHandlerRegion(touch_handler_region);
- root->AddChild(test_layer.Pass());
- }
-
- host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
-
- // Sanity check the scenario we just created.
- // The visible content rect for test_layer is actually 100x100, even though
- // its layout size is 50x50, positioned at 25x25.
- LayerImpl* test_layer =
- host_impl().active_tree()->root_layer()->children()[0];
- EXPECT_EQ(gfx::Rect(0, 0, 100, 100), test_layer->visible_content_rect());
- ASSERT_EQ(1u, RenderSurfaceLayerList().size());
- ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
-
- // Hit checking for a point outside the layer should return a null pointer
- // (the root layer does not draw content, so it will not be tested either).
- gfx::Point test_point(76, 76);
- LayerImpl* result_layer =
- host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
- test_point);
- EXPECT_FALSE(result_layer);
-
- // Hit checking for a point inside the layer, but outside the touch handler
- // region should return a null pointer.
- test_point = gfx::Point(26, 26);
- result_layer =
- host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
- test_point);
- EXPECT_FALSE(result_layer);
-
- test_point = gfx::Point(34, 34);
- result_layer =
- host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
- test_point);
- EXPECT_FALSE(result_layer);
-
- test_point = gfx::Point(65, 65);
- result_layer =
- host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
- test_point);
- EXPECT_FALSE(result_layer);
-
- test_point = gfx::Point(74, 74);
- result_layer =
- host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
- test_point);
- EXPECT_FALSE(result_layer);
-
- // Hit checking for a point inside the touch event handler region should
- // return the root layer.
- test_point = gfx::Point(35, 35);
- result_layer =
- host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
- test_point);
- ASSERT_TRUE(result_layer);
- EXPECT_EQ(12345, result_layer->id());
-
- test_point = gfx::Point(64, 64);
- result_layer =
- host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
- test_point);
- ASSERT_TRUE(result_layer);
- EXPECT_EQ(12345, result_layer->id());
-}
-
-TEST_F(LayerTreeImplTest,
HitCheckingTouchHandlerRegionsForSingleLayerWithDeviceScale) {
// The layer's device_scale_factor and page_scale_factor should scale the
// content rect and we should be able to hit the touch handler region by
@@ -1655,8 +1470,7 @@ TEST_F(LayerTreeImplTest,
ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
// Check whether the child layer fits into the root after scaled.
- EXPECT_EQ(gfx::Rect(test_layer->content_bounds()),
- test_layer->visible_content_rect());
+ EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect());
// Hit checking for a point outside the layer should return a null pointer
// (the root layer does not draw content, so it will not be tested either).
@@ -2127,11 +1941,11 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) {
host_impl().active_tree()->GetViewportSelection(&output);
EXPECT_EQ(input.start.type, output.start.type);
gfx::PointF expected_output_start_top = input.start.edge_top;
- gfx::PointF expected_output_edge_botom = input.start.edge_bottom;
+ gfx::PointF expected_output_edge_bottom = input.start.edge_bottom;
expected_output_start_top.Scale(page_scale_factor);
- expected_output_edge_botom.Scale(page_scale_factor);
- EXPECT_EQ(input.start.edge_top, output.start.edge_top);
- EXPECT_EQ(input.start.edge_bottom, output.start.edge_bottom);
+ expected_output_edge_bottom.Scale(page_scale_factor);
+ EXPECT_EQ(expected_output_start_top, output.start.edge_top);
+ EXPECT_EQ(expected_output_edge_bottom, output.start.edge_bottom);
EXPECT_TRUE(output.start.visible);
EXPECT_EQ(input.end.type, output.end.type);
diff --git a/chromium/cc/trees/layer_tree_settings.cc b/chromium/cc/trees/layer_tree_settings.cc
index f7f6f3047da..92d7dda7040 100644
--- a/chromium/cc/trees/layer_tree_settings.cc
+++ b/chromium/cc/trees/layer_tree_settings.cc
@@ -13,16 +13,18 @@
namespace cc {
+LayerSettings::LayerSettings() : use_compositor_animation_timelines(false) {
+}
+
+LayerSettings::~LayerSettings() {
+}
+
LayerTreeSettings::LayerTreeSettings()
- : impl_side_painting(false),
- raster_enabled(true),
- throttle_frame_production(true),
- single_thread_proxy_scheduler(true),
+ : single_thread_proxy_scheduler(true),
use_external_begin_frame_source(false),
main_frame_before_activation_enabled(false),
using_synchronous_renderer_compositor(false),
report_overscroll_only_for_scrollable_axes(false),
- per_tile_painting_enabled(false),
accelerated_animation_enabled(true),
can_use_lcd_text(true),
use_distance_field_text(false),
@@ -38,7 +40,6 @@ LayerTreeSettings::LayerTreeSettings()
scrollbar_show_scale_threshold(1.0f),
solid_color_scrollbar_color(SK_ColorWHITE),
timeout_and_draw_when_animation_checkerboards(true),
- maximum_number_of_failed_draws_before_draw_is_forced_(3),
layer_transforms_should_scale_layer_contents(false),
layers_always_allowed_lcd_text(false),
minimum_contents_scale(0.0625f),
@@ -51,7 +52,6 @@ LayerTreeSettings::LayerTreeSettings()
max_untiled_layer_size(gfx::Size(512, 512)),
default_tile_grid_size(gfx::Size(256, 256)),
minimum_occlusion_tracking_size(gfx::Size(160, 160)),
- use_pinch_virtual_viewport(false),
// At 256x256 tiles, 128 tiles cover an area of 2048x4096 pixels.
max_tiles_for_interest_area(128),
skewport_target_time_in_seconds(1.0f),
@@ -59,8 +59,9 @@ LayerTreeSettings::LayerTreeSettings()
max_unused_resource_memory_percentage(100),
max_memory_for_prepaint_percentage(100),
strict_layer_property_change_checking(false),
- use_one_copy(false),
+ use_one_copy(true),
use_zero_copy(false),
+ use_persistent_map_for_gpu_memory_buffers(false),
enable_elastic_overscroll(false),
use_image_texture_target(GL_TEXTURE_2D),
ignore_root_layer_flings(false),
@@ -68,10 +69,10 @@ LayerTreeSettings::LayerTreeSettings()
use_occlusion_for_tile_prioritization(false),
record_full_layer(false),
use_display_lists(false),
- use_cached_picture_in_display_list(true),
verify_property_trees(false),
gather_pixel_refs(false),
- use_compositor_animation_timelines(false) {
+ use_compositor_animation_timelines(false),
+ invert_viewport_scroll_order(false) {
}
LayerTreeSettings::~LayerTreeSettings() {}
@@ -82,15 +83,12 @@ SchedulerSettings LayerTreeSettings::ToSchedulerSettings() const {
use_external_begin_frame_source;
scheduler_settings.main_frame_before_activation_enabled =
main_frame_before_activation_enabled;
- scheduler_settings.impl_side_painting = impl_side_painting;
scheduler_settings.timeout_and_draw_when_animation_checkerboards =
timeout_and_draw_when_animation_checkerboards;
- scheduler_settings.maximum_number_of_failed_draws_before_draw_is_forced_ =
- maximum_number_of_failed_draws_before_draw_is_forced_;
scheduler_settings.using_synchronous_renderer_compositor =
using_synchronous_renderer_compositor;
- scheduler_settings.throttle_frame_production = throttle_frame_production;
- scheduler_settings.main_thread_should_always_be_low_latency = false;
+ scheduler_settings.throttle_frame_production =
+ !renderer_settings.disable_gpu_vsync;
scheduler_settings.background_frame_interval =
base::TimeDelta::FromSecondsD(1.0 / background_animation_rate);
return scheduler_settings;
diff --git a/chromium/cc/trees/layer_tree_settings.h b/chromium/cc/trees/layer_tree_settings.h
index 56cfa3a9809..6334f94bb13 100644
--- a/chromium/cc/trees/layer_tree_settings.h
+++ b/chromium/cc/trees/layer_tree_settings.h
@@ -15,21 +15,25 @@
namespace cc {
+class CC_EXPORT LayerSettings {
+ public:
+ LayerSettings();
+ ~LayerSettings();
+
+ bool use_compositor_animation_timelines;
+};
+
class CC_EXPORT LayerTreeSettings {
public:
LayerTreeSettings();
~LayerTreeSettings();
RendererSettings renderer_settings;
- bool impl_side_painting;
- bool raster_enabled;
- bool throttle_frame_production;
bool single_thread_proxy_scheduler;
bool use_external_begin_frame_source;
bool main_frame_before_activation_enabled;
bool using_synchronous_renderer_compositor;
bool report_overscroll_only_for_scrollable_axes;
- bool per_tile_painting_enabled;
bool accelerated_animation_enabled;
bool can_use_lcd_text;
bool use_distance_field_text;
@@ -51,7 +55,6 @@ class CC_EXPORT LayerTreeSettings {
float scrollbar_show_scale_threshold;
SkColor solid_color_scrollbar_color;
bool timeout_and_draw_when_animation_checkerboards;
- int maximum_number_of_failed_draws_before_draw_is_forced_;
bool layer_transforms_should_scale_layer_contents;
bool layers_always_allowed_lcd_text;
float minimum_contents_scale;
@@ -64,7 +67,6 @@ class CC_EXPORT LayerTreeSettings {
gfx::Size max_untiled_layer_size;
gfx::Size default_tile_grid_size;
gfx::Size minimum_occlusion_tracking_size;
- bool use_pinch_virtual_viewport;
size_t max_tiles_for_interest_area;
float skewport_target_time_in_seconds;
int skewport_extrapolation_limit_in_content_pixels;
@@ -73,6 +75,7 @@ class CC_EXPORT LayerTreeSettings {
bool strict_layer_property_change_checking;
bool use_one_copy;
bool use_zero_copy;
+ bool use_persistent_map_for_gpu_memory_buffers;
bool enable_elastic_overscroll;
unsigned use_image_texture_target;
bool ignore_root_layer_flings;
@@ -80,10 +83,10 @@ class CC_EXPORT LayerTreeSettings {
bool use_occlusion_for_tile_prioritization;
bool record_full_layer;
bool use_display_lists;
- bool use_cached_picture_in_display_list;
bool verify_property_trees;
bool gather_pixel_refs;
bool use_compositor_animation_timelines;
+ bool invert_viewport_scroll_order;
LayerTreeDebugState initial_debug_state;
diff --git a/chromium/cc/trees/mutator_host_client.h b/chromium/cc/trees/mutator_host_client.h
new file mode 100644
index 00000000000..56123b4a62a
--- /dev/null
+++ b/chromium/cc/trees/mutator_host_client.h
@@ -0,0 +1,45 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_TREES_MUTATOR_HOST_CLIENT_H_
+#define CC_TREES_MUTATOR_HOST_CLIENT_H_
+
+namespace gfx {
+class Transform;
+class ScrollOffset;
+}
+
+namespace cc {
+
+class FilterOperations;
+class Layer;
+
+enum class LayerTreeType { ACTIVE, PENDING };
+
+class MutatorHostClient {
+ public:
+ virtual bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const = 0;
+ virtual void SetMutatorsNeedCommit() = 0;
+
+ virtual void SetLayerFilterMutated(int layer_id,
+ LayerTreeType tree_type,
+ const FilterOperations& filters) = 0;
+ virtual void SetLayerOpacityMutated(int layer_id,
+ LayerTreeType tree_type,
+ float opacity) = 0;
+ virtual void SetLayerTransformMutated(int layer_id,
+ LayerTreeType tree_type,
+ const gfx::Transform& transform) = 0;
+ virtual void SetLayerScrollOffsetMutated(
+ int layer_id,
+ LayerTreeType tree_type,
+ const gfx::ScrollOffset& scroll_offset) = 0;
+
+ virtual void ScrollOffsetAnimationFinished() = 0;
+ virtual gfx::ScrollOffset GetScrollOffsetForAnimation(int layer_id) const = 0;
+};
+
+} // namespace cc
+
+#endif // CC_TREES_MUTATOR_HOST_CLIENT_H_
diff --git a/chromium/cc/trees/occlusion_tracker.cc b/chromium/cc/trees/occlusion_tracker.cc
index 0f0ce158400..996adc895af 100644
--- a/chromium/cc/trees/occlusion_tracker.cc
+++ b/chromium/cc/trees/occlusion_tracker.cc
@@ -17,18 +17,14 @@
namespace cc {
-template <typename LayerType>
-OcclusionTracker<LayerType>::OcclusionTracker(
- const gfx::Rect& screen_space_clip_rect)
+OcclusionTracker::OcclusionTracker(const gfx::Rect& screen_space_clip_rect)
: screen_space_clip_rect_(screen_space_clip_rect) {
}
-template <typename LayerType>
-OcclusionTracker<LayerType>::~OcclusionTracker() {
+OcclusionTracker::~OcclusionTracker() {
}
-template <typename LayerType>
-Occlusion OcclusionTracker<LayerType>::GetCurrentOcclusionForLayer(
+Occlusion OcclusionTracker::GetCurrentOcclusionForLayer(
const gfx::Transform& draw_transform) const {
DCHECK(!stack_.empty());
const StackObject& back = stack_.back();
@@ -37,9 +33,7 @@ Occlusion OcclusionTracker<LayerType>::GetCurrentOcclusionForLayer(
back.occlusion_from_inside_target);
}
-template <typename LayerType>
-Occlusion
-OcclusionTracker<LayerType>::GetCurrentOcclusionForContributingSurface(
+Occlusion OcclusionTracker::GetCurrentOcclusionForContributingSurface(
const gfx::Transform& draw_transform) const {
DCHECK(!stack_.empty());
if (stack_.size() < 2)
@@ -52,10 +46,8 @@ OcclusionTracker<LayerType>::GetCurrentOcclusionForContributingSurface(
second_last.occlusion_from_inside_target);
}
-template <typename LayerType>
-void OcclusionTracker<LayerType>::EnterLayer(
- const LayerIteratorPosition<LayerType>& layer_iterator) {
- LayerType* render_target = layer_iterator.target_render_surface_layer;
+void OcclusionTracker::EnterLayer(const LayerIteratorPosition& layer_iterator) {
+ LayerImpl* render_target = layer_iterator.target_render_surface_layer;
if (layer_iterator.represents_itself)
EnterRenderTarget(render_target);
@@ -63,10 +55,8 @@ void OcclusionTracker<LayerType>::EnterLayer(
FinishedRenderTarget(render_target);
}
-template <typename LayerType>
-void OcclusionTracker<LayerType>::LeaveLayer(
- const LayerIteratorPosition<LayerType>& layer_iterator) {
- LayerType* render_target = layer_iterator.target_render_surface_layer;
+void OcclusionTracker::LeaveLayer(const LayerIteratorPosition& layer_iterator) {
+ LayerImpl* render_target = layer_iterator.target_render_surface_layer;
if (layer_iterator.represents_itself)
MarkOccludedBehindLayer(layer_iterator.current_layer);
@@ -76,9 +66,8 @@ void OcclusionTracker<LayerType>::LeaveLayer(
LeaveToRenderTarget(render_target);
}
-template <typename RenderSurfaceType>
static gfx::Rect ScreenSpaceClipRectInTargetSurface(
- const RenderSurfaceType* target_surface,
+ const RenderSurfaceImpl* target_surface,
const gfx::Rect& screen_space_clip_rect) {
gfx::Transform inverse_screen_space_transform(
gfx::Transform::kSkipInitialization);
@@ -90,7 +79,6 @@ static gfx::Rect ScreenSpaceClipRectInTargetSurface(
screen_space_clip_rect);
}
-template <typename RenderSurfaceType>
static SimpleEnclosedRegion TransformSurfaceOpaqueRegion(
const SimpleEnclosedRegion& region,
bool have_clip_rect,
@@ -119,73 +107,25 @@ static SimpleEnclosedRegion TransformSurfaceOpaqueRegion(
return transformed_region;
}
-static inline bool LayerOpacityKnown(const Layer* layer) {
- return !layer->draw_opacity_is_animating();
-}
-static inline bool LayerOpacityKnown(const LayerImpl* layer) {
- return true;
-}
-static inline bool LayerTransformsToTargetKnown(const Layer* layer) {
- return !layer->draw_transform_is_animating();
-}
-static inline bool LayerTransformsToTargetKnown(const LayerImpl* layer) {
- return true;
-}
-
-static inline bool SurfaceOpacityKnown(const RenderSurface* rs) {
- return !rs->draw_opacity_is_animating();
-}
-static inline bool SurfaceOpacityKnown(const RenderSurfaceImpl* rs) {
- return true;
-}
-static inline bool SurfaceTransformsToTargetKnown(const RenderSurface* rs) {
- return !rs->target_surface_transforms_are_animating();
-}
-static inline bool SurfaceTransformsToTargetKnown(const RenderSurfaceImpl* rs) {
- return true;
-}
-static inline bool SurfaceTransformsToScreenKnown(const RenderSurface* rs) {
- return !rs->screen_space_transforms_are_animating();
-}
-static inline bool SurfaceTransformsToScreenKnown(const RenderSurfaceImpl* rs) {
- return true;
-}
-
-static inline bool LayerIsInUnsorted3dRenderingContext(const Layer* layer) {
- return layer->Is3dSorted();
-}
-static inline bool LayerIsInUnsorted3dRenderingContext(const LayerImpl* layer) {
- return layer->Is3dSorted();
-}
-
-template <typename LayerType>
-static inline bool LayerIsHidden(const LayerType* layer) {
- return layer->hide_layer_and_subtree() ||
- (layer->parent() && LayerIsHidden(layer->parent()));
-}
-
-template <typename LayerType>
-void OcclusionTracker<LayerType>::EnterRenderTarget(
- const LayerType* new_target) {
+void OcclusionTracker::EnterRenderTarget(const LayerImpl* new_target) {
if (!stack_.empty() && stack_.back().target == new_target)
return;
- const LayerType* old_target = NULL;
- const typename LayerType::RenderSurfaceType* old_occlusion_immune_ancestor =
- NULL;
+ const LayerImpl* old_target = NULL;
+ const RenderSurfaceImpl* old_occlusion_immune_ancestor = NULL;
if (!stack_.empty()) {
old_target = stack_.back().target;
old_occlusion_immune_ancestor =
old_target->render_surface()->nearest_occlusion_immune_ancestor();
}
- const typename LayerType::RenderSurfaceType* new_occlusion_immune_ancestor =
+ const RenderSurfaceImpl* new_occlusion_immune_ancestor =
new_target->render_surface()->nearest_occlusion_immune_ancestor();
stack_.push_back(StackObject(new_target));
- // We copy the screen occlusion into the new RenderSurface subtree, but we
+ // We copy the screen occlusion into the new RenderSurfaceImpl subtree, but we
// never copy in the occlusion from inside the target, since we are looking
- // at a new RenderSurface target.
+ // at a new RenderSurfaceImpl target.
// If entering an unoccluded subtree, do not carry forward the outside
// occlusion calculated so far.
@@ -193,15 +133,12 @@ void OcclusionTracker<LayerType>::EnterRenderTarget(
new_occlusion_immune_ancestor &&
new_occlusion_immune_ancestor != old_occlusion_immune_ancestor;
- bool have_transform_from_screen_to_new_target = false;
gfx::Transform inverse_new_target_screen_space_transform(
// Note carefully, not used if screen space transform is uninvertible.
gfx::Transform::kSkipInitialization);
- if (SurfaceTransformsToScreenKnown(new_target->render_surface())) {
- have_transform_from_screen_to_new_target =
- new_target->render_surface()->screen_space_transform().GetInverse(
- &inverse_new_target_screen_space_transform);
- }
+ bool have_transform_from_screen_to_new_target =
+ new_target->render_surface()->screen_space_transform().GetInverse(
+ &inverse_new_target_screen_space_transform);
bool entering_root_target = new_target->parent() == NULL;
@@ -213,32 +150,30 @@ void OcclusionTracker<LayerType>::EnterRenderTarget(
if (!copy_outside_occlusion_forward)
return;
- int last_index = stack_.size() - 1;
+ size_t last_index = stack_.size() - 1;
gfx::Transform old_target_to_new_target_transform(
inverse_new_target_screen_space_transform,
old_target->render_surface()->screen_space_transform());
stack_[last_index].occlusion_from_outside_target =
- TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>(
- stack_[last_index - 1].occlusion_from_outside_target,
- false,
- gfx::Rect(),
- old_target_to_new_target_transform);
+ TransformSurfaceOpaqueRegion(
+ stack_[last_index - 1].occlusion_from_outside_target, false,
+ gfx::Rect(), old_target_to_new_target_transform);
stack_[last_index].occlusion_from_outside_target.Union(
- TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>(
- stack_[last_index - 1].occlusion_from_inside_target,
- false,
- gfx::Rect(),
- old_target_to_new_target_transform));
+ TransformSurfaceOpaqueRegion(
+ stack_[last_index - 1].occlusion_from_inside_target, false,
+ gfx::Rect(), old_target_to_new_target_transform));
}
-template <typename LayerType>
-void OcclusionTracker<LayerType>::FinishedRenderTarget(
- const LayerType* finished_target) {
+static bool LayerIsHidden(const LayerImpl* layer) {
+ return layer->hide_layer_and_subtree() ||
+ (layer->parent() && LayerIsHidden(layer->parent()));
+}
+
+void OcclusionTracker::FinishedRenderTarget(const LayerImpl* finished_target) {
// Make sure we know about the target surface.
EnterRenderTarget(finished_target);
- typename LayerType::RenderSurfaceType* surface =
- finished_target->render_surface();
+ RenderSurfaceImpl* surface = finished_target->render_surface();
// Readbacks always happen on render targets so we only need to check
// for readbacks here.
@@ -247,25 +182,20 @@ void OcclusionTracker<LayerType>::FinishedRenderTarget(
// If the occlusion within the surface can not be applied to things outside of
// the surface's subtree, then clear the occlusion here so it won't be used.
- if (finished_target->mask_layer() || !SurfaceOpacityKnown(surface) ||
- surface->draw_opacity() < 1 ||
+ if (finished_target->mask_layer() || surface->draw_opacity() < 1 ||
!finished_target->uses_default_blend_mode() ||
target_is_only_for_copy_request ||
finished_target->filters().HasFilterThatAffectsOpacity()) {
stack_.back().occlusion_from_outside_target.Clear();
stack_.back().occlusion_from_inside_target.Clear();
- } else if (!SurfaceTransformsToTargetKnown(surface)) {
- stack_.back().occlusion_from_inside_target.Clear();
- stack_.back().occlusion_from_outside_target.Clear();
}
}
-template <typename LayerType>
static void ReduceOcclusionBelowSurface(
- LayerType* contributing_layer,
+ const LayerImpl* contributing_layer,
const gfx::Rect& surface_rect,
const gfx::Transform& surface_transform,
- LayerType* render_target,
+ const LayerImpl* render_target,
SimpleEnclosedRegion* occlusion_from_inside_target) {
if (surface_rect.IsEmpty())
return;
@@ -315,10 +245,9 @@ static void ReduceOcclusionBelowSurface(
}
}
-template <typename LayerType>
-void OcclusionTracker<LayerType>::LeaveToRenderTarget(
- const LayerType* new_target) {
- int last_index = stack_.size() - 1;
+void OcclusionTracker::LeaveToRenderTarget(const LayerImpl* new_target) {
+ DCHECK(!stack_.empty());
+ size_t last_index = stack_.size() - 1;
bool surface_will_be_at_top_after_pop =
stack_.size() > 1 && stack_[last_index - 1].target == new_target;
@@ -326,30 +255,25 @@ void OcclusionTracker<LayerType>::LeaveToRenderTarget(
// out to its parent target RenderSurfaceImpl. The target occlusion can be
// merged out as well but needs to be transformed to the new target.
- const LayerType* old_target = stack_[last_index].target;
- const typename LayerType::RenderSurfaceType* old_surface =
- old_target->render_surface();
+ const LayerImpl* old_target = stack_[last_index].target;
+ const RenderSurfaceImpl* old_surface = old_target->render_surface();
SimpleEnclosedRegion old_occlusion_from_inside_target_in_new_target =
- TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>(
+ TransformSurfaceOpaqueRegion(
stack_[last_index].occlusion_from_inside_target,
- old_surface->is_clipped(),
- old_surface->clip_rect(),
+ old_surface->is_clipped(), old_surface->clip_rect(),
old_surface->draw_transform());
if (old_target->has_replica() && !old_target->replica_has_mask()) {
old_occlusion_from_inside_target_in_new_target.Union(
- TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>(
+ TransformSurfaceOpaqueRegion(
stack_[last_index].occlusion_from_inside_target,
- old_surface->is_clipped(),
- old_surface->clip_rect(),
+ old_surface->is_clipped(), old_surface->clip_rect(),
old_surface->replica_draw_transform()));
}
SimpleEnclosedRegion old_occlusion_from_outside_target_in_new_target =
- TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>(
- stack_[last_index].occlusion_from_outside_target,
- false,
- gfx::Rect(),
+ TransformSurfaceOpaqueRegion(
+ stack_[last_index].occlusion_from_outside_target, false, gfx::Rect(),
old_surface->draw_transform());
gfx::Rect unoccluded_surface_rect;
@@ -419,29 +343,24 @@ void OcclusionTracker<LayerType>::LeaveToRenderTarget(
&stack_.back().occlusion_from_outside_target);
}
-template <typename LayerType>
-void OcclusionTracker<LayerType>::MarkOccludedBehindLayer(
- const LayerType* layer) {
+void OcclusionTracker::MarkOccludedBehindLayer(const LayerImpl* layer) {
DCHECK(!stack_.empty());
DCHECK_EQ(layer->render_target(), stack_.back().target);
- if (!LayerOpacityKnown(layer) || layer->draw_opacity() < 1)
+ if (layer->draw_opacity() < 1)
return;
if (!layer->uses_default_blend_mode())
return;
- if (LayerIsInUnsorted3dRenderingContext(layer))
+ if (layer->Is3dSorted())
return;
- if (!LayerTransformsToTargetKnown(layer))
+ SimpleEnclosedRegion opaque_layer_region = layer->VisibleOpaqueRegion();
+ if (opaque_layer_region.IsEmpty())
return;
- SimpleEnclosedRegion opaque_contents = layer->VisibleContentOpaqueRegion();
- if (opaque_contents.IsEmpty())
- return;
-
- DCHECK(layer->visible_content_rect().Contains(opaque_contents.bounds()));
+ DCHECK(layer->visible_layer_rect().Contains(opaque_layer_region.bounds()));
// TODO(danakj): Find a rect interior to each transformed quad.
if (!layer->draw_transform().Preserves2dAxisAlignment())
@@ -456,10 +375,10 @@ void OcclusionTracker<LayerType>::MarkOccludedBehindLayer(
layer->render_target()->render_surface()->content_rect());
}
- for (size_t i = 0; i < opaque_contents.GetRegionComplexity(); ++i) {
+ for (size_t i = 0; i < opaque_layer_region.GetRegionComplexity(); ++i) {
gfx::Rect transformed_rect =
MathUtil::MapEnclosedRectWith2dAxisAlignedTransform(
- layer->draw_transform(), opaque_contents.GetRect(i));
+ layer->draw_transform(), opaque_layer_region.GetRect(i));
transformed_rect.Intersect(clip_rect_in_target);
if (transformed_rect.width() < minimum_tracking_size_.width() &&
transformed_rect.height() < minimum_tracking_size_.height())
@@ -468,8 +387,7 @@ void OcclusionTracker<LayerType>::MarkOccludedBehindLayer(
}
}
-template <typename LayerType>
-Region OcclusionTracker<LayerType>::ComputeVisibleRegionInScreen() const {
+Region OcclusionTracker::ComputeVisibleRegionInScreen() const {
DCHECK(!stack_.back().target->parent());
const SimpleEnclosedRegion& occluded =
stack_.back().occlusion_from_inside_target;
@@ -479,8 +397,4 @@ Region OcclusionTracker<LayerType>::ComputeVisibleRegionInScreen() const {
return visible_region;
}
-// Instantiate (and export) templates here for the linker.
-template class OcclusionTracker<Layer>;
-template class OcclusionTracker<LayerImpl>;
-
} // namespace cc
diff --git a/chromium/cc/trees/occlusion_tracker.h b/chromium/cc/trees/occlusion_tracker.h
index ff6f18dda9c..9a9294c779d 100644
--- a/chromium/cc/trees/occlusion_tracker.h
+++ b/chromium/cc/trees/occlusion_tracker.h
@@ -18,8 +18,6 @@ namespace cc {
class LayerImpl;
class Region;
class RenderSurfaceImpl;
-class Layer;
-class RenderSurface;
// This class is used to track occlusion of layers while traversing them in a
// front-to-back order. As each layer is visited, one of the methods in this
@@ -30,7 +28,6 @@ class RenderSurface;
// queried via surfaceOccluded() and surfaceUnoccludedContentRect(). Finally,
// once finished with the layer, occlusion behind the layer should be marked by
// calling MarkOccludedBehindLayer().
-template <typename LayerType>
class CC_EXPORT OcclusionTracker {
public:
explicit OcclusionTracker(const gfx::Rect& screen_space_clip_rect);
@@ -45,10 +42,10 @@ class CC_EXPORT OcclusionTracker {
// Called at the beginning of each step in the LayerIterator's front-to-back
// traversal.
- void EnterLayer(const LayerIteratorPosition<LayerType>& layer_iterator);
+ void EnterLayer(const LayerIteratorPosition& layer_iterator);
// Called at the end of each step in the LayerIterator's front-to-back
// traversal.
- void LeaveLayer(const LayerIteratorPosition<LayerType>& layer_iterator);
+ void LeaveLayer(const LayerIteratorPosition& layer_iterator);
// Gives the region of the screen that is not occluded by something opaque.
Region ComputeVisibleRegionInScreen() const;
@@ -60,8 +57,8 @@ class CC_EXPORT OcclusionTracker {
protected:
struct StackObject {
StackObject() : target(0) {}
- explicit StackObject(const LayerType* target) : target(target) {}
- const LayerType* target;
+ explicit StackObject(const LayerImpl* target) : target(target) {}
+ const LayerImpl* target;
SimpleEnclosedRegion occlusion_from_outside_target;
SimpleEnclosedRegion occlusion_from_inside_target;
};
@@ -86,21 +83,21 @@ class CC_EXPORT OcclusionTracker {
private:
// Called when visiting a layer representing itself. If the target was not
// already current, then this indicates we have entered a new surface subtree.
- void EnterRenderTarget(const LayerType* new_target);
+ void EnterRenderTarget(const LayerImpl* new_target);
// Called when visiting a layer representing a target surface. This indicates
// we have visited all the layers within the surface, and we may perform any
// surface-wide operations.
- void FinishedRenderTarget(const LayerType* finished_target);
+ void FinishedRenderTarget(const LayerImpl* finished_target);
// Called when visiting a layer representing a contributing surface. This
// indicates that we are leaving our current surface, and entering the new
// one. We then perform any operations required for merging results from the
// child subtree into its parent.
- void LeaveToRenderTarget(const LayerType* new_target);
+ void LeaveToRenderTarget(const LayerImpl* new_target);
// Add the layer's occlusion to the tracked state.
- void MarkOccludedBehindLayer(const LayerType* layer);
+ void MarkOccludedBehindLayer(const LayerImpl* layer);
gfx::Rect screen_space_clip_rect_;
gfx::Size minimum_tracking_size_;
@@ -108,11 +105,6 @@ class CC_EXPORT OcclusionTracker {
DISALLOW_COPY_AND_ASSIGN(OcclusionTracker);
};
-#if !defined(COMPILER_MSVC)
-extern template class OcclusionTracker<Layer>;
-extern template class OcclusionTracker<LayerImpl>;
-#endif
-
} // namespace cc
#endif // CC_TREES_OCCLUSION_TRACKER_H_
diff --git a/chromium/cc/trees/occlusion_tracker_perftest.cc b/chromium/cc/trees/occlusion_tracker_perftest.cc
index 854dacdb5f0..209399dce11 100644
--- a/chromium/cc/trees/occlusion_tracker_perftest.cc
+++ b/chromium/cc/trees/occlusion_tracker_perftest.cc
@@ -4,6 +4,7 @@
#include "cc/trees/occlusion_tracker.h"
+#include "base/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "cc/debug/lap_timer.h"
#include "cc/layers/layer_iterator.h"
@@ -13,6 +14,7 @@
#include "cc/test/fake_proxy.h"
#include "cc/test/fake_rendering_stats_instrumentation.h"
#include "cc/test/test_shared_bitmap_manager.h"
+#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_host_impl.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/single_thread_proxy.h"
@@ -32,13 +34,13 @@ class OcclusionTrackerPerfTest : public testing::Test {
: timer_(kWarmupRuns,
base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
kTimeCheckInterval),
+ proxy_(base::ThreadTaskRunnerHandle::Get(), nullptr),
impl_(&proxy_) {}
void CreateHost() {
LayerTreeSettings settings;
- shared_bitmap_manager_.reset(new TestSharedBitmapManager());
- host_impl_ =
- LayerTreeHostImpl::Create(settings, &client_, &proxy_, &stats_,
- shared_bitmap_manager_.get(), NULL, NULL, 1);
+ host_impl_ = LayerTreeHostImpl::Create(settings, &client_, &proxy_, &stats_,
+ &shared_bitmap_manager_, nullptr,
+ &task_graph_runner_, 1);
host_impl_->InitializeRenderer(FakeOutputSurface::Create3d());
scoped_ptr<LayerImpl> root_layer = LayerImpl::Create(active_tree(), 1);
@@ -67,7 +69,8 @@ class OcclusionTrackerPerfTest : public testing::Test {
FakeProxy proxy_;
DebugScopedSetImplThread impl_;
FakeRenderingStatsInstrumentation stats_;
- scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
+ TestSharedBitmapManager shared_bitmap_manager_;
+ TestTaskGraphRunner task_graph_runner_;
scoped_ptr<LayerTreeHostImpl> host_impl_;
};
@@ -75,7 +78,7 @@ TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_FullyOccluded) {
SetTestName("unoccluded_content_rect_fully_occluded");
gfx::Rect viewport_rect(768, 1038);
- OcclusionTracker<LayerImpl> tracker(viewport_rect);
+ OcclusionTracker tracker(viewport_rect);
CreateHost();
host_impl_->SetViewportSize(viewport_rect.size());
@@ -86,7 +89,6 @@ TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_FullyOccluded) {
opaque_layer->SetContentsOpaque(true);
opaque_layer->SetDrawsContent(true);
opaque_layer->SetBounds(viewport_rect.size());
- opaque_layer->SetContentBounds(viewport_rect.size());
active_tree()->root_layer()->AddChild(opaque_layer.Pass());
bool update_lcd_text = false;
@@ -95,10 +97,10 @@ TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_FullyOccluded) {
ASSERT_EQ(1u, rsll.size());
EXPECT_EQ(1u, rsll[0]->render_surface()->layer_list().size());
- LayerIterator<LayerImpl> begin = LayerIterator<LayerImpl>::Begin(&rsll);
- LayerIterator<LayerImpl> end = LayerIterator<LayerImpl>::End(&rsll);
+ LayerIterator begin = LayerIterator::Begin(&rsll);
+ LayerIterator end = LayerIterator::End(&rsll);
- LayerIteratorPosition<LayerImpl> pos = begin;
+ LayerIteratorPosition pos = begin;
// The opaque_layer adds occlusion over the whole viewport.
tracker.EnterLayer(pos);
@@ -128,7 +130,7 @@ TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_FullyOccluded) {
} while (!timer_.HasTimeLimitExpired());
++begin;
- LayerIteratorPosition<LayerImpl> next = begin;
+ LayerIteratorPosition next = begin;
EXPECT_EQ(active_tree()->root_layer(), next.current_layer);
++begin;
@@ -142,7 +144,7 @@ TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_10OpaqueLayers) {
SetTestName("unoccluded_content_rect_10_opaque_layers");
gfx::Rect viewport_rect(768, 1038);
- OcclusionTracker<LayerImpl> tracker(viewport_rect);
+ OcclusionTracker tracker(viewport_rect);
CreateHost();
host_impl_->SetViewportSize(viewport_rect.size());
@@ -155,8 +157,6 @@ TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_10OpaqueLayers) {
opaque_layer->SetDrawsContent(true);
opaque_layer->SetBounds(
gfx::Size(viewport_rect.width() / 2, viewport_rect.height() / 2));
- opaque_layer->SetContentBounds(
- gfx::Size(viewport_rect.width() / 2, viewport_rect.height() / 2));
opaque_layer->SetPosition(gfx::Point(i, i));
active_tree()->root_layer()->AddChild(opaque_layer.Pass());
}
@@ -168,17 +168,17 @@ TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_10OpaqueLayers) {
EXPECT_EQ(static_cast<size_t>(kNumOpaqueLayers),
rsll[0]->render_surface()->layer_list().size());
- LayerIterator<LayerImpl> begin = LayerIterator<LayerImpl>::Begin(&rsll);
- LayerIterator<LayerImpl> end = LayerIterator<LayerImpl>::End(&rsll);
+ LayerIterator begin = LayerIterator::Begin(&rsll);
+ LayerIterator end = LayerIterator::End(&rsll);
// The opaque_layers add occlusion.
for (int i = 0; i < kNumOpaqueLayers - 1; ++i) {
- LayerIteratorPosition<LayerImpl> pos = begin;
+ LayerIteratorPosition pos = begin;
tracker.EnterLayer(pos);
tracker.LeaveLayer(pos);
++begin;
}
- LayerIteratorPosition<LayerImpl> pos = begin;
+ LayerIteratorPosition pos = begin;
tracker.EnterLayer(pos);
tracker.LeaveLayer(pos);
@@ -200,7 +200,7 @@ TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_10OpaqueLayers) {
} while (!timer_.HasTimeLimitExpired());
++begin;
- LayerIteratorPosition<LayerImpl> next = begin;
+ LayerIteratorPosition next = begin;
EXPECT_EQ(active_tree()->root_layer(), next.current_layer);
++begin;
diff --git a/chromium/cc/trees/occlusion_tracker_unittest.cc b/chromium/cc/trees/occlusion_tracker_unittest.cc
index f3f218570eb..08cfcf7290e 100644
--- a/chromium/cc/trees/occlusion_tracker_unittest.cc
+++ b/chromium/cc/trees/occlusion_tracker_unittest.cc
@@ -18,6 +18,7 @@
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/test_occlusion_tracker.h"
+#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_host_common.h"
#include "cc/trees/single_thread_proxy.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -27,31 +28,6 @@
namespace cc {
namespace {
-class TestContentLayer : public Layer {
- public:
- TestContentLayer() : Layer(), override_opaque_contents_rect_(false) {
- SetIsDrawable(true);
- }
-
- SimpleEnclosedRegion VisibleContentOpaqueRegion() const override {
- if (override_opaque_contents_rect_) {
- return SimpleEnclosedRegion(
- gfx::IntersectRects(opaque_contents_rect_, visible_content_rect()));
- }
- return Layer::VisibleContentOpaqueRegion();
- }
- void SetOpaqueContentsRect(const gfx::Rect& opaque_contents_rect) {
- override_opaque_contents_rect_ = true;
- opaque_contents_rect_ = opaque_contents_rect;
- }
-
- private:
- ~TestContentLayer() override {}
-
- bool override_opaque_contents_rect_;
- gfx::Rect opaque_contents_rect_;
-};
-
class TestContentLayerImpl : public LayerImpl {
public:
TestContentLayerImpl(LayerTreeImpl* tree_impl, int id)
@@ -59,12 +35,12 @@ class TestContentLayerImpl : public LayerImpl {
SetDrawsContent(true);
}
- SimpleEnclosedRegion VisibleContentOpaqueRegion() const override {
+ SimpleEnclosedRegion VisibleOpaqueRegion() const override {
if (override_opaque_contents_rect_) {
return SimpleEnclosedRegion(
- gfx::IntersectRects(opaque_contents_rect_, visible_content_rect()));
+ gfx::IntersectRects(opaque_contents_rect_, visible_layer_rect()));
}
- return LayerImpl::VisibleContentOpaqueRegion();
+ return LayerImpl::VisibleOpaqueRegion();
}
void SetOpaqueContentsRect(const gfx::Rect& opaque_contents_rect) {
override_opaque_contents_rect_ = true;
@@ -76,162 +52,97 @@ class TestContentLayerImpl : public LayerImpl {
gfx::Rect opaque_contents_rect_;
};
-template <typename LayerType>
-class TestOcclusionTrackerWithClip : public TestOcclusionTracker<LayerType> {
+class TestOcclusionTrackerWithClip : public TestOcclusionTracker {
public:
explicit TestOcclusionTrackerWithClip(const gfx::Rect& viewport_rect)
- : TestOcclusionTracker<LayerType>(viewport_rect) {}
+ : TestOcclusionTracker(viewport_rect) {}
- bool OccludedLayer(const LayerType* layer,
+ bool OccludedLayer(const LayerImpl* layer,
const gfx::Rect& content_rect) const {
- DCHECK(layer->visible_content_rect().Contains(content_rect));
+ DCHECK(layer->visible_layer_rect().Contains(content_rect));
return this->GetCurrentOcclusionForLayer(layer->draw_transform())
.IsOccluded(content_rect);
}
// Gives an unoccluded sub-rect of |content_rect| in the content space of the
// layer. Simple wrapper around GetUnoccludedContentRect.
- gfx::Rect UnoccludedLayerContentRect(const LayerType* layer,
+ gfx::Rect UnoccludedLayerContentRect(const LayerImpl* layer,
const gfx::Rect& content_rect) const {
- DCHECK(layer->visible_content_rect().Contains(content_rect));
+ DCHECK(layer->visible_layer_rect().Contains(content_rect));
return this->GetCurrentOcclusionForLayer(layer->draw_transform())
.GetUnoccludedContentRect(content_rect);
}
- gfx::Rect UnoccludedSurfaceContentRect(const LayerType* layer,
+ gfx::Rect UnoccludedSurfaceContentRect(const LayerImpl* layer,
const gfx::Rect& content_rect) const {
- typename LayerType::RenderSurfaceType* surface = layer->render_surface();
+ RenderSurfaceImpl* surface = layer->render_surface();
return this->GetCurrentOcclusionForContributingSurface(
surface->draw_transform())
.GetUnoccludedContentRect(content_rect);
}
};
-struct OcclusionTrackerTestMainThreadTypes {
- typedef Layer LayerType;
- typedef FakeLayerTreeHost HostType;
- typedef RenderSurface RenderSurfaceType;
- typedef TestContentLayer ContentLayerType;
- typedef scoped_refptr<Layer> LayerPtrType;
- typedef scoped_refptr<ContentLayerType> ContentLayerPtrType;
- typedef LayerIterator<Layer> TestLayerIterator;
- typedef OcclusionTracker<Layer> OcclusionTrackerType;
-
- static LayerPtrType CreateLayer(HostType* host) { return Layer::Create(); }
- static ContentLayerPtrType CreateContentLayer(HostType* host) {
- return make_scoped_refptr(new ContentLayerType());
- }
-
- template <typename T>
- static LayerPtrType PassLayerPtr(T* layer) {
- LayerPtrType ref(*layer);
- *layer = NULL;
- return ref;
- }
- static void SetForceRenderSurface(LayerType* layer, bool force) {
- layer->SetForceRenderSurface(force);
- }
-
- static void DestroyLayer(LayerPtrType* layer) { *layer = NULL; }
-
- static void RecursiveUpdateNumChildren(LayerType* layerType) {}
-};
-
-struct OcclusionTrackerTestImplThreadTypes {
- typedef LayerImpl LayerType;
- typedef LayerTreeImpl HostType;
- typedef RenderSurfaceImpl RenderSurfaceType;
- typedef TestContentLayerImpl ContentLayerType;
- typedef scoped_ptr<LayerImpl> LayerPtrType;
- typedef scoped_ptr<ContentLayerType> ContentLayerPtrType;
- typedef LayerIterator<LayerImpl> TestLayerIterator;
- typedef OcclusionTracker<LayerImpl> OcclusionTrackerType;
-
- static LayerPtrType CreateLayer(HostType* host) {
- return LayerImpl::Create(host, next_layer_impl_id++);
- }
- static ContentLayerPtrType CreateContentLayer(HostType* host) {
- return make_scoped_ptr(new ContentLayerType(host, next_layer_impl_id++));
- }
- static int next_layer_impl_id;
-
- template <typename T>
- static LayerPtrType PassLayerPtr(T* layer) {
- return layer->Pass();
- }
-
- static void SetForceRenderSurface(LayerType* layer, bool force) {
- layer->SetHasRenderSurface(force);
- }
- static void DestroyLayer(LayerPtrType* layer) { layer->reset(); }
-
- static void RecursiveUpdateNumChildren(LayerType* layer) {
- FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(layer);
- }
-};
-
-int OcclusionTrackerTestImplThreadTypes::next_layer_impl_id = 1;
-
-template <typename Types> class OcclusionTrackerTest : public testing::Test {
+class OcclusionTrackerTest : public testing::Test {
protected:
explicit OcclusionTrackerTest(bool opaque_layers)
: opaque_layers_(opaque_layers),
client_(FakeLayerTreeHostClient::DIRECT_3D),
- host_(FakeLayerTreeHost::Create(&client_)) {}
+ host_(FakeLayerTreeHost::Create(&client_, &task_graph_runner_)),
+ next_layer_impl_id_(1) {}
virtual void RunMyTest() = 0;
void TearDown() override { DestroyLayers(); }
- typename Types::HostType* GetHost();
-
- typename Types::ContentLayerType* CreateRoot(const gfx::Transform& transform,
- const gfx::PointF& position,
- const gfx::Size& bounds) {
- typename Types::ContentLayerPtrType layer(
- Types::CreateContentLayer(GetHost()));
- typename Types::ContentLayerType* layer_ptr = layer.get();
+ TestContentLayerImpl* CreateRoot(const gfx::Transform& transform,
+ const gfx::PointF& position,
+ const gfx::Size& bounds) {
+ LayerTreeImpl* tree = host_->host_impl()->active_tree();
+ int id = next_layer_impl_id_++;
+ scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id));
+ TestContentLayerImpl* layer_ptr = layer.get();
SetProperties(layer_ptr, transform, position, bounds);
DCHECK(!root_.get());
- root_ = Types::PassLayerPtr(&layer);
+ root_ = layer.Pass();
- Types::SetForceRenderSurface(layer_ptr, true);
+ layer_ptr->SetHasRenderSurface(true);
SetRootLayerOnMainThread(layer_ptr);
return layer_ptr;
}
- typename Types::LayerType* CreateLayer(typename Types::LayerType* parent,
- const gfx::Transform& transform,
- const gfx::PointF& position,
- const gfx::Size& bounds) {
- typename Types::LayerPtrType layer(Types::CreateLayer(GetHost()));
- typename Types::LayerType* layer_ptr = layer.get();
+ LayerImpl* CreateLayer(LayerImpl* parent,
+ const gfx::Transform& transform,
+ const gfx::PointF& position,
+ const gfx::Size& bounds) {
+ LayerTreeImpl* tree = host_->host_impl()->active_tree();
+ int id = next_layer_impl_id_++;
+ scoped_ptr<LayerImpl> layer = LayerImpl::Create(tree, id);
+ LayerImpl* layer_ptr = layer.get();
SetProperties(layer_ptr, transform, position, bounds);
- parent->AddChild(Types::PassLayerPtr(&layer));
+ parent->AddChild(layer.Pass());
return layer_ptr;
}
- typename Types::LayerType* CreateSurface(typename Types::LayerType* parent,
- const gfx::Transform& transform,
- const gfx::PointF& position,
- const gfx::Size& bounds) {
- typename Types::LayerType* layer =
- CreateLayer(parent, transform, position, bounds);
- Types::SetForceRenderSurface(layer, true);
+ LayerImpl* CreateSurface(LayerImpl* parent,
+ const gfx::Transform& transform,
+ const gfx::PointF& position,
+ const gfx::Size& bounds) {
+ LayerImpl* layer = CreateLayer(parent, transform, position, bounds);
+ layer->SetHasRenderSurface(true);
return layer;
}
- typename Types::ContentLayerType* CreateDrawingLayer(
- typename Types::LayerType* parent,
- const gfx::Transform& transform,
- const gfx::PointF& position,
- const gfx::Size& bounds,
- bool opaque) {
- typename Types::ContentLayerPtrType layer(
- Types::CreateContentLayer(GetHost()));
- typename Types::ContentLayerType* layer_ptr = layer.get();
+ TestContentLayerImpl* CreateDrawingLayer(LayerImpl* parent,
+ const gfx::Transform& transform,
+ const gfx::PointF& position,
+ const gfx::Size& bounds,
+ bool opaque) {
+ LayerTreeImpl* tree = host_->host_impl()->active_tree();
+ int id = next_layer_impl_id_++;
+ scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id));
+ TestContentLayerImpl* layer_ptr = layer.get();
SetProperties(layer_ptr, transform, position, bounds);
if (opaque_layers_) {
@@ -244,48 +155,46 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test {
layer_ptr->SetOpaqueContentsRect(gfx::Rect());
}
- parent->AddChild(Types::PassLayerPtr(&layer));
+ parent->AddChild(layer.Pass());
return layer_ptr;
}
- typename Types::LayerType* CreateReplicaLayer(
- typename Types::LayerType* owning_layer,
- const gfx::Transform& transform,
- const gfx::PointF& position,
- const gfx::Size& bounds) {
- typename Types::ContentLayerPtrType layer(
- Types::CreateContentLayer(GetHost()));
- typename Types::ContentLayerType* layer_ptr = layer.get();
+ LayerImpl* CreateReplicaLayer(LayerImpl* owning_layer,
+ const gfx::Transform& transform,
+ const gfx::PointF& position,
+ const gfx::Size& bounds) {
+ LayerTreeImpl* tree = host_->host_impl()->active_tree();
+ int id = next_layer_impl_id_++;
+ scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id));
+ TestContentLayerImpl* layer_ptr = layer.get();
SetProperties(layer_ptr, transform, position, bounds);
- SetReplica(owning_layer, Types::PassLayerPtr(&layer));
+ SetReplica(owning_layer, layer.Pass());
return layer_ptr;
}
- typename Types::LayerType* CreateMaskLayer(
- typename Types::LayerType* owning_layer,
- const gfx::Size& bounds) {
- typename Types::ContentLayerPtrType layer(
- Types::CreateContentLayer(GetHost()));
- typename Types::ContentLayerType* layer_ptr = layer.get();
+ LayerImpl* CreateMaskLayer(LayerImpl* owning_layer, const gfx::Size& bounds) {
+ LayerTreeImpl* tree = host_->host_impl()->active_tree();
+ int id = next_layer_impl_id_++;
+ scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id));
+ TestContentLayerImpl* layer_ptr = layer.get();
SetProperties(layer_ptr, identity_matrix, gfx::PointF(), bounds);
- SetMask(owning_layer, Types::PassLayerPtr(&layer));
+ SetMask(owning_layer, layer.Pass());
return layer_ptr;
}
- typename Types::ContentLayerType* CreateDrawingSurface(
- typename Types::LayerType* parent,
- const gfx::Transform& transform,
- const gfx::PointF& position,
- const gfx::Size& bounds,
- bool opaque) {
- typename Types::ContentLayerType* layer =
+ TestContentLayerImpl* CreateDrawingSurface(LayerImpl* parent,
+ const gfx::Transform& transform,
+ const gfx::PointF& position,
+ const gfx::Size& bounds,
+ bool opaque) {
+ TestContentLayerImpl* layer =
CreateDrawingLayer(parent, transform, position, bounds, opaque);
- Types::SetForceRenderSurface(layer, true);
+ layer->SetHasRenderSurface(true);
return layer;
}
void DestroyLayers() {
- Types::DestroyLayer(&root_);
+ root_ = nullptr;
render_surface_layer_list_ = nullptr;
render_surface_layer_list_impl_.clear();
replica_layers_.clear();
@@ -296,18 +205,15 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test {
void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {}
void AddCopyRequest(Layer* layer) {
- layer->RequestCopyOfOutput(
- CopyOutputRequest::CreateBitmapRequest(base::Bind(
- &OcclusionTrackerTest<Types>::CopyOutputCallback,
- base::Unretained(this))));
+ layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest(
+ base::Bind(&OcclusionTrackerTest::CopyOutputCallback,
+ base::Unretained(this))));
}
void AddCopyRequest(LayerImpl* layer) {
ScopedPtrVector<CopyOutputRequest> requests;
- requests.push_back(
- CopyOutputRequest::CreateBitmapRequest(base::Bind(
- &OcclusionTrackerTest<Types>::CopyOutputCallback,
- base::Unretained(this))));
+ requests.push_back(CopyOutputRequest::CreateBitmapRequest(base::Bind(
+ &OcclusionTrackerTest::CopyOutputCallback, base::Unretained(this))));
layer->SetHasRenderSurface(true);
layer->PassCopyRequests(&requests);
}
@@ -315,54 +221,40 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test {
void CalcDrawEtc(TestContentLayerImpl* root) {
DCHECK(root == root_.get());
- Types::RecursiveUpdateNumChildren(root);
- LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
- root, root->bounds(), &render_surface_layer_list_impl_);
- inputs.can_adjust_raster_scales = true;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
+ // These occlusion tests attach and detach layers in multiple
+ // iterations, so rebuild property trees every time.
+ root->layer_tree_impl()->property_trees()->needs_rebuild = true;
- layer_iterator_ = layer_iterator_begin_ =
- Types::TestLayerIterator::Begin(&render_surface_layer_list_impl_);
- }
+ FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root);
- void CalcDrawEtc(TestContentLayer* root) {
- DCHECK(root == root_.get());
- DCHECK(!root->render_surface());
-
- render_surface_layer_list_.reset(new RenderSurfaceLayerList);
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root, root->bounds(), render_surface_layer_list_.get());
+ LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
+ root, root->bounds(), &render_surface_layer_list_impl_);
inputs.can_adjust_raster_scales = true;
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
layer_iterator_ = layer_iterator_begin_ =
- Types::TestLayerIterator::Begin(render_surface_layer_list_.get());
+ LayerIterator::Begin(&render_surface_layer_list_impl_);
}
- void EnterLayer(typename Types::LayerType* layer,
- typename Types::OcclusionTrackerType* occlusion) {
+ void EnterLayer(LayerImpl* layer, OcclusionTracker* occlusion) {
ASSERT_EQ(*layer_iterator_, layer);
ASSERT_TRUE(layer_iterator_.represents_itself());
occlusion->EnterLayer(layer_iterator_);
}
- void LeaveLayer(typename Types::LayerType* layer,
- typename Types::OcclusionTrackerType* occlusion) {
+ void LeaveLayer(LayerImpl* layer, OcclusionTracker* occlusion) {
ASSERT_EQ(*layer_iterator_, layer);
ASSERT_TRUE(layer_iterator_.represents_itself());
occlusion->LeaveLayer(layer_iterator_);
++layer_iterator_;
}
- void VisitLayer(typename Types::LayerType* layer,
- typename Types::OcclusionTrackerType* occlusion) {
+ void VisitLayer(LayerImpl* layer, OcclusionTracker* occlusion) {
EnterLayer(layer, occlusion);
LeaveLayer(layer, occlusion);
}
- void EnterContributingSurface(
- typename Types::LayerType* layer,
- typename Types::OcclusionTrackerType* occlusion) {
+ void EnterContributingSurface(LayerImpl* layer, OcclusionTracker* occlusion) {
ASSERT_EQ(*layer_iterator_, layer);
ASSERT_TRUE(layer_iterator_.represents_target_render_surface());
occlusion->EnterLayer(layer_iterator_);
@@ -372,18 +264,14 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test {
occlusion->EnterLayer(layer_iterator_);
}
- void LeaveContributingSurface(
- typename Types::LayerType* layer,
- typename Types::OcclusionTrackerType* occlusion) {
+ void LeaveContributingSurface(LayerImpl* layer, OcclusionTracker* occlusion) {
ASSERT_EQ(*layer_iterator_, layer);
ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface());
occlusion->LeaveLayer(layer_iterator_);
++layer_iterator_;
}
- void VisitContributingSurface(
- typename Types::LayerType* layer,
- typename Types::OcclusionTrackerType* occlusion) {
+ void VisitContributingSurface(LayerImpl* layer, OcclusionTracker* occlusion) {
EnterContributingSurface(layer, occlusion);
LeaveContributingSurface(layer, occlusion);
}
@@ -399,148 +287,72 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test {
void SetRootLayerOnMainThread(LayerImpl* root) {}
- void SetBaseProperties(typename Types::LayerType* layer,
- const gfx::Transform& transform,
- const gfx::PointF& position,
- const gfx::Size& bounds) {
- layer->SetTransform(transform);
- layer->SetPosition(position);
- layer->SetBounds(bounds);
- }
-
- void SetProperties(Layer* layer,
- const gfx::Transform& transform,
- const gfx::PointF& position,
- const gfx::Size& bounds) {
- SetBaseProperties(layer, transform, position, bounds);
- }
-
void SetProperties(LayerImpl* layer,
const gfx::Transform& transform,
const gfx::PointF& position,
const gfx::Size& bounds) {
- SetBaseProperties(layer, transform, position, bounds);
-
- layer->SetContentBounds(layer->bounds());
- }
-
- void SetReplica(Layer* owning_layer, scoped_refptr<Layer> layer) {
- owning_layer->SetReplicaLayer(layer.get());
- replica_layers_.push_back(layer);
+ layer->SetTransform(transform);
+ layer->SetPosition(position);
+ layer->SetBounds(bounds);
}
void SetReplica(LayerImpl* owning_layer, scoped_ptr<LayerImpl> layer) {
owning_layer->SetReplicaLayer(layer.Pass());
}
- void SetMask(Layer* owning_layer, scoped_refptr<Layer> layer) {
- owning_layer->SetMaskLayer(layer.get());
- mask_layers_.push_back(layer);
- }
-
void SetMask(LayerImpl* owning_layer, scoped_ptr<LayerImpl> layer) {
owning_layer->SetMaskLayer(layer.Pass());
}
bool opaque_layers_;
FakeLayerTreeHostClient client_;
+ TestTaskGraphRunner task_graph_runner_;
scoped_ptr<FakeLayerTreeHost> host_;
// These hold ownership of the layers for the duration of the test.
- typename Types::LayerPtrType root_;
+ scoped_ptr<LayerImpl> root_;
scoped_ptr<RenderSurfaceLayerList> render_surface_layer_list_;
LayerImplList render_surface_layer_list_impl_;
- typename Types::TestLayerIterator layer_iterator_begin_;
- typename Types::TestLayerIterator layer_iterator_;
- typename Types::LayerType* last_layer_visited_;
+ LayerIterator layer_iterator_begin_;
+ LayerIterator layer_iterator_;
LayerList replica_layers_;
LayerList mask_layers_;
+ int next_layer_impl_id_;
};
-template <>
-FakeLayerTreeHost*
-OcclusionTrackerTest<OcclusionTrackerTestMainThreadTypes>::GetHost() {
- return host_.get();
-}
-
-template <>
-LayerTreeImpl*
-OcclusionTrackerTest<OcclusionTrackerTestImplThreadTypes>::GetHost() {
- return host_->host_impl()->active_tree();
-}
-
-#define RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \
- class ClassName##MainThreadOpaqueLayers \
- : public ClassName<OcclusionTrackerTestMainThreadTypes> { \
- public: /* NOLINT(whitespace/indent) */ \
- ClassName##MainThreadOpaqueLayers() \
- : ClassName<OcclusionTrackerTestMainThreadTypes>(true) {} \
- }; \
- TEST_F(ClassName##MainThreadOpaqueLayers, RunTest) { RunMyTest(); }
-#define RUN_TEST_MAIN_THREAD_OPAQUE_PAINTS(ClassName) \
- class ClassName##MainThreadOpaquePaints \
- : public ClassName<OcclusionTrackerTestMainThreadTypes> { \
- public: /* NOLINT(whitespace/indent) */ \
- ClassName##MainThreadOpaquePaints() \
- : ClassName<OcclusionTrackerTestMainThreadTypes>(false) {} \
- }; \
- TEST_F(ClassName##MainThreadOpaquePaints, RunTest) { RunMyTest(); }
-
-#define RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \
- class ClassName##ImplThreadOpaqueLayers \
- : public ClassName<OcclusionTrackerTestImplThreadTypes> { \
- public: /* NOLINT(whitespace/indent) */ \
- ClassName##ImplThreadOpaqueLayers() \
- : ClassName<OcclusionTrackerTestImplThreadTypes>(true) {} \
- }; \
+#define RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \
+ class ClassName##ImplThreadOpaqueLayers : public ClassName { \
+ public: /* NOLINT(whitespace/indent) */ \
+ ClassName##ImplThreadOpaqueLayers() : ClassName(true) {} \
+ }; \
TEST_F(ClassName##ImplThreadOpaqueLayers, RunTest) { RunMyTest(); }
-#define RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName) \
- class ClassName##ImplThreadOpaquePaints \
- : public ClassName<OcclusionTrackerTestImplThreadTypes> { \
- public: /* NOLINT(whitespace/indent) */ \
- ClassName##ImplThreadOpaquePaints() \
- : ClassName<OcclusionTrackerTestImplThreadTypes>(false) {} \
- }; \
+#define RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName) \
+ class ClassName##ImplThreadOpaquePaints : public ClassName { \
+ public: /* NOLINT(whitespace/indent) */ \
+ ClassName##ImplThreadOpaquePaints() : ClassName(false) {} \
+ }; \
TEST_F(ClassName##ImplThreadOpaquePaints, RunTest) { RunMyTest(); }
#define ALL_OCCLUSIONTRACKER_TEST(ClassName) \
- RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \
- RUN_TEST_MAIN_THREAD_OPAQUE_PAINTS(ClassName) \
RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \
RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName)
-#define MAIN_THREAD_TEST(ClassName) \
- RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName)
-
-#define IMPL_THREAD_TEST(ClassName) \
- RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName)
-
-#define MAIN_AND_IMPL_THREAD_TEST(ClassName) \
- RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \
- RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName)
-
-template <class Types>
-class OcclusionTrackerTestIdentityTransforms
- : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestIdentityTransforms : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestIdentityTransforms(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- typename Types::ContentLayerType* root = this->CreateRoot(
+ TestContentLayerImpl* root = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
- typename Types::ContentLayerType* parent = this->CreateDrawingLayer(
+ TestContentLayerImpl* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true);
- typename Types::ContentLayerType* layer =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(30.f, 30.f),
- gfx::Size(500, 500),
- true);
+ TestContentLayerImpl* layer = this->CreateDrawingLayer(
+ parent, this->identity_matrix, gfx::PointF(30.f, 30.f),
+ gfx::Size(500, 500), true);
parent->SetMasksToBounds(true);
this->CalcDrawEtc(root);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(layer, &occlusion);
this->EnterLayer(parent, &occlusion);
@@ -554,32 +366,27 @@ class OcclusionTrackerTestIdentityTransforms
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestIdentityTransforms);
-template <class Types>
-class OcclusionTrackerTestRotatedChild : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestRotatedChild : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestRotatedChild(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform layer_transform;
layer_transform.Translate(250.0, 250.0);
layer_transform.Rotate(90.0);
layer_transform.Translate(-250.0, -250.0);
- typename Types::ContentLayerType* root = this->CreateRoot(
+ TestContentLayerImpl* root = this->CreateRoot(
this->identity_matrix, gfx::Point(0, 0), gfx::Size(200, 200));
- typename Types::ContentLayerType* parent = this->CreateDrawingLayer(
+ TestContentLayerImpl* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true);
- typename Types::ContentLayerType* layer =
- this->CreateDrawingLayer(parent,
- layer_transform,
- gfx::PointF(30.f, 30.f),
- gfx::Size(500, 500),
- true);
+ TestContentLayerImpl* layer = this->CreateDrawingLayer(
+ parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500),
+ true);
parent->SetMasksToBounds(true);
this->CalcDrawEtc(root);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(layer, &occlusion);
this->EnterLayer(parent, &occlusion);
@@ -593,30 +400,25 @@ class OcclusionTrackerTestRotatedChild : public OcclusionTrackerTest<Types> {
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestRotatedChild);
-template <class Types>
-class OcclusionTrackerTestTranslatedChild : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestTranslatedChild : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestTranslatedChild(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform layer_transform;
layer_transform.Translate(20.0, 20.0);
- typename Types::ContentLayerType* root = this->CreateRoot(
+ TestContentLayerImpl* root = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
- typename Types::ContentLayerType* parent = this->CreateDrawingLayer(
+ TestContentLayerImpl* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true);
- typename Types::ContentLayerType* layer =
- this->CreateDrawingLayer(parent,
- layer_transform,
- gfx::PointF(30.f, 30.f),
- gfx::Size(500, 500),
- true);
+ TestContentLayerImpl* layer = this->CreateDrawingLayer(
+ parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500),
+ true);
parent->SetMasksToBounds(true);
this->CalcDrawEtc(root);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(layer, &occlusion);
this->EnterLayer(parent, &occlusion);
@@ -630,34 +432,28 @@ class OcclusionTrackerTestTranslatedChild : public OcclusionTrackerTest<Types> {
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestTranslatedChild);
-template <class Types>
-class OcclusionTrackerTestChildInRotatedChild
- : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestChildInRotatedChild : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestChildInRotatedChild(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform child_transform;
child_transform.Translate(250.0, 250.0);
child_transform.Rotate(90.0);
child_transform.Translate(-250.0, -250.0);
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
parent->SetMasksToBounds(true);
- typename Types::LayerType* child = this->CreateSurface(
+ LayerImpl* child = this->CreateSurface(
parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500));
child->SetMasksToBounds(true);
- typename Types::ContentLayerType* layer =
- this->CreateDrawingLayer(child,
- this->identity_matrix,
- gfx::PointF(10.f, 10.f),
- gfx::Size(500, 500),
- true);
+ TestContentLayerImpl* layer = this->CreateDrawingLayer(
+ child, this->identity_matrix, gfx::PointF(10.f, 10.f),
+ gfx::Size(500, 500), true);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(layer, &occlusion);
this->EnterContributingSurface(child, &occlusion);
@@ -727,37 +523,31 @@ class OcclusionTrackerTestChildInRotatedChild
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestChildInRotatedChild);
-template <class Types>
-class OcclusionTrackerTestScaledRenderSurface
- : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestScaledRenderSurface : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestScaledRenderSurface(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
gfx::Transform layer1_matrix;
layer1_matrix.Scale(2.0, 2.0);
- typename Types::ContentLayerType* layer1 = this->CreateDrawingLayer(
+ TestContentLayerImpl* layer1 = this->CreateDrawingLayer(
parent, layer1_matrix, gfx::PointF(), gfx::Size(100, 100), true);
- Types::SetForceRenderSurface(layer1, true);
+ layer1->SetHasRenderSurface(true);
gfx::Transform layer2_matrix;
layer2_matrix.Translate(25.0, 25.0);
- typename Types::ContentLayerType* layer2 = this->CreateDrawingLayer(
+ TestContentLayerImpl* layer2 = this->CreateDrawingLayer(
layer1, layer2_matrix, gfx::PointF(), gfx::Size(50, 50), true);
- typename Types::ContentLayerType* occluder =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(100.f, 100.f),
- gfx::Size(500, 500),
- true);
+ TestContentLayerImpl* occluder = this->CreateDrawingLayer(
+ parent, this->identity_matrix, gfx::PointF(100.f, 100.f),
+ gfx::Size(500, 500), true);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(occluder, &occlusion);
this->EnterLayer(layer2, &occlusion);
@@ -771,37 +561,28 @@ class OcclusionTrackerTestScaledRenderSurface
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledRenderSurface);
-template <class Types>
-class OcclusionTrackerTestVisitTargetTwoTimes
- : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestVisitTargetTwoTimes : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestVisitTargetTwoTimes(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- typename Types::ContentLayerType* root = this->CreateRoot(
+ TestContentLayerImpl* root = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
- typename Types::LayerType* surface = this->CreateSurface(
+ LayerImpl* surface = this->CreateSurface(
root, this->identity_matrix, gfx::PointF(30.f, 30.f), gfx::Size());
- typename Types::ContentLayerType* surface_child =
- this->CreateDrawingLayer(surface,
- this->identity_matrix,
- gfx::PointF(10.f, 10.f),
- gfx::Size(50, 50),
- true);
+ TestContentLayerImpl* surface_child = this->CreateDrawingLayer(
+ surface, this->identity_matrix, gfx::PointF(10.f, 10.f),
+ gfx::Size(50, 50), true);
// |top_layer| makes |root|'s surface get considered by OcclusionTracker
// first, instead of |surface|'s. This exercises different code in
// LeaveToRenderTarget, as the target surface has already been seen when
// leaving |surface| later.
- typename Types::ContentLayerType* top_layer =
- this->CreateDrawingLayer(root,
- this->identity_matrix,
- gfx::PointF(40.f, 90.f),
- gfx::Size(50, 20),
- true);
+ TestContentLayerImpl* top_layer = this->CreateDrawingLayer(
+ root, this->identity_matrix, gfx::PointF(40.f, 90.f), gfx::Size(50, 20),
+ true);
this->CalcDrawEtc(root);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(top_layer, &occlusion);
@@ -837,12 +618,10 @@ class OcclusionTrackerTestVisitTargetTwoTimes
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestVisitTargetTwoTimes);
-template <class Types>
-class OcclusionTrackerTestSurfaceRotatedOffAxis
- : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestSurfaceRotatedOffAxis : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestSurfaceRotatedOffAxis(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform child_transform;
child_transform.Translate(250.0, 250.0);
@@ -852,21 +631,20 @@ class OcclusionTrackerTestSurfaceRotatedOffAxis
gfx::Transform layer_transform;
layer_transform.Translate(10.0, 10.0);
- typename Types::ContentLayerType* root = this->CreateRoot(
+ TestContentLayerImpl* root = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(1000, 1000));
- typename Types::ContentLayerType* parent = this->CreateDrawingLayer(
+ TestContentLayerImpl* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true);
- typename Types::LayerType* child = this->CreateSurface(
+ LayerImpl* child = this->CreateSurface(
parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500));
- typename Types::ContentLayerType* layer = this->CreateDrawingLayer(
+ TestContentLayerImpl* layer = this->CreateDrawingLayer(
child, layer_transform, gfx::PointF(), gfx::Size(500, 500), true);
this->CalcDrawEtc(root);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
gfx::Rect clipped_layer_in_child = MathUtil::MapEnclosingClippedRect(
- layer_transform, layer->visible_content_rect());
+ layer_transform, layer->visible_layer_rect());
this->VisitLayer(layer, &occlusion);
this->EnterContributingSurface(child, &occlusion);
@@ -888,46 +666,35 @@ class OcclusionTrackerTestSurfaceRotatedOffAxis
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceRotatedOffAxis);
-template <class Types>
class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestSurfaceWithTwoOpaqueChildren(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform child_transform;
child_transform.Translate(250.0, 250.0);
child_transform.Rotate(90.0);
child_transform.Translate(-250.0, -250.0);
- typename Types::ContentLayerType* root = this->CreateRoot(
+ TestContentLayerImpl* root = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(1000, 1000));
- typename Types::ContentLayerType* parent = this->CreateDrawingLayer(
+ TestContentLayerImpl* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true);
parent->SetMasksToBounds(true);
- typename Types::ContentLayerType* child =
- this->CreateDrawingSurface(parent,
- child_transform,
- gfx::PointF(30.f, 30.f),
- gfx::Size(500, 500),
- false);
+ TestContentLayerImpl* child = this->CreateDrawingSurface(
+ parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500),
+ false);
child->SetMasksToBounds(true);
- typename Types::ContentLayerType* layer1 =
- this->CreateDrawingLayer(child,
- this->identity_matrix,
- gfx::PointF(10.f, 10.f),
- gfx::Size(500, 500),
- true);
- typename Types::ContentLayerType* layer2 =
- this->CreateDrawingLayer(child,
- this->identity_matrix,
- gfx::PointF(10.f, 450.f),
- gfx::Size(500, 60),
- true);
+ TestContentLayerImpl* layer1 = this->CreateDrawingLayer(
+ child, this->identity_matrix, gfx::PointF(10.f, 10.f),
+ gfx::Size(500, 500), true);
+ TestContentLayerImpl* layer2 = this->CreateDrawingLayer(
+ child, this->identity_matrix, gfx::PointF(10.f, 450.f),
+ gfx::Size(500, 60), true);
this->CalcDrawEtc(root);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(layer2, &occlusion);
this->VisitLayer(layer1, &occlusion);
@@ -976,32 +743,27 @@ class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithTwoOpaqueChildren);
-template <class Types>
class OcclusionTrackerTestOverlappingSurfaceSiblings
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestOverlappingSurfaceSiblings(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
parent->SetMasksToBounds(true);
- typename Types::LayerType* child1 = this->CreateSurface(
+ LayerImpl* child1 = this->CreateSurface(
parent, this->identity_matrix, gfx::PointF(10.f, 0.f), gfx::Size());
- typename Types::LayerType* child2 = this->CreateSurface(
+ LayerImpl* child2 = this->CreateSurface(
parent, this->identity_matrix, gfx::PointF(30.f, 0.f), gfx::Size());
- typename Types::ContentLayerType* layer1 = this->CreateDrawingLayer(
+ TestContentLayerImpl* layer1 = this->CreateDrawingLayer(
child1, this->identity_matrix, gfx::PointF(), gfx::Size(40, 50), true);
- typename Types::ContentLayerType* layer2 =
- this->CreateDrawingLayer(child2,
- this->identity_matrix,
- gfx::PointF(10.f, 0.f),
- gfx::Size(40, 50),
- true);
+ TestContentLayerImpl* layer2 = this->CreateDrawingLayer(
+ child2, this->identity_matrix, gfx::PointF(10.f, 0.f),
+ gfx::Size(40, 50), true);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(layer2, &occlusion);
this->EnterContributingSurface(child2, &occlusion);
@@ -1035,13 +797,12 @@ class OcclusionTrackerTestOverlappingSurfaceSiblings
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOverlappingSurfaceSiblings);
-template <class Types>
class OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms(
bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform child1_transform;
child1_transform.Translate(250.0, 250.0);
@@ -1053,33 +814,23 @@ class OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms
child2_transform.Rotate(90.0);
child2_transform.Translate(-250.0, -250.0);
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
parent->SetMasksToBounds(true);
- typename Types::LayerType* child1 = this->CreateSurface(
+ LayerImpl* child1 = this->CreateSurface(
parent, child1_transform, gfx::PointF(30.f, 20.f), gfx::Size(10, 10));
- typename Types::LayerType* child2 =
- this->CreateDrawingSurface(parent,
- child2_transform,
- gfx::PointF(20.f, 40.f),
- gfx::Size(10, 10),
- false);
- typename Types::ContentLayerType* layer1 =
- this->CreateDrawingLayer(child1,
- this->identity_matrix,
- gfx::PointF(-10.f, -20.f),
- gfx::Size(510, 510),
- true);
- typename Types::ContentLayerType* layer2 =
- this->CreateDrawingLayer(child2,
- this->identity_matrix,
- gfx::PointF(-10.f, -10.f),
- gfx::Size(510, 510),
- true);
+ LayerImpl* child2 = this->CreateDrawingSurface(parent, child2_transform,
+ gfx::PointF(20.f, 40.f),
+ gfx::Size(10, 10), false);
+ TestContentLayerImpl* layer1 = this->CreateDrawingLayer(
+ child1, this->identity_matrix, gfx::PointF(-10.f, -20.f),
+ gfx::Size(510, 510), true);
+ TestContentLayerImpl* layer2 = this->CreateDrawingLayer(
+ child2, this->identity_matrix, gfx::PointF(-10.f, -10.f),
+ gfx::Size(510, 510), true);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(layer2, &occlusion);
this->EnterLayer(child2, &occlusion);
@@ -1143,58 +894,47 @@ class OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms
ALL_OCCLUSIONTRACKER_TEST(
OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms);
-template <class Types>
-class OcclusionTrackerTestFilters : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestFilters : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestFilters(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform layer_transform;
layer_transform.Translate(250.0, 250.0);
layer_transform.Rotate(90.0);
layer_transform.Translate(-250.0, -250.0);
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
parent->SetMasksToBounds(true);
- typename Types::ContentLayerType* blur_layer =
- this->CreateDrawingLayer(parent,
- layer_transform,
- gfx::PointF(30.f, 30.f),
- gfx::Size(500, 500),
- true);
- typename Types::ContentLayerType* opaque_layer =
- this->CreateDrawingLayer(parent,
- layer_transform,
- gfx::PointF(30.f, 30.f),
- gfx::Size(500, 500),
- true);
- typename Types::ContentLayerType* opacity_layer =
- this->CreateDrawingLayer(parent,
- layer_transform,
- gfx::PointF(30.f, 30.f),
- gfx::Size(500, 500),
- true);
-
- Types::SetForceRenderSurface(blur_layer, true);
+ TestContentLayerImpl* blur_layer = this->CreateDrawingLayer(
+ parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500),
+ true);
+ TestContentLayerImpl* opaque_layer = this->CreateDrawingLayer(
+ parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500),
+ true);
+ TestContentLayerImpl* opacity_layer = this->CreateDrawingLayer(
+ parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500),
+ true);
+
+ blur_layer->SetHasRenderSurface(true);
FilterOperations filters;
filters.Append(FilterOperation::CreateBlurFilter(10.f));
blur_layer->SetFilters(filters);
- Types::SetForceRenderSurface(opaque_layer, true);
+ opaque_layer->SetHasRenderSurface(true);
filters.Clear();
filters.Append(FilterOperation::CreateGrayscaleFilter(0.5f));
opaque_layer->SetFilters(filters);
- Types::SetForceRenderSurface(opacity_layer, true);
+ opacity_layer->SetHasRenderSurface(true);
filters.Clear();
filters.Append(FilterOperation::CreateOpacityFilter(0.5f));
opacity_layer->SetFilters(filters);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
// Opacity layer won't contribute to occlusion.
this->VisitLayer(opacity_layer, &occlusion);
@@ -1245,23 +985,20 @@ class OcclusionTrackerTestFilters : public OcclusionTrackerTest<Types> {
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestFilters);
-template <class Types>
-class OcclusionTrackerTestReplicaDoesOcclude
- : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestReplicaDoesOcclude : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestReplicaDoesOcclude(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(100, 200));
- typename Types::LayerType* surface = this->CreateDrawingSurface(
+ LayerImpl* surface = this->CreateDrawingSurface(
parent, this->identity_matrix, gfx::PointF(), gfx::Size(50, 50), true);
this->CreateReplicaLayer(
surface, this->identity_matrix, gfx::PointF(0.f, 50.f), gfx::Size());
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(surface, &occlusion);
@@ -1279,28 +1016,22 @@ class OcclusionTrackerTestReplicaDoesOcclude
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaDoesOcclude);
-template <class Types>
-class OcclusionTrackerTestReplicaWithClipping
- : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestReplicaWithClipping : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestReplicaWithClipping(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(100, 170));
parent->SetMasksToBounds(true);
- typename Types::LayerType* surface =
- this->CreateDrawingSurface(parent,
- this->identity_matrix,
- gfx::PointF(0.f, 100.f),
- gfx::Size(50, 50),
- true);
+ LayerImpl* surface = this->CreateDrawingSurface(
+ parent, this->identity_matrix, gfx::PointF(0.f, 100.f),
+ gfx::Size(50, 50), true);
this->CreateReplicaLayer(
surface, this->identity_matrix, gfx::PointF(0.f, 50.f), gfx::Size());
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(surface, &occlusion);
@@ -1322,27 +1053,22 @@ class OcclusionTrackerTestReplicaWithClipping
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithClipping);
-template <class Types>
-class OcclusionTrackerTestReplicaWithMask : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestReplicaWithMask : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestReplicaWithMask(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(100, 200));
- typename Types::LayerType* surface =
- this->CreateDrawingSurface(parent,
- this->identity_matrix,
- gfx::PointF(0.f, 100.f),
- gfx::Size(50, 50),
- true);
- typename Types::LayerType* replica = this->CreateReplicaLayer(
+ LayerImpl* surface = this->CreateDrawingSurface(
+ parent, this->identity_matrix, gfx::PointF(0.f, 100.f),
+ gfx::Size(50, 50), true);
+ LayerImpl* replica = this->CreateReplicaLayer(
surface, this->identity_matrix, gfx::PointF(50.f, 50.f), gfx::Size());
this->CreateMaskLayer(replica, gfx::Size(10, 10));
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(surface, &occlusion);
@@ -1361,25 +1087,20 @@ class OcclusionTrackerTestReplicaWithMask : public OcclusionTrackerTest<Types> {
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithMask);
-template <class Types>
class OcclusionTrackerTestOpaqueContentsRegionEmpty
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestOpaqueContentsRegionEmpty(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(300, 300));
- typename Types::ContentLayerType* layer =
- this->CreateDrawingSurface(parent,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(200, 200),
- false);
+ TestContentLayerImpl* layer =
+ this->CreateDrawingSurface(parent, this->identity_matrix, gfx::PointF(),
+ gfx::Size(200, 200), false);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->EnterLayer(layer, &occlusion);
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
@@ -1394,27 +1115,22 @@ class OcclusionTrackerTestOpaqueContentsRegionEmpty
}
};
-MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionEmpty);
+ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOpaqueContentsRegionEmpty);
-template <class Types>
class OcclusionTrackerTestOpaqueContentsRegionNonEmpty
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestOpaqueContentsRegionNonEmpty(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(300, 300));
- typename Types::ContentLayerType* layer =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(100.f, 100.f),
- gfx::Size(200, 200),
- false);
+ TestContentLayerImpl* layer = this->CreateDrawingLayer(
+ parent, this->identity_matrix, gfx::PointF(100.f, 100.f),
+ gfx::Size(200, 200), false);
this->CalcDrawEtc(parent);
{
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
layer->SetOpaqueContentsRect(gfx::Rect(0, 0, 100, 100));
this->ResetLayerIterator();
@@ -1425,8 +1141,7 @@ class OcclusionTrackerTestOpaqueContentsRegionNonEmpty
occlusion.occlusion_from_inside_target().ToString());
}
{
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
layer->SetOpaqueContentsRect(gfx::Rect(20, 20, 180, 180));
this->ResetLayerIterator();
@@ -1437,8 +1152,7 @@ class OcclusionTrackerTestOpaqueContentsRegionNonEmpty
occlusion.occlusion_from_inside_target().ToString());
}
{
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
layer->SetOpaqueContentsRect(gfx::Rect(150, 150, 100, 100));
this->ResetLayerIterator();
@@ -1451,67 +1165,14 @@ class OcclusionTrackerTestOpaqueContentsRegionNonEmpty
}
};
-MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionNonEmpty);
-
-template <class Types>
-class OcclusionTrackerTestUnsorted3dLayers
- : public OcclusionTrackerTest<Types> {
- protected:
- explicit OcclusionTrackerTestUnsorted3dLayers(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
- void RunMyTest() override {
- // Currently, The main thread layer iterator does not iterate over 3d items
- // in sorted order, because layer sorting is not performed on the main
- // thread. Because of this, the occlusion tracker cannot assume that a 3d
- // layer occludes other layers that have not yet been iterated over. For
- // now, the expected behavior is that a 3d layer simply does not add any
- // occlusion to the occlusion tracker.
-
- gfx::Transform translation_to_front;
- translation_to_front.Translate3d(0.0, 0.0, -10.0);
- gfx::Transform translation_to_back;
- translation_to_front.Translate3d(0.0, 0.0, -100.0);
-
- typename Types::ContentLayerType* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(300, 300));
- typename Types::ContentLayerType* child1 = this->CreateDrawingLayer(
- parent, translation_to_back, gfx::PointF(), gfx::Size(100, 100), true);
- typename Types::ContentLayerType* child2 =
- this->CreateDrawingLayer(parent,
- translation_to_front,
- gfx::PointF(50.f, 50.f),
- gfx::Size(100, 100),
- true);
- parent->SetShouldFlattenTransform(false);
- parent->Set3dSortingContextId(1);
- child1->Set3dSortingContextId(1);
- child2->Set3dSortingContextId(1);
-
- this->CalcDrawEtc(parent);
-
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(child2, &occlusion);
- EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
- EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
-
- this->VisitLayer(child1, &occlusion);
- EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
- EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
- }
-};
-
-// This test will have different layer ordering on the impl thread; the test
-// will only work on the main thread.
-MAIN_THREAD_TEST(OcclusionTrackerTestUnsorted3dLayers);
+ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOpaqueContentsRegionNonEmpty);
-template <class Types>
class OcclusionTrackerTestLayerBehindCameraDoesNotOcclude
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestLayerBehindCameraDoesNotOcclude(
bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform transform;
transform.Translate(50.0, 50.0);
@@ -1519,9 +1180,9 @@ class OcclusionTrackerTestLayerBehindCameraDoesNotOcclude
transform.Translate3d(0.0, 0.0, 110.0);
transform.Translate(-50.0, -50.0);
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
- typename Types::ContentLayerType* layer = this->CreateDrawingLayer(
+ TestContentLayerImpl* layer = this->CreateDrawingLayer(
parent, transform, gfx::PointF(), gfx::Size(100, 100), true);
parent->SetShouldFlattenTransform(false);
parent->Set3dSortingContextId(1);
@@ -1529,8 +1190,7 @@ class OcclusionTrackerTestLayerBehindCameraDoesNotOcclude
layer->Set3dSortingContextId(1);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
// The |layer| is entirely behind the camera and should not occlude.
this->VisitLayer(layer, &occlusion);
@@ -1540,394 +1200,30 @@ class OcclusionTrackerTestLayerBehindCameraDoesNotOcclude
}
};
-template <class Types>
-class OcclusionTrackerTestAnimationOpacity1OnMainThread
- : public OcclusionTrackerTest<Types> {
- protected:
- explicit OcclusionTrackerTestAnimationOpacity1OnMainThread(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
- void RunMyTest() override {
- // parent
- // +--layer
- // +--surface
- // | +--surface_child
- // | +--surface_child2
- // +--parent2
- // +--topmost
-
- typename Types::ContentLayerType* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(300, 300));
- typename Types::ContentLayerType* layer =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(300, 300),
- true);
- typename Types::ContentLayerType* surface =
- this->CreateDrawingSurface(parent,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(300, 300),
- true);
- typename Types::ContentLayerType* surface_child =
- this->CreateDrawingLayer(surface,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(200, 300),
- true);
- typename Types::ContentLayerType* surface_child2 =
- this->CreateDrawingLayer(surface,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(100, 300),
- true);
- typename Types::ContentLayerType* parent2 =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(300, 300),
- false);
- typename Types::ContentLayerType* topmost =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(250.f, 0.f),
- gfx::Size(50, 300),
- true);
-
- AddOpacityTransitionToController(
- layer->layer_animation_controller(), 10.0, 0.f, 1.f, false);
- AddOpacityTransitionToController(
- surface->layer_animation_controller(), 10.0, 0.f, 1.f, false);
- this->CalcDrawEtc(parent);
-
- EXPECT_TRUE(layer->draw_opacity_is_animating());
- EXPECT_FALSE(surface->draw_opacity_is_animating());
- EXPECT_TRUE(surface->render_surface()->draw_opacity_is_animating());
-
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
-
- this->VisitLayer(topmost, &occlusion);
- this->EnterLayer(parent2, &occlusion);
-
- // This occlusion will affect all surfaces.
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
- EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
-
- this->LeaveLayer(parent2, &occlusion);
- this->VisitLayer(surface_child2, &occlusion);
- this->EnterLayer(surface_child, &occlusion);
- EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
- occlusion.occlusion_from_outside_target().ToString());
- EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
-
- this->LeaveLayer(surface_child, &occlusion);
- this->EnterLayer(surface, &occlusion);
- EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
- occlusion.occlusion_from_outside_target().ToString());
- EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
-
- this->LeaveLayer(surface, &occlusion);
- this->EnterContributingSurface(surface, &occlusion);
- // Occlusion within the surface is lost when leaving the animating surface.
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_inside_target().ToString());
-
- this->LeaveContributingSurface(surface, &occlusion);
- // Occlusion from outside the animating surface still exists.
- EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
-
- this->VisitLayer(layer, &occlusion);
- this->EnterLayer(parent, &occlusion);
-
- // Occlusion is not added for the animating |layer|.
- EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
- }
-};
-
-MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity1OnMainThread);
-
-template <class Types>
-class OcclusionTrackerTestAnimationOpacity0OnMainThread
- : public OcclusionTrackerTest<Types> {
- protected:
- explicit OcclusionTrackerTestAnimationOpacity0OnMainThread(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
- void RunMyTest() override {
- typename Types::ContentLayerType* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(300, 300));
- typename Types::ContentLayerType* layer =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(300, 300),
- true);
- typename Types::ContentLayerType* surface =
- this->CreateDrawingSurface(parent,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(300, 300),
- true);
- typename Types::ContentLayerType* surface_child =
- this->CreateDrawingLayer(surface,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(200, 300),
- true);
- typename Types::ContentLayerType* surface_child2 =
- this->CreateDrawingLayer(surface,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(100, 300),
- true);
- typename Types::ContentLayerType* parent2 =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(300, 300),
- false);
- typename Types::ContentLayerType* topmost =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(250.f, 0.f),
- gfx::Size(50, 300),
- true);
-
- AddOpacityTransitionToController(
- layer->layer_animation_controller(), 10.0, 1.f, 0.f, false);
- AddOpacityTransitionToController(
- surface->layer_animation_controller(), 10.0, 1.f, 0.f, false);
- this->CalcDrawEtc(parent);
-
- EXPECT_TRUE(layer->draw_opacity_is_animating());
- EXPECT_FALSE(surface->draw_opacity_is_animating());
- EXPECT_TRUE(surface->render_surface()->draw_opacity_is_animating());
-
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
-
- this->VisitLayer(topmost, &occlusion);
- this->EnterLayer(parent2, &occlusion);
- // This occlusion will affect all surfaces.
- EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
-
- this->LeaveLayer(parent2, &occlusion);
- this->VisitLayer(surface_child2, &occlusion);
- this->EnterLayer(surface_child, &occlusion);
- EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
- EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
- occlusion.occlusion_from_outside_target().ToString());
-
- this->LeaveLayer(surface_child, &occlusion);
- this->EnterLayer(surface, &occlusion);
- EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
- EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
- occlusion.occlusion_from_outside_target().ToString());
-
- this->LeaveLayer(surface, &occlusion);
- this->EnterContributingSurface(surface, &occlusion);
- // Occlusion within the surface is lost when leaving the animating surface.
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_inside_target().ToString());
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
-
- this->LeaveContributingSurface(surface, &occlusion);
- // Occlusion from outside the animating surface still exists.
- EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
-
- this->VisitLayer(layer, &occlusion);
- this->EnterLayer(parent, &occlusion);
-
- // Occlusion is not added for the animating |layer|.
- EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
- }
-};
-
-MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity0OnMainThread);
-
-template <class Types>
-class OcclusionTrackerTestAnimationTranslateOnMainThread
- : public OcclusionTrackerTest<Types> {
- protected:
- explicit OcclusionTrackerTestAnimationTranslateOnMainThread(
- bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
- void RunMyTest() override {
- typename Types::ContentLayerType* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(300, 300));
- typename Types::ContentLayerType* layer =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(300, 300),
- true);
- typename Types::ContentLayerType* surface =
- this->CreateDrawingSurface(parent,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(300, 300),
- true);
- typename Types::ContentLayerType* surface_child =
- this->CreateDrawingLayer(surface,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(200, 300),
- true);
- typename Types::ContentLayerType* surface_child2 =
- this->CreateDrawingLayer(surface,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(100, 300),
- true);
- typename Types::ContentLayerType* surface2 = this->CreateDrawingSurface(
- parent, this->identity_matrix, gfx::PointF(), gfx::Size(50, 300), true);
-
- AddAnimatedTransformToController(
- layer->layer_animation_controller(), 10.0, 30, 0);
- AddAnimatedTransformToController(
- surface->layer_animation_controller(), 10.0, 30, 0);
- AddAnimatedTransformToController(
- surface_child->layer_animation_controller(), 10.0, 30, 0);
- this->CalcDrawEtc(parent);
-
- EXPECT_TRUE(layer->draw_transform_is_animating());
- EXPECT_TRUE(layer->screen_space_transform_is_animating());
- EXPECT_TRUE(
- surface->render_surface()->target_surface_transforms_are_animating());
- EXPECT_TRUE(
- surface->render_surface()->screen_space_transforms_are_animating());
- // The surface owning layer doesn't animate against its own surface.
- EXPECT_FALSE(surface->draw_transform_is_animating());
- EXPECT_TRUE(surface->screen_space_transform_is_animating());
- EXPECT_TRUE(surface_child->draw_transform_is_animating());
- EXPECT_TRUE(surface_child->screen_space_transform_is_animating());
-
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
-
- this->VisitLayer(surface2, &occlusion);
- this->EnterContributingSurface(surface2, &occlusion);
-
- EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
-
- this->LeaveContributingSurface(surface2, &occlusion);
- this->EnterLayer(surface_child2, &occlusion);
- // surface_child2 is moving in screen space but not relative to its target,
- // so occlusion should happen in its target space only. It also means that
- // things occluding from outside the target (e.g. surface2) cannot occlude
- // this layer.
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_inside_target().ToString());
-
- this->LeaveLayer(surface_child2, &occlusion);
- this->EnterLayer(surface_child, &occlusion);
- // surface_child2 added to the occlusion since it is not moving relative
- // to its target.
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
- EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
-
- this->LeaveLayer(surface_child, &occlusion);
- // surface_child is moving relative to its target, so it does not add
- // occlusion.
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
- EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
-
- this->EnterLayer(surface, &occlusion);
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
- EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
-
- this->LeaveLayer(surface, &occlusion);
- // The surface's owning layer is moving in screen space but not relative to
- // its target, so it adds to the occlusion.
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
- EXPECT_EQ(gfx::Rect(0, 0, 300, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
-
- this->EnterContributingSurface(surface, &occlusion);
- this->LeaveContributingSurface(surface, &occlusion);
- // The |surface| is moving in the screen and in its target, so all occlusion
- // within the surface is lost when leaving it. Only the |surface2| occlusion
- // is left.
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
- EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
-
- this->VisitLayer(layer, &occlusion);
- // The |layer| is animating in the screen and in its target, so no occlusion
- // is added.
- EXPECT_EQ(gfx::Rect().ToString(),
- occlusion.occlusion_from_outside_target().ToString());
- EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(),
- occlusion.occlusion_from_inside_target().ToString());
- }
-};
-
-MAIN_THREAD_TEST(OcclusionTrackerTestAnimationTranslateOnMainThread);
-
-template <class Types>
class OcclusionTrackerTestSurfaceOcclusionTranslatesToParent
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestSurfaceOcclusionTranslatesToParent(
bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform surface_transform;
surface_transform.Translate(300.0, 300.0);
surface_transform.Scale(2.0, 2.0);
surface_transform.Translate(-150.0, -150.0);
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(500, 500));
- typename Types::ContentLayerType* surface = this->CreateDrawingSurface(
+ TestContentLayerImpl* surface = this->CreateDrawingSurface(
parent, surface_transform, gfx::PointF(), gfx::Size(300, 300), false);
- typename Types::ContentLayerType* surface2 =
- this->CreateDrawingSurface(parent,
- this->identity_matrix,
- gfx::PointF(50.f, 50.f),
- gfx::Size(300, 300),
- false);
+ TestContentLayerImpl* surface2 = this->CreateDrawingSurface(
+ parent, this->identity_matrix, gfx::PointF(50.f, 50.f),
+ gfx::Size(300, 300), false);
surface->SetOpaqueContentsRect(gfx::Rect(0, 0, 200, 200));
surface2->SetOpaqueContentsRect(gfx::Rect(0, 0, 200, 200));
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(surface2, &occlusion);
this->VisitContributingSurface(surface2, &occlusion);
@@ -1951,31 +1247,26 @@ class OcclusionTrackerTestSurfaceOcclusionTranslatesToParent
}
};
-MAIN_AND_IMPL_THREAD_TEST(
+ALL_OCCLUSIONTRACKER_TEST(
OcclusionTrackerTestSurfaceOcclusionTranslatesToParent);
-template <class Types>
class OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping(
bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(300, 300));
parent->SetMasksToBounds(true);
- typename Types::ContentLayerType* surface =
- this->CreateDrawingSurface(parent,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(500, 300),
- false);
+ TestContentLayerImpl* surface =
+ this->CreateDrawingSurface(parent, this->identity_matrix, gfx::PointF(),
+ gfx::Size(500, 300), false);
surface->SetOpaqueContentsRect(gfx::Rect(0, 0, 400, 200));
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(surface, &occlusion);
this->VisitContributingSurface(surface, &occlusion);
@@ -1987,38 +1278,30 @@ class OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping
}
};
-MAIN_AND_IMPL_THREAD_TEST(
+ALL_OCCLUSIONTRACKER_TEST(
OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping);
-template <class Types>
class OcclusionTrackerTestSurfaceWithReplicaUnoccluded
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestSurfaceWithReplicaUnoccluded(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(100, 200));
- typename Types::LayerType* surface =
- this->CreateDrawingSurface(parent,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(100, 100),
- true);
+ LayerImpl* surface =
+ this->CreateDrawingSurface(parent, this->identity_matrix, gfx::PointF(),
+ gfx::Size(100, 100), true);
this->CreateReplicaLayer(surface,
this->identity_matrix,
gfx::PointF(0.f, 100.f),
gfx::Size(100, 100));
- typename Types::LayerType* topmost =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(100, 110),
- true);
+ LayerImpl* topmost =
+ this->CreateDrawingLayer(parent, this->identity_matrix, gfx::PointF(),
+ gfx::Size(100, 110), true);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
// |topmost| occludes the surface, but not the entire surface's replica.
this->VisitLayer(topmost, &occlusion);
@@ -2050,36 +1333,27 @@ class OcclusionTrackerTestSurfaceWithReplicaUnoccluded
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithReplicaUnoccluded);
-template <class Types>
-class OcclusionTrackerTestSurfaceChildOfSurface
- : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestSurfaceChildOfSurface : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestSurfaceChildOfSurface(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
// This test verifies that the surface cliprect does not end up empty and
// clip away the entire unoccluded rect.
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(100, 200));
- typename Types::LayerType* surface =
- this->CreateDrawingSurface(parent,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(100, 100),
- false);
- typename Types::LayerType* surface_child =
- this->CreateDrawingSurface(surface,
- this->identity_matrix,
- gfx::PointF(0.f, 10.f),
- gfx::Size(100, 50),
- true);
- typename Types::LayerType* topmost = this->CreateDrawingLayer(
+ LayerImpl* surface =
+ this->CreateDrawingSurface(parent, this->identity_matrix, gfx::PointF(),
+ gfx::Size(100, 100), false);
+ LayerImpl* surface_child = this->CreateDrawingSurface(
+ surface, this->identity_matrix, gfx::PointF(0.f, 10.f),
+ gfx::Size(100, 50), true);
+ LayerImpl* topmost = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(), gfx::Size(100, 50), true);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(-100, -100, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(-100, -100, 1000, 1000));
// |topmost| occludes everything partially so we know occlusion is happening
// at all.
@@ -2147,13 +1421,12 @@ class OcclusionTrackerTestSurfaceChildOfSurface
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface);
-template <class Types>
class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter(
bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform scale_by_half;
scale_by_half.Scale(0.5, 0.5);
@@ -2181,15 +1454,12 @@ class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter
// which are above it in the z-order in various configurations. The
// surface is scaled to test that the pixel moving is done in the target
// space, where the background filter is applied.
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
- typename Types::LayerType* filtered_surface =
- this->CreateDrawingLayer(parent,
- scale_by_half,
- gfx::PointF(50.f, 50.f),
- gfx::Size(100, 100),
- false);
- Types::SetForceRenderSurface(filtered_surface, true);
+ LayerImpl* filtered_surface = this->CreateDrawingLayer(
+ parent, scale_by_half, gfx::PointF(50.f, 50.f), gfx::Size(100, 100),
+ false);
+ filtered_surface->SetHasRenderSurface(true);
filtered_surface->SetBackgroundFilters(filters);
gfx::Rect occlusion_rect;
switch (i) {
@@ -2207,16 +1477,12 @@ class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter
break;
}
- typename Types::LayerType* occluding_layer =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- occlusion_rect.origin(),
- occlusion_rect.size(),
- true);
+ LayerImpl* occluding_layer = this->CreateDrawingLayer(
+ parent, this->identity_matrix, occlusion_rect.origin(),
+ occlusion_rect.size(), true);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 200, 200));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200));
// This layer occludes pixels directly beside the filtered_surface.
// Because filtered surface blends pixels in a radius, it will need to see
@@ -2271,38 +1537,34 @@ class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter
ALL_OCCLUSIONTRACKER_TEST(
OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter);
-template <class Types>
class OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice(
bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform scale_by_half;
scale_by_half.Scale(0.5, 0.5);
// Makes two surfaces that completely cover |parent|. The occlusion both
// above and below the filters will be reduced by each of them.
- typename Types::ContentLayerType* root = this->CreateRoot(
+ TestContentLayerImpl* root = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(75, 75));
- typename Types::LayerType* parent = this->CreateSurface(
- root, scale_by_half, gfx::PointF(), gfx::Size(150, 150));
+ LayerImpl* parent = this->CreateSurface(root, scale_by_half, gfx::PointF(),
+ gfx::Size(150, 150));
parent->SetMasksToBounds(true);
- typename Types::LayerType* filtered_surface1 = this->CreateDrawingLayer(
+ LayerImpl* filtered_surface1 = this->CreateDrawingLayer(
parent, scale_by_half, gfx::PointF(), gfx::Size(300, 300), false);
- typename Types::LayerType* filtered_surface2 = this->CreateDrawingLayer(
+ LayerImpl* filtered_surface2 = this->CreateDrawingLayer(
parent, scale_by_half, gfx::PointF(), gfx::Size(300, 300), false);
- typename Types::LayerType* occluding_layer_above =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(100.f, 100.f),
- gfx::Size(50, 50),
- true);
+ LayerImpl* occluding_layer_above = this->CreateDrawingLayer(
+ parent, this->identity_matrix, gfx::PointF(100.f, 100.f),
+ gfx::Size(50, 50), true);
// Filters make the layers own surfaces.
- Types::SetForceRenderSurface(filtered_surface1, true);
- Types::SetForceRenderSurface(filtered_surface2, true);
+ filtered_surface1->SetHasRenderSurface(true);
+ filtered_surface2->SetHasRenderSurface(true);
FilterOperations filters;
filters.Append(FilterOperation::CreateBlurFilter(1.f));
filtered_surface1->SetBackgroundFilters(filters);
@@ -2315,8 +1577,7 @@ class OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice
this->CalcDrawEtc(root);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(occluding_layer_above, &occlusion);
EXPECT_EQ(gfx::Rect().ToString(),
@@ -2348,13 +1609,12 @@ class OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice
ALL_OCCLUSIONTRACKER_TEST(
OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice);
-template <class Types>
class OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter(
bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform scale_by_half;
scale_by_half.Scale(0.5, 0.5);
@@ -2363,41 +1623,31 @@ class OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter
// centered below each. The surface is scaled to test that the pixel moving
// is done in the target space, where the background filter is applied, but
// the surface appears at 50, 50 and the replica at 200, 50.
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(300, 150));
- typename Types::LayerType* behind_surface_layer =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(60.f, 60.f),
- gfx::Size(30, 30),
- true);
- typename Types::LayerType* behind_replica_layer =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(210.f, 60.f),
- gfx::Size(30, 30),
- true);
- typename Types::LayerType* filtered_surface =
- this->CreateDrawingLayer(parent,
- scale_by_half,
- gfx::PointF(50.f, 50.f),
- gfx::Size(100, 100),
- false);
+ LayerImpl* behind_surface_layer = this->CreateDrawingLayer(
+ parent, this->identity_matrix, gfx::PointF(60.f, 60.f),
+ gfx::Size(30, 30), true);
+ LayerImpl* behind_replica_layer = this->CreateDrawingLayer(
+ parent, this->identity_matrix, gfx::PointF(210.f, 60.f),
+ gfx::Size(30, 30), true);
+ LayerImpl* filtered_surface =
+ this->CreateDrawingLayer(parent, scale_by_half, gfx::PointF(50.f, 50.f),
+ gfx::Size(100, 100), false);
this->CreateReplicaLayer(filtered_surface,
this->identity_matrix,
gfx::PointF(300.f, 0.f),
gfx::Size());
// Filters make the layer own a surface.
- Types::SetForceRenderSurface(filtered_surface, true);
+ filtered_surface->SetHasRenderSurface(true);
FilterOperations filters;
filters.Append(FilterOperation::CreateBlurFilter(3.f));
filtered_surface->SetBackgroundFilters(filters);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
// The surface has a background blur, so it blurs non-opaque pixels below
// it.
@@ -2433,13 +1683,12 @@ class OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter
ALL_OCCLUSIONTRACKER_TEST(
OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter);
-template <class Types>
class OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded(
bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform scale_by_half;
scale_by_half.Scale(0.5, 0.5);
@@ -2448,31 +1697,24 @@ class OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded
// layer which is above it in the z-order. The surface is
// scaled to test that the pixel moving is done in the target space, where
// the background filter is applied, but the surface appears at 50, 50.
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(200, 150));
- typename Types::LayerType* filtered_surface =
- this->CreateDrawingLayer(parent,
- scale_by_half,
- gfx::PointF(50.f, 50.f),
- gfx::Size(100, 100),
- false);
- typename Types::LayerType* occluding_layer =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(50.f, 50.f),
- gfx::Size(50, 50),
- true);
+ LayerImpl* filtered_surface =
+ this->CreateDrawingLayer(parent, scale_by_half, gfx::PointF(50.f, 50.f),
+ gfx::Size(100, 100), false);
+ LayerImpl* occluding_layer = this->CreateDrawingLayer(
+ parent, this->identity_matrix, gfx::PointF(50.f, 50.f),
+ gfx::Size(50, 50), true);
// Filters make the layer own a surface.
- Types::SetForceRenderSurface(filtered_surface, true);
+ filtered_surface->SetHasRenderSurface(true);
FilterOperations filters;
filters.Append(FilterOperation::CreateBlurFilter(3.f));
filtered_surface->SetBackgroundFilters(filters);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(occluding_layer, &occlusion);
@@ -2506,14 +1748,12 @@ class OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded
ALL_OCCLUSIONTRACKER_TEST(
OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded);
-template <class Types>
-class OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded
- : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestReduceOcclusionWhenBkgdFilterIsPartiallyOccluded
+ : public OcclusionTrackerTest {
protected:
- explicit
- OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded(
+ explicit OcclusionTrackerTestReduceOcclusionWhenBkgdFilterIsPartiallyOccluded(
bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform scale_by_half;
scale_by_half.Scale(0.5, 0.5);
@@ -2523,45 +1763,30 @@ class OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded
// scaled to test that the pixel moving is done in the target space, where
// the background filter is applied, but the surface appears at 50, 50 and
// the replica at 200, 50.
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(300, 150));
- typename Types::LayerType* filtered_surface =
- this->CreateDrawingLayer(parent,
- scale_by_half,
- gfx::PointF(50.f, 50.f),
- gfx::Size(100, 100),
- false);
+ LayerImpl* filtered_surface =
+ this->CreateDrawingLayer(parent, scale_by_half, gfx::PointF(50.f, 50.f),
+ gfx::Size(100, 100), false);
this->CreateReplicaLayer(filtered_surface,
this->identity_matrix,
gfx::PointF(300.f, 0.f),
gfx::Size());
- typename Types::LayerType* above_surface_layer =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(70.f, 50.f),
- gfx::Size(30, 50),
- true);
- typename Types::LayerType* above_replica_layer =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(200.f, 50.f),
- gfx::Size(30, 50),
- true);
- typename Types::LayerType* beside_surface_layer =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(90.f, 40.f),
- gfx::Size(10, 10),
- true);
- typename Types::LayerType* beside_replica_layer =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(200.f, 40.f),
- gfx::Size(10, 10),
- true);
+ LayerImpl* above_surface_layer = this->CreateDrawingLayer(
+ parent, this->identity_matrix, gfx::PointF(70.f, 50.f),
+ gfx::Size(30, 50), true);
+ LayerImpl* above_replica_layer = this->CreateDrawingLayer(
+ parent, this->identity_matrix, gfx::PointF(200.f, 50.f),
+ gfx::Size(30, 50), true);
+ LayerImpl* beside_surface_layer = this->CreateDrawingLayer(
+ parent, this->identity_matrix, gfx::PointF(90.f, 40.f),
+ gfx::Size(10, 10), true);
+ LayerImpl* beside_replica_layer = this->CreateDrawingLayer(
+ parent, this->identity_matrix, gfx::PointF(200.f, 40.f),
+ gfx::Size(10, 10), true);
// Filters make the layer own a surface.
- Types::SetForceRenderSurface(filtered_surface, true);
+ filtered_surface->SetHasRenderSurface(true);
FilterOperations filters;
filters.Append(FilterOperation::CreateBlurFilter(3.f));
filtered_surface->SetBackgroundFilters(filters);
@@ -2573,8 +1798,7 @@ class OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(beside_replica_layer, &occlusion);
this->VisitLayer(beside_surface_layer, &occlusion);
@@ -2619,32 +1843,30 @@ class OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded
};
ALL_OCCLUSIONTRACKER_TEST(
- OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded);
+ OcclusionTrackerTestReduceOcclusionWhenBkgdFilterIsPartiallyOccluded);
-template <class Types>
class OcclusionTrackerTestBlendModeDoesNotOcclude
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestBlendModeDoesNotOcclude(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
- typename Types::LayerType* blend_mode_layer = this->CreateDrawingLayer(
+ LayerImpl* blend_mode_layer = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(0.f, 0.f),
gfx::Size(100, 100), true);
- typename Types::LayerType* top_layer = this->CreateDrawingLayer(
+ LayerImpl* top_layer = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(10.f, 12.f),
gfx::Size(20, 22), true);
// Blend mode makes the layer own a surface.
- Types::SetForceRenderSurface(blend_mode_layer, true);
+ blend_mode_layer->SetHasRenderSurface(true);
blend_mode_layer->SetBlendMode(SkXfermode::kMultiply_Mode);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(top_layer, &occlusion);
// |top_layer| occludes.
@@ -2668,30 +1890,24 @@ class OcclusionTrackerTestBlendModeDoesNotOcclude
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestBlendModeDoesNotOcclude);
-template <class Types>
-class OcclusionTrackerTestMinimumTrackingSize
- : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestMinimumTrackingSize : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestMinimumTrackingSize(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Size tracking_size(100, 100);
gfx::Size below_tracking_size(99, 99);
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(400, 400));
- typename Types::LayerType* large = this->CreateDrawingLayer(
+ LayerImpl* large = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(), tracking_size, true);
- typename Types::LayerType* small =
- this->CreateDrawingLayer(parent,
- this->identity_matrix,
- gfx::PointF(),
- below_tracking_size,
- true);
+ LayerImpl* small =
+ this->CreateDrawingLayer(parent, this->identity_matrix, gfx::PointF(),
+ below_tracking_size, true);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
occlusion.set_minimum_tracking_size(tracking_size);
// The small layer is not tracked because it is too small.
@@ -2714,31 +1930,27 @@ class OcclusionTrackerTestMinimumTrackingSize
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestMinimumTrackingSize);
-template <class Types>
-class OcclusionTrackerTestScaledLayerIsClipped
- : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestScaledLayerIsClipped : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestScaledLayerIsClipped(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform scale_transform;
scale_transform.Scale(512.0, 512.0);
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(400, 400));
- typename Types::LayerType* clip = this->CreateLayer(parent,
- this->identity_matrix,
- gfx::PointF(10.f, 10.f),
- gfx::Size(50, 50));
+ LayerImpl* clip =
+ this->CreateLayer(parent, this->identity_matrix,
+ gfx::PointF(10.f, 10.f), gfx::Size(50, 50));
clip->SetMasksToBounds(true);
- typename Types::LayerType* scale = this->CreateLayer(
- clip, scale_transform, gfx::PointF(), gfx::Size(1, 1));
- typename Types::LayerType* scaled = this->CreateDrawingLayer(
+ LayerImpl* scale = this->CreateLayer(clip, scale_transform, gfx::PointF(),
+ gfx::Size(1, 1));
+ LayerImpl* scaled = this->CreateDrawingLayer(
scale, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500), true);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(scaled, &occlusion);
@@ -2751,33 +1963,30 @@ class OcclusionTrackerTestScaledLayerIsClipped
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledLayerIsClipped)
-template <class Types>
class OcclusionTrackerTestScaledLayerInSurfaceIsClipped
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestScaledLayerInSurfaceIsClipped(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform scale_transform;
scale_transform.Scale(512.0, 512.0);
- typename Types::ContentLayerType* parent = this->CreateRoot(
+ TestContentLayerImpl* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(400, 400));
- typename Types::LayerType* clip = this->CreateLayer(parent,
- this->identity_matrix,
- gfx::PointF(10.f, 10.f),
- gfx::Size(50, 50));
+ LayerImpl* clip =
+ this->CreateLayer(parent, this->identity_matrix,
+ gfx::PointF(10.f, 10.f), gfx::Size(50, 50));
clip->SetMasksToBounds(true);
- typename Types::LayerType* surface = this->CreateDrawingSurface(
+ LayerImpl* surface = this->CreateDrawingSurface(
clip, this->identity_matrix, gfx::PointF(), gfx::Size(400, 30), false);
- typename Types::LayerType* scale = this->CreateLayer(
- surface, scale_transform, gfx::PointF(), gfx::Size(1, 1));
- typename Types::LayerType* scaled = this->CreateDrawingLayer(
+ LayerImpl* scale = this->CreateLayer(surface, scale_transform,
+ gfx::PointF(), gfx::Size(1, 1));
+ LayerImpl* scaled = this->CreateDrawingLayer(
scale, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500), true);
this->CalcDrawEtc(parent);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(scaled, &occlusion);
this->VisitLayer(surface, &occlusion);
@@ -2792,35 +2001,26 @@ class OcclusionTrackerTestScaledLayerInSurfaceIsClipped
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledLayerInSurfaceIsClipped)
-template <class Types>
-class OcclusionTrackerTestCopyRequestDoesOcclude
- : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestCopyRequestDoesOcclude : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestCopyRequestDoesOcclude(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- typename Types::ContentLayerType* root = this->CreateRoot(
+ TestContentLayerImpl* root = this->CreateRoot(
this->identity_matrix, gfx::Point(), gfx::Size(400, 400));
- typename Types::ContentLayerType* parent = this->CreateDrawingLayer(
+ TestContentLayerImpl* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::Point(), gfx::Size(400, 400), true);
- typename Types::LayerType* copy = this->CreateLayer(parent,
- this->identity_matrix,
- gfx::Point(100, 0),
- gfx::Size(200, 400));
+ LayerImpl* copy = this->CreateLayer(
+ parent, this->identity_matrix, gfx::Point(100, 0), gfx::Size(200, 400));
this->AddCopyRequest(copy);
- typename Types::LayerType* copy_child = this->CreateDrawingLayer(
- copy,
- this->identity_matrix,
- gfx::PointF(),
- gfx::Size(200, 400),
- true);
- typename Types::LayerType* top_layer =
+ LayerImpl* copy_child = this->CreateDrawingLayer(
+ copy, this->identity_matrix, gfx::PointF(), gfx::Size(200, 400), true);
+ LayerImpl* top_layer =
this->CreateDrawingLayer(root, this->identity_matrix,
gfx::PointF(50, 0), gfx::Size(50, 400), true);
this->CalcDrawEtc(root);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(top_layer, &occlusion);
EXPECT_EQ(gfx::Rect().ToString(),
@@ -2848,24 +2048,23 @@ class OcclusionTrackerTestCopyRequestDoesOcclude
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestCopyRequestDoesOcclude)
-template <class Types>
class OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude
- : public OcclusionTrackerTest<Types> {
+ : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude(
bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- typename Types::ContentLayerType* root = this->CreateRoot(
+ TestContentLayerImpl* root = this->CreateRoot(
this->identity_matrix, gfx::Point(), gfx::Size(400, 400));
- typename Types::ContentLayerType* parent = this->CreateDrawingLayer(
+ TestContentLayerImpl* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::Point(), gfx::Size(400, 400), true);
- typename Types::LayerType* hide = this->CreateLayer(
- parent, this->identity_matrix, gfx::Point(), gfx::Size());
- typename Types::LayerType* copy = this->CreateLayer(
+ LayerImpl* hide = this->CreateLayer(parent, this->identity_matrix,
+ gfx::Point(), gfx::Size());
+ LayerImpl* copy = this->CreateLayer(
hide, this->identity_matrix, gfx::Point(100, 0), gfx::Size(200, 400));
this->AddCopyRequest(copy);
- typename Types::LayerType* copy_child = this->CreateDrawingLayer(
+ LayerImpl* copy_child = this->CreateDrawingLayer(
copy, this->identity_matrix, gfx::PointF(), gfx::Size(200, 400), true);
// The |copy| layer is hidden but since it is being copied, it will be
@@ -2874,8 +2073,7 @@ class OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude
this->CalcDrawEtc(root);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 1000, 1000));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
this->VisitLayer(copy_child, &occlusion);
EXPECT_EQ(gfx::Rect().ToString(),
@@ -2896,26 +2094,24 @@ class OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude)
-template <class Types>
-class OcclusionTrackerTestOccludedLayer : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestOccludedLayer : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestOccludedLayer(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform translate;
translate.Translate(10.0, 20.0);
- typename Types::ContentLayerType* root = this->CreateRoot(
+ TestContentLayerImpl* root = this->CreateRoot(
this->identity_matrix, gfx::Point(), gfx::Size(200, 200));
- typename Types::LayerType* surface = this->CreateSurface(
- root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200));
- typename Types::LayerType* layer = this->CreateDrawingLayer(
+ LayerImpl* surface = this->CreateSurface(root, this->identity_matrix,
+ gfx::Point(), gfx::Size(200, 200));
+ LayerImpl* layer = this->CreateDrawingLayer(
surface, translate, gfx::Point(), gfx::Size(200, 200), false);
- typename Types::ContentLayerType* outside_layer = this->CreateDrawingLayer(
+ TestContentLayerImpl* outside_layer = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200), false);
this->CalcDrawEtc(root);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 200, 200));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200));
this->VisitLayer(outside_layer, &occlusion);
this->EnterLayer(layer, &occlusion);
@@ -2986,27 +2182,24 @@ class OcclusionTrackerTestOccludedLayer : public OcclusionTrackerTest<Types> {
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOccludedLayer)
-template <class Types>
-class OcclusionTrackerTestUnoccludedLayerQuery
- : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestUnoccludedLayerQuery : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestUnoccludedLayerQuery(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform translate;
translate.Translate(10.0, 20.0);
- typename Types::ContentLayerType* root = this->CreateRoot(
+ TestContentLayerImpl* root = this->CreateRoot(
this->identity_matrix, gfx::Point(), gfx::Size(200, 200));
- typename Types::LayerType* surface = this->CreateSurface(
- root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200));
- typename Types::LayerType* layer = this->CreateDrawingLayer(
+ LayerImpl* surface = this->CreateSurface(root, this->identity_matrix,
+ gfx::Point(), gfx::Size(200, 200));
+ LayerImpl* layer = this->CreateDrawingLayer(
surface, translate, gfx::Point(), gfx::Size(200, 200), false);
- typename Types::ContentLayerType* outside_layer = this->CreateDrawingLayer(
+ TestContentLayerImpl* outside_layer = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200), false);
this->CalcDrawEtc(root);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 200, 200));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200));
this->VisitLayer(outside_layer, &occlusion);
this->EnterLayer(layer, &occlusion);
@@ -3152,31 +2345,25 @@ class OcclusionTrackerTestUnoccludedLayerQuery
ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedLayerQuery)
-template <class Types>
-class OcclusionTrackerTestUnoccludedSurfaceQuery
- : public OcclusionTrackerTest<Types> {
+class OcclusionTrackerTestUnoccludedSurfaceQuery : public OcclusionTrackerTest {
protected:
explicit OcclusionTrackerTestUnoccludedSurfaceQuery(bool opaque_layers)
- : OcclusionTrackerTest<Types>(opaque_layers) {}
+ : OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
gfx::Transform translate;
translate.Translate(10.0, 20.0);
- typename Types::ContentLayerType* root = this->CreateRoot(
+ TestContentLayerImpl* root = this->CreateRoot(
this->identity_matrix, gfx::Point(), gfx::Size(200, 200));
- typename Types::LayerType* surface =
+ LayerImpl* surface =
this->CreateSurface(root, translate, gfx::Point(), gfx::Size(200, 200));
- typename Types::LayerType* layer =
- this->CreateDrawingLayer(surface,
- this->identity_matrix,
- gfx::Point(),
- gfx::Size(200, 200),
- false);
- typename Types::ContentLayerType* outside_layer = this->CreateDrawingLayer(
+ LayerImpl* layer =
+ this->CreateDrawingLayer(surface, this->identity_matrix, gfx::Point(),
+ gfx::Size(200, 200), false);
+ TestContentLayerImpl* outside_layer = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200), false);
this->CalcDrawEtc(root);
- TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
- gfx::Rect(0, 0, 200, 200));
+ TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200));
this->VisitLayer(outside_layer, &occlusion);
this->VisitLayer(layer, &occlusion);
this->EnterContributingSurface(surface, &occlusion);
diff --git a/chromium/cc/trees/property_tree.cc b/chromium/cc/trees/property_tree.cc
index d369ad91060..05fa3947f0c 100644
--- a/chromium/cc/trees/property_tree.cc
+++ b/chromium/cc/trees/property_tree.cc
@@ -23,6 +23,12 @@ template <typename T>
PropertyTree<T>::~PropertyTree() {
}
+TransformTree::TransformTree() : source_to_parent_updates_allowed_(true) {
+}
+
+TransformTree::~TransformTree() {
+}
+
template <typename T>
int PropertyTree<T>::Insert(const T& tree_node, int parent_id) {
DCHECK_GT(nodes_.size(), 0u);
@@ -56,9 +62,15 @@ TransformNodeData::TransformNodeData()
to_screen_is_animated(false),
flattens_inherited_transform(false),
node_and_ancestors_are_flat(true),
+ node_and_ancestors_have_only_integer_translation(true),
scrolls(false),
needs_sublayer_scale(false),
- layer_scale_factor(1.0f) {
+ affected_by_inner_viewport_bounds_delta_x(false),
+ affected_by_inner_viewport_bounds_delta_y(false),
+ affected_by_outer_viewport_bounds_delta_x(false),
+ affected_by_outer_viewport_bounds_delta_y(false),
+ layer_scale_factor(1.0f),
+ post_local_scale_factor(1.0f) {
}
TransformNodeData::~TransformNodeData() {
@@ -85,6 +97,16 @@ void TransformNodeData::update_post_local_transform(
ClipNodeData::ClipNodeData() : transform_id(-1), target_id(-1) {
}
+OpacityNodeData::OpacityNodeData() : opacity(1.f), screen_space_opacity(1.f) {
+}
+
+void TransformTree::clear() {
+ PropertyTree<TransformNode>::clear();
+
+ nodes_affected_by_inner_viewport_bounds_delta_.clear();
+ nodes_affected_by_outer_viewport_bounds_delta_.clear();
+}
+
bool TransformTree::ComputeTransform(int source_id,
int dest_id,
gfx::Transform* transform) const {
@@ -136,18 +158,24 @@ bool TransformTree::Are2DAxisAligned(int source_id, int dest_id) const {
transform.Preserves2dAxisAlignment();
}
+bool TransformTree::NeedsSourceToParentUpdate(TransformNode* node) {
+ return (source_to_parent_updates_allowed() &&
+ node->parent_id != node->data.source_node_id);
+}
+
void TransformTree::UpdateTransforms(int id) {
TransformNode* node = Node(id);
TransformNode* parent_node = parent(node);
TransformNode* target_node = Node(node->data.target_id);
if (node->data.needs_local_transform_update ||
- node->parent_id != node->data.source_node_id)
+ NeedsSourceToParentUpdate(node))
UpdateLocalTransform(node);
UpdateScreenSpaceTransform(node, parent_node, target_node);
UpdateSublayerScale(node);
UpdateTargetSpaceTransform(node, target_node);
UpdateIsAnimated(node, parent_node);
UpdateSnapping(node);
+ UpdateNodeAndAncestorsHaveIntegerTranslations(node, parent_node);
}
bool TransformTree::IsDescendant(int desc_id, int source_id) const {
@@ -188,12 +216,21 @@ bool TransformTree::CombineTransformsBetween(int source_id,
// path from the source to the destination (this is traversing upward), and
// then we visit these nodes in reverse order, flattening as needed. We
// early-out if we get to a node whose target node is the destination, since
- // we can then re-use the target space transform stored at that node.
+ // we can then re-use the target space transform stored at that node. However,
+ // we cannot re-use a stored target space transform if the destination has a
+ // zero sublayer scale, since stored target space transforms have sublayer
+ // scale baked in, but we need to compute an unscaled transform.
std::vector<int> source_to_destination;
source_to_destination.push_back(current->id);
current = parent(current);
+ bool destination_has_non_zero_sublayer_scale =
+ dest->data.sublayer_scale.x() != 0.f &&
+ dest->data.sublayer_scale.y() != 0.f;
+ DCHECK(destination_has_non_zero_sublayer_scale ||
+ !dest->data.ancestors_are_invertible);
for (; current && current->id > dest_id; current = parent(current)) {
- if (current->data.target_id == dest_id &&
+ if (destination_has_non_zero_sublayer_scale &&
+ current->data.target_id == dest_id &&
current->data.content_target_id == dest_id)
break;
source_to_destination.push_back(current->id);
@@ -230,8 +267,10 @@ bool TransformTree::CombineTransformsBetween(int source_id,
SkDoubleToMScalar(1e-4)));
}
- for (int i = source_to_destination.size() - 1; i >= 0; i--) {
- const TransformNode* node = Node(source_to_destination[i]);
+ size_t source_to_destination_size = source_to_destination.size();
+ for (size_t i = 0; i < source_to_destination_size; ++i) {
+ size_t index = source_to_destination_size - 1 - i;
+ const TransformNode* node = Node(source_to_destination[index]);
if (node->data.flattens_inherited_transform)
combined_transform.FlattenTo2d();
combined_transform.PreconcatTransform(node->data.to_parent);
@@ -273,14 +312,28 @@ bool TransformTree::CombineInversesBetween(int source_id,
void TransformTree::UpdateLocalTransform(TransformNode* node) {
gfx::Transform transform = node->data.post_local;
- gfx::Vector2dF source_to_parent;
- if (node->parent_id != node->data.source_node_id) {
+ if (NeedsSourceToParentUpdate(node)) {
gfx::Transform to_parent;
ComputeTransform(node->data.source_node_id, node->parent_id, &to_parent);
- source_to_parent = to_parent.To2dTranslation();
+ node->data.source_to_parent = to_parent.To2dTranslation();
}
- transform.Translate(source_to_parent.x() - node->data.scroll_offset.x(),
- source_to_parent.y() - node->data.scroll_offset.y());
+
+ gfx::Vector2dF fixed_position_adjustment;
+ if (node->data.affected_by_inner_viewport_bounds_delta_x)
+ fixed_position_adjustment.set_x(inner_viewport_bounds_delta_.x());
+ else if (node->data.affected_by_outer_viewport_bounds_delta_x)
+ fixed_position_adjustment.set_x(outer_viewport_bounds_delta_.x());
+
+ if (node->data.affected_by_inner_viewport_bounds_delta_y)
+ fixed_position_adjustment.set_y(inner_viewport_bounds_delta_.y());
+ else if (node->data.affected_by_outer_viewport_bounds_delta_y)
+ fixed_position_adjustment.set_y(outer_viewport_bounds_delta_.y());
+
+ transform.Translate(
+ node->data.source_to_parent.x() - node->data.scroll_offset.x() +
+ fixed_position_adjustment.x(),
+ node->data.source_to_parent.y() - node->data.scroll_offset.y() +
+ fixed_position_adjustment.y());
transform.PreconcatTransform(node->data.local);
transform.PreconcatTransform(node->data.pre_local);
node->data.set_to_parent(transform);
@@ -382,6 +435,70 @@ void TransformTree::UpdateSnapping(TransformNode* node) {
node->data.scroll_snap = translation;
}
+void TransformTree::SetInnerViewportBoundsDelta(gfx::Vector2dF bounds_delta) {
+ if (inner_viewport_bounds_delta_ == bounds_delta)
+ return;
+
+ inner_viewport_bounds_delta_ = bounds_delta;
+
+ if (nodes_affected_by_inner_viewport_bounds_delta_.empty())
+ return;
+
+ set_needs_update(true);
+ for (int i : nodes_affected_by_inner_viewport_bounds_delta_)
+ Node(i)->data.needs_local_transform_update = true;
+}
+
+void TransformTree::SetOuterViewportBoundsDelta(gfx::Vector2dF bounds_delta) {
+ if (outer_viewport_bounds_delta_ == bounds_delta)
+ return;
+
+ outer_viewport_bounds_delta_ = bounds_delta;
+
+ if (nodes_affected_by_outer_viewport_bounds_delta_.empty())
+ return;
+
+ set_needs_update(true);
+ for (int i : nodes_affected_by_outer_viewport_bounds_delta_)
+ Node(i)->data.needs_local_transform_update = true;
+}
+
+void TransformTree::AddNodeAffectedByInnerViewportBoundsDelta(int node_id) {
+ nodes_affected_by_inner_viewport_bounds_delta_.push_back(node_id);
+}
+
+void TransformTree::AddNodeAffectedByOuterViewportBoundsDelta(int node_id) {
+ nodes_affected_by_outer_viewport_bounds_delta_.push_back(node_id);
+}
+
+bool TransformTree::HasNodesAffectedByInnerViewportBoundsDelta() const {
+ return !nodes_affected_by_inner_viewport_bounds_delta_.empty();
+}
+
+bool TransformTree::HasNodesAffectedByOuterViewportBoundsDelta() const {
+ return !nodes_affected_by_outer_viewport_bounds_delta_.empty();
+}
+
+void OpacityTree::UpdateOpacities(int id) {
+ OpacityNode* node = Node(id);
+ node->data.screen_space_opacity = node->data.opacity;
+
+ OpacityNode* parent_node = parent(node);
+ if (parent_node)
+ node->data.screen_space_opacity *= parent_node->data.screen_space_opacity;
+}
+
+void TransformTree::UpdateNodeAndAncestorsHaveIntegerTranslations(
+ TransformNode* node,
+ TransformNode* parent_node) {
+ node->data.node_and_ancestors_have_only_integer_translation =
+ node->data.to_parent.IsIdentityOrIntegerTranslation();
+ if (parent_node)
+ node->data.node_and_ancestors_have_only_integer_translation =
+ node->data.node_and_ancestors_have_only_integer_translation &&
+ parent_node->data.node_and_ancestors_have_only_integer_translation;
+}
+
PropertyTrees::PropertyTrees() : needs_rebuild(true), sequence_number(0) {
}
diff --git a/chromium/cc/trees/property_tree.h b/chromium/cc/trees/property_tree.h
index caa819c6c6d..0ec77bc5bbe 100644
--- a/chromium/cc/trees/property_tree.h
+++ b/chromium/cc/trees/property_tree.h
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "cc/base/cc_export.h"
#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/scroll_offset.h"
#include "ui/gfx/transform.h"
namespace cc {
@@ -67,25 +68,36 @@ struct CC_EXPORT TransformNodeData {
int source_node_id;
// TODO(vollick): will be moved when accelerated effects are implemented.
- bool needs_local_transform_update;
+ bool needs_local_transform_update : 1;
- bool is_invertible;
- bool ancestors_are_invertible;
+ bool is_invertible : 1;
+ bool ancestors_are_invertible : 1;
- bool is_animated;
- bool to_screen_is_animated;
+ bool is_animated : 1;
+ bool to_screen_is_animated : 1;
// Flattening, when needed, is only applied to a node's inherited transform,
// never to its local transform.
- bool flattens_inherited_transform;
+ bool flattens_inherited_transform : 1;
// This is true if the to_parent transform at every node on the path to the
// root is flat.
- bool node_and_ancestors_are_flat;
+ bool node_and_ancestors_are_flat : 1;
- bool scrolls;
+ // This is needed to know if a layer can use lcd text.
+ bool node_and_ancestors_have_only_integer_translation : 1;
+
+ bool scrolls : 1;
+
+ bool needs_sublayer_scale : 1;
+
+ // These are used to position nodes wrt the right or bottom of the inner or
+ // outer viewport.
+ bool affected_by_inner_viewport_bounds_delta_x : 1;
+ bool affected_by_inner_viewport_bounds_delta_y : 1;
+ bool affected_by_outer_viewport_bounds_delta_x : 1;
+ bool affected_by_outer_viewport_bounds_delta_y : 1;
- bool needs_sublayer_scale;
// This is used as a fallback when we either cannot adjust raster scale or if
// the raster scale cannot be extracted from the screen space transform.
float layer_scale_factor;
@@ -96,7 +108,7 @@ struct CC_EXPORT TransformNodeData {
gfx::Vector2dF sublayer_scale;
// TODO(vollick): will be moved when accelerated effects are implemented.
- gfx::Vector2dF scroll_offset;
+ gfx::ScrollOffset scroll_offset;
// We scroll snap where possible, but this has an effect on scroll
// compensation: the snap is yet more scrolling that must be compensated for.
@@ -105,6 +117,7 @@ struct CC_EXPORT TransformNodeData {
// TODO(vollick): will be moved when accelerated effects are implemented.
gfx::Vector2dF source_offset;
+ gfx::Vector2dF source_to_parent;
void set_to_parent(const gfx::Transform& transform) {
to_parent = transform;
@@ -130,7 +143,14 @@ struct CC_EXPORT ClipNodeData {
typedef TreeNode<ClipNodeData> ClipNode;
-typedef TreeNode<float> OpacityNode;
+struct CC_EXPORT OpacityNodeData {
+ OpacityNodeData();
+
+ float opacity;
+ float screen_space_opacity;
+};
+
+typedef TreeNode<OpacityNodeData> OpacityNode;
template <typename T>
class CC_EXPORT PropertyTree {
@@ -159,7 +179,7 @@ class CC_EXPORT PropertyTree {
return size() ? &nodes_[nodes_.size() - 1] : nullptr;
}
- void clear();
+ virtual void clear();
size_t size() const { return nodes_.size(); }
void set_needs_update(bool needs_update) { needs_update_ = needs_update; }
@@ -174,6 +194,11 @@ class CC_EXPORT PropertyTree {
class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> {
public:
+ TransformTree();
+ ~TransformTree() override;
+
+ void clear() override;
+
// Computes the change of basis transform from node |source_id| to |dest_id|.
// The function returns false iff the inverse of a singular transform was
// used (and the result should, therefore, not be trusted). Transforms may
@@ -211,6 +236,37 @@ class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> {
// Updates the parent, target, and screen space transforms and snapping.
void UpdateTransforms(int id);
+ // A TransformNode's source_to_parent value is used to account for the fact
+ // that fixed-position layers are positioned by Blink wrt to their layer tree
+ // parent (their "source"), but are parented in the transform tree by their
+ // fixed-position container. This value needs to be updated on main-thread
+ // property trees (for position changes initiated by Blink), but not on the
+ // compositor thread (since the offset from a node corresponding to a
+ // fixed-position layer to its fixed-position container is unaffected by
+ // compositor-driven effects).
+ void set_source_to_parent_updates_allowed(bool allowed) {
+ source_to_parent_updates_allowed_ = allowed;
+ }
+ bool source_to_parent_updates_allowed() const {
+ return source_to_parent_updates_allowed_;
+ }
+
+ void SetInnerViewportBoundsDelta(gfx::Vector2dF bounds_delta);
+ gfx::Vector2dF inner_viewport_bounds_delta() const {
+ return inner_viewport_bounds_delta_;
+ }
+
+ void SetOuterViewportBoundsDelta(gfx::Vector2dF bounds_delta);
+ gfx::Vector2dF outer_viewport_bounds_delta() const {
+ return outer_viewport_bounds_delta_;
+ }
+
+ void AddNodeAffectedByInnerViewportBoundsDelta(int node_id);
+ void AddNodeAffectedByOuterViewportBoundsDelta(int node_id);
+
+ bool HasNodesAffectedByInnerViewportBoundsDelta() const;
+ bool HasNodesAffectedByOuterViewportBoundsDelta() const;
+
private:
// Returns true iff the node at |desc_id| is a descendant of the node at
// |anc_id|.
@@ -239,11 +295,24 @@ class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> {
TransformNode* target_node);
void UpdateIsAnimated(TransformNode* node, TransformNode* parent_node);
void UpdateSnapping(TransformNode* node);
+ void UpdateNodeAndAncestorsHaveIntegerTranslations(
+ TransformNode* node,
+ TransformNode* parent_node);
+ bool NeedsSourceToParentUpdate(TransformNode* node);
+
+ bool source_to_parent_updates_allowed_;
+ gfx::Vector2dF inner_viewport_bounds_delta_;
+ gfx::Vector2dF outer_viewport_bounds_delta_;
+ std::vector<int> nodes_affected_by_inner_viewport_bounds_delta_;
+ std::vector<int> nodes_affected_by_outer_viewport_bounds_delta_;
};
class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> {};
-class CC_EXPORT OpacityTree final : public PropertyTree<OpacityNode> {};
+class CC_EXPORT OpacityTree final : public PropertyTree<OpacityNode> {
+ public:
+ void UpdateOpacities(int id);
+};
class CC_EXPORT PropertyTrees final {
public:
diff --git a/chromium/cc/trees/property_tree_builder.cc b/chromium/cc/trees/property_tree_builder.cc
index 815692db211..28ad43f3091 100644
--- a/chromium/cc/trees/property_tree_builder.cc
+++ b/chromium/cc/trees/property_tree_builder.cc
@@ -31,9 +31,13 @@ struct DataForRecursion {
int clip_tree_parent;
int opacity_tree_parent;
const LayerType* page_scale_layer;
+ const LayerType* inner_viewport_scroll_layer;
+ const LayerType* outer_viewport_scroll_layer;
float page_scale_factor;
float device_scale_factor;
- bool in_subtree_of_page_scale_application_layer;
+ bool in_subtree_of_page_scale_layer;
+ bool affected_by_inner_viewport_bounds_delta;
+ bool affected_by_outer_viewport_bounds_delta;
bool should_flatten;
bool ancestor_clips_subtree;
const gfx::Transform* device_transform;
@@ -59,16 +63,6 @@ static ClipNode* GetClipParent(const DataForRecursion<LayerType>& data,
}
template <typename LayerType>
-static bool HasPotentiallyRunningAnimation(LayerType* layer,
- Animation::TargetProperty property) {
- if (Animation* animation =
- layer->layer_animation_controller()->GetAnimation(property)) {
- return !animation->is_finished();
- }
- return false;
-}
-
-template <typename LayerType>
static bool RequiresClipNode(LayerType* layer,
const DataForRecursion<LayerType>& data,
int parent_transform_id,
@@ -78,7 +72,7 @@ static bool RequiresClipNode(LayerType* layer,
const bool render_surface_may_grow_due_to_clip_children =
layer->render_surface() && layer->num_unclipped_descendants() > 0;
- if (!layer->parent() || layer->masks_to_bounds() || layer->mask_layer() ||
+ if (layer->masks_to_bounds() || layer->mask_layer() ||
render_surface_may_grow_due_to_clip_children)
return true;
@@ -130,8 +124,7 @@ void AddClipNodeIfNeeded(const DataForRecursion<LayerType>& data_from_ancestor,
data_for_children->ancestor_clips_subtree)) {
// Unclipped surfaces reset the clip rect.
data_for_children->clip_tree_parent = parent_id;
- } else if (layer->parent()) {
- // Note the root clip gets handled elsewhere.
+ } else {
LayerType* transform_parent = data_for_children->transform_tree_parent;
if (layer->position_constraint().is_fixed_position() &&
!created_transform_node) {
@@ -163,8 +156,7 @@ bool AddTransformNodeIfNeeded(
LayerType* layer,
DataForRecursion<LayerType>* data_for_children) {
const bool is_root = !layer->parent();
- const bool is_page_scale_application_layer =
- layer->parent() && layer->parent() == data_from_ancestor.page_scale_layer;
+ const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer;
const bool is_scrollable = layer->scrollable();
const bool is_fixed = layer->position_constraint().is_fixed_position();
@@ -172,19 +164,17 @@ bool AddTransformNodeIfNeeded(
!layer->transform().IsIdentityOr2DTranslation();
const bool has_potentially_animated_transform =
- HasPotentiallyRunningAnimation(layer, Animation::TRANSFORM);
-
- const bool has_animated_transform =
- layer->layer_animation_controller()->IsAnimatingProperty(
- Animation::TRANSFORM);
+ layer->HasPotentiallyRunningTransformAnimation();
+ const bool has_animated_transform = layer->TransformIsAnimating();
const bool has_surface = !!layer->render_surface();
bool requires_node = is_root || is_scrollable || has_significant_transform ||
has_potentially_animated_transform || has_surface ||
- is_fixed || is_page_scale_application_layer;
+ is_fixed || is_page_scale_layer;
LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer);
+ DCHECK_IMPLIES(!is_root, transform_parent);
int parent_index = 0;
if (transform_parent)
@@ -201,19 +191,27 @@ bool AddTransformNodeIfNeeded(
} else if (!is_fixed) {
source_offset = transform_parent->offset_to_transform_parent();
} else {
- if (data_from_ancestor.transform_tree_parent !=
- data_from_ancestor.transform_fixed_parent) {
- source_offset = data_from_ancestor.transform_tree_parent
- ->offset_to_transform_parent();
- source_index =
- data_from_ancestor.transform_tree_parent->transform_tree_index();
- }
+ source_offset = data_from_ancestor.transform_tree_parent
+ ->offset_to_transform_parent();
+ source_index =
+ data_from_ancestor.transform_tree_parent->transform_tree_index();
source_offset += data_from_ancestor.scroll_compensation_adjustment;
}
}
- if (layer->IsContainerForFixedPositionLayers() || is_root)
- data_for_children->transform_fixed_parent = layer;
+ if (layer->IsContainerForFixedPositionLayers() || is_root) {
+ data_for_children->affected_by_inner_viewport_bounds_delta =
+ layer == data_from_ancestor.inner_viewport_scroll_layer;
+ data_for_children->affected_by_outer_viewport_bounds_delta =
+ layer == data_from_ancestor.outer_viewport_scroll_layer;
+ if (is_scrollable) {
+ DCHECK(!is_root);
+ DCHECK(layer->transform().IsIdentity());
+ data_for_children->transform_fixed_parent = layer->parent();
+ } else {
+ data_for_children->transform_fixed_parent = layer;
+ }
+ }
data_for_children->transform_tree_parent = layer;
if (layer->IsContainerForFixedPositionLayers() || is_fixed)
@@ -262,30 +260,54 @@ bool AddTransformNodeIfNeeded(
post_local_scale_factor = data_from_ancestor.device_scale_factor;
}
- if (is_page_scale_application_layer)
+ if (is_page_scale_layer)
post_local_scale_factor *= data_from_ancestor.page_scale_factor;
if (has_surface && !is_root) {
node->data.needs_sublayer_scale = true;
node->data.layer_scale_factor = data_from_ancestor.device_scale_factor;
- if (data_from_ancestor.in_subtree_of_page_scale_application_layer)
+ if (data_from_ancestor.in_subtree_of_page_scale_layer)
node->data.layer_scale_factor *= data_from_ancestor.page_scale_factor;
}
+ node->data.source_node_id = source_index;
if (is_root) {
node->data.post_local.Scale(post_local_scale_factor,
post_local_scale_factor);
+ node->data.post_local.Translate(layer->position().x(),
+ layer->position().y());
} else {
node->data.post_local_scale_factor = post_local_scale_factor;
node->data.source_offset = source_offset;
- node->data.source_node_id = source_index;
node->data.update_post_local_transform(layer->position(),
layer->transform_origin());
}
- if (!layer->scroll_parent()) {
- node->data.scroll_offset =
- gfx::ScrollOffsetToVector2dF(layer->CurrentScrollOffset());
+ if (!layer->scroll_parent())
+ node->data.scroll_offset = layer->CurrentScrollOffset();
+
+ if (is_fixed) {
+ if (data_from_ancestor.affected_by_inner_viewport_bounds_delta) {
+ node->data.affected_by_inner_viewport_bounds_delta_x =
+ layer->position_constraint().is_fixed_to_right_edge();
+ node->data.affected_by_inner_viewport_bounds_delta_y =
+ layer->position_constraint().is_fixed_to_bottom_edge();
+ if (node->data.affected_by_inner_viewport_bounds_delta_x ||
+ node->data.affected_by_inner_viewport_bounds_delta_y) {
+ data_for_children->transform_tree
+ ->AddNodeAffectedByInnerViewportBoundsDelta(node->id);
+ }
+ } else if (data_from_ancestor.affected_by_outer_viewport_bounds_delta) {
+ node->data.affected_by_outer_viewport_bounds_delta_x =
+ layer->position_constraint().is_fixed_to_right_edge();
+ node->data.affected_by_outer_viewport_bounds_delta_y =
+ layer->position_constraint().is_fixed_to_bottom_edge();
+ if (node->data.affected_by_outer_viewport_bounds_delta_x ||
+ node->data.affected_by_outer_viewport_bounds_delta_y) {
+ data_for_children->transform_tree
+ ->AddNodeAffectedByOuterViewportBoundsDelta(node->id);
+ }
+ }
}
node->data.local = layer->transform();
@@ -308,12 +330,12 @@ bool AddTransformNodeIfNeeded(
}
bool IsAnimatingOpacity(Layer* layer) {
- return HasPotentiallyRunningAnimation(layer, Animation::OPACITY) ||
+ return layer->HasPotentiallyRunningOpacityAnimation() ||
layer->OpacityCanAnimateOnImplThread();
}
bool IsAnimatingOpacity(LayerImpl* layer) {
- return HasPotentiallyRunningAnimation(layer, Animation::OPACITY);
+ return layer->HasPotentiallyRunningOpacityAnimation();
}
template <typename LayerType>
@@ -336,7 +358,12 @@ void AddOpacityNodeIfNeeded(
OpacityNode node;
node.owner_id = layer->id();
- node.data = layer->opacity();
+ node.data.opacity = layer->opacity();
+ node.data.screen_space_opacity = layer->opacity();
+ if (!is_root)
+ node.data.screen_space_opacity *=
+ data_from_ancestor.opacity_tree->Node(parent_id)
+ ->data.screen_space_opacity;
data_for_children->opacity_tree_parent =
data_for_children->opacity_tree->Insert(node, parent_id);
layer->SetOpacityTreeIndex(data_for_children->opacity_tree_parent);
@@ -360,15 +387,22 @@ void BuildPropertyTreesInternal(
AddOpacityNodeIfNeeded(data_from_parent, layer, &data_for_children);
if (layer == data_from_parent.page_scale_layer)
- data_for_children.in_subtree_of_page_scale_application_layer = true;
+ data_for_children.in_subtree_of_page_scale_layer = true;
for (size_t i = 0; i < layer->children().size(); ++i) {
- if (!layer->child_at(i)->scroll_parent())
+ if (!layer->child_at(i)->scroll_parent()) {
BuildPropertyTreesInternal(layer->child_at(i), data_for_children);
+ } else {
+ // The child should be included in its scroll parent's list of scroll
+ // children.
+ DCHECK(layer->child_at(i)->scroll_parent()->scroll_children()->count(
+ layer->child_at(i)));
+ }
}
if (layer->scroll_children()) {
for (LayerType* scroll_child : *layer->scroll_children()) {
+ DCHECK_EQ(scroll_child->scroll_parent(), layer);
BuildPropertyTreesInternal(scroll_child, data_for_children);
}
}
@@ -380,13 +414,19 @@ void BuildPropertyTreesInternal(
} // namespace
template <typename LayerType>
-void BuildPropertyTreesTopLevelInternal(LayerType* root_layer,
- const LayerType* page_scale_layer,
- float page_scale_factor,
- float device_scale_factor,
- const gfx::Rect& viewport,
- const gfx::Transform& device_transform,
- PropertyTrees* property_trees) {
+void BuildPropertyTreesTopLevelInternal(
+ LayerType* root_layer,
+ const LayerType* page_scale_layer,
+ const LayerType* inner_viewport_scroll_layer,
+ const LayerType* outer_viewport_scroll_layer,
+ float page_scale_factor,
+ float device_scale_factor,
+ const gfx::Rect& viewport,
+ const gfx::Transform& device_transform,
+ PropertyTrees* property_trees) {
+ if (!property_trees->needs_rebuild)
+ return;
+
property_trees->sequence_number++;
DataForRecursion<LayerType> data_for_recursion;
@@ -399,9 +439,13 @@ void BuildPropertyTreesTopLevelInternal(LayerType* root_layer,
data_for_recursion.clip_tree_parent = 0;
data_for_recursion.opacity_tree_parent = -1;
data_for_recursion.page_scale_layer = page_scale_layer;
+ data_for_recursion.inner_viewport_scroll_layer = inner_viewport_scroll_layer;
+ data_for_recursion.outer_viewport_scroll_layer = outer_viewport_scroll_layer;
data_for_recursion.page_scale_factor = page_scale_factor;
data_for_recursion.device_scale_factor = device_scale_factor;
- data_for_recursion.in_subtree_of_page_scale_application_layer = false;
+ data_for_recursion.in_subtree_of_page_scale_layer = false;
+ data_for_recursion.affected_by_inner_viewport_bounds_delta = false;
+ data_for_recursion.affected_by_outer_viewport_bounds_delta = false;
data_for_recursion.should_flatten = false;
data_for_recursion.ancestor_clips_subtree = true;
data_for_recursion.device_transform = &device_transform;
@@ -424,35 +468,38 @@ void BuildPropertyTreesTopLevelInternal(LayerType* root_layer,
// building.
property_trees->transform_tree.set_needs_update(false);
property_trees->clip_tree.set_needs_update(true);
+ property_trees->opacity_tree.set_needs_update(false);
}
void PropertyTreeBuilder::BuildPropertyTrees(
Layer* root_layer,
const Layer* page_scale_layer,
+ const Layer* inner_viewport_scroll_layer,
+ const Layer* outer_viewport_scroll_layer,
float page_scale_factor,
float device_scale_factor,
const gfx::Rect& viewport,
const gfx::Transform& device_transform,
PropertyTrees* property_trees) {
- // TODO(enne): hoist this out of here
- if (!property_trees->needs_rebuild)
- return;
-
BuildPropertyTreesTopLevelInternal(
- root_layer, page_scale_layer, page_scale_factor, device_scale_factor,
+ root_layer, page_scale_layer, inner_viewport_scroll_layer,
+ outer_viewport_scroll_layer, page_scale_factor, device_scale_factor,
viewport, device_transform, property_trees);
}
void PropertyTreeBuilder::BuildPropertyTrees(
LayerImpl* root_layer,
const LayerImpl* page_scale_layer,
+ const LayerImpl* inner_viewport_scroll_layer,
+ const LayerImpl* outer_viewport_scroll_layer,
float page_scale_factor,
float device_scale_factor,
const gfx::Rect& viewport,
const gfx::Transform& device_transform,
PropertyTrees* property_trees) {
BuildPropertyTreesTopLevelInternal(
- root_layer, page_scale_layer, page_scale_factor, device_scale_factor,
+ root_layer, page_scale_layer, inner_viewport_scroll_layer,
+ outer_viewport_scroll_layer, page_scale_factor, device_scale_factor,
viewport, device_transform, property_trees);
}
diff --git a/chromium/cc/trees/property_tree_builder.h b/chromium/cc/trees/property_tree_builder.h
index 15f326ef15c..f877aebe3dd 100644
--- a/chromium/cc/trees/property_tree_builder.h
+++ b/chromium/cc/trees/property_tree_builder.h
@@ -20,6 +20,8 @@ class PropertyTreeBuilder {
// in a null |opacity_tree|.
static void BuildPropertyTrees(Layer* root_layer,
const Layer* page_scale_layer,
+ const Layer* inner_viewport_scroll_layer,
+ const Layer* outer_viewport_scroll_layer,
float page_scale_factor,
float device_scale_factor,
const gfx::Rect& viewport,
@@ -27,6 +29,8 @@ class PropertyTreeBuilder {
PropertyTrees* property_trees);
static void BuildPropertyTrees(LayerImpl* root_layer,
const LayerImpl* page_scale_layer,
+ const LayerImpl* inner_viewport_scroll_layer,
+ const LayerImpl* outer_viewport_scroll_layer,
float page_scale_factor,
float device_scale_factor,
const gfx::Rect& viewport,
diff --git a/chromium/cc/trees/property_tree_unittest.cc b/chromium/cc/trees/property_tree_unittest.cc
index 7e179388b5f..8497dca6af1 100644
--- a/chromium/cc/trees/property_tree_unittest.cc
+++ b/chromium/cc/trees/property_tree_unittest.cc
@@ -422,6 +422,68 @@ TEST(PropertyTreeTest, ComputeTransformWithSublayerScale) {
transform);
}
+TEST(PropertyTreeTest, ComputeTransformToTargetWithZeroSublayerScale) {
+ TransformTree tree;
+ TransformNode& root = *tree.Node(0);
+ root.data.target_id = 0;
+ tree.UpdateTransforms(0);
+
+ TransformNode grand_parent;
+ grand_parent.data.local.Scale(2.f, 0.f);
+ grand_parent.data.target_id = 0;
+ grand_parent.data.source_node_id = 0;
+ grand_parent.data.needs_sublayer_scale = true;
+ int grand_parent_id = tree.Insert(grand_parent, 0);
+ tree.Node(grand_parent_id)->data.content_target_id = grand_parent_id;
+ tree.UpdateTransforms(grand_parent_id);
+
+ TransformNode parent;
+ parent.data.local.Translate(1.f, 1.f);
+ parent.data.target_id = grand_parent_id;
+ parent.data.content_target_id = grand_parent_id;
+ parent.data.source_node_id = grand_parent_id;
+ int parent_id = tree.Insert(parent, grand_parent_id);
+ tree.UpdateTransforms(parent_id);
+
+ TransformNode child;
+ child.data.local.Translate(3.f, 4.f);
+ child.data.target_id = grand_parent_id;
+ child.data.content_target_id = grand_parent_id;
+ child.data.source_node_id = parent_id;
+ int child_id = tree.Insert(child, parent_id);
+ tree.UpdateTransforms(child_id);
+
+ gfx::Transform expected_transform;
+ expected_transform.Translate(4.f, 5.f);
+
+ gfx::Transform transform;
+ bool success = tree.ComputeTransform(child_id, grand_parent_id, &transform);
+ EXPECT_TRUE(success);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, transform);
+
+ tree.Node(grand_parent_id)->data.local.MakeIdentity();
+ tree.Node(grand_parent_id)->data.local.Scale(0.f, 2.f);
+ tree.Node(grand_parent_id)->data.needs_local_transform_update = true;
+ tree.set_needs_update(true);
+
+ ComputeTransforms(&tree);
+
+ success = tree.ComputeTransform(child_id, grand_parent_id, &transform);
+ EXPECT_TRUE(success);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, transform);
+
+ tree.Node(grand_parent_id)->data.local.MakeIdentity();
+ tree.Node(grand_parent_id)->data.local.Scale(0.f, 0.f);
+ tree.Node(grand_parent_id)->data.needs_local_transform_update = true;
+ tree.set_needs_update(true);
+
+ ComputeTransforms(&tree);
+
+ success = tree.ComputeTransform(child_id, grand_parent_id, &transform);
+ EXPECT_TRUE(success);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, transform);
+}
+
TEST(PropertyTreeTest, FlatteningWhenDestinationHasOnlyFlatAncestors) {
// This tests that flattening is performed correctly when
// destination and its ancestors are flat, but there are 3d transforms
@@ -464,4 +526,62 @@ TEST(PropertyTreeTest, FlatteningWhenDestinationHasOnlyFlatAncestors) {
grand_child_to_parent);
}
+TEST(PropertyTreeTest, ScreenSpaceOpacityUpdateTest) {
+ // This tests that screen space opacity is updated for the subtree when
+ // opacity of a node changes.
+ OpacityTree tree;
+
+ int parent = tree.Insert(OpacityNode(), 0);
+ int child = tree.Insert(OpacityNode(), parent);
+
+ EXPECT_EQ(tree.Node(child)->data.screen_space_opacity, 1.f);
+ tree.Node(parent)->data.opacity = 0.5f;
+ tree.set_needs_update(true);
+ ComputeOpacities(&tree);
+ EXPECT_EQ(tree.Node(child)->data.screen_space_opacity, 0.5f);
+
+ tree.Node(child)->data.opacity = 0.5f;
+ tree.set_needs_update(true);
+ ComputeOpacities(&tree);
+ EXPECT_EQ(tree.Node(child)->data.screen_space_opacity, 0.25f);
+}
+
+TEST(PropertyTreeTest, NonIntegerTranslationTest) {
+ // This tests that when a node has non-integer translation, the information
+ // is propagated to the subtree.
+ TransformTree tree;
+
+ int parent = tree.Insert(TransformNode(), 0);
+ tree.Node(parent)->data.target_id = parent;
+ tree.Node(parent)->data.local.Translate(1.5f, 1.5f);
+
+ int child = tree.Insert(TransformNode(), parent);
+ tree.Node(child)->data.target_id = parent;
+ tree.Node(child)->data.local.Translate(1, 1);
+ tree.set_needs_update(true);
+ ComputeTransforms(&tree);
+ EXPECT_FALSE(
+ tree.Node(parent)->data.node_and_ancestors_have_only_integer_translation);
+ EXPECT_FALSE(
+ tree.Node(child)->data.node_and_ancestors_have_only_integer_translation);
+
+ tree.Node(parent)->data.local.Translate(0.5f, 0.5f);
+ tree.Node(child)->data.local.Translate(0.5f, 0.5f);
+ tree.set_needs_update(true);
+ ComputeTransforms(&tree);
+ EXPECT_TRUE(
+ tree.Node(parent)->data.node_and_ancestors_have_only_integer_translation);
+ EXPECT_FALSE(
+ tree.Node(child)->data.node_and_ancestors_have_only_integer_translation);
+
+ tree.Node(child)->data.local.Translate(0.5f, 0.5f);
+ tree.Node(child)->data.target_id = child;
+ tree.set_needs_update(true);
+ ComputeTransforms(&tree);
+ EXPECT_TRUE(
+ tree.Node(parent)->data.node_and_ancestors_have_only_integer_translation);
+ EXPECT_TRUE(
+ tree.Node(child)->data.node_and_ancestors_have_only_integer_translation);
+}
+
} // namespace cc
diff --git a/chromium/cc/trees/proxy.cc b/chromium/cc/trees/proxy.cc
index eb81e2e6735..58d10b910cb 100644
--- a/chromium/cc/trees/proxy.cc
+++ b/chromium/cc/trees/proxy.cc
@@ -4,7 +4,6 @@
#include "cc/trees/proxy.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/single_thread_task_runner.h"
#include "cc/trees/blocking_task_runner.h"
diff --git a/chromium/cc/trees/proxy.h b/chromium/cc/trees/proxy.h
index 55e54beb6ae..d403ae0eb6d 100644
--- a/chromium/cc/trees/proxy.h
+++ b/chromium/cc/trees/proxy.h
@@ -97,9 +97,6 @@ class CC_EXPORT Proxy {
// to finish before executing in the GPU process.
virtual void ForceSerializeOnSwapBuffers() = 0;
- // Maximum number of sub-region texture updates supported for each commit.
- virtual size_t MaxPartialTextureUpdates() const = 0;
-
virtual bool SupportsImplScrolling() const = 0;
virtual void SetDebugState(const LayerTreeDebugState& debug_state) = 0;
diff --git a/chromium/cc/trees/proxy_timing_history.cc b/chromium/cc/trees/proxy_timing_history.cc
deleted file mode 100644
index 90abad1632f..00000000000
--- a/chromium/cc/trees/proxy_timing_history.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "cc/trees/proxy_timing_history.h"
-
-#include "base/metrics/histogram.h"
-
-const size_t kDurationHistorySize = 60;
-const double kCommitAndActivationDurationEstimationPercentile = 50.0;
-const double kDrawDurationEstimationPercentile = 100.0;
-const int kDrawDurationEstimatePaddingInMicroseconds = 0;
-
-namespace cc {
-
-ProxyTimingHistory::ProxyTimingHistory(
- RenderingStatsInstrumentation* rendering_stats_instrumentation)
- : draw_duration_history_(kDurationHistorySize),
- begin_main_frame_to_commit_duration_history_(kDurationHistorySize),
- commit_to_activate_duration_history_(kDurationHistorySize),
- rendering_stats_instrumentation_(rendering_stats_instrumentation) {
-}
-
-ProxyTimingHistory::~ProxyTimingHistory() {}
-
-base::TimeDelta ProxyTimingHistory::DrawDurationEstimate() const {
- base::TimeDelta historical_estimate =
- draw_duration_history_.Percentile(kDrawDurationEstimationPercentile);
- base::TimeDelta padding = base::TimeDelta::FromMicroseconds(
- kDrawDurationEstimatePaddingInMicroseconds);
- return historical_estimate + padding;
-}
-
-base::TimeDelta ProxyTimingHistory::BeginMainFrameToCommitDurationEstimate()
- const {
- return begin_main_frame_to_commit_duration_history_.Percentile(
- kCommitAndActivationDurationEstimationPercentile);
-}
-
-base::TimeDelta ProxyTimingHistory::CommitToActivateDurationEstimate() const {
- return commit_to_activate_duration_history_.Percentile(
- kCommitAndActivationDurationEstimationPercentile);
-}
-
-void ProxyTimingHistory::DidBeginMainFrame() {
- begin_main_frame_sent_time_ = base::TimeTicks::Now();
-}
-
-void ProxyTimingHistory::DidCommit() {
- commit_complete_time_ = base::TimeTicks::Now();
- base::TimeDelta begin_main_frame_to_commit_duration =
- commit_complete_time_ - begin_main_frame_sent_time_;
-
- // Before adding the new data point to the timing history, see what we would
- // have predicted for this frame. This allows us to keep track of the accuracy
- // of our predictions.
- rendering_stats_instrumentation_->AddBeginMainFrameToCommitDuration(
- begin_main_frame_to_commit_duration,
- BeginMainFrameToCommitDurationEstimate());
-
- begin_main_frame_to_commit_duration_history_.InsertSample(
- begin_main_frame_to_commit_duration);
-}
-
-void ProxyTimingHistory::DidActivateSyncTree() {
- base::TimeDelta commit_to_activate_duration =
- base::TimeTicks::Now() - commit_complete_time_;
-
- // Before adding the new data point to the timing history, see what we would
- // have predicted for this frame. This allows us to keep track of the accuracy
- // of our predictions.
- rendering_stats_instrumentation_->AddCommitToActivateDuration(
- commit_to_activate_duration, CommitToActivateDurationEstimate());
-
- commit_to_activate_duration_history_.InsertSample(
- commit_to_activate_duration);
-}
-
-void ProxyTimingHistory::DidStartDrawing() {
- start_draw_time_ = base::TimeTicks::Now();
-}
-
-void ProxyTimingHistory::DidFinishDrawing() {
- base::TimeDelta draw_duration = base::TimeTicks::Now() - start_draw_time_;
-
- // Before adding the new data point to the timing history, see what we would
- // have predicted for this frame. This allows us to keep track of the accuracy
- // of our predictions.
- base::TimeDelta draw_duration_estimate = DrawDurationEstimate();
- rendering_stats_instrumentation_->AddDrawDuration(draw_duration,
- draw_duration_estimate);
-
- AddDrawDurationUMA(draw_duration, draw_duration_estimate);
-
- draw_duration_history_.InsertSample(draw_duration);
-}
-
-void ProxyTimingHistory::AddDrawDurationUMA(
- base::TimeDelta draw_duration,
- base::TimeDelta draw_duration_estimate) {
- base::TimeDelta draw_duration_overestimate;
- base::TimeDelta draw_duration_underestimate;
- if (draw_duration > draw_duration_estimate)
- draw_duration_underestimate = draw_duration - draw_duration_estimate;
- else
- draw_duration_overestimate = draw_duration_estimate - draw_duration;
- UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDuration",
- draw_duration,
- base::TimeDelta::FromMilliseconds(1),
- base::TimeDelta::FromMilliseconds(100),
- 50);
- UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDurationUnderestimate",
- draw_duration_underestimate,
- base::TimeDelta::FromMilliseconds(1),
- base::TimeDelta::FromMilliseconds(100),
- 50);
- UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDurationOverestimate",
- draw_duration_overestimate,
- base::TimeDelta::FromMilliseconds(1),
- base::TimeDelta::FromMilliseconds(100),
- 50);
-}
-
-} // namespace cc
diff --git a/chromium/cc/trees/proxy_timing_history.h b/chromium/cc/trees/proxy_timing_history.h
deleted file mode 100644
index aa213b6bdb7..00000000000
--- a/chromium/cc/trees/proxy_timing_history.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CC_TREES_PROXY_TIMING_HISTORY_H_
-#define CC_TREES_PROXY_TIMING_HISTORY_H_
-
-#include "cc/base/rolling_time_delta_history.h"
-#include "cc/debug/rendering_stats_instrumentation.h"
-
-namespace cc {
-
-class ProxyTimingHistory {
- public:
- explicit ProxyTimingHistory(
- RenderingStatsInstrumentation* rendering_stats_instrumentation);
- ~ProxyTimingHistory();
-
- base::TimeDelta DrawDurationEstimate() const;
- base::TimeDelta BeginMainFrameToCommitDurationEstimate() const;
- base::TimeDelta CommitToActivateDurationEstimate() const;
-
- void DidBeginMainFrame();
- void DidCommit();
- void DidActivateSyncTree();
- void DidStartDrawing();
- void DidFinishDrawing();
-
- protected:
- void AddDrawDurationUMA(base::TimeDelta draw_duration,
- base::TimeDelta draw_duration_estimate);
-
- RollingTimeDeltaHistory draw_duration_history_;
- RollingTimeDeltaHistory begin_main_frame_to_commit_duration_history_;
- RollingTimeDeltaHistory commit_to_activate_duration_history_;
-
- base::TimeTicks begin_main_frame_sent_time_;
- base::TimeTicks commit_complete_time_;
- base::TimeTicks start_draw_time_;
-
- RenderingStatsInstrumentation* rendering_stats_instrumentation_;
-};
-
-} // namespace cc
-
-#endif // CC_TREES_PROXY_TIMING_HISTORY_H_
diff --git a/chromium/cc/trees/single_thread_proxy.cc b/chromium/cc/trees/single_thread_proxy.cc
index f05a9a6a529..b6d120b4805 100644
--- a/chromium/cc/trees/single_thread_proxy.cc
+++ b/chromium/cc/trees/single_thread_proxy.cc
@@ -12,14 +12,13 @@
#include "cc/output/context_provider.h"
#include "cc/output/output_surface.h"
#include "cc/quads/draw_quad.h"
-#include "cc/resources/prioritized_resource_manager.h"
-#include "cc/resources/resource_update_controller.h"
#include "cc/scheduler/commit_earlyout_reason.h"
+#include "cc/scheduler/compositor_timing_history.h"
+#include "cc/scheduler/scheduler.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_host_single_thread_client.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/scoped_abort_remaining_swap_promises.h"
-#include "ui/gfx/frame_time.h"
namespace cc {
@@ -43,7 +42,7 @@ SingleThreadProxy::SingleThreadProxy(
: Proxy(main_task_runner, NULL),
layer_tree_host_(layer_tree_host),
client_(client),
- timing_history_(layer_tree_host->rendering_stats_instrumentation()),
+ external_begin_frame_source_(external_begin_frame_source.Pass()),
next_frame_is_newly_committed_frame_(false),
#if DCHECK_IS_ON()
inside_impl_frame_(false),
@@ -63,11 +62,16 @@ SingleThreadProxy::SingleThreadProxy(
!scheduler_on_impl_thread_) {
SchedulerSettings scheduler_settings(
layer_tree_host->settings().ToSchedulerSettings());
- // SingleThreadProxy should run in main thread low latency mode.
- scheduler_settings.main_thread_should_always_be_low_latency = true;
+ scheduler_settings.commit_to_active_tree = CommitToActiveTree();
+
+ scoped_ptr<CompositorTimingHistory> compositor_timing_history(
+ new CompositorTimingHistory(
+ layer_tree_host->rendering_stats_instrumentation()));
+
scheduler_on_impl_thread_ = Scheduler::Create(
this, scheduler_settings, layer_tree_host_->id(),
- MainThreadTaskRunner(), external_begin_frame_source.Pass());
+ MainThreadTaskRunner(), external_begin_frame_source_.get(),
+ compositor_timing_history.Pass());
}
}
@@ -153,8 +157,6 @@ void SingleThreadProxy::SetOutputSurface(
{
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
DebugScopedSetImplThread impl(this);
- layer_tree_host_->DeleteContentsTexturesOnImplThread(
- layer_tree_host_impl_->resource_provider());
success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass());
}
@@ -243,39 +245,10 @@ void SingleThreadProxy::DoCommit() {
blocking_main_thread_task_runner()));
layer_tree_host_impl_->BeginCommit();
-
- if (PrioritizedResourceManager* contents_texture_manager =
- layer_tree_host_->contents_texture_manager()) {
- // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
- // is fixed.
- tracked_objects::ScopedTracker tracking_profile3(
- FROM_HERE_WITH_EXPLICIT_FUNCTION(
- "461509 SingleThreadProxy::DoCommit3"));
- contents_texture_manager->PushTexturePrioritiesToBackings();
- }
layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get());
// TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
// is fixed.
- tracked_objects::ScopedTracker tracking_profile4(
- FROM_HERE_WITH_EXPLICIT_FUNCTION(
- "461509 SingleThreadProxy::DoCommit4"));
- scoped_ptr<ResourceUpdateController> update_controller =
- ResourceUpdateController::Create(
- NULL,
- MainThreadTaskRunner(),
- queue_for_commit_.Pass(),
- layer_tree_host_impl_->resource_provider());
-
- // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
- // is fixed.
- tracked_objects::ScopedTracker tracking_profile5(
- FROM_HERE_WITH_EXPLICIT_FUNCTION(
- "461509 SingleThreadProxy::DoCommit5"));
- update_controller->Finalize();
-
- // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
- // is fixed.
tracked_objects::ScopedTracker tracking_profile6(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"461509 SingleThreadProxy::DoCommit6"));
@@ -298,26 +271,17 @@ void SingleThreadProxy::DoCommit() {
DCHECK_EQ(1.f, scroll_info->page_scale_delta);
#endif
- if (layer_tree_host_->settings().impl_side_painting) {
- // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
- // is fixed.
- tracked_objects::ScopedTracker tracking_profile8(
- FROM_HERE_WITH_EXPLICIT_FUNCTION(
- "461509 SingleThreadProxy::DoCommit8"));
- // Commit goes directly to the active tree, but we need to synchronously
- // "activate" the tree still during commit to satisfy any potential
- // SetNextCommitWaitsForActivation calls. Unfortunately, the tree
- // might not be ready to draw, so DidActivateSyncTree must set
- // the flag to force the tree to not draw until textures are ready.
- NotifyReadyToActivate();
- } else {
- // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
- // is fixed.
- tracked_objects::ScopedTracker tracking_profile9(
- FROM_HERE_WITH_EXPLICIT_FUNCTION(
- "461509 SingleThreadProxy::DoCommit9"));
- CommitComplete();
- }
+ // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
+ // is fixed.
+ tracked_objects::ScopedTracker tracking_profile8(
+ FROM_HERE_WITH_EXPLICIT_FUNCTION(
+ "461509 SingleThreadProxy::DoCommit8"));
+ // Commit goes directly to the active tree, but we need to synchronously
+ // "activate" the tree still during commit to satisfy any potential
+ // SetNextCommitWaitsForActivation calls. Unfortunately, the tree
+ // might not be ready to draw, so DidActivateSyncTree must set
+ // the flag to force the tree to not draw until textures are ready.
+ NotifyReadyToActivate();
}
}
@@ -326,6 +290,9 @@ void SingleThreadProxy::CommitComplete() {
<< "Activation is expected to have synchronously occurred by now.";
DCHECK(commit_blocking_task_runner_);
+ if (scheduler_on_impl_thread_)
+ scheduler_on_impl_thread_->DidCommit();
+
// Notify commit complete on the impl side after activate to satisfy any
// SetNextCommitWaitsForActivation calls.
layer_tree_host_impl_->CommitComplete();
@@ -334,7 +301,6 @@ void SingleThreadProxy::CommitComplete() {
commit_blocking_task_runner_.reset();
layer_tree_host_->CommitComplete();
layer_tree_host_->DidBeginMainFrame();
- timing_history_.DidCommit();
next_frame_is_newly_committed_frame_ = true;
}
@@ -394,10 +360,6 @@ bool SingleThreadProxy::BeginMainFrameRequested() const {
return commit_requested_;
}
-size_t SingleThreadProxy::MaxPartialTextureUpdates() const {
- return std::numeric_limits<size_t>::max();
-}
-
void SingleThreadProxy::Stop() {
TRACE_EVENT0("cc", "SingleThreadProxy::stop");
DCHECK(Proxy::IsMainThread());
@@ -407,8 +369,6 @@ void SingleThreadProxy::Stop() {
BlockingTaskRunner::CapturePostTasks blocked(
blocking_main_thread_task_runner());
- layer_tree_host_->DeleteContentsTexturesOnImplThread(
- layer_tree_host_impl_->resource_provider());
scheduler_on_impl_thread_ = nullptr;
layer_tree_host_impl_ = nullptr;
}
@@ -484,45 +444,27 @@ void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread(
layer_tree_host_->SetAnimationEvents(events.Pass());
}
-bool SingleThreadProxy::ReduceContentsTextureMemoryOnImplThread(
- size_t limit_bytes,
- int priority_cutoff) {
- DCHECK(IsImplThread());
- PrioritizedResourceManager* contents_texture_manager =
- layer_tree_host_->contents_texture_manager();
-
- ResourceProvider* resource_provider =
- layer_tree_host_impl_->resource_provider();
-
- if (!contents_texture_manager || !resource_provider)
- return false;
-
- return contents_texture_manager->ReduceMemoryOnImplThread(
- limit_bytes, priority_cutoff, resource_provider);
-}
-
bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; }
void SingleThreadProxy::DidActivateSyncTree() {
- // Non-impl-side painting finishes commit in DoCommit. Impl-side painting
- // defers until here to simulate SetNextCommitWaitsForActivation.
- if (layer_tree_host_impl_->settings().impl_side_painting) {
- // This is required because NotifyReadyToActivate gets called immediately
- // after commit since single thread commits directly to the active tree.
- if (scheduler_on_impl_thread_)
- scheduler_on_impl_thread_->SetWaitForReadyToDraw();
+ // This is required because NotifyReadyToActivate gets called immediately
+ // after commit since single thread commits directly to the active tree.
+ if (scheduler_on_impl_thread_)
+ scheduler_on_impl_thread_->SetWaitForReadyToDraw();
- // Synchronously call to CommitComplete. Resetting
- // |commit_blocking_task_runner| would make sure all tasks posted during
- // commit/activation before CommitComplete.
- CommitComplete();
- }
+ // Synchronously call to CommitComplete. Resetting
+ // |commit_blocking_task_runner| would make sure all tasks posted during
+ // commit/activation before CommitComplete.
+ CommitComplete();
+}
- timing_history_.DidActivateSyncTree();
+void SingleThreadProxy::WillPrepareTiles() {
+ DCHECK(Proxy::IsImplThread());
+ if (scheduler_on_impl_thread_)
+ scheduler_on_impl_thread_->WillPrepareTiles();
}
void SingleThreadProxy::DidPrepareTiles() {
- DCHECK(layer_tree_host_impl_->settings().impl_side_painting);
DCHECK(Proxy::IsImplThread());
if (scheduler_on_impl_thread_)
scheduler_on_impl_thread_->DidPrepareTiles();
@@ -586,6 +528,26 @@ void SingleThreadProxy::OnDrawForOutputSurface() {
NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor.";
}
+void SingleThreadProxy::PostFrameTimingEventsOnImplThread(
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
+ scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
+ layer_tree_host_->RecordFrameTimingEvents(composite_events.Pass(),
+ main_frame_events.Pass());
+}
+
+void SingleThreadProxy::LayoutAndUpdateLayers() {
+ if (layer_tree_host_->output_surface_lost()) {
+ RequestNewOutputSurface();
+ // RequestNewOutputSurface could have synchronously created an output
+ // surface, so check again before returning.
+ if (layer_tree_host_->output_surface_lost())
+ return;
+ }
+
+ layer_tree_host_->Layout();
+ layer_tree_host_->UpdateLayers();
+}
+
void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) {
TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately");
DCHECK(Proxy::IsMainThread());
@@ -627,13 +589,11 @@ void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) {
// Finish the impl frame.
{
DebugScopedSetImplThread impl(this);
- if (layer_tree_host_impl_->settings().impl_side_painting) {
- layer_tree_host_impl_->ActivateSyncTree();
- DCHECK(!layer_tree_host_impl_->active_tree()
- ->needs_update_draw_properties());
- layer_tree_host_impl_->PrepareTiles();
- layer_tree_host_impl_->SynchronouslyInitializeAllTiles();
- }
+ layer_tree_host_impl_->ActivateSyncTree();
+ DCHECK(
+ !layer_tree_host_impl_->active_tree()->needs_update_draw_properties());
+ layer_tree_host_impl_->PrepareTiles();
+ layer_tree_host_impl_->SynchronouslyInitializeAllTiles();
DoAnimate();
@@ -704,8 +664,6 @@ DrawResult SingleThreadProxy::DoComposite(LayerTreeHostImpl::FrameData* frame) {
return DRAW_ABORTED_CANT_DRAW;
}
- timing_history_.DidStartDrawing();
-
// TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
// is fixed.
tracked_objects::ScopedTracker tracking_profile2(
@@ -741,7 +699,6 @@ DrawResult SingleThreadProxy::DoComposite(LayerTreeHostImpl::FrameData* frame) {
tracked_objects::ScopedTracker tracking_profile7(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"461509 SingleThreadProxy::DoComposite7"));
- timing_history_.DidFinishDrawing();
}
if (draw_frame) {
@@ -883,24 +840,10 @@ void SingleThreadProxy::DoBeginMainFrame(
layer_tree_host_->AnimateLayers(begin_frame_args.frame_time);
layer_tree_host_->Layout();
- if (PrioritizedResourceManager* contents_texture_manager =
- layer_tree_host_->contents_texture_manager()) {
- contents_texture_manager->UnlinkAndClearEvictedBackings();
- contents_texture_manager->SetMaxMemoryLimitBytes(
- layer_tree_host_impl_->memory_allocation_limit_bytes());
- contents_texture_manager->SetExternalPriorityCutoff(
- layer_tree_host_impl_->memory_allocation_priority_cutoff());
- }
-
- DCHECK(!queue_for_commit_);
- queue_for_commit_ = make_scoped_ptr(new ResourceUpdateQueue);
-
// New commits requested inside UpdateLayers should be respected.
commit_requested_ = false;
- layer_tree_host_->UpdateLayers(queue_for_commit_.get());
-
- timing_history_.DidBeginMainFrame();
+ layer_tree_host_->UpdateLayers();
// TODO(enne): SingleThreadProxy does not support cancelling commits yet,
// search for CommitEarlyOutReason::FINISHED_NO_UPDATES inside
@@ -964,7 +907,6 @@ void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() {
void SingleThreadProxy::ScheduledActionPrepareTiles() {
TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionPrepareTiles");
- DCHECK(layer_tree_host_impl_->settings().impl_side_painting);
DebugScopedSetImplThread impl(this);
layer_tree_host_impl_->PrepareTiles();
}
@@ -973,21 +915,6 @@ void SingleThreadProxy::ScheduledActionInvalidateOutputSurface() {
NOTREACHED();
}
-void SingleThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) {
-}
-
-base::TimeDelta SingleThreadProxy::DrawDurationEstimate() {
- return timing_history_.DrawDurationEstimate();
-}
-
-base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() {
- return timing_history_.BeginMainFrameToCommitDurationEstimate();
-}
-
-base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() {
- return timing_history_.CommitToActivateDurationEstimate();
-}
-
void SingleThreadProxy::DidFinishImplFrame() {
layer_tree_host_impl_->DidFinishImplFrame();
#if DCHECK_IS_ON()
diff --git a/chromium/cc/trees/single_thread_proxy.h b/chromium/cc/trees/single_thread_proxy.h
index 98ac5e5c7d4..8bec2b133f9 100644
--- a/chromium/cc/trees/single_thread_proxy.h
+++ b/chromium/cc/trees/single_thread_proxy.h
@@ -15,7 +15,6 @@
#include "cc/trees/blocking_task_runner.h"
#include "cc/trees/layer_tree_host_impl.h"
#include "cc/trees/proxy.h"
-#include "cc/trees/proxy_timing_history.h"
namespace cc {
@@ -23,7 +22,6 @@ class BeginFrameSource;
class ContextProvider;
class LayerTreeHost;
class LayerTreeHostSingleThreadClient;
-class ResourceUpdateQueue;
class CC_EXPORT SingleThreadProxy : public Proxy,
NON_EXPORTED_BASE(LayerTreeHostImplClient),
@@ -57,7 +55,6 @@ class CC_EXPORT SingleThreadProxy : public Proxy,
void MainThreadHasStoppedFlinging() override {}
void Start() override;
void Stop() override;
- size_t MaxPartialTextureUpdates() const override;
void ForceSerializeOnSwapBuffers() override;
bool SupportsImplScrolling() const override;
bool MainFrameWillHappenForTesting() override;
@@ -76,10 +73,6 @@ class CC_EXPORT SingleThreadProxy : public Proxy,
void ScheduledActionBeginOutputSurfaceCreation() override;
void ScheduledActionPrepareTiles() override;
void ScheduledActionInvalidateOutputSurface() override;
- void DidAnticipatedDrawTimeChange(base::TimeTicks time) override;
- base::TimeDelta DrawDurationEstimate() override;
- base::TimeDelta BeginMainFrameToCommitDurationEstimate() override;
- base::TimeDelta CommitToActivateDurationEstimate() override;
void SendBeginFramesToChildren(const BeginFrameArgs& args) override;
void SendBeginMainFrameNotExpectedSoon() override;
@@ -103,22 +96,26 @@ class CC_EXPORT SingleThreadProxy : public Proxy,
void SetVideoNeedsBeginFrames(bool needs_begin_frames) override;
void PostAnimationEventsToMainThreadOnImplThread(
scoped_ptr<AnimationEventsVector> events) override;
- bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes,
- int priority_cutoff) override;
bool IsInsideDraw() override;
void RenewTreePriority() override {}
void PostDelayedAnimationTaskOnImplThread(const base::Closure& task,
base::TimeDelta delay) override {}
void DidActivateSyncTree() override;
+ void WillPrepareTiles() override;
void DidPrepareTiles() override;
void DidCompletePageScaleAnimationOnImplThread() override;
void OnDrawForOutputSurface() override;
+ void PostFrameTimingEventsOnImplThread(
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
+ scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events)
+ override;
void SetDebugState(const LayerTreeDebugState& debug_state) override {}
void RequestNewOutputSurface();
// Called by the legacy path where RenderWidget does the scheduling.
+ void LayoutAndUpdateLayers();
void CompositeImmediately(base::TimeTicks frame_begin_time);
protected:
@@ -152,11 +149,10 @@ class CC_EXPORT SingleThreadProxy : public Proxy,
RendererCapabilities renderer_capabilities_for_main_thread_;
// Accessed from both threads.
+ scoped_ptr<BeginFrameSource> external_begin_frame_source_;
scoped_ptr<Scheduler> scheduler_on_impl_thread_;
- ProxyTimingHistory timing_history_;
scoped_ptr<BlockingTaskRunner::CapturePostTasks> commit_blocking_task_runner_;
- scoped_ptr<ResourceUpdateQueue> queue_for_commit_;
bool next_frame_is_newly_committed_frame_;
#if DCHECK_IS_ON()
diff --git a/chromium/cc/trees/thread_proxy.cc b/chromium/cc/trees/thread_proxy.cc
index 3010fba95c3..533c4906a01 100644
--- a/chromium/cc/trees/thread_proxy.cc
+++ b/chromium/cc/trees/thread_proxy.cc
@@ -19,16 +19,14 @@
#include "cc/output/output_surface.h"
#include "cc/output/swap_promise.h"
#include "cc/quads/draw_quad.h"
-#include "cc/resources/prioritized_resource_manager.h"
#include "cc/scheduler/commit_earlyout_reason.h"
-#include "cc/scheduler/delay_based_time_source.h"
+#include "cc/scheduler/compositor_timing_history.h"
#include "cc/scheduler/scheduler.h"
#include "cc/trees/blocking_task_runner.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/scoped_abort_remaining_swap_promises.h"
#include "gpu/command_buffer/client/gles2_interface.h"
-#include "ui/gfx/frame_time.h"
namespace cc {
@@ -98,18 +96,12 @@ ThreadProxy::MainThreadOrBlockedMainThread::MainThreadOrBlockedMainThread(
ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {}
-PrioritizedResourceManager*
-ThreadProxy::MainThreadOrBlockedMainThread::contents_texture_manager() {
- return layer_tree_host->contents_texture_manager();
-}
-
ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(
ThreadProxy* proxy,
int layer_tree_host_id,
RenderingStatsInstrumentation* rendering_stats_instrumentation,
scoped_ptr<BeginFrameSource> external_begin_frame_source)
: layer_tree_host_id(layer_tree_host_id),
- contents_texture_manager(NULL),
commit_completion_event(NULL),
completion_event_for_commit_held_on_tree_activation(NULL),
next_frame_is_newly_committed_frame(false),
@@ -120,8 +112,8 @@ ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(
base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)),
base::TimeDelta::FromMilliseconds(
kSmoothnessTakesPriorityExpirationDelay * 1000)),
- timing_history(rendering_stats_instrumentation),
external_begin_frame_source(external_begin_frame_source.Pass()),
+ rendering_stats_instrumentation(rendering_stats_instrumentation),
weak_factory(proxy) {
}
@@ -154,9 +146,9 @@ bool ThreadProxy::IsStarted() const {
}
bool ThreadProxy::CommitToActiveTree() const {
- // With ThreadProxy and impl-side painting, we use a pending tree and activate
- // it once it's ready to draw.
- return !impl().layer_tree_host_impl->settings().impl_side_painting;
+ // With ThreadProxy, we use a pending tree and activate it once it's ready to
+ // draw to allow input to modify the active tree and draw during raster.
+ return false;
}
void ThreadProxy::SetLayerTreeHostClientReady() {
@@ -213,22 +205,6 @@ void ThreadProxy::DidLoseOutputSurface() {
TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface");
DCHECK(IsMainThread());
layer_tree_host()->DidLoseOutputSurface();
-
- {
- DebugScopedSetMainThreadBlocked main_thread_blocked(this);
-
- // Return lost resources to their owners immediately.
- BlockingTaskRunner::CapturePostTasks blocked(
- blocking_main_thread_task_runner());
-
- CompletionEvent completion;
- Proxy::ImplThreadTaskRunner()->PostTask(
- FROM_HERE,
- base::Bind(&ThreadProxy::DeleteContentsTexturesOnImplThread,
- impl_thread_weak_ptr_,
- &completion));
- completion.Wait();
- }
}
void ThreadProxy::RequestNewOutputSurface() {
@@ -422,32 +398,6 @@ void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread(
base::Passed(&events)));
}
-bool ThreadProxy::ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes,
- int priority_cutoff) {
- DCHECK(IsImplThread());
-
- if (!impl().contents_texture_manager)
- return false;
- if (!impl().layer_tree_host_impl->resource_provider())
- return false;
-
- bool reduce_result =
- impl().contents_texture_manager->ReduceMemoryOnImplThread(
- limit_bytes,
- priority_cutoff,
- impl().layer_tree_host_impl->resource_provider());
- if (!reduce_result)
- return false;
-
- // The texture upload queue may reference textures that were just purged,
- // clear them from the queue.
- if (impl().current_resource_update_controller) {
- impl()
- .current_resource_update_controller->DiscardUploadsToEvictedResources();
- }
- return true;
-}
-
bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; }
void ThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) {
@@ -700,14 +650,8 @@ void ThreadProxy::ScheduledActionSendBeginMainFrame() {
impl().layer_tree_host_impl->CurrentBeginFrameArgs();
begin_main_frame_state->scroll_info =
impl().layer_tree_host_impl->ProcessScrollDeltas();
-
- if (!impl().layer_tree_host_impl->settings().impl_side_painting) {
- DCHECK_GT(impl().layer_tree_host_impl->memory_allocation_limit_bytes(), 0u);
- }
begin_main_frame_state->memory_allocation_limit_bytes =
impl().layer_tree_host_impl->memory_allocation_limit_bytes();
- begin_main_frame_state->memory_allocation_priority_cutoff =
- impl().layer_tree_host_impl->memory_allocation_priority_cutoff();
begin_main_frame_state->evicted_ui_resources =
impl().layer_tree_host_impl->EvictedUIResourcesExist();
// TODO(vmpstr): This needs to be fixed if
@@ -721,7 +665,6 @@ void ThreadProxy::ScheduledActionSendBeginMainFrame() {
base::Passed(&begin_main_frame_state)));
devtools_instrumentation::DidRequestMainThreadFrame(
impl().layer_tree_host_id);
- impl().timing_history.DidBeginMainFrame();
}
void ThreadProxy::SendBeginMainFrameNotExpectedSoon() {
@@ -797,17 +740,6 @@ void ThreadProxy::BeginMainFrame(
layer_tree_host()->AnimateLayers(
begin_main_frame_state->begin_frame_args.frame_time);
- // Unlink any backings that the impl thread has evicted, so that we know to
- // re-paint them in UpdateLayers.
- if (blocked_main().contents_texture_manager()) {
- blocked_main().contents_texture_manager()->UnlinkAndClearEvictedBackings();
-
- blocked_main().contents_texture_manager()->SetMaxMemoryLimitBytes(
- begin_main_frame_state->memory_allocation_limit_bytes);
- blocked_main().contents_texture_manager()->SetExternalPriorityCutoff(
- begin_main_frame_state->memory_allocation_priority_cutoff);
- }
-
// Recreate all UI resources if there were evicted UI resources when the impl
// thread initiated the commit.
if (begin_main_frame_state->evicted_ui_resources)
@@ -825,10 +757,7 @@ void ThreadProxy::BeginMainFrame(
main().can_cancel_commit && !begin_main_frame_state->evicted_ui_resources;
main().can_cancel_commit = true;
- scoped_ptr<ResourceUpdateQueue> queue =
- make_scoped_ptr(new ResourceUpdateQueue);
-
- bool updated = layer_tree_host()->UpdateLayers(queue.get());
+ bool updated = layer_tree_host()->UpdateLayers();
layer_tree_host()->WillCommit();
devtools_instrumentation::ScopedCommitTrace commit_task(
@@ -878,11 +807,8 @@ void ThreadProxy::BeginMainFrame(
CompletionEvent completion;
Proxy::ImplThreadTaskRunner()->PostTask(
- FROM_HERE,
- base::Bind(&ThreadProxy::StartCommitOnImplThread,
- impl_thread_weak_ptr_,
- &completion,
- queue.release()));
+ FROM_HERE, base::Bind(&ThreadProxy::StartCommitOnImplThread,
+ impl_thread_weak_ptr_, &completion));
completion.Wait();
}
@@ -896,8 +822,7 @@ void ThreadProxy::BeginMainFrameNotExpectedSoon() {
layer_tree_host()->BeginMainFrameNotExpectedSoon();
}
-void ThreadProxy::StartCommitOnImplThread(CompletionEvent* completion,
- ResourceUpdateQueue* raw_queue) {
+void ThreadProxy::StartCommitOnImplThread(CompletionEvent* completion) {
TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread");
DCHECK(!impl().commit_completion_event);
DCHECK(IsImplThread() && IsMainThreadBlocked());
@@ -914,39 +839,8 @@ void ThreadProxy::StartCommitOnImplThread(CompletionEvent* completion,
// Ideally, we should inform to impl thread when BeginMainFrame is started.
// But, we can avoid a PostTask in here.
impl().scheduler->NotifyBeginMainFrameStarted();
-
- scoped_ptr<ResourceUpdateQueue> queue(raw_queue);
-
- if (impl().contents_texture_manager) {
- DCHECK_EQ(impl().contents_texture_manager,
- blocked_main().contents_texture_manager());
- } else {
- // Cache this pointer that was created on the main thread side to avoid a
- // data race between creating it and using it on the compositor thread.
- impl().contents_texture_manager = blocked_main().contents_texture_manager();
- }
-
- if (impl().contents_texture_manager) {
- if (impl().contents_texture_manager->LinkedEvictedBackingsExist()) {
- // Clear any uploads we were making to textures linked to evicted
- // resources
- queue->ClearUploadsToEvictedResources();
- // Some textures in the layer tree are invalid. Kick off another commit
- // to fill them again.
- SetNeedsCommitOnImplThread();
- }
-
- impl().contents_texture_manager->PushTexturePrioritiesToBackings();
- }
-
impl().commit_completion_event = completion;
- impl().current_resource_update_controller = ResourceUpdateController::Create(
- this,
- Proxy::ImplThreadTaskRunner(),
- queue.Pass(),
- impl().layer_tree_host_impl->resource_provider());
- impl().current_resource_update_controller->PerformMoreUpdates(
- impl().scheduler->AnticipatedDrawTime());
+ impl().scheduler->NotifyReadyToCommit();
}
void ThreadProxy::BeginMainFrameAbortedOnImplThread(
@@ -994,11 +888,6 @@ void ThreadProxy::ScheduledActionCommit() {
DCHECK(IsImplThread());
DCHECK(IsMainThreadBlocked());
DCHECK(impl().commit_completion_event);
- DCHECK(impl().current_resource_update_controller);
-
- // Complete all remaining texture updates.
- impl().current_resource_update_controller->Finalize();
- impl().current_resource_update_controller = nullptr;
blocked_main().main_thread_inside_commit = true;
impl().layer_tree_host_impl->BeginCommit();
@@ -1007,8 +896,7 @@ void ThreadProxy::ScheduledActionCommit() {
impl().layer_tree_host_impl.get());
blocked_main().main_thread_inside_commit = false;
- bool hold_commit = layer_tree_host()->settings().impl_side_painting &&
- blocked_main().commit_waits_for_activation;
+ bool hold_commit = blocked_main().commit_waits_for_activation;
blocked_main().commit_waits_for_activation = false;
if (hold_commit) {
@@ -1024,6 +912,8 @@ void ThreadProxy::ScheduledActionCommit() {
impl().commit_completion_event = NULL;
}
+ impl().scheduler->DidCommit();
+
// Delay this step until afer the main thread has been released as it's
// often a good bit of work to update the tree and prepare the new frame.
impl().layer_tree_host_impl->CommitComplete();
@@ -1031,8 +921,6 @@ void ThreadProxy::ScheduledActionCommit() {
SetInputThrottledUntilCommitOnImplThread(false);
impl().next_frame_is_newly_committed_frame = true;
-
- impl().timing_history.DidCommit();
}
void ThreadProxy::ScheduledActionActivateSyncTree() {
@@ -1056,7 +944,6 @@ DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) {
DCHECK(IsImplThread());
DCHECK(impl().layer_tree_host_impl.get());
- impl().timing_history.DidStartDrawing();
base::AutoReset<bool> mark_inside(&impl().inside_draw, true);
if (impl().layer_tree_host_impl->pending_tree()) {
@@ -1108,16 +995,12 @@ DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) {
base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_));
}
- if (result == DRAW_SUCCESS)
- impl().timing_history.DidFinishDrawing();
-
DCHECK_NE(INVALID_RESULT, result);
return result;
}
void ThreadProxy::ScheduledActionPrepareTiles() {
TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionPrepareTiles");
- DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting);
impl().layer_tree_host_impl->PrepareTiles();
}
@@ -1145,23 +1028,6 @@ void ThreadProxy::ScheduledActionInvalidateOutputSurface() {
impl().layer_tree_host_impl->output_surface()->Invalidate();
}
-void ThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) {
- if (impl().current_resource_update_controller)
- impl().current_resource_update_controller->PerformMoreUpdates(time);
-}
-
-base::TimeDelta ThreadProxy::DrawDurationEstimate() {
- return impl().timing_history.DrawDurationEstimate();
-}
-
-base::TimeDelta ThreadProxy::BeginMainFrameToCommitDurationEstimate() {
- return impl().timing_history.BeginMainFrameToCommitDurationEstimate();
-}
-
-base::TimeDelta ThreadProxy::CommitToActivateDurationEstimate() {
- return impl().timing_history.CommitToActivateDurationEstimate();
-}
-
void ThreadProxy::DidFinishImplFrame() {
impl().layer_tree_host_impl->DidFinishImplFrame();
}
@@ -1175,11 +1041,6 @@ void ThreadProxy::SetAuthoritativeVSyncInterval(
NOTREACHED() << "Only used by SingleThreadProxy";
}
-void ThreadProxy::ReadyToFinalizeTextureUpdates() {
- DCHECK(IsImplThread());
- impl().scheduler->NotifyReadyToCommit();
-}
-
void ThreadProxy::DidCommitAndDrawFrame() {
DCHECK(IsMainThread());
layer_tree_host()->DidCommitAndDrawFrame();
@@ -1201,29 +1062,23 @@ void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) {
DCHECK(IsImplThread());
impl().layer_tree_host_impl =
layer_tree_host()->CreateLayerTreeHostImpl(this);
+
SchedulerSettings scheduler_settings(
layer_tree_host()->settings().ToSchedulerSettings());
+
+ scoped_ptr<CompositorTimingHistory> compositor_timing_history(
+ new CompositorTimingHistory(impl().rendering_stats_instrumentation));
+
impl().scheduler = Scheduler::Create(
- this,
- scheduler_settings,
- impl().layer_tree_host_id,
- ImplThreadTaskRunner(),
- impl().external_begin_frame_source.Pass());
+ this, scheduler_settings, impl().layer_tree_host_id,
+ ImplThreadTaskRunner(), impl().external_begin_frame_source.get(),
+ compositor_timing_history.Pass());
+
impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible());
impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr();
completion->Signal();
}
-void ThreadProxy::DeleteContentsTexturesOnImplThread(
- CompletionEvent* completion) {
- TRACE_EVENT0("cc", "ThreadProxy::DeleteContentsTexturesOnImplThread");
- DCHECK(IsImplThread());
- DCHECK(IsMainThreadBlocked());
- layer_tree_host()->DeleteContentsTexturesOnImplThread(
- impl().layer_tree_host_impl->resource_provider());
- completion->Signal();
-}
-
void ThreadProxy::InitializeOutputSurfaceOnImplThread(
scoped_ptr<OutputSurface> output_surface) {
TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread");
@@ -1264,27 +1119,19 @@ void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) {
TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread");
DCHECK(IsImplThread());
DCHECK(IsMainThreadBlocked());
- layer_tree_host()->DeleteContentsTexturesOnImplThread(
- impl().layer_tree_host_impl->resource_provider());
- impl().current_resource_update_controller = nullptr;
impl().scheduler = nullptr;
+ impl().external_begin_frame_source = nullptr;
impl().layer_tree_host_impl = nullptr;
impl().weak_factory.InvalidateWeakPtrs();
// We need to explicitly shutdown the notifier to destroy any weakptrs it is
// holding while still on the compositor thread. This also ensures any
// callbacks holding a ThreadProxy pointer are cancelled.
impl().smoothness_priority_expiration_notifier.Shutdown();
- impl().contents_texture_manager = NULL;
completion->Signal();
}
-size_t ThreadProxy::MaxPartialTextureUpdates() const {
- return ResourceUpdateController::MaxPartialTextureUpdates();
-}
-
ThreadProxy::BeginMainFrameAndCommitState::BeginMainFrameAndCommitState()
: memory_allocation_limit_bytes(0),
- memory_allocation_priority_cutoff(0),
evicted_ui_resources(false) {}
ThreadProxy::BeginMainFrameAndCommitState::~BeginMainFrameAndCommitState() {}
@@ -1340,10 +1187,9 @@ void ThreadProxy::RenewTreePriority() {
if (impl().smoothness_priority_expiration_notifier.HasPendingNotification())
priority = SMOOTHNESS_TAKES_PRIORITY;
- // New content always takes priority when the active tree has
- // evicted resources or there is an invalid viewport size.
- if (impl().layer_tree_host_impl->active_tree()->ContentsTexturesPurged() ||
- impl().layer_tree_host_impl->active_tree()->ViewportSizeInvalid() ||
+ // New content always takes priority when there is an invalid viewport size or
+ // ui resources have been evicted.
+ if (impl().layer_tree_host_impl->active_tree()->ViewportSizeInvalid() ||
impl().layer_tree_host_impl->EvictedUIResourcesExist() ||
impl().input_throttled_until_commit) {
// Once we enter NEW_CONTENTS_TAKES_PRIORITY mode, visible tiles on active
@@ -1386,16 +1232,19 @@ void ThreadProxy::DidActivateSyncTree() {
if (impl().completion_event_for_commit_held_on_tree_activation) {
TRACE_EVENT_INSTANT0(
"cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD);
- DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting);
impl().completion_event_for_commit_held_on_tree_activation->Signal();
impl().completion_event_for_commit_held_on_tree_activation = NULL;
}
- impl().timing_history.DidActivateSyncTree();
impl().last_processed_begin_main_frame_args =
impl().last_begin_main_frame_args;
}
+void ThreadProxy::WillPrepareTiles() {
+ DCHECK(IsImplThread());
+ impl().scheduler->WillPrepareTiles();
+}
+
void ThreadProxy::DidPrepareTiles() {
DCHECK(IsImplThread());
impl().scheduler->DidPrepareTiles();
@@ -1413,4 +1262,23 @@ void ThreadProxy::OnDrawForOutputSurface() {
impl().scheduler->OnDrawForOutputSurface();
}
+void ThreadProxy::PostFrameTimingEventsOnImplThread(
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
+ scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
+ DCHECK(IsImplThread());
+ Proxy::MainThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&ThreadProxy::PostFrameTimingEvents, main_thread_weak_ptr_,
+ base::Passed(composite_events.Pass()),
+ base::Passed(main_frame_events.Pass())));
+}
+
+void ThreadProxy::PostFrameTimingEvents(
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
+ scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
+ DCHECK(IsMainThread());
+ layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(),
+ main_frame_events.Pass());
+}
+
} // namespace cc
diff --git a/chromium/cc/trees/thread_proxy.h b/chromium/cc/trees/thread_proxy.h
index f4f1f283c77..ca76e42669b 100644
--- a/chromium/cc/trees/thread_proxy.h
+++ b/chromium/cc/trees/thread_proxy.h
@@ -13,12 +13,10 @@
#include "cc/animation/animation_events.h"
#include "cc/base/completion_event.h"
#include "cc/base/delayed_unique_notifier.h"
-#include "cc/resources/resource_update_controller.h"
#include "cc/scheduler/commit_earlyout_reason.h"
#include "cc/scheduler/scheduler.h"
#include "cc/trees/layer_tree_host_impl.h"
#include "cc/trees/proxy.h"
-#include "cc/trees/proxy_timing_history.h"
namespace base {
class SingleThreadTaskRunner;
@@ -30,15 +28,12 @@ class BeginFrameSource;
class ContextProvider;
class InputHandlerClient;
class LayerTreeHost;
-class PrioritizedResourceManager;
-class ResourceUpdateQueue;
class Scheduler;
class ScopedThreadProxy;
class CC_EXPORT ThreadProxy : public Proxy,
- NON_EXPORTED_BASE(LayerTreeHostImplClient),
- NON_EXPORTED_BASE(SchedulerClient),
- NON_EXPORTED_BASE(ResourceUpdateControllerClient) {
+ NON_EXPORTED_BASE(LayerTreeHostImplClient),
+ NON_EXPORTED_BASE(SchedulerClient) {
public:
static scoped_ptr<Proxy> Create(
LayerTreeHost* layer_tree_host,
@@ -56,7 +51,6 @@ class CC_EXPORT ThreadProxy : public Proxy,
BeginFrameArgs begin_frame_args;
scoped_ptr<ScrollAndScaleSet> scroll_info;
size_t memory_allocation_limit_bytes;
- int memory_allocation_priority_cutoff;
bool evicted_ui_resources;
};
@@ -88,8 +82,6 @@ class CC_EXPORT ThreadProxy : public Proxy,
explicit MainThreadOrBlockedMainThread(LayerTreeHost* host);
~MainThreadOrBlockedMainThread();
- PrioritizedResourceManager* contents_texture_manager();
-
LayerTreeHost* layer_tree_host;
bool commit_waits_for_activation;
bool main_thread_inside_commit;
@@ -105,10 +97,6 @@ class CC_EXPORT ThreadProxy : public Proxy,
const int layer_tree_host_id;
- // Copy of the main thread side contents texture manager for work
- // that needs to be done on the compositor thread.
- PrioritizedResourceManager* contents_texture_manager;
-
scoped_ptr<Scheduler> scheduler;
// Set when the main thread is waiting on a
@@ -121,8 +109,6 @@ class CC_EXPORT ThreadProxy : public Proxy,
// Set when the main thread is waiting on a pending tree activation.
CompletionEvent* completion_event_for_commit_held_on_tree_activation;
- scoped_ptr<ResourceUpdateController> current_resource_update_controller;
-
// Set when the next draw should post DidCommitAndDrawFrame to the main
// thread.
bool next_frame_is_newly_committed_frame;
@@ -139,10 +125,10 @@ class CC_EXPORT ThreadProxy : public Proxy,
DelayedUniqueNotifier smoothness_priority_expiration_notifier;
- ProxyTimingHistory timing_history;
-
scoped_ptr<BeginFrameSource> external_begin_frame_source;
+ RenderingStatsInstrumentation* rendering_stats_instrumentation;
+
// Values used to keep track of frame durations. Used only in frame timing.
BeginFrameArgs last_begin_main_frame_args;
BeginFrameArgs last_processed_begin_main_frame_args;
@@ -176,7 +162,6 @@ class CC_EXPORT ThreadProxy : public Proxy,
void MainThreadHasStoppedFlinging() override;
void Start() override;
void Stop() override;
- size_t MaxPartialTextureUpdates() const override;
void ForceSerializeOnSwapBuffers() override;
bool SupportsImplScrolling() const override;
void SetDebugState(const LayerTreeDebugState& debug_state) override;
@@ -207,16 +192,20 @@ class CC_EXPORT ThreadProxy : public Proxy,
void SetVideoNeedsBeginFrames(bool needs_begin_frames) override;
void PostAnimationEventsToMainThreadOnImplThread(
scoped_ptr<AnimationEventsVector> queue) override;
- bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes,
- int priority_cutoff) override;
bool IsInsideDraw() override;
void RenewTreePriority() override;
void PostDelayedAnimationTaskOnImplThread(const base::Closure& task,
base::TimeDelta delay) override;
void DidActivateSyncTree() override;
+ void WillPrepareTiles() override;
void DidPrepareTiles() override;
void DidCompletePageScaleAnimationOnImplThread() override;
void OnDrawForOutputSurface() override;
+ // This should only be called by LayerTreeHostImpl::PostFrameTimingEvents.
+ void PostFrameTimingEventsOnImplThread(
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
+ scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events)
+ override;
// SchedulerClient implementation
void WillBeginImplFrame(const BeginFrameArgs& args) override;
@@ -230,16 +219,9 @@ class CC_EXPORT ThreadProxy : public Proxy,
void ScheduledActionBeginOutputSurfaceCreation() override;
void ScheduledActionPrepareTiles() override;
void ScheduledActionInvalidateOutputSurface() override;
- void DidAnticipatedDrawTimeChange(base::TimeTicks time) override;
- base::TimeDelta DrawDurationEstimate() override;
- base::TimeDelta BeginMainFrameToCommitDurationEstimate() override;
- base::TimeDelta CommitToActivateDurationEstimate() override;
void SendBeginFramesToChildren(const BeginFrameArgs& args) override;
void SendBeginMainFrameNotExpectedSoon() override;
- // ResourceUpdateControllerClient implementation
- void ReadyToFinalizeTextureUpdates() override;
-
protected:
ThreadProxy(
LayerTreeHost* layer_tree_host,
@@ -267,8 +249,7 @@ class CC_EXPORT ThreadProxy : public Proxy,
// Called on impl thread.
struct SchedulerStateRequest;
- void StartCommitOnImplThread(CompletionEvent* completion,
- ResourceUpdateQueue* queue);
+ void StartCommitOnImplThread(CompletionEvent* completion);
void BeginMainFrameAbortedOnImplThread(CommitEarlyOutReason reason);
void FinishAllRenderingOnImplThread(CompletionEvent* completion);
void InitializeImplOnImplThread(CompletionEvent* completion);
@@ -292,6 +273,9 @@ class CC_EXPORT ThreadProxy : public Proxy,
void SetInputThrottledUntilCommitOnImplThread(bool is_throttled);
void SetDebugStateOnImplThread(const LayerTreeDebugState& debug_state);
void SetDeferCommitsOnImplThread(bool defer_commits) const;
+ void PostFrameTimingEvents(
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
+ scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events);
LayerTreeHost* layer_tree_host();
const LayerTreeHost* layer_tree_host() const;
diff --git a/chromium/cc/trees/tree_synchronizer.cc b/chromium/cc/trees/tree_synchronizer.cc
index 8fe23077a41..3646dcaa4f7 100644
--- a/chromium/cc/trees/tree_synchronizer.cc
+++ b/chromium/cc/trees/tree_synchronizer.cc
@@ -188,7 +188,7 @@ template <typename LayerType>
void TreeSynchronizer::PushPropertiesInternal(
LayerType* layer,
LayerImpl* layer_impl,
- size_t* num_dependents_need_push_properties_for_parent) {
+ int* num_dependents_need_push_properties_for_parent) {
if (!layer) {
DCHECK(!layer_impl);
return;
@@ -205,7 +205,7 @@ void TreeSynchronizer::PushPropertiesInternal(
else if (layer->ToScrollbarLayer())
layer->ToScrollbarLayer()->PushScrollClipPropertiesTo(layer_impl);
- size_t num_dependents_need_push_properties = 0;
+ int num_dependents_need_push_properties = 0;
if (recurse_on_children_and_dependents) {
PushPropertiesInternal(layer->mask_layer(),
layer_impl->mask_layer(),
@@ -295,7 +295,7 @@ static void CheckScrollAndClipPointersRecursive(Layer* layer,
void TreeSynchronizer::PushProperties(Layer* layer,
LayerImpl* layer_impl) {
- size_t num_dependents_need_push_properties = 0;
+ int num_dependents_need_push_properties = 0;
PushPropertiesInternal(
layer, layer_impl, &num_dependents_need_push_properties);
#if DCHECK_IS_ON()
@@ -304,7 +304,7 @@ void TreeSynchronizer::PushProperties(Layer* layer,
}
void TreeSynchronizer::PushProperties(LayerImpl* layer, LayerImpl* layer_impl) {
- size_t num_dependents_need_push_properties = 0;
+ int num_dependents_need_push_properties = 0;
PushPropertiesInternal(
layer, layer_impl, &num_dependents_need_push_properties);
}
diff --git a/chromium/cc/trees/tree_synchronizer.h b/chromium/cc/trees/tree_synchronizer.h
index e7b2e2bdeda..ef13b1dba81 100644
--- a/chromium/cc/trees/tree_synchronizer.h
+++ b/chromium/cc/trees/tree_synchronizer.h
@@ -42,7 +42,7 @@ class CC_EXPORT TreeSynchronizer {
static void PushPropertiesInternal(
LayerType* layer,
LayerImpl* layer_impl,
- size_t* num_dependents_need_push_properties_for_parent);
+ int* num_dependents_need_push_properties_for_parent);
DISALLOW_COPY_AND_ASSIGN(TreeSynchronizer);
};
diff --git a/chromium/cc/trees/tree_synchronizer_unittest.cc b/chromium/cc/trees/tree_synchronizer_unittest.cc
index a17bec8e53b..466a7017a72 100644
--- a/chromium/cc/trees/tree_synchronizer_unittest.cc
+++ b/chromium/cc/trees/tree_synchronizer_unittest.cc
@@ -18,6 +18,7 @@
#include "cc/test/fake_layer_tree_host.h"
#include "cc/test/fake_rendering_stats_instrumentation.h"
#include "cc/test/test_shared_bitmap_manager.h"
+#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/proxy.h"
#include "cc/trees/single_thread_proxy.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -51,8 +52,10 @@ class MockLayerImpl : public LayerImpl {
class MockLayer : public Layer {
public:
static scoped_refptr<MockLayer> Create(
+ const LayerSettings& settings,
std::vector<int>* layer_impl_destruction_list) {
- return make_scoped_refptr(new MockLayer(layer_impl_destruction_list));
+ return make_scoped_refptr(
+ new MockLayer(settings, layer_impl_destruction_list));
}
scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override {
@@ -67,8 +70,10 @@ class MockLayer : public Layer {
}
private:
- explicit MockLayer(std::vector<int>* layer_impl_destruction_list)
- : Layer(), layer_impl_destruction_list_(layer_impl_destruction_list) {}
+ explicit MockLayer(const LayerSettings& settings,
+ std::vector<int>* layer_impl_destruction_list)
+ : Layer(settings),
+ layer_impl_destruction_list_(layer_impl_destruction_list) {}
~MockLayer() override {}
std::vector<int>* layer_impl_destruction_list_;
@@ -191,11 +196,13 @@ class TreeSynchronizerTest : public testing::Test {
public:
TreeSynchronizerTest()
: client_(FakeLayerTreeHostClient::DIRECT_3D),
- host_(FakeLayerTreeHost::Create(&client_)) {}
+ host_(FakeLayerTreeHost::Create(&client_, &task_graph_runner_)) {}
protected:
FakeLayerTreeHostClient client_;
+ TestTaskGraphRunner task_graph_runner_;
scoped_ptr<FakeLayerTreeHost> host_;
+ LayerSettings layer_settings_;
};
// Attempts to synchronizes a null tree. This should not crash, and should
@@ -211,9 +218,9 @@ TEST_F(TreeSynchronizerTest, SyncNullTree) {
// Constructs a very simple tree and synchronizes it without trying to reuse any
// preexisting layers.
TEST_F(TreeSynchronizerTest, SyncSimpleTreeFromEmpty) {
- scoped_refptr<Layer> layer_tree_root = Layer::Create();
- layer_tree_root->AddChild(Layer::Create());
- layer_tree_root->AddChild(Layer::Create());
+ scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_);
+ layer_tree_root->AddChild(Layer::Create(layer_settings_));
+ layer_tree_root->AddChild(Layer::Create(layer_settings_));
host_->SetRootLayer(layer_tree_root);
@@ -232,9 +239,11 @@ TEST_F(TreeSynchronizerTest, SyncSimpleTreeReusingLayers) {
std::vector<int> layer_impl_destruction_list;
scoped_refptr<Layer> layer_tree_root =
- MockLayer::Create(&layer_impl_destruction_list);
- layer_tree_root->AddChild(MockLayer::Create(&layer_impl_destruction_list));
- layer_tree_root->AddChild(MockLayer::Create(&layer_impl_destruction_list));
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list);
+ layer_tree_root->AddChild(
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list));
+ layer_tree_root->AddChild(
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list));
host_->SetRootLayer(layer_tree_root);
@@ -250,8 +259,8 @@ TEST_F(TreeSynchronizerTest, SyncSimpleTreeReusingLayers) {
layer_impl_tree_root.get());
// Add a new layer to the Layer side
- layer_tree_root->children()[0]->
- AddChild(MockLayer::Create(&layer_impl_destruction_list));
+ layer_tree_root->children()[0]->AddChild(
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list));
// Remove one.
layer_tree_root->children()[1]->RemoveFromParent();
int second_layer_impl_id = layer_impl_tree_root->children()[1]->id();
@@ -278,9 +287,11 @@ TEST_F(TreeSynchronizerTest, SyncSimpleTreeAndTrackStackingOrderChange) {
// Set up the tree and sync once. child2 needs to be synced here, too, even
// though we remove it to set up the intended scenario.
scoped_refptr<Layer> layer_tree_root =
- MockLayer::Create(&layer_impl_destruction_list);
- scoped_refptr<Layer> child2 = MockLayer::Create(&layer_impl_destruction_list);
- layer_tree_root->AddChild(MockLayer::Create(&layer_impl_destruction_list));
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list);
+ scoped_refptr<Layer> child2 =
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list);
+ layer_tree_root->AddChild(
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list));
layer_tree_root->AddChild(child2);
host_->SetRootLayer(layer_tree_root);
@@ -319,9 +330,9 @@ TEST_F(TreeSynchronizerTest, SyncSimpleTreeAndTrackStackingOrderChange) {
}
TEST_F(TreeSynchronizerTest, SyncSimpleTreeAndProperties) {
- scoped_refptr<Layer> layer_tree_root = Layer::Create();
- layer_tree_root->AddChild(Layer::Create());
- layer_tree_root->AddChild(Layer::Create());
+ scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_);
+ layer_tree_root->AddChild(Layer::Create(layer_settings_));
+ layer_tree_root->AddChild(Layer::Create(layer_settings_));
host_->SetRootLayer(layer_tree_root);
@@ -372,17 +383,21 @@ TEST_F(TreeSynchronizerTest, ReuseLayerImplsAfterStructuralChange) {
// |
// +--- D
scoped_refptr<Layer> layer_tree_root =
- MockLayer::Create(&layer_impl_destruction_list);
- layer_tree_root->AddChild(MockLayer::Create(&layer_impl_destruction_list));
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list);
+ layer_tree_root->AddChild(
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list));
scoped_refptr<Layer> layer_a = layer_tree_root->children()[0].get();
- layer_a->AddChild(MockLayer::Create(&layer_impl_destruction_list));
+ layer_a->AddChild(
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list));
scoped_refptr<Layer> layer_b = layer_a->children()[0].get();
- layer_b->AddChild(MockLayer::Create(&layer_impl_destruction_list));
+ layer_b->AddChild(
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list));
scoped_refptr<Layer> layer_c = layer_b->children()[0].get();
- layer_b->AddChild(MockLayer::Create(&layer_impl_destruction_list));
+ layer_b->AddChild(
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list));
scoped_refptr<Layer> layer_d = layer_b->children()[1].get();
host_->SetRootLayer(layer_tree_root);
@@ -431,11 +446,11 @@ TEST_F(TreeSynchronizerTest, SyncSimpleTreeThenDestroy) {
std::vector<int> layer_impl_destruction_list;
scoped_refptr<Layer> old_layer_tree_root =
- MockLayer::Create(&layer_impl_destruction_list);
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list);
old_layer_tree_root->AddChild(
- MockLayer::Create(&layer_impl_destruction_list));
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list));
old_layer_tree_root->AddChild(
- MockLayer::Create(&layer_impl_destruction_list));
+ MockLayer::Create(layer_settings_, &layer_impl_destruction_list));
host_->SetRootLayer(old_layer_tree_root);
@@ -459,7 +474,7 @@ TEST_F(TreeSynchronizerTest, SyncSimpleTreeThenDestroy) {
// Synchronize again. After the sync all LayerImpls from the old tree should
// be deleted.
- scoped_refptr<Layer> new_layer_tree_root = Layer::Create();
+ scoped_refptr<Layer> new_layer_tree_root = Layer::Create(layer_settings_);
host_->SetRootLayer(new_layer_tree_root);
layer_impl_tree_root =
TreeSynchronizer::SynchronizeTrees(new_layer_tree_root.get(),
@@ -487,22 +502,22 @@ TEST_F(TreeSynchronizerTest, SyncSimpleTreeThenDestroy) {
// Constructs+syncs a tree with mask, replica, and replica mask layers.
TEST_F(TreeSynchronizerTest, SyncMaskReplicaAndReplicaMaskLayers) {
- scoped_refptr<Layer> layer_tree_root = Layer::Create();
- layer_tree_root->AddChild(Layer::Create());
- layer_tree_root->AddChild(Layer::Create());
- layer_tree_root->AddChild(Layer::Create());
+ scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_);
+ layer_tree_root->AddChild(Layer::Create(layer_settings_));
+ layer_tree_root->AddChild(Layer::Create(layer_settings_));
+ layer_tree_root->AddChild(Layer::Create(layer_settings_));
// First child gets a mask layer.
- scoped_refptr<Layer> mask_layer = Layer::Create();
+ scoped_refptr<Layer> mask_layer = Layer::Create(layer_settings_);
layer_tree_root->children()[0]->SetMaskLayer(mask_layer.get());
// Second child gets a replica layer.
- scoped_refptr<Layer> replica_layer = Layer::Create();
+ scoped_refptr<Layer> replica_layer = Layer::Create(layer_settings_);
layer_tree_root->children()[1]->SetReplicaLayer(replica_layer.get());
// Third child gets a replica layer with a mask layer.
- scoped_refptr<Layer> replica_layer_with_mask = Layer::Create();
- scoped_refptr<Layer> replica_mask_layer = Layer::Create();
+ scoped_refptr<Layer> replica_layer_with_mask = Layer::Create(layer_settings_);
+ scoped_refptr<Layer> replica_mask_layer = Layer::Create(layer_settings_);
replica_layer_with_mask->SetMaskLayer(replica_mask_layer.get());
layer_tree_root->children()[2]->
SetReplicaLayer(replica_layer_with_mask.get());
@@ -553,13 +568,13 @@ TEST_F(TreeSynchronizerTest, SynchronizeAnimations) {
FakeProxy proxy;
DebugScopedSetImplThread impl(&proxy);
FakeRenderingStatsInstrumentation stats_instrumentation;
- scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
- new TestSharedBitmapManager());
- scoped_ptr<LayerTreeHostImpl> host_impl =
- LayerTreeHostImpl::Create(settings, NULL, &proxy, &stats_instrumentation,
- shared_bitmap_manager.get(), NULL, NULL, 0);
+ TestSharedBitmapManager shared_bitmap_manager;
+ TestTaskGraphRunner task_graph_runner;
+ scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create(
+ settings, nullptr, &proxy, &stats_instrumentation, &shared_bitmap_manager,
+ nullptr, &task_graph_runner, 0);
- scoped_refptr<Layer> layer_tree_root = Layer::Create();
+ scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_);
host_->SetRootLayer(layer_tree_root);
layer_tree_root->SetLayerAnimationControllerForTest(
@@ -587,17 +602,17 @@ TEST_F(TreeSynchronizerTest, SynchronizeScrollParent) {
FakeProxy proxy;
DebugScopedSetImplThread impl(&proxy);
FakeRenderingStatsInstrumentation stats_instrumentation;
- scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
- new TestSharedBitmapManager());
- scoped_ptr<LayerTreeHostImpl> host_impl =
- LayerTreeHostImpl::Create(settings, NULL, &proxy, &stats_instrumentation,
- shared_bitmap_manager.get(), NULL, NULL, 0);
-
- scoped_refptr<Layer> layer_tree_root = Layer::Create();
- scoped_refptr<Layer> scroll_parent = Layer::Create();
+ TestSharedBitmapManager shared_bitmap_manager;
+ TestTaskGraphRunner task_graph_runner;
+ scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create(
+ settings, nullptr, &proxy, &stats_instrumentation, &shared_bitmap_manager,
+ nullptr, &task_graph_runner, 0);
+
+ scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_);
+ scoped_refptr<Layer> scroll_parent = Layer::Create(layer_settings_);
layer_tree_root->AddChild(scroll_parent);
- layer_tree_root->AddChild(Layer::Create());
- layer_tree_root->AddChild(Layer::Create());
+ layer_tree_root->AddChild(Layer::Create(layer_settings_));
+ layer_tree_root->AddChild(Layer::Create(layer_settings_));
host_->SetRootLayer(layer_tree_root);
@@ -633,7 +648,7 @@ TEST_F(TreeSynchronizerTest, SynchronizeScrollParent) {
}
// Add an additional scroll layer.
- scoped_refptr<Layer> additional_scroll_child = Layer::Create();
+ scoped_refptr<Layer> additional_scroll_child = Layer::Create(layer_settings_);
layer_tree_root->AddChild(additional_scroll_child);
additional_scroll_child->SetScrollParent(scroll_parent.get());
layer_impl_tree_root =
@@ -655,17 +670,17 @@ TEST_F(TreeSynchronizerTest, SynchronizeClipParent) {
FakeProxy proxy;
DebugScopedSetImplThread impl(&proxy);
FakeRenderingStatsInstrumentation stats_instrumentation;
- scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
- new TestSharedBitmapManager());
- scoped_ptr<LayerTreeHostImpl> host_impl =
- LayerTreeHostImpl::Create(settings, NULL, &proxy, &stats_instrumentation,
- shared_bitmap_manager.get(), NULL, NULL, 0);
-
- scoped_refptr<Layer> layer_tree_root = Layer::Create();
- scoped_refptr<Layer> clip_parent = Layer::Create();
- scoped_refptr<Layer> intervening = Layer::Create();
- scoped_refptr<Layer> clip_child1 = Layer::Create();
- scoped_refptr<Layer> clip_child2 = Layer::Create();
+ TestSharedBitmapManager shared_bitmap_manager;
+ TestTaskGraphRunner task_graph_runner;
+ scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create(
+ settings, nullptr, &proxy, &stats_instrumentation, &shared_bitmap_manager,
+ nullptr, &task_graph_runner, 0);
+
+ scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_);
+ scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings_);
+ scoped_refptr<Layer> intervening = Layer::Create(layer_settings_);
+ scoped_refptr<Layer> clip_child1 = Layer::Create(layer_settings_);
+ scoped_refptr<Layer> clip_child2 = Layer::Create(layer_settings_);
layer_tree_root->AddChild(clip_parent);
clip_parent->AddChild(intervening);
intervening->AddChild(clip_child1);
@@ -701,7 +716,7 @@ TEST_F(TreeSynchronizerTest, SynchronizeClipParent) {
host_impl->active_tree());
// Add an additional clip child.
- scoped_refptr<Layer> additional_clip_child = Layer::Create();
+ scoped_refptr<Layer> additional_clip_child = Layer::Create(layer_settings_);
intervening->AddChild(additional_clip_child);
additional_clip_child->SetClipParent(clip_parent.get());
layer_impl_tree_root =