summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvollick <vollick@chromium.org>2016-01-22 11:13:29 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-22 19:15:16 +0000
commitfd6e4f4a7a3f166de9d2fbc89770b4f2eb90272f (patch)
tree1f8fca4ee6c31d1247fe57532f1abfba3a0a3f52
parent3537f56b3e87d722b1e7caa3d996874f3199f750 (diff)
downloadchromium_src-fd6e4f4a7a3f166de9d2fbc89770b4f2eb90272f.zip
chromium_src-fd6e4f4a7a3f166de9d2fbc89770b4f2eb90272f.tar.gz
chromium_src-fd6e4f4a7a3f166de9d2fbc89770b4f2eb90272f.tar.bz2
compositor-worker: Remove code from cc_blink
In this CL, the compositor worker code in cc_blink has been removed, mostly by moving it into Source/platform/graphics, a more natural home for compositor-related stuff. An additional benefit is that much of the code in public/platform/ is unnecessary now. It was there only so that it could be implemented by classes in cc_blink. There was a wrinkle when moving the test: the cc test machinery expected a base::MessageLoop to have been constructed to work. This violated the current DEPS rules for platform/graphics. I did try to remove this dependency, but the code is quite coupled and the refactor was not only large, it resulted in more complex code in cc. Since platform is in general allowed to talk to base, it seemed more reasonable to update the DEPS in platform/graphics/ to allow the use of message_loop.h in tests. BUG=430155 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1599673002 Cr-Commit-Position: refs/heads/master@{#371006}
-rw-r--r--cc/animation/layer_tree_mutation.h63
-rw-r--r--cc/animation/mutable_properties.h16
-rw-r--r--cc/blink/BUILD.gn5
-rw-r--r--cc/blink/cc_blink.gyp4
-rw-r--r--cc/blink/cc_blink_tests.gyp1
-rw-r--r--cc/blink/web_compositor_mutable_state_impl.cc72
-rw-r--r--cc/blink/web_compositor_mutable_state_impl.h46
-rw-r--r--cc/blink/web_compositor_mutable_state_impl_unittest.cc172
-rw-r--r--cc/blink/web_compositor_mutable_state_provider_impl.cc34
-rw-r--r--cc/blink/web_compositor_mutable_state_provider_impl.h44
-rw-r--r--cc/blink/web_layer_impl.cc31
-rw-r--r--cc/layers/layer.cc2
-rw-r--r--cc/layers/layer_impl.cc4
-rw-r--r--cc/layers/layer_impl_unittest.cc4
-rw-r--r--cc/layers/layer_unittest.cc8
-rw-r--r--cc/trees/layer_tree_impl.cc4
-rw-r--r--third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp1
-rw-r--r--third_party/WebKit/Source/core/dom/CompositorProxiedPropertySet.cpp8
-rw-r--r--third_party/WebKit/Source/core/dom/CompositorProxiedPropertySet.h4
-rw-r--r--third_party/WebKit/Source/core/dom/CompositorProxy.cpp44
-rw-r--r--third_party/WebKit/Source/core/dom/Element.cpp5
-rw-r--r--third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp10
-rw-r--r--third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp6
-rw-r--r--third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp4
-rw-r--r--third_party/WebKit/Source/platform/BUILD.gn4
-rw-r--r--third_party/WebKit/Source/platform/blink_platform.gypi7
-rw-r--r--third_party/WebKit/Source/platform/blink_platform_tests.gyp4
-rw-r--r--third_party/WebKit/Source/platform/graphics/CompositorMutableProperties.h16
-rw-r--r--third_party/WebKit/Source/platform/graphics/CompositorMutableState.cpp78
-rw-r--r--third_party/WebKit/Source/platform/graphics/CompositorMutableState.h46
-rw-r--r--third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.cpp43
-rw-r--r--third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.h37
-rw-r--r--third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp159
-rw-r--r--third_party/WebKit/Source/platform/graphics/CompositorMutation.h61
-rw-r--r--third_party/WebKit/Source/platform/graphics/DEPS1
-rw-r--r--third_party/WebKit/Source/web/tests/CompositorWorkerTest.cpp14
-rw-r--r--third_party/WebKit/public/platform/WebCompositorMutableProperties.h24
-rw-r--r--third_party/WebKit/public/platform/WebCompositorMutableState.h34
-rw-r--r--third_party/WebKit/public/platform/WebCompositorMutableStateProvider.h28
39 files changed, 524 insertions, 624 deletions
diff --git a/cc/animation/layer_tree_mutation.h b/cc/animation/layer_tree_mutation.h
deleted file mode 100644
index 0fdd592..0000000
--- a/cc/animation/layer_tree_mutation.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// 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_ANIMATION_LAYER_TREE_MUTATION_H_
-#define CC_ANIMATION_LAYER_TREE_MUTATION_H_
-
-#include "base/containers/hash_tables.h"
-#include "cc/animation/mutable_properties.h"
-#include "third_party/skia/include/utils/SkMatrix44.h"
-
-namespace cc {
-
-class LayerTreeMutation {
- public:
- void SetOpacity(float opacity) {
- mutated_flags_ |= kMutablePropertyOpacity;
- opacity_ = opacity;
- }
- void SetScrollLeft(float scroll_left) {
- mutated_flags_ |= kMutablePropertyScrollLeft;
- scroll_left_ = scroll_left;
- }
- void SetScrollTop(float scroll_top) {
- mutated_flags_ |= kMutablePropertyScrollTop;
- scroll_top_ = scroll_top;
- }
- void SetTransform(const SkMatrix44& transform) {
- mutated_flags_ |= kMutablePropertyTransform;
- transform_ = transform;
- }
-
- bool is_opacity_mutated() const {
- return !!(mutated_flags_ & kMutablePropertyOpacity);
- }
- bool is_scroll_left_mutated() const {
- return !!(mutated_flags_ & kMutablePropertyScrollLeft);
- }
- bool is_scroll_top_mutated() const {
- return !!(mutated_flags_ & kMutablePropertyScrollTop);
- }
- bool is_transform_mutated() const {
- return !!(mutated_flags_ & kMutablePropertyTransform);
- }
-
- float opacity() const { return opacity_; }
- float scroll_left() const { return scroll_left_; }
- float scroll_top() const { return scroll_top_; }
- SkMatrix44 transform() const { return transform_; }
-
- private:
- uint32_t mutated_flags_ = 0;
- float opacity_ = 0;
- float scroll_left_ = 0;
- float scroll_top_ = 0;
- SkMatrix44 transform_;
-};
-
-typedef base::hash_map<uint64_t, LayerTreeMutation> LayerTreeMutationMap;
-
-} // namespace cc
-
-#endif // CC_ANIMATION_LAYER_TREE_MUTATION_H_
diff --git a/cc/animation/mutable_properties.h b/cc/animation/mutable_properties.h
index dfe06b6..daec225 100644
--- a/cc/animation/mutable_properties.h
+++ b/cc/animation/mutable_properties.h
@@ -5,14 +5,18 @@
#ifndef CC_ANIMATION_MUTABLE_PROPERTIES_H_
#define CC_ANIMATION_MUTABLE_PROPERTIES_H_
+#include <stdint.h>
+
namespace cc {
-enum MutableProperty {
- kMutablePropertyNone = 0,
- kMutablePropertyOpacity = 1 << 0,
- kMutablePropertyScrollLeft = 1 << 1,
- kMutablePropertyScrollTop = 1 << 2,
- kMutablePropertyTransform = 1 << 3,
+struct MutableProperty {
+ enum : uint32_t { kNone = 0 };
+ enum : uint32_t { kOpacity = 1 << 0 };
+ enum : uint32_t { kScrollLeft = 1 << 1 };
+ enum : uint32_t { kScrollTop = 1 << 2 };
+ enum : uint32_t { kTransform = 1 << 3 };
+
+ enum : int { kNumProperties = 4 };
};
} // namespace cc
diff --git a/cc/blink/BUILD.gn b/cc/blink/BUILD.gn
index cbdeef8..93915b0 100644
--- a/cc/blink/BUILD.gn
+++ b/cc/blink/BUILD.gn
@@ -21,10 +21,6 @@ component("blink") {
"web_compositor_animation_player_impl.h",
"web_compositor_animation_timeline_impl.cc",
"web_compositor_animation_timeline_impl.h",
- "web_compositor_mutable_state_impl.cc",
- "web_compositor_mutable_state_impl.h",
- "web_compositor_mutable_state_provider_impl.cc",
- "web_compositor_mutable_state_provider_impl.h",
"web_compositor_support_impl.cc",
"web_compositor_support_impl.h",
"web_content_layer_impl.cc",
@@ -83,7 +79,6 @@ if (!is_mac) {
sources = [
"web_animation_unittest.cc",
"web_compositor_animation_player_unittest.cc",
- "web_compositor_mutable_state_impl_unittest.cc",
"web_float_animation_curve_unittest.cc",
"web_layer_impl_fixed_bounds_unittest.cc",
diff --git a/cc/blink/cc_blink.gyp b/cc/blink/cc_blink.gyp
index 995af72..dc01cae 100644
--- a/cc/blink/cc_blink.gyp
+++ b/cc/blink/cc_blink.gyp
@@ -37,10 +37,6 @@
'web_compositor_animation_player_impl.h',
'web_compositor_animation_timeline_impl.cc',
'web_compositor_animation_timeline_impl.h',
- 'web_compositor_mutable_state_impl.cc',
- 'web_compositor_mutable_state_impl.h',
- 'web_compositor_mutable_state_provider_impl.cc',
- 'web_compositor_mutable_state_provider_impl.h',
'web_compositor_support_impl.cc',
'web_compositor_support_impl.h',
'web_content_layer_impl.cc',
diff --git a/cc/blink/cc_blink_tests.gyp b/cc/blink/cc_blink_tests.gyp
index edcd118..f72a5db 100644
--- a/cc/blink/cc_blink_tests.gyp
+++ b/cc/blink/cc_blink_tests.gyp
@@ -28,7 +28,6 @@
'web_compositor_animation_player_unittest.cc',
'web_float_animation_curve_unittest.cc',
'web_layer_impl_fixed_bounds_unittest.cc',
- 'web_compositor_mutable_state_impl_unittest.cc',
],
}
],
diff --git a/cc/blink/web_compositor_mutable_state_impl.cc b/cc/blink/web_compositor_mutable_state_impl.cc
deleted file mode 100644
index b0421e8..0000000
--- a/cc/blink/web_compositor_mutable_state_impl.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-// 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/blink/web_compositor_mutable_state_impl.h"
-
-#include "cc/animation/layer_tree_mutation.h"
-#include "cc/layers/layer_impl.h"
-#include "cc/trees/layer_tree_impl.h"
-
-namespace cc_blink {
-
-WebCompositorMutableStateImpl::WebCompositorMutableStateImpl(
- cc::LayerTreeMutation* mutation,
- cc::LayerImpl* main_layer,
- cc::LayerImpl* scroll_layer)
- : mutation_(mutation),
- main_layer_(main_layer),
- scroll_layer_(scroll_layer) {}
-
-WebCompositorMutableStateImpl::~WebCompositorMutableStateImpl() {}
-
-double WebCompositorMutableStateImpl::opacity() const {
- return main_layer_->opacity();
-}
-
-void WebCompositorMutableStateImpl::setOpacity(double opacity) {
- if (!main_layer_)
- return;
- main_layer_->OnOpacityAnimated(opacity);
- mutation_->SetOpacity(opacity);
-}
-
-const SkMatrix44& WebCompositorMutableStateImpl::transform() const {
- static SkMatrix44 identity;
- return main_layer_ ? main_layer_->transform().matrix() : identity;
-}
-
-void WebCompositorMutableStateImpl::setTransform(const SkMatrix44& matrix) {
- if (!main_layer_)
- return;
- main_layer_->OnTransformAnimated(gfx::Transform(matrix));
- mutation_->SetTransform(matrix);
-}
-
-double WebCompositorMutableStateImpl::scrollLeft() const {
- return scroll_layer_ ? scroll_layer_->CurrentScrollOffset().x() : 0.0;
-}
-
-void WebCompositorMutableStateImpl::setScrollLeft(double scroll_left) {
- if (!scroll_layer_)
- return;
- gfx::ScrollOffset offset = scroll_layer_->CurrentScrollOffset();
- offset.set_x(scroll_left);
- scroll_layer_->OnScrollOffsetAnimated(offset);
- mutation_->SetScrollLeft(scroll_left);
-}
-
-double WebCompositorMutableStateImpl::scrollTop() const {
- return scroll_layer_ ? scroll_layer_->CurrentScrollOffset().y() : 0.0;
-}
-
-void WebCompositorMutableStateImpl::setScrollTop(double scroll_top) {
- if (!scroll_layer_)
- return;
- gfx::ScrollOffset offset = scroll_layer_->CurrentScrollOffset();
- offset.set_y(scroll_top);
- scroll_layer_->OnScrollOffsetAnimated(offset);
- mutation_->SetScrollTop(scroll_top);
-}
-
-} // namespace cc_blink
diff --git a/cc/blink/web_compositor_mutable_state_impl.h b/cc/blink/web_compositor_mutable_state_impl.h
deleted file mode 100644
index b052eca..0000000
--- a/cc/blink/web_compositor_mutable_state_impl.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// 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_BLINK_WEB_COMPOSITOR_MUTABLE_STATE_IMPL_H_
-#define CC_BLINK_WEB_COMPOSITOR_MUTABLE_STATE_IMPL_H_
-
-#include "cc/blink/cc_blink_export.h"
-
-#include "third_party/WebKit/public/platform/WebCompositorMutableState.h"
-
-namespace cc {
-class LayerImpl;
-class LayerTreeMutation;
-}
-
-namespace cc_blink {
-
-class WebCompositorMutableStateImpl : public blink::WebCompositorMutableState {
- public:
- WebCompositorMutableStateImpl(cc::LayerTreeMutation* mutation,
- cc::LayerImpl* main_layer,
- cc::LayerImpl* scroll_layer);
- ~WebCompositorMutableStateImpl() override;
-
- double opacity() const override;
- void setOpacity(double opacity) override;
-
- const SkMatrix44& transform() const override;
- void setTransform(const SkMatrix44& transform) override;
-
- double scrollLeft() const override;
- void setScrollLeft(double scroll_left) override;
-
- double scrollTop() const override;
- void setScrollTop(double scroll_top) override;
-
- private:
- cc::LayerTreeMutation* mutation_;
- cc::LayerImpl* main_layer_;
- cc::LayerImpl* scroll_layer_;
-};
-
-} // namespace cc_blink
-
-#endif // CC_BLINK_WEB_COMPOSITOR_MUTABLE_STATE_IMPL_H_
diff --git a/cc/blink/web_compositor_mutable_state_impl_unittest.cc b/cc/blink/web_compositor_mutable_state_impl_unittest.cc
deleted file mode 100644
index d2dc7df..0000000
--- a/cc/blink/web_compositor_mutable_state_impl_unittest.cc
+++ /dev/null
@@ -1,172 +0,0 @@
-// 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/blink/web_compositor_mutable_state_impl.h"
-
-#include "cc/animation/layer_tree_mutation.h"
-#include "cc/blink/web_compositor_mutable_state_provider_impl.h"
-#include "cc/test/fake_impl_task_runner_provider.h"
-#include "cc/test/fake_layer_tree_host_impl.h"
-#include "cc/test/fake_output_surface.h"
-#include "cc/test/layer_tree_host_common_test.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 "testing/gtest/include/gtest/gtest.h"
-
-namespace cc_blink {
-namespace {
-
-using cc::FakeImplTaskRunnerProvider;
-using cc::FakeLayerTreeHostImpl;
-using cc::FakeOutputSurface;
-using cc::LayerImpl;
-using cc::LayerImplList;
-using cc::LayerTreeHostCommonTest;
-using cc::LayerTreeMutation;
-using cc::LayerTreeMutationMap;
-using cc::LayerTreeSettings;
-using cc::OutputSurface;
-using cc::TestTaskGraphRunner;
-using cc::TestSharedBitmapManager;
-
-using blink::WebCompositorMutableState;
-
-class WebCompositorMutableStateTest : public LayerTreeHostCommonTest {
- public:
- WebCompositorMutableStateTest()
- : output_surface_(FakeOutputSurface::Create3d()) {
- LayerTreeSettings settings;
- settings.layer_transforms_should_scale_layer_contents = true;
- settings.verify_property_trees = true;
- host_impl_.reset(new FakeLayerTreeHostImpl(settings, &task_runner_provider_,
- &shared_bitmap_manager_,
- &task_graph_runner_));
- host_impl_->SetVisible(true);
- EXPECT_TRUE(host_impl_->InitializeRenderer(output_surface_.get()));
- }
-
- FakeLayerTreeHostImpl& host_impl() { return *host_impl_; }
-
- LayerImpl* root_layer() { return host_impl_->active_tree()->root_layer(); }
-
- private:
- TestSharedBitmapManager shared_bitmap_manager_;
- TestTaskGraphRunner task_graph_runner_;
- FakeImplTaskRunnerProvider task_runner_provider_;
- scoped_ptr<OutputSurface> output_surface_;
- scoped_ptr<FakeLayerTreeHostImpl> host_impl_;
-};
-
-TEST_F(WebCompositorMutableStateTest, NoMutableState) {
- // In this test, there are no layers with either an element id or mutable
- // properties. We should not be able to get any mutable state.
- scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 42);
-
- gfx::Transform identity_matrix;
- gfx::Point3F transform_origin;
- gfx::PointF position;
- gfx::Size bounds(100, 100);
- SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
- position, bounds, true, false, true);
- root->SetDrawsContent(true);
-
- host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
- host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
-
- LayerTreeMutationMap mutations;
- WebCompositorMutableStateProviderImpl provider(host_impl().active_tree(),
- &mutations);
- scoped_ptr<WebCompositorMutableState> state(provider.getMutableStateFor(42));
- EXPECT_FALSE(state);
-}
-
-TEST_F(WebCompositorMutableStateTest, MutableStateNoMutableProperties) {
- // In this test, there is a layer with an element id, but no mutable
- // properties. This should behave just as if we'd had no element id.
- scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 42);
-
- gfx::Transform identity_matrix;
- gfx::Point3F transform_origin;
- gfx::PointF position;
- gfx::Size bounds(100, 100);
- SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
- position, bounds, true, false, true);
- root->SetDrawsContent(true);
- root->SetElementId(42);
-
- host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
- host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
-
- LayerTreeMutationMap mutations;
- WebCompositorMutableStateProviderImpl provider(host_impl().active_tree(),
- &mutations);
- scoped_ptr<WebCompositorMutableState> state(provider.getMutableStateFor(42));
- EXPECT_FALSE(state);
-}
-
-TEST_F(WebCompositorMutableStateTest, MutableStateMutableProperties) {
- // In this test, there is a layer with an element id and mutable properties.
- // In this case, we should get a valid mutable state for this element id that
- // has a real effect on the corresponding layer.
- scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 42);
-
- gfx::Transform identity_matrix;
- gfx::Point3F transform_origin;
- gfx::PointF position;
- gfx::Size bounds(100, 100);
- SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
- position, bounds, true, false, true);
- root->SetDrawsContent(true);
- root->SetElementId(42);
- root->SetMutableProperties(
- cc::kMutablePropertyOpacity | cc::kMutablePropertyTransform |
- cc::kMutablePropertyScrollLeft | cc::kMutablePropertyScrollTop);
-
- host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
- host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
-
- LayerTreeMutationMap mutations;
- WebCompositorMutableStateProviderImpl provider(host_impl().active_tree(),
- &mutations);
-
- scoped_ptr<WebCompositorMutableState> state(provider.getMutableStateFor(42));
- EXPECT_TRUE(state.get());
-
- EXPECT_EQ(1.0, root_layer()->opacity());
- EXPECT_EQ(identity_matrix.ToString(), root_layer()->transform().ToString());
- EXPECT_EQ(0.0, root_layer()->CurrentScrollOffset().x());
- EXPECT_EQ(0.0, root_layer()->CurrentScrollOffset().y());
-
- gfx::Transform zero(0, 0, 0, 0, 0, 0);
- state->setOpacity(0.5);
- state->setTransform(zero.matrix());
- state->setScrollLeft(1.0);
- state->setScrollTop(1.0);
-
- EXPECT_EQ(0.5, root_layer()->opacity());
- EXPECT_EQ(zero.ToString(), root_layer()->transform().ToString());
- EXPECT_EQ(1.0, root_layer()->CurrentScrollOffset().x());
- EXPECT_EQ(1.0, root_layer()->CurrentScrollOffset().y());
-
- // The corresponding mutation should reflect the changed values.
- EXPECT_EQ(1ul, mutations.size());
-
- const LayerTreeMutation& mutation = mutations[42];
- EXPECT_TRUE(mutation.is_opacity_mutated());
- EXPECT_TRUE(mutation.is_transform_mutated());
- EXPECT_TRUE(mutation.is_scroll_left_mutated());
- EXPECT_TRUE(mutation.is_scroll_top_mutated());
-
- EXPECT_EQ(0.5, mutation.opacity());
- EXPECT_EQ(zero.ToString(), gfx::Transform(mutation.transform()).ToString());
- EXPECT_EQ(1.0, mutation.scroll_left());
- EXPECT_EQ(1.0, mutation.scroll_top());
-}
-
-} // namespace
-} // namespace cc_blink
diff --git a/cc/blink/web_compositor_mutable_state_provider_impl.cc b/cc/blink/web_compositor_mutable_state_provider_impl.cc
deleted file mode 100644
index 713a542..0000000
--- a/cc/blink/web_compositor_mutable_state_provider_impl.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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/blink/web_compositor_mutable_state_provider_impl.h"
-
-#include "cc/blink/web_compositor_mutable_state_impl.h"
-#include "cc/layers/layer_impl.h"
-#include "cc/trees/layer_tree_impl.h"
-
-namespace cc_blink {
-
-WebCompositorMutableStateProviderImpl::WebCompositorMutableStateProviderImpl(
- cc::LayerTreeImpl* state,
- cc::LayerTreeMutationMap* mutations)
- : state_(state), mutations_(mutations) {}
-
-WebCompositorMutableStateProviderImpl::
- ~WebCompositorMutableStateProviderImpl() {}
-
-blink::WebPassOwnPtr<blink::WebCompositorMutableState>
-WebCompositorMutableStateProviderImpl::getMutableStateFor(uint64_t element_id) {
- cc::LayerTreeImpl::ElementLayers layers =
- state_->GetMutableLayers(element_id);
-
- if (!layers.main && !layers.scroll)
- return nullptr;
-
- return blink::adoptWebPtr<blink::WebCompositorMutableState>(
- new WebCompositorMutableStateImpl(&(*mutations_)[element_id], layers.main,
- layers.scroll));
-}
-
-} // namespace cc_blink
diff --git a/cc/blink/web_compositor_mutable_state_provider_impl.h b/cc/blink/web_compositor_mutable_state_provider_impl.h
deleted file mode 100644
index 138103d..0000000
--- a/cc/blink/web_compositor_mutable_state_provider_impl.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// 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_BLINK_WEB_COMPOSITOR_MUTABLE_STATE_PROVIDER_IMPL_H_
-#define CC_BLINK_WEB_COMPOSITOR_MUTABLE_STATE_PROVIDER_IMPL_H_
-
-#include "base/compiler_specific.h"
-#include "base/containers/hash_tables.h"
-#include "cc/animation/layer_tree_mutation.h"
-#include "cc/blink/cc_blink_export.h"
-
-#include "third_party/WebKit/public/platform/WebCompositorMutableStateProvider.h"
-
-namespace cc {
-class LayerTreeImpl;
-} // namespace cc
-
-namespace cc_blink {
-
-class WebCompositorMutableStateProviderImpl
- : public blink::WebCompositorMutableStateProvider {
- public:
- // TODO(vollick): after slimming paint v2, this will need to operate on
- // property trees, not the layer tree impl.
- //
- // The LayerTreeImpl and the LayerTreeMutationMap are both owned by caller.
- CC_BLINK_EXPORT WebCompositorMutableStateProviderImpl(
- cc::LayerTreeImpl* state,
- cc::LayerTreeMutationMap* mutations);
-
- CC_BLINK_EXPORT ~WebCompositorMutableStateProviderImpl() override;
-
- CC_BLINK_EXPORT blink::WebPassOwnPtr<blink::WebCompositorMutableState>
- getMutableStateFor(uint64_t element_id) override WARN_UNUSED_RESULT;
-
- private:
- cc::LayerTreeImpl* state_;
- cc::LayerTreeMutationMap* mutations_;
-};
-
-} // namespace cc_blink
-
-#endif // CC_BLINK_WEB_COMPOSITOR_MUTABLE_STATE_PROVIDER_IMPL_H_
diff --git a/cc/blink/web_layer_impl.cc b/cc/blink/web_layer_impl.cc
index a901b15..992157b 100644
--- a/cc/blink/web_layer_impl.cc
+++ b/cc/blink/web_layer_impl.cc
@@ -16,7 +16,6 @@
#include "base/threading/thread_checker.h"
#include "base/trace_event/trace_event_impl.h"
#include "cc/animation/animation.h"
-#include "cc/animation/mutable_properties.h"
#include "cc/base/region.h"
#include "cc/base/switches.h"
#include "cc/blink/web_animation_impl.h"
@@ -27,7 +26,6 @@
#include "cc/layers/layer_position_constraint.h"
#include "cc/layers/layer_settings.h"
#include "cc/trees/layer_tree_host.h"
-#include "third_party/WebKit/public/platform/WebCompositorMutableProperties.h"
#include "third_party/WebKit/public/platform/WebFloatPoint.h"
#include "third_party/WebKit/public/platform/WebFloatRect.h"
#include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h"
@@ -563,35 +561,6 @@ uint64_t WebLayerImpl::elementId() const {
return layer_->element_id();
}
-static_assert(
- static_cast<cc::MutableProperty>(blink::WebCompositorMutablePropertyNone) ==
- cc::kMutablePropertyNone,
- "MutableProperty and WebCompositorMutableProperty enums must match");
-
-static_assert(
- static_cast<cc::MutableProperty>(
- blink::WebCompositorMutablePropertyOpacity) ==
- cc::kMutablePropertyOpacity,
- "MutableProperty and WebCompositorMutableProperty enums must match");
-
-static_assert(
- static_cast<cc::MutableProperty>(
- blink::WebCompositorMutablePropertyScrollLeft) ==
- cc::kMutablePropertyScrollLeft,
- "MutableProperty and WebCompositorMutableProperty enums must match");
-
-static_assert(
- static_cast<cc::MutableProperty>(
- blink::WebCompositorMutablePropertyScrollTop) ==
- cc::kMutablePropertyScrollTop,
- "MutableProperty and WebCompositorMutableProperty enums must match");
-
-static_assert(
- static_cast<cc::MutableProperty>(
- blink::WebCompositorMutablePropertyTransform) ==
- cc::kMutablePropertyTransform,
- "MutableProperty and WebCompositorMutableProperty enums must match");
-
void WebLayerImpl::setCompositorMutableProperties(uint32_t properties) {
layer_->SetMutableProperties(properties);
}
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 68e153f..2519daa 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -66,7 +66,7 @@ Layer::Layer(const LayerSettings& settings)
clip_tree_index_(-1),
property_tree_sequence_number_(-1),
element_id_(0),
- mutable_properties_(kMutablePropertyNone),
+ mutable_properties_(MutableProperty::kNone),
main_thread_scrolling_reasons_(
MainThreadScrollingReason::kNotScrollingOnMain),
should_flatten_transform_from_property_tree_(false),
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc
index 540de09..57b62f8 100644
--- a/cc/layers/layer_impl.cc
+++ b/cc/layers/layer_impl.cc
@@ -94,7 +94,7 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl,
sorting_context_id_(0),
current_draw_mode_(DRAW_MODE_NONE),
element_id_(0),
- mutable_properties_(kMutablePropertyNone),
+ mutable_properties_(MutableProperty::kNone),
force_render_surface_(false),
frame_timing_requests_dirty_(false),
visited_(false),
@@ -1720,7 +1720,7 @@ void LayerImpl::AsValueInto(base::trace_event::TracedValue* state) const {
state->SetInteger("gpu_memory_usage",
base::saturated_cast<int>(GPUMemoryUsageInBytes()));
- if (mutable_properties_ != kMutablePropertyNone) {
+ if (mutable_properties_ != MutableProperty::kNone) {
state->SetInteger("element_id", base::saturated_cast<int>(element_id_));
state->SetInteger("mutable_properties", mutable_properties_);
}
diff --git a/cc/layers/layer_impl_unittest.cc b/cc/layers/layer_impl_unittest.cc
index b9fb767..496f4ff 100644
--- a/cc/layers/layer_impl_unittest.cc
+++ b/cc/layers/layer_impl_unittest.cc
@@ -207,7 +207,7 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) {
EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
root->SetElementId(2));
EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
- root->SetMutableProperties(kMutablePropertyOpacity));
+ root->SetMutableProperties(MutableProperty::kOpacity));
EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
root->SetScrollParent(scroll_parent.get()));
EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
@@ -385,7 +385,7 @@ TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) {
VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size));
VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetElementId(2));
VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
- layer->SetMutableProperties(kMutablePropertyTransform));
+ layer->SetMutableProperties(MutableProperty::kTransform));
}
TEST(LayerImplTest, SafeOpaqueBackgroundColor) {
diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc
index 226b997..5b48056 100644
--- a/cc/layers/layer_unittest.cc
+++ b/cc/layers/layer_unittest.cc
@@ -984,7 +984,7 @@ TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) {
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetHideLayerAndSubtree(true));
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetElementId(2));
EXPECT_SET_NEEDS_COMMIT(
- 1, test_layer->SetMutableProperties(kMutablePropertyTransform));
+ 1, test_layer->SetMutableProperties(MutableProperty::kTransform));
EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, test_layer->SetMaskLayer(
dummy_layer1.get()));
@@ -2125,15 +2125,15 @@ TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) {
EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2);
test_layer->SetElementId(2);
- test_layer->SetMutableProperties(kMutablePropertyTransform);
+ test_layer->SetMutableProperties(MutableProperty::kTransform);
EXPECT_EQ(0lu, impl_layer->element_id());
- EXPECT_EQ(kMutablePropertyNone, impl_layer->mutable_properties());
+ EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties());
test_layer->PushPropertiesTo(impl_layer.get());
EXPECT_EQ(2lu, impl_layer->element_id());
- EXPECT_EQ(kMutablePropertyTransform, impl_layer->mutable_properties());
+ EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties());
}
} // namespace
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index 513ce5e..d44aa67 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -50,9 +50,9 @@ namespace cc {
namespace {
const uint32_t kMainLayerFlags =
- kMutablePropertyOpacity | kMutablePropertyTransform;
+ MutableProperty::kOpacity | MutableProperty::kTransform;
const uint32_t kScrollLayerFlags =
- kMutablePropertyScrollLeft | kMutablePropertyScrollTop;
+ MutableProperty::kScrollLeft | MutableProperty::kScrollTop;
} // namespace
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp b/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
index 3e335f4..afac17c 100644
--- a/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
@@ -48,7 +48,6 @@
#include "core/svg/SVGSVGElement.h"
#include "platform/Length.h"
#include "platform/transforms/TransformOperations.h"
-#include "public/platform/WebCompositorMutableProperties.h"
#include "wtf/Assertions.h"
namespace blink {
diff --git a/third_party/WebKit/Source/core/dom/CompositorProxiedPropertySet.cpp b/third_party/WebKit/Source/core/dom/CompositorProxiedPropertySet.cpp
index 90a4930..2f9c3d3 100644
--- a/third_party/WebKit/Source/core/dom/CompositorProxiedPropertySet.cpp
+++ b/third_party/WebKit/Source/core/dom/CompositorProxiedPropertySet.cpp
@@ -27,7 +27,7 @@ bool CompositorProxiedPropertySet::isEmpty() const
void CompositorProxiedPropertySet::increment(uint32_t mutableProperties)
{
- for (int i = 0; i < kNumWebCompositorMutableProperties; ++i) {
+ for (int i = 0; i < CompositorMutableProperty::kNumProperties; ++i) {
if (mutableProperties & (1 << i))
++m_counts[i];
}
@@ -35,7 +35,7 @@ void CompositorProxiedPropertySet::increment(uint32_t mutableProperties)
void CompositorProxiedPropertySet::decrement(uint32_t mutableProperties)
{
- for (int i = 0; i < kNumWebCompositorMutableProperties; ++i) {
+ for (int i = 0; i < CompositorMutableProperty::kNumProperties; ++i) {
if (mutableProperties & (1 << i)) {
ASSERT(m_counts[i]);
--m_counts[i];
@@ -45,8 +45,8 @@ void CompositorProxiedPropertySet::decrement(uint32_t mutableProperties)
uint32_t CompositorProxiedPropertySet::proxiedProperties() const
{
- uint32_t properties = WebCompositorMutablePropertyNone;
- for (int i = 0; i < kNumWebCompositorMutableProperties; ++i) {
+ uint32_t properties = CompositorMutableProperty::kNone;
+ for (int i = 0; i < CompositorMutableProperty::kNumProperties; ++i) {
if (m_counts[i])
properties |= 1 << i;
}
diff --git a/third_party/WebKit/Source/core/dom/CompositorProxiedPropertySet.h b/third_party/WebKit/Source/core/dom/CompositorProxiedPropertySet.h
index f104ed4..874b6ea 100644
--- a/third_party/WebKit/Source/core/dom/CompositorProxiedPropertySet.h
+++ b/third_party/WebKit/Source/core/dom/CompositorProxiedPropertySet.h
@@ -5,7 +5,7 @@
#ifndef CompositorProxiedPropertySet_h
#define CompositorProxiedPropertySet_h
-#include "public/platform/WebCompositorMutableProperties.h"
+#include "platform/graphics/CompositorMutableProperties.h"
#include "wtf/Allocator.h"
#include "wtf/Forward.h"
#include "wtf/Noncopyable.h"
@@ -28,7 +28,7 @@ public:
private:
CompositorProxiedPropertySet();
- unsigned short m_counts[kNumWebCompositorMutableProperties];
+ unsigned short m_counts[CompositorMutableProperty::kNumProperties];
};
} // namespace blink
diff --git a/third_party/WebKit/Source/core/dom/CompositorProxy.cpp b/third_party/WebKit/Source/core/dom/CompositorProxy.cpp
index f45d7cc..3ad9c0c 100644
--- a/third_party/WebKit/Source/core/dom/CompositorProxy.cpp
+++ b/third_party/WebKit/Source/core/dom/CompositorProxy.cpp
@@ -10,8 +10,8 @@
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h"
#include "platform/ThreadSafeFunctional.h"
+#include "platform/graphics/CompositorMutableProperties.h"
#include "public/platform/Platform.h"
-#include "public/platform/WebCompositorMutableProperties.h"
#include "public/platform/WebTraceLocation.h"
#include <algorithm>
@@ -19,21 +19,21 @@ namespace blink {
static const struct {
const char* name;
- WebCompositorMutableProperty property;
+ uint32_t property;
} allowedProperties[] = {
- { "opacity", WebCompositorMutablePropertyOpacity },
- { "scrollleft", WebCompositorMutablePropertyScrollLeft },
- { "scrolltop", WebCompositorMutablePropertyScrollTop },
- { "transform", WebCompositorMutablePropertyTransform },
+ { "opacity", CompositorMutableProperty::kOpacity },
+ { "scrollleft", CompositorMutableProperty::kScrollLeft },
+ { "scrolltop", CompositorMutableProperty::kScrollTop },
+ { "transform", CompositorMutableProperty::kTransform },
};
-static WebCompositorMutableProperty compositorMutablePropertyForName(const String& attributeName)
+static uint32_t compositorMutablePropertyForName(const String& attributeName)
{
for (const auto& mapping : allowedProperties) {
if (equalIgnoringCase(mapping.name, attributeName))
return mapping.property;
}
- return WebCompositorMutablePropertyNone;
+ return CompositorMutableProperty::kNone;
}
static bool isControlThread()
@@ -84,7 +84,7 @@ static uint32_t compositorMutablePropertiesFromNames(const Vector<String>& attri
{
uint32_t properties = 0;
for (const auto& attribute : attributeArray) {
- properties |= static_cast<uint32_t>(compositorMutablePropertyForName(attribute));
+ properties |= compositorMutablePropertyForName(attribute);
}
return properties;
}
@@ -145,14 +145,14 @@ CompositorProxy::~CompositorProxy()
bool CompositorProxy::supports(const String& attributeName) const
{
- return !!(m_compositorMutableProperties & static_cast<uint32_t>(compositorMutablePropertyForName(attributeName)));
+ return m_compositorMutableProperties & compositorMutablePropertyForName(attributeName);
}
double CompositorProxy::opacity(ExceptionState& exceptionState) const
{
if (raiseExceptionIfMutationNotAllowed(exceptionState))
return 0.0;
- if (raiseExceptionIfNotMutable(static_cast<uint32_t>(WebCompositorMutablePropertyOpacity), exceptionState))
+ if (raiseExceptionIfNotMutable(CompositorMutableProperty::kOpacity, exceptionState))
return 0.0;
return m_opacity;
}
@@ -161,7 +161,7 @@ double CompositorProxy::scrollLeft(ExceptionState& exceptionState) const
{
if (raiseExceptionIfMutationNotAllowed(exceptionState))
return 0.0;
- if (raiseExceptionIfNotMutable(static_cast<uint32_t>(WebCompositorMutablePropertyScrollLeft), exceptionState))
+ if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollLeft, exceptionState))
return 0.0;
return m_scrollLeft;
}
@@ -170,7 +170,7 @@ double CompositorProxy::scrollTop(ExceptionState& exceptionState) const
{
if (raiseExceptionIfMutationNotAllowed(exceptionState))
return 0.0;
- if (raiseExceptionIfNotMutable(static_cast<uint32_t>(WebCompositorMutablePropertyScrollTop), exceptionState))
+ if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollTop, exceptionState))
return 0.0;
return m_scrollTop;
}
@@ -179,7 +179,7 @@ DOMMatrix* CompositorProxy::transform(ExceptionState& exceptionState) const
{
if (raiseExceptionIfMutationNotAllowed(exceptionState))
return nullptr;
- if (raiseExceptionIfNotMutable(static_cast<uint32_t>(WebCompositorMutablePropertyTransform), exceptionState))
+ if (raiseExceptionIfNotMutable(CompositorMutableProperty::kTransform, exceptionState))
return nullptr;
return m_transform;
}
@@ -188,40 +188,40 @@ void CompositorProxy::setOpacity(double opacity, ExceptionState& exceptionState)
{
if (raiseExceptionIfMutationNotAllowed(exceptionState))
return;
- if (raiseExceptionIfNotMutable(static_cast<uint32_t>(WebCompositorMutablePropertyOpacity), exceptionState))
+ if (raiseExceptionIfNotMutable(CompositorMutableProperty::kOpacity, exceptionState))
return;
m_opacity = std::min(1., std::max(0., opacity));
- m_mutatedProperties |= static_cast<uint32_t>(WebCompositorMutablePropertyTransform);
+ m_mutatedProperties |= CompositorMutableProperty::kTransform;
}
void CompositorProxy::setScrollLeft(double scrollLeft, ExceptionState& exceptionState)
{
if (raiseExceptionIfMutationNotAllowed(exceptionState))
return;
- if (raiseExceptionIfNotMutable(static_cast<uint32_t>(WebCompositorMutablePropertyScrollLeft), exceptionState))
+ if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollLeft, exceptionState))
return;
m_scrollLeft = scrollLeft;
- m_mutatedProperties |= static_cast<uint32_t>(WebCompositorMutablePropertyScrollLeft);
+ m_mutatedProperties |= CompositorMutableProperty::kScrollLeft;
}
void CompositorProxy::setScrollTop(double scrollTop, ExceptionState& exceptionState)
{
if (raiseExceptionIfMutationNotAllowed(exceptionState))
return;
- if (raiseExceptionIfNotMutable(static_cast<uint32_t>(WebCompositorMutablePropertyScrollTop), exceptionState))
+ if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollTop, exceptionState))
return;
m_scrollTop = scrollTop;
- m_mutatedProperties |= static_cast<uint32_t>(WebCompositorMutablePropertyScrollTop);
+ m_mutatedProperties |= CompositorMutableProperty::kScrollTop;
}
void CompositorProxy::setTransform(DOMMatrix* transform, ExceptionState& exceptionState)
{
if (raiseExceptionIfMutationNotAllowed(exceptionState))
return;
- if (raiseExceptionIfNotMutable(static_cast<uint32_t>(WebCompositorMutablePropertyTransform), exceptionState))
+ if (raiseExceptionIfNotMutable(CompositorMutableProperty::kTransform, exceptionState))
return;
m_transform = transform;
- m_mutatedProperties |= static_cast<uint32_t>(WebCompositorMutablePropertyTransform);
+ m_mutatedProperties |= CompositorMutableProperty::kTransform;
}
bool CompositorProxy::raiseExceptionIfNotMutable(uint32_t property, ExceptionState& exceptionState) const
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp
index 5fafc39..b130342 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -123,6 +123,7 @@
#include "platform/EventDispatchForbiddenScope.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/UserGestureIndicator.h"
+#include "platform/graphics/CompositorMutableProperties.h"
#include "platform/scroll/ScrollableArea.h"
#include "wtf/BitVector.h"
#include "wtf/HashFunctions.h"
@@ -996,10 +997,10 @@ void Element::decrementCompositorProxiedProperties(uint32_t mutableProperties)
uint32_t Element::compositorMutableProperties() const
{
if (!hasRareData())
- return WebCompositorMutablePropertyNone;
+ return CompositorMutableProperty::kNone;
if (CompositorProxiedPropertySet* set = elementRareData()->proxiedPropertyCounts())
return set->proxiedProperties();
- return WebCompositorMutablePropertyNone;
+ return CompositorMutableProperty::kNone;
}
bool Element::hasNonEmptyLayoutSize() const
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
index 7c798e2..d41aef2 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
@@ -60,12 +60,12 @@
#include "platform/fonts/FontCache.h"
#include "platform/geometry/TransformState.h"
#include "platform/graphics/BitmapImage.h"
+#include "platform/graphics/CompositorMutableProperties.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/paint/ClipDisplayItem.h"
#include "platform/graphics/paint/CullRect.h"
#include "platform/graphics/paint/PaintController.h"
#include "platform/graphics/paint/TransformDisplayItem.h"
-#include "public/platform/WebCompositorMutableProperties.h"
#include "wtf/CurrentTime.h"
#include "wtf/text/StringBuilder.h"
@@ -1528,8 +1528,8 @@ void CompositedLayerMapping::updateElementIdAndCompositorMutableProperties()
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), "CompositedLayerMapping::updateElementId()");
uint64_t elementId = 0;
- uint32_t mainMutableProperties = WebCompositorMutablePropertyNone;
- uint32_t scrollMutableProperties = WebCompositorMutablePropertyNone;
+ uint32_t mainMutableProperties = CompositorMutableProperty::kNone;
+ uint32_t scrollMutableProperties = CompositorMutableProperty::kNone;
if (m_owningLayer.layoutObject()->style()->hasCompositorProxy()) {
if (Node* owningNode = m_owningLayer.layoutObject()->generatingNode()) {
@@ -1537,8 +1537,8 @@ void CompositedLayerMapping::updateElementIdAndCompositorMutableProperties()
Element* owningElement = toElement(owningNode);
uint32_t compositorMutableProperties = owningElement->compositorMutableProperties();
elementId = DOMNodeIds::idForNode(owningNode);
- mainMutableProperties = (WebCompositorMutablePropertyOpacity | WebCompositorMutablePropertyTransform) & compositorMutableProperties;
- scrollMutableProperties = (WebCompositorMutablePropertyScrollLeft | WebCompositorMutablePropertyScrollTop) & compositorMutableProperties;
+ mainMutableProperties = (CompositorMutableProperty::kOpacity | CompositorMutableProperty::kTransform) & compositorMutableProperties;
+ scrollMutableProperties = (CompositorMutableProperty::kScrollLeft | CompositorMutableProperty::kScrollTop) & compositorMutableProperties;
}
}
}
diff --git a/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp b/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp
index c05c19d..baf3d27 100644
--- a/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp
@@ -55,13 +55,13 @@
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/ScriptForbiddenScope.h"
#include "platform/TraceEvent.h"
+#include "platform/graphics/CompositorMutableProperties.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/paint/CullRect.h"
#include "platform/graphics/paint/DrawingRecorder.h"
#include "platform/graphics/paint/PaintController.h"
#include "platform/graphics/paint/TransformDisplayItem.h"
#include "public/platform/Platform.h"
-#include "public/platform/WebCompositorMutableProperties.h"
namespace blink {
@@ -396,10 +396,10 @@ void PaintLayerCompositor::updateIfNeeded()
if (RuntimeEnabledFeatures::compositorWorkerEnabled() && m_scrollLayer) {
if (Element* scrollingElement = m_layoutView.document().scrollingElement()) {
uint64_t elementId = 0;
- uint32_t mutableProperties = WebCompositorMutablePropertyNone;
+ uint32_t mutableProperties = CompositorMutableProperty::kNone;
if (scrollingElement->hasCompositorProxy()) {
elementId = DOMNodeIds::idForNode(scrollingElement);
- mutableProperties = (WebCompositorMutablePropertyScrollLeft | WebCompositorMutablePropertyScrollTop) & scrollingElement->compositorMutableProperties();
+ mutableProperties = (CompositorMutableProperty::kScrollLeft | CompositorMutableProperty::kScrollTop) & scrollingElement->compositorMutableProperties();
}
m_scrollLayer->setElementId(elementId);
m_scrollLayer->setCompositorMutableProperties(mutableProperties);
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
index 0845a12..9ae466e 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
@@ -70,12 +70,12 @@
#include "core/paint/PaintLayerFragment.h"
#include "platform/PlatformGestureEvent.h"
#include "platform/PlatformMouseEvent.h"
+#include "platform/graphics/CompositorMutableProperties.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/paint/DrawingRecorder.h"
#include "platform/scroll/ScrollAnimatorBase.h"
#include "platform/scroll/ScrollbarTheme.h"
#include "public/platform/Platform.h"
-#include "public/platform/WebCompositorMutableProperties.h"
namespace blink {
@@ -1392,7 +1392,7 @@ static bool layerNeedsCompositedScrolling(PaintLayerScrollableArea::LCDTextMode
return false;
Node* node = layer->enclosingNode();
- if (node && node->isElementNode() && (toElement(node)->compositorMutableProperties() & (WebCompositorMutablePropertyScrollTop | WebCompositorMutablePropertyScrollLeft)))
+ if (node && node->isElementNode() && (toElement(node)->compositorMutableProperties() & (CompositorMutableProperty::kScrollTop | CompositorMutableProperty::kScrollLeft)))
return true;
if (mode == PaintLayerScrollableArea::ConsiderLCDText && !layer->compositor()->preferCompositingToLCDTextEnabled())
diff --git a/third_party/WebKit/Source/platform/BUILD.gn b/third_party/WebKit/Source/platform/BUILD.gn
index 5fb1d3a..023849d 100644
--- a/third_party/WebKit/Source/platform/BUILD.gn
+++ b/third_party/WebKit/Source/platform/BUILD.gn
@@ -409,6 +409,8 @@ test("blink_platform_unittests") {
"//base",
"//base/allocator",
"//base/test:test_support",
+ "//cc",
+ "//cc:test_support",
"//cc/blink",
"//skia",
"//testing/gmock",
@@ -416,6 +418,8 @@ test("blink_platform_unittests") {
"//third_party/WebKit/Source/wtf",
"//third_party/WebKit/Source/wtf:test_support",
"//third_party/harfbuzz-ng",
+ "//ui/gfx",
+ "//ui/gfx/geometry",
"//url",
]
diff --git a/third_party/WebKit/Source/platform/blink_platform.gypi b/third_party/WebKit/Source/platform/blink_platform.gypi
index 9edcdad..bd43088 100644
--- a/third_party/WebKit/Source/platform/blink_platform.gypi
+++ b/third_party/WebKit/Source/platform/blink_platform.gypi
@@ -521,6 +521,10 @@
'graphics/ColorSpace.h',
'graphics/CompositingReasons.cpp',
'graphics/CompositingReasons.h',
+ 'graphics/CompositorMutableState.cpp',
+ 'graphics/CompositorMutableState.h',
+ 'graphics/CompositorMutableStateProvider.cpp',
+ 'graphics/CompositorMutableStateProvider.h',
'graphics/ContentLayerDelegate.cpp',
'graphics/ContentLayerDelegate.h',
'graphics/ContiguousContainer.cpp',
@@ -944,7 +948,7 @@
'text/UnicodeUtilities.cpp',
'text/UnicodeUtilities.h',
'threading/BackgroundTaskRunner.cpp',
- 'threading/BackgroundTaskRunner.h',
+ 'threading/BackgroundTaskRunner.h',
'transforms/AffineTransform.cpp',
'transforms/AffineTransform.h',
'transforms/IdentityTransformOperation.h',
@@ -1037,6 +1041,7 @@
'geometry/GeometryTestHelpers.cpp',
'geometry/LayoutRectOutsetsTest.cpp',
'geometry/RegionTest.cpp',
+ 'graphics/CompositorMutableStateTest.cpp',
'graphics/ContiguousContainerTest.cpp',
'graphics/GraphicsContextTest.cpp',
'graphics/RecordingImageBufferSurfaceTest.cpp',
diff --git a/third_party/WebKit/Source/platform/blink_platform_tests.gyp b/third_party/WebKit/Source/platform/blink_platform_tests.gyp
index 5305eeb..9bb1a84 100644
--- a/third_party/WebKit/Source/platform/blink_platform_tests.gyp
+++ b/third_party/WebKit/Source/platform/blink_platform_tests.gyp
@@ -82,9 +82,13 @@
'../wtf/wtf.gyp:wtf',
'../wtf/wtf_tests.gyp:wtf_unittest_helpers',
'<(DEPTH)/base/base.gyp:test_support_base',
+ '<(DEPTH)/cc/cc.gyp:cc',
+ '<(DEPTH)/cc/cc_tests.gyp:cc_test_support',
'<(DEPTH)/cc/blink/cc_blink.gyp:cc_blink',
'<(DEPTH)/skia/skia.gyp:skia',
'<(DEPTH)/third_party/harfbuzz-ng/harfbuzz.gyp:harfbuzz-ng',
+ '<(DEPTH)/ui/gfx/gfx.gyp:gfx',
+ '<(DEPTH)/ui/gfx/gfx.gyp:gfx_geometry',
'<(DEPTH)/url/url.gyp:url_lib',
'blink_platform.gyp:blink_common',
'blink_platform.gyp:blink_platform',
diff --git a/third_party/WebKit/Source/platform/graphics/CompositorMutableProperties.h b/third_party/WebKit/Source/platform/graphics/CompositorMutableProperties.h
new file mode 100644
index 0000000..477785a
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/CompositorMutableProperties.h
@@ -0,0 +1,16 @@
+// Copyright 2016 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 CompositorMutableProperties_h
+#define CompositorMutableProperties_h
+
+#include "cc/animation/mutable_properties.h"
+
+namespace blink {
+
+using CompositorMutableProperty = cc::MutableProperty;
+
+} // namespace blink
+
+#endif // CompositorMutableProperties_h
diff --git a/third_party/WebKit/Source/platform/graphics/CompositorMutableState.cpp b/third_party/WebKit/Source/platform/graphics/CompositorMutableState.cpp
new file mode 100644
index 0000000..c149cf8
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/CompositorMutableState.cpp
@@ -0,0 +1,78 @@
+// Copyright 2016 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 "platform/graphics/CompositorMutableState.h"
+
+#include "cc/layers/layer_impl.h"
+#include "cc/trees/layer_tree_impl.h"
+#include "platform/graphics/CompositorMutation.h"
+
+namespace blink {
+CompositorMutableState::CompositorMutableState(CompositorMutation* mutation, cc::LayerImpl* main, cc::LayerImpl* scroll)
+ : m_mutation(mutation)
+ , m_mainLayer(main)
+ , m_scrollLayer(scroll)
+{
+}
+
+CompositorMutableState::~CompositorMutableState() {}
+
+double CompositorMutableState::opacity() const
+{
+ return m_mainLayer->opacity();
+}
+
+void CompositorMutableState::setOpacity(double opacity)
+{
+ if (!m_mainLayer)
+ return;
+ m_mainLayer->OnOpacityAnimated(opacity);
+ m_mutation->setOpacity(opacity);
+}
+
+const SkMatrix44& CompositorMutableState::transform() const
+{
+ return m_mainLayer ? m_mainLayer->transform().matrix() : SkMatrix44::I();
+}
+
+void CompositorMutableState::setTransform(const SkMatrix44& matrix)
+{
+ if (!m_mainLayer)
+ return;
+ m_mainLayer->OnTransformAnimated(gfx::Transform(matrix));
+ m_mutation->setTransform(matrix);
+}
+
+double CompositorMutableState::scrollLeft() const
+{
+ return m_scrollLayer ? m_scrollLayer->CurrentScrollOffset().x() : 0.0;
+}
+
+void CompositorMutableState::setScrollLeft(double scrollLeft)
+{
+ if (!m_scrollLayer)
+ return;
+
+ gfx::ScrollOffset offset = m_scrollLayer->CurrentScrollOffset();
+ offset.set_x(scrollLeft);
+ m_scrollLayer->OnScrollOffsetAnimated(offset);
+ m_mutation->setScrollLeft(scrollLeft);
+}
+
+double CompositorMutableState::scrollTop() const
+{
+ return m_scrollLayer ? m_scrollLayer->CurrentScrollOffset().y() : 0.0;
+}
+
+void CompositorMutableState::setScrollTop(double scrollTop)
+{
+ if (!m_scrollLayer)
+ return;
+ gfx::ScrollOffset offset = m_scrollLayer->CurrentScrollOffset();
+ offset.set_y(scrollTop);
+ m_scrollLayer->OnScrollOffsetAnimated(offset);
+ m_mutation->setScrollTop(scrollTop);
+}
+
+} // namespace blink
diff --git a/third_party/WebKit/Source/platform/graphics/CompositorMutableState.h b/third_party/WebKit/Source/platform/graphics/CompositorMutableState.h
new file mode 100644
index 0000000..4838d66
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/CompositorMutableState.h
@@ -0,0 +1,46 @@
+// Copyright 2016 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 CompositorMutableState_h
+#define CompositorMutableState_h
+
+#include "platform/PlatformExport.h"
+
+class SkMatrix44;
+
+namespace cc {
+class LayerImpl;
+} // namespace cc
+
+namespace blink {
+
+class CompositorMutation;
+
+// This class wraps the compositor-owned, mutable state for a single element.
+class PLATFORM_EXPORT CompositorMutableState {
+public:
+ CompositorMutableState(CompositorMutation*, cc::LayerImpl* main, cc::LayerImpl* scroll);
+ ~CompositorMutableState();
+
+ double opacity() const;
+ void setOpacity(double);
+
+ const SkMatrix44& transform() const;
+ void setTransform(const SkMatrix44&);
+
+ double scrollLeft() const;
+ void setScrollLeft(double);
+
+ double scrollTop() const;
+ void setScrollTop(double);
+
+private:
+ CompositorMutation* m_mutation;
+ cc::LayerImpl* m_mainLayer;
+ cc::LayerImpl* m_scrollLayer;
+};
+
+} // namespace blink
+
+#endif // CompositorMutableState_h
diff --git a/third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.cpp b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.cpp
new file mode 100644
index 0000000..cb2d9b1
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.cpp
@@ -0,0 +1,43 @@
+// Copyright 2016 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 "platform/graphics/CompositorMutableStateProvider.h"
+
+#include "cc/layers/layer_impl.h"
+#include "cc/trees/layer_tree_impl.h"
+#include "platform/graphics/CompositorMutableState.h"
+#include "platform/graphics/CompositorMutation.h"
+#include "wtf/PassOwnPtr.h"
+
+namespace blink {
+
+CompositorMutableStateProvider::CompositorMutableStateProvider(cc::LayerTreeImpl* state, CompositorMutations* mutations)
+ : m_state(state)
+ , m_mutations(mutations)
+{
+}
+
+CompositorMutableStateProvider::~CompositorMutableStateProvider() {}
+
+PassOwnPtr<CompositorMutableState>
+CompositorMutableStateProvider::getMutableStateFor(uint64_t element_id)
+{
+ cc::LayerTreeImpl::ElementLayers layers = m_state->GetMutableLayers(element_id);
+
+ if (!layers.main && !layers.scroll)
+ return nullptr;
+
+ // Ensure that we have an entry in the map for |element_id| but do as few
+ // allocations and queries as possible. This will update the map only if we
+ // have not added a value for |element_id|.
+ auto result = m_mutations->map.add(element_id, nullptr);
+
+ // Only if this is a new entry do we want to allocate a new mutation.
+ if (result.isNewEntry)
+ result.storedValue->value = adoptPtr(new CompositorMutation);
+
+ return adoptPtr(new CompositorMutableState(result.storedValue->value.get(), layers.main, layers.scroll));
+}
+
+} // namespace blink
diff --git a/third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.h b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.h
new file mode 100644
index 0000000..3f1b8fc
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.h
@@ -0,0 +1,37 @@
+// Copyright 2016 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 CompositorMutableStateProvider_h
+#define CompositorMutableStateProvider_h
+
+#include "platform/PlatformExport.h"
+#include "wtf/PassOwnPtr.h"
+
+#include <cstdint>
+
+namespace cc {
+class LayerTreeImpl;
+} // namespace cc
+
+namespace blink {
+
+class CompositorMutableState;
+struct CompositorMutations;
+
+// This class is a window onto compositor-owned state. It vends out wrappers
+// around per-element bits of this state.
+class PLATFORM_EXPORT CompositorMutableStateProvider {
+public:
+ CompositorMutableStateProvider(cc::LayerTreeImpl*, CompositorMutations*);
+ ~CompositorMutableStateProvider();
+
+ PassOwnPtr<CompositorMutableState> getMutableStateFor(uint64_t elementId);
+private:
+ cc::LayerTreeImpl* m_state;
+ CompositorMutations* m_mutations;
+};
+
+} // namespace blink
+
+#endif // CompositorMutableStateProvider_h
diff --git a/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp
new file mode 100644
index 0000000..1b4d2a9
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp
@@ -0,0 +1,159 @@
+// Copyright 2016 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 "platform/graphics/CompositorMutableState.h"
+
+#include "base/message_loop/message_loop.h"
+#include "cc/test/fake_impl_task_runner_provider.h"
+#include "cc/test/fake_layer_tree_host_impl.h"
+#include "cc/test/fake_output_surface.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 "platform/graphics/CompositorMutableProperties.h"
+#include "platform/graphics/CompositorMutableStateProvider.h"
+#include "platform/graphics/CompositorMutation.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "wtf/OwnPtr.h"
+
+namespace blink {
+
+using cc::FakeImplTaskRunnerProvider;
+using cc::FakeLayerTreeHostImpl;
+using cc::FakeOutputSurface;
+using cc::LayerImpl;
+using cc::LayerTreeSettings;
+using cc::OutputSurface;
+using cc::TestTaskGraphRunner;
+using cc::TestSharedBitmapManager;
+
+class CompositorMutableStateTest : public testing::Test {
+public:
+ CompositorMutableStateTest()
+ : m_outputSurface(FakeOutputSurface::Create3d())
+ {
+ LayerTreeSettings settings;
+ settings.layer_transforms_should_scale_layer_contents = true;
+ settings.verify_property_trees = true;
+ m_hostImpl.reset(new FakeLayerTreeHostImpl(settings, &m_taskRunnerProvider, &m_sharedBitmapManager, &m_taskGraphRunner));
+ m_hostImpl->SetVisible(true);
+ EXPECT_TRUE(m_hostImpl->InitializeRenderer(m_outputSurface.get()));
+ }
+
+ void SetLayerPropertiesForTesting(LayerImpl* layer)
+ {
+ layer->SetTransform(gfx::Transform());
+ layer->SetTransformOrigin(gfx::Point3F());
+ layer->SetPosition(gfx::PointF());
+ layer->SetBounds(gfx::Size(100, 100));
+ layer->SetShouldFlattenTransform(true);
+ layer->Set3dSortingContextId(0);
+ layer->SetForceRenderSurface(true);
+ layer->SetDrawsContent(true);
+ }
+
+ FakeLayerTreeHostImpl& hostImpl() { return *m_hostImpl; }
+
+ LayerImpl* rootLayer() { return m_hostImpl->active_tree()->root_layer(); }
+
+private:
+ // The cc testing machinery has fairly deep dependency on having a main
+ // message loop (one example is the task runner provider). We construct one
+ // here so that it's installed in TLA and can be found by other cc classes.
+ base::MessageLoop m_messageLoop;
+ TestSharedBitmapManager m_sharedBitmapManager;
+ TestTaskGraphRunner m_taskGraphRunner;
+ FakeImplTaskRunnerProvider m_taskRunnerProvider;
+ scoped_ptr<OutputSurface> m_outputSurface;
+ scoped_ptr<FakeLayerTreeHostImpl> m_hostImpl;
+};
+
+TEST_F(CompositorMutableStateTest, NoMutableState)
+{
+ // In this test, there are no layers with either an element id or mutable
+ // properties. We should not be able to get any mutable state.
+ scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree(), 42);
+ SetLayerPropertiesForTesting(root.get());
+
+ hostImpl().SetViewportSize(root->bounds());
+ hostImpl().active_tree()->SetRootLayer(std::move(root));
+ hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
+
+ CompositorMutations mutations;
+ CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations);
+ OwnPtr<CompositorMutableState> state(provider.getMutableStateFor(42));
+ EXPECT_FALSE(state);
+}
+
+TEST_F(CompositorMutableStateTest, MutableStateNoMutableProperties)
+{
+ // In this test, there is a layer with an element id, but no mutable
+ // properties. This should behave just as if we'd had no element id.
+ scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree(), 42);
+ SetLayerPropertiesForTesting(root.get());
+ root->SetElementId(42);
+
+ hostImpl().SetViewportSize(root->bounds());
+ hostImpl().active_tree()->SetRootLayer(std::move(root));
+ hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
+
+ CompositorMutations mutations;
+ CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations);
+ OwnPtr<CompositorMutableState> state(provider.getMutableStateFor(42));
+ EXPECT_FALSE(state);
+}
+
+TEST_F(CompositorMutableStateTest, MutableStateMutableProperties)
+{
+ // In this test, there is a layer with an element id and mutable properties.
+ // In this case, we should get a valid mutable state for this element id that
+ // has a real effect on the corresponding layer.
+ scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree(), 42);
+ SetLayerPropertiesForTesting(root.get());
+ root->SetElementId(42);
+ root->SetMutableProperties(CompositorMutableProperty::kOpacity | CompositorMutableProperty::kTransform | CompositorMutableProperty::kScrollLeft | CompositorMutableProperty::kScrollTop);
+
+ hostImpl().SetViewportSize(root->bounds());
+ hostImpl().active_tree()->SetRootLayer(std::move(root));
+ hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
+
+ CompositorMutations mutations;
+ CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations);
+
+ OwnPtr<CompositorMutableState> state(provider.getMutableStateFor(42));
+ EXPECT_TRUE(state.get());
+
+ EXPECT_EQ(1.0, rootLayer()->opacity());
+ EXPECT_EQ(gfx::Transform().ToString(), rootLayer()->transform().ToString());
+ EXPECT_EQ(0.0, rootLayer()->CurrentScrollOffset().x());
+ EXPECT_EQ(0.0, rootLayer()->CurrentScrollOffset().y());
+
+ gfx::Transform zero(0, 0, 0, 0, 0, 0);
+ state->setOpacity(0.5);
+ state->setTransform(zero.matrix());
+ state->setScrollLeft(1.0);
+ state->setScrollTop(1.0);
+
+ EXPECT_EQ(0.5, rootLayer()->opacity());
+ EXPECT_EQ(zero.ToString(), rootLayer()->transform().ToString());
+ EXPECT_EQ(1.0, rootLayer()->CurrentScrollOffset().x());
+ EXPECT_EQ(1.0, rootLayer()->CurrentScrollOffset().y());
+
+ // The corresponding mutation should reflect the changed values.
+ EXPECT_EQ(1ul, mutations.map.size());
+
+ const CompositorMutation& mutation = *mutations.map.find(42)->value;
+ EXPECT_TRUE(mutation.isOpacityMutated());
+ EXPECT_TRUE(mutation.isTransformMutated());
+ EXPECT_TRUE(mutation.isScrollLeftMutated());
+ EXPECT_TRUE(mutation.isScrollTopMutated());
+
+ EXPECT_EQ(0.5, mutation.opacity());
+ EXPECT_EQ(zero.ToString(), gfx::Transform(mutation.transform()).ToString());
+ EXPECT_EQ(1.0, mutation.scrollLeft());
+ EXPECT_EQ(1.0, mutation.scrollTop());
+}
+
+} // namespace blink
diff --git a/third_party/WebKit/Source/platform/graphics/CompositorMutation.h b/third_party/WebKit/Source/platform/graphics/CompositorMutation.h
new file mode 100644
index 0000000..21c620c
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/CompositorMutation.h
@@ -0,0 +1,61 @@
+// Copyright 2016 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 CompositorMutation_h
+#define CompositorMutation_h
+
+#include "platform/graphics/CompositorMutableProperties.h"
+#include "third_party/skia/include/utils/SkMatrix44.h"
+#include "wtf/HashMap.h"
+
+namespace blink {
+
+class CompositorMutation {
+public:
+ void setOpacity(float opacity)
+ {
+ m_mutatedFlags |= CompositorMutableProperty::kOpacity;
+ m_opacity = opacity;
+ }
+ void setScrollLeft(float scrollLeft)
+ {
+ m_mutatedFlags |= CompositorMutableProperty::kScrollLeft;
+ m_scrollLeft = scrollLeft;
+ }
+ void setScrollTop(float scrollTop)
+ {
+ m_mutatedFlags |= CompositorMutableProperty::kScrollTop;
+ m_scrollTop = scrollTop;
+ }
+ void setTransform(const SkMatrix44& transform)
+ {
+ m_mutatedFlags |= CompositorMutableProperty::kTransform;
+ m_transform = transform;
+ }
+
+ bool isOpacityMutated() const { return m_mutatedFlags & CompositorMutableProperty::kOpacity; }
+ bool isScrollLeftMutated() const { return m_mutatedFlags & CompositorMutableProperty::kScrollLeft; }
+ bool isScrollTopMutated() const { return m_mutatedFlags & CompositorMutableProperty::kScrollTop; }
+ bool isTransformMutated() const { return m_mutatedFlags & CompositorMutableProperty::kTransform; }
+
+ float opacity() const { return m_opacity; }
+ float scrollLeft() const { return m_scrollLeft; }
+ float scrollTop() const { return m_scrollTop; }
+ SkMatrix44 transform() const { return m_transform; }
+
+private:
+ uint32_t m_mutatedFlags = 0;
+ float m_opacity = 0;
+ float m_scrollLeft = 0;
+ float m_scrollTop = 0;
+ SkMatrix44 m_transform;
+};
+
+struct CompositorMutations {
+ HashMap<uint64_t, OwnPtr<CompositorMutation>> map;
+};
+
+} // namespace blink
+
+#endif // CompositorMutation_h
diff --git a/third_party/WebKit/Source/platform/graphics/DEPS b/third_party/WebKit/Source/platform/graphics/DEPS
index e19930c..226f05e 100644
--- a/third_party/WebKit/Source/platform/graphics/DEPS
+++ b/third_party/WebKit/Source/platform/graphics/DEPS
@@ -1,6 +1,7 @@
include_rules = [
# To whitelist base/ stuff Blink is allowed to include, we list up all
# directories and files instead of writing 'base/'.
+ "+base/message_loop",
"+cc",
"-cc/blink",
]
diff --git a/third_party/WebKit/Source/web/tests/CompositorWorkerTest.cpp b/third_party/WebKit/Source/web/tests/CompositorWorkerTest.cpp
index d5874a3..d622662 100644
--- a/third_party/WebKit/Source/web/tests/CompositorWorkerTest.cpp
+++ b/third_party/WebKit/Source/web/tests/CompositorWorkerTest.cpp
@@ -7,10 +7,10 @@
#include "core/layout/compositing/CompositedLayerMapping.h"
#include "core/layout/compositing/PaintLayerCompositor.h"
#include "core/page/Page.h"
+#include "platform/graphics/CompositorMutableProperties.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/testing/URLTestHelpers.h"
#include "public/platform/Platform.h"
-#include "public/platform/WebCompositorMutableProperties.h"
#include "public/platform/WebLayer.h"
#include "public/platform/WebLayerTreeView.h"
#include "public/platform/WebUnitTestSupport.h"
@@ -135,19 +135,19 @@ TEST_F(CompositorWorkerTest, plumbingElementIdAndMutableProperties)
Element* proxiedElement = document->getElementById("proxied");
WebLayer* proxiedLayer = webLayerFromElement(proxiedElement);
- EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & WebCompositorMutablePropertyTransform);
- EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (WebCompositorMutablePropertyScrollLeft | WebCompositorMutablePropertyScrollTop | WebCompositorMutablePropertyOpacity));
+ EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMutableProperty::kTransform);
+ EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (CompositorMutableProperty::kScrollLeft | CompositorMutableProperty::kScrollTop | CompositorMutableProperty::kOpacity));
EXPECT_NE(0UL, proxiedLayer->elementId());
Element* scrollElement = document->getElementById("proxied-scroller");
WebLayer* scrollLayer = scrollingWebLayerFromElement(scrollElement);
- EXPECT_TRUE(scrollLayer->compositorMutableProperties() & (WebCompositorMutablePropertyScrollLeft | WebCompositorMutablePropertyScrollTop));
- EXPECT_FALSE(scrollLayer->compositorMutableProperties() & (WebCompositorMutablePropertyTransform | WebCompositorMutablePropertyOpacity));
+ EXPECT_TRUE(scrollLayer->compositorMutableProperties() & (CompositorMutableProperty::kScrollLeft | CompositorMutableProperty::kScrollTop));
+ EXPECT_FALSE(scrollLayer->compositorMutableProperties() & (CompositorMutableProperty::kTransform | CompositorMutableProperty::kOpacity));
EXPECT_NE(0UL, scrollLayer->elementId());
WebLayer* rootScrollLayer = getRootScrollLayer();
- EXPECT_TRUE(rootScrollLayer->compositorMutableProperties() & (WebCompositorMutablePropertyScrollLeft | WebCompositorMutablePropertyScrollTop));
- EXPECT_FALSE(rootScrollLayer->compositorMutableProperties() & (WebCompositorMutablePropertyTransform | WebCompositorMutablePropertyOpacity));
+ EXPECT_TRUE(rootScrollLayer->compositorMutableProperties() & (CompositorMutableProperty::kScrollLeft | CompositorMutableProperty::kScrollTop));
+ EXPECT_FALSE(rootScrollLayer->compositorMutableProperties() & (CompositorMutableProperty::kTransform | CompositorMutableProperty::kOpacity));
EXPECT_NE(0UL, rootScrollLayer->elementId());
}
diff --git a/third_party/WebKit/public/platform/WebCompositorMutableProperties.h b/third_party/WebKit/public/platform/WebCompositorMutableProperties.h
deleted file mode 100644
index 63b3797..0000000
--- a/third_party/WebKit/public/platform/WebCompositorMutableProperties.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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 WebCompositorMutableProperties_h
-#define WebCompositorMutableProperties_h
-
-namespace blink {
-
-// TODO(vollick): we should not need a parallel enum. This must be kept in sync
-// with the cc::MutableProperty enum.
-enum WebCompositorMutableProperty {
- WebCompositorMutablePropertyNone = 0,
- WebCompositorMutablePropertyOpacity = 1 << 0,
- WebCompositorMutablePropertyScrollLeft = 1 << 1,
- WebCompositorMutablePropertyScrollTop = 1 << 2,
- WebCompositorMutablePropertyTransform = 1 << 3,
-};
-
-const int kNumWebCompositorMutableProperties = 4;
-
-} // namespace blink
-
-#endif // WebCompositorMutableProperties_h
diff --git a/third_party/WebKit/public/platform/WebCompositorMutableState.h b/third_party/WebKit/public/platform/WebCompositorMutableState.h
deleted file mode 100644
index a4d57d2..0000000
--- a/third_party/WebKit/public/platform/WebCompositorMutableState.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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 WebCompositorMutableState_h
-#define WebCompositorMutableState_h
-
-#include <cstdint>
-
-class SkMatrix44;
-
-namespace blink {
-
-// This class wraps the compositor-owned, mutable state for a single element.
-class WebCompositorMutableState {
-public:
- virtual ~WebCompositorMutableState() { }
-
- virtual double opacity() const = 0;
- virtual void setOpacity(double) = 0;
-
- virtual const SkMatrix44& transform() const = 0;
- virtual void setTransform(const SkMatrix44&) = 0;
-
- virtual double scrollLeft() const = 0;
- virtual void setScrollLeft(double) = 0;
-
- virtual double scrollTop() const = 0;
- virtual void setScrollTop(double) = 0;
-};
-
-} // namespace blink
-
-#endif // WebCompositorMutableState_h
diff --git a/third_party/WebKit/public/platform/WebCompositorMutableStateProvider.h b/third_party/WebKit/public/platform/WebCompositorMutableStateProvider.h
deleted file mode 100644
index c2dca7c..0000000
--- a/third_party/WebKit/public/platform/WebCompositorMutableStateProvider.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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 WebCompositorMutableStateProvider_h
-#define WebCompositorMutableStateProvider_h
-
-#include "public/platform/WebPassOwnPtr.h"
-
-#include <cstdint>
-
-namespace blink {
-
-class WebCompositorMutableState;
-
-// This class is a window onto compositor-owned state. It vends out wrappers
-// around per-element bits of this state.
-class WebCompositorMutableStateProvider {
-public:
- virtual ~WebCompositorMutableStateProvider() { }
-
- // The caller is expected to take ownership.
- virtual WebPassOwnPtr<WebCompositorMutableState> getMutableStateFor(uint64_t elementId) = 0;
-};
-
-} // namespace blink
-
-#endif // WebCompositorMutableStateProvider_h