summaryrefslogtreecommitdiff
path: root/chromium/ui/compositor
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-07-14 17:41:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-08-04 12:37:36 +0000
commit399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (patch)
tree6b06b60ff365abef0e13b3503d593a0df48d20e8 /chromium/ui/compositor
parent7366110654eec46f21b6824f302356426f48cd74 (diff)
downloadqtwebengine-chromium-399c965b6064c440ddcf4015f5f8e9d131c7a0a6.tar.gz
BASELINE: Update Chromium to 52.0.2743.76 and Ninja to 1.7.1
Change-Id: I382f51b959689505a60f8b707255ecb344f7d8b4 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/ui/compositor')
-rw-r--r--chromium/ui/compositor/BUILD.gn1
-rw-r--r--chromium/ui/compositor/callback_layer_animation_observer_unittest.cc17
-rw-r--r--chromium/ui/compositor/compositor.cc64
-rw-r--r--chromium/ui/compositor/compositor.gyp1
-rw-r--r--chromium/ui/compositor/compositor.h48
-rw-r--r--chromium/ui/compositor/compositor_unittest.cc123
-rw-r--r--chromium/ui/compositor/debug_utils.cc67
-rw-r--r--chromium/ui/compositor/dip_util.cc1
-rw-r--r--chromium/ui/compositor/float_animation_curve_adapter.cc5
-rw-r--r--chromium/ui/compositor/float_animation_curve_adapter.h4
-rw-r--r--chromium/ui/compositor/layer.cc43
-rw-r--r--chromium/ui/compositor/layer.h48
-rw-r--r--chromium/ui/compositor/layer_animation_element.cc34
-rw-r--r--chromium/ui/compositor/layer_animation_element_unittest.cc33
-rw-r--r--chromium/ui/compositor/layer_animation_sequence.cc10
-rw-r--r--chromium/ui/compositor/layer_animation_sequence.h8
-rw-r--r--chromium/ui/compositor/layer_animation_sequence_unittest.cc22
-rw-r--r--chromium/ui/compositor/layer_animator.cc141
-rw-r--r--chromium/ui/compositor/layer_animator.h34
-rw-r--r--chromium/ui/compositor/layer_animator_unittest.cc142
-rw-r--r--chromium/ui/compositor/layer_owner.cc9
-rw-r--r--chromium/ui/compositor/layer_owner.h9
-rw-r--r--chromium/ui/compositor/layer_owner_unittest.cc40
-rw-r--r--chromium/ui/compositor/layer_threaded_animation_delegate.h6
-rw-r--r--chromium/ui/compositor/layer_unittest.cc285
-rw-r--r--chromium/ui/compositor/paint_context.h5
-rw-r--r--chromium/ui/compositor/paint_recorder.cc5
-rw-r--r--chromium/ui/compositor/paint_recorder.h4
-rw-r--r--chromium/ui/compositor/scoped_layer_animation_settings.cc36
-rw-r--r--chromium/ui/compositor/scoped_layer_animation_settings.h2
-rw-r--r--chromium/ui/compositor/test/test_compositor_host_ozone.cc8
-rw-r--r--chromium/ui/compositor/transform_animation_curve_adapter.cc11
-rw-r--r--chromium/ui/compositor/transform_animation_curve_adapter.h6
33 files changed, 589 insertions, 683 deletions
diff --git a/chromium/ui/compositor/BUILD.gn b/chromium/ui/compositor/BUILD.gn
index 7f849b7846a..d1175eaca70 100644
--- a/chromium/ui/compositor/BUILD.gn
+++ b/chromium/ui/compositor/BUILD.gn
@@ -146,6 +146,7 @@ source_set("test_support") {
"//skia",
"//testing/gtest",
"//ui/base",
+ "//ui/display",
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/gl:test_support",
diff --git a/chromium/ui/compositor/callback_layer_animation_observer_unittest.cc b/chromium/ui/compositor/callback_layer_animation_observer_unittest.cc
index f42f561e0a1..6ea60b7fd37 100644
--- a/chromium/ui/compositor/callback_layer_animation_observer_unittest.cc
+++ b/chromium/ui/compositor/callback_layer_animation_observer_unittest.cc
@@ -4,9 +4,11 @@
#include "ui/compositor/callback_layer_animation_observer.h"
+#include <memory>
+
#include "base/bind.h"
#include "base/macros.h"
-#include "base/memory/scoped_vector.h"
+#include "base/memory/ptr_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/compositor/layer_animation_sequence.h"
#include "ui/compositor/test/layer_animation_observer_test_api.h"
@@ -218,15 +220,15 @@ class CallbackLayerAnimationObserverTest : public testing::Test {
// managed by this.
LayerAnimationSequence* CreateLayerAnimationSequence();
- scoped_ptr<TestCallbacks> callbacks_;
+ std::unique_ptr<TestCallbacks> callbacks_;
- scoped_ptr<CallbackLayerAnimationObserver> observer_;
+ std::unique_ptr<CallbackLayerAnimationObserver> observer_;
- scoped_ptr<LayerAnimationObserverTestApi> observer_test_api_;
+ std::unique_ptr<LayerAnimationObserverTestApi> observer_test_api_;
// List of managaged sequences created by CreateLayerAnimationSequence() that
// need to be destroyed.
- ScopedVector<LayerAnimationSequence> sequences_;
+ std::vector<std::unique_ptr<LayerAnimationSequence>> sequences_;
private:
DISALLOW_COPY_AND_ASSIGN(CallbackLayerAnimationObserverTest);
@@ -251,9 +253,8 @@ CallbackLayerAnimationObserverTest::~CallbackLayerAnimationObserverTest() {
LayerAnimationSequence*
CallbackLayerAnimationObserverTest::CreateLayerAnimationSequence() {
- LayerAnimationSequence* sequence = new LayerAnimationSequence();
- sequences_.push_back(sequence);
- return sequence;
+ sequences_.emplace_back(new LayerAnimationSequence);
+ return sequences_.back().get();
}
TEST(CallbackLayerAnimationObserverDestructionTest, VerifyFalseAutoDelete) {
diff --git a/chromium/ui/compositor/compositor.cc b/chromium/ui/compositor/compositor.cc
index 9c492698b5c..47c5c9f0d5f 100644
--- a/chromium/ui/compositor/compositor.cc
+++ b/chromium/ui/compositor/compositor.cc
@@ -45,6 +45,11 @@ namespace {
const double kDefaultRefreshRate = 60.0;
const double kTestRefreshRate = 200.0;
+bool IsRunningInMojoShell(base::CommandLine* command_line) {
+ const char kMojoShellFlag[] = "mojo-platform-channel-handle";
+ return command_line->HasSwitch(kMojoShellFlag);
+}
+
} // namespace
namespace ui {
@@ -149,6 +154,9 @@ Compositor::Compositor(ui::ContextFactory* context_factory,
if (command_line->HasSwitch(switches::kUIEnableRGBA4444Textures))
settings.renderer_settings.preferred_tile_format = cc::RGBA_4444;
+ settings.use_layer_lists =
+ command_line->HasSwitch(cc::switches::kUIEnableLayerLists);
+
// UI compositor always uses partial raster if not using zero-copy. Zero copy
// doesn't currently support partial raster.
settings.use_partial_raster = !settings.use_zero_copy;
@@ -172,6 +180,11 @@ Compositor::Compositor(ui::ContextFactory* context_factory,
// thread.
settings.image_decode_tasks_enabled = false;
+ // TODO(crbug.com/603600): This should always be turned on once mus tells its
+ // clients about BeginFrame.
+ settings.use_output_surface_begin_frame_source =
+ !IsRunningInMojoShell(command_line);
+
#if !defined(OS_ANDROID)
// TODO(sohanjg): Revisit this memory usage in tile manager.
cc::ManagedMemoryPolicy policy(
@@ -229,7 +242,7 @@ Compositor::~Compositor() {
}
void Compositor::SetOutputSurface(
- scoped_ptr<cc::OutputSurface> output_surface) {
+ std::unique_ptr<cc::OutputSurface> output_surface) {
output_surface_requested_ = false;
host_->SetOutputSurface(std::move(output_surface));
}
@@ -283,7 +296,7 @@ void Compositor::DisableSwapUntilResize() {
}
void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) {
- scoped_ptr<cc::SwapPromise> swap_promise(
+ std::unique_ptr<cc::SwapPromise> swap_promise(
new cc::LatencyInfoSwapPromise(latency_info));
host_->QueueSwapPromise(std::move(swap_promise));
}
@@ -319,13 +332,11 @@ bool Compositor::IsVisible() {
void Compositor::SetAuthoritativeVSyncInterval(
const base::TimeDelta& interval) {
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ context_factory_->SetAuthoritativeVSyncInterval(this, interval);
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
cc::switches::kEnableBeginFrameScheduling)) {
- host_->SetAuthoritativeVSyncInterval(interval);
- return;
+ vsync_manager_->SetAuthoritativeVSyncInterval(interval);
}
-
- vsync_manager_->SetAuthoritativeVSyncInterval(interval);
}
void Compositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) {
@@ -384,24 +395,6 @@ bool Compositor::HasAnimationObserver(
return animation_observer_list_.HasObserver(observer);
}
-void Compositor::AddBeginFrameObserver(CompositorBeginFrameObserver* observer) {
- if (!begin_frame_observer_list_.might_have_observers())
- host_->SetChildrenNeedBeginFrames(true);
-
- begin_frame_observer_list_.AddObserver(observer);
-
- if (missed_begin_frame_args_.IsValid())
- observer->OnSendBeginFrame(missed_begin_frame_args_);
-}
-
-void Compositor::RemoveBeginFrameObserver(
- CompositorBeginFrameObserver* observer) {
- begin_frame_observer_list_.RemoveObserver(observer);
-
- // As this call may take place while iterating over observers, unsubscription
- // from |host_| is performed after iteration in |SendBeginFramesToChildren()|.
-}
-
void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) {
FOR_EACH_OBSERVER(CompositorAnimationObserver,
animation_observer_list_,
@@ -469,26 +462,7 @@ void Compositor::DidAbortSwapBuffers() {
}
void Compositor::SetOutputIsSecure(bool output_is_secure) {
- host_->SetOutputIsSecure(output_is_secure);
- host_->SetNeedsRedraw();
-}
-
-void Compositor::SendBeginFramesToChildren(const cc::BeginFrameArgs& args) {
- FOR_EACH_OBSERVER(CompositorBeginFrameObserver, begin_frame_observer_list_,
- OnSendBeginFrame(args));
-
- // Unsubscription is performed here, after iteration, to handle the case where
- // the last BeginFrame observer is removed while iterating over the observers.
- if (!begin_frame_observer_list_.might_have_observers()) {
- host_->SetChildrenNeedBeginFrames(false);
- // Unsubscription should reset |missed_begin_frame_args_|, avoiding stale
- // BeginFrame dispatch when the next BeginFrame observer is added.
- missed_begin_frame_args_ = cc::BeginFrameArgs();
- return;
- }
-
- missed_begin_frame_args_ = args;
- missed_begin_frame_args_.type = cc::BeginFrameArgs::MISSED;
+ context_factory_->SetOutputIsSecure(this, output_is_secure);
}
const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const {
diff --git a/chromium/ui/compositor/compositor.gyp b/chromium/ui/compositor/compositor.gyp
index c692274f84e..5a0f68c4324 100644
--- a/chromium/ui/compositor/compositor.gyp
+++ b/chromium/ui/compositor/compositor.gyp
@@ -111,6 +111,7 @@
'<(DEPTH)/testing/gtest.gyp:gtest',
'<(DEPTH)/third_party/WebKit/public/blink.gyp:blink_minimal',
'<(DEPTH)/ui/base/ui_base.gyp:ui_base',
+ '<(DEPTH)/ui/display/display.gyp:display',
'<(DEPTH)/ui/gfx/gfx.gyp:gfx',
'<(DEPTH)/ui/gfx/gfx.gyp:gfx_geometry',
'<(DEPTH)/ui/gl/gl.gyp:gl',
diff --git a/chromium/ui/compositor/compositor.h b/chromium/ui/compositor/compositor.h
index acae0be40c2..a6245dae5af 100644
--- a/chromium/ui/compositor/compositor.h
+++ b/chromium/ui/compositor/compositor.h
@@ -7,12 +7,12 @@
#include <stdint.h>
+#include <memory>
#include <string>
#include "base/containers/hash_tables.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
@@ -44,6 +44,7 @@ class LayerTreeHost;
class RendererSettings;
class SharedBitmapManager;
class SurfaceIdAllocator;
+class SurfaceManager;
class TaskGraphRunner;
}
@@ -81,8 +82,9 @@ class COMPOSITOR_EXPORT ContextFactory {
// Creates a reflector that copies the content of the |mirrored_compositor|
// onto |mirroring_layer|.
- virtual scoped_ptr<Reflector> CreateReflector(Compositor* mirrored_compositor,
- Layer* mirroring_layer) = 0;
+ virtual std::unique_ptr<Reflector> CreateReflector(
+ Compositor* mirrored_compositor,
+ Layer* mirroring_layer) = 0;
// Removes the reflector, which stops the mirroring.
virtual void RemoveReflector(Reflector* reflector) = 0;
@@ -112,11 +114,20 @@ class COMPOSITOR_EXPORT ContextFactory {
virtual cc::TaskGraphRunner* GetTaskGraphRunner() = 0;
// Creates a Surface ID allocator with a new namespace.
- virtual scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator() = 0;
+ virtual std::unique_ptr<cc::SurfaceIdAllocator>
+ CreateSurfaceIdAllocator() = 0;
+
+ // Gets the surface manager.
+ virtual cc::SurfaceManager* GetSurfaceManager() = 0;
// Resize the display corresponding to this compositor to a particular size.
virtual void ResizeDisplay(ui::Compositor* compositor,
const gfx::Size& size) = 0;
+
+ virtual void SetAuthoritativeVSyncInterval(ui::Compositor* compositor,
+ base::TimeDelta interval) = 0;
+
+ virtual void SetOutputIsSecure(Compositor* compositor, bool secure) = 0;
};
// This class represents a lock on the compositor, that can be used to prevent
@@ -145,13 +156,6 @@ class COMPOSITOR_EXPORT CompositorLock
DISALLOW_COPY_AND_ASSIGN(CompositorLock);
};
-// This class observes BeginFrame notification from LayerTreeHost.
-class COMPOSITOR_EXPORT CompositorBeginFrameObserver {
- public:
- virtual ~CompositorBeginFrameObserver() {}
- virtual void OnSendBeginFrame(const cc::BeginFrameArgs& args) = 0;
-};
-
// Compositor object to take care of GPU painting.
// A Browser compositor object is responsible for generating the final
// displayable form of pixels comprising a single widget's contents. It draws an
@@ -167,7 +171,7 @@ class COMPOSITOR_EXPORT Compositor
ui::ContextFactory* context_factory() { return context_factory_; }
- void SetOutputSurface(scoped_ptr<cc::OutputSurface> surface);
+ void SetOutputSurface(std::unique_ptr<cc::OutputSurface> surface);
// Schedules a redraw of the layer tree associated with this compositor.
void ScheduleDraw();
@@ -261,9 +265,6 @@ class COMPOSITOR_EXPORT Compositor
void RemoveAnimationObserver(CompositorAnimationObserver* observer);
bool HasAnimationObserver(const CompositorAnimationObserver* observer) const;
- void AddBeginFrameObserver(CompositorBeginFrameObserver* observer);
- void RemoveBeginFrameObserver(CompositorBeginFrameObserver* observer);
-
// Change the timeout behavior for all future locks that are created. Locks
// should time out if there is an expectation that the compositor will be
// responsive.
@@ -306,11 +307,9 @@ class COMPOSITOR_EXPORT Compositor
void DidCommitAndDrawFrame() override;
void DidCompleteSwapBuffers() override;
void DidCompletePageScaleAnimation() override {}
- void SendBeginFramesToChildren(const cc::BeginFrameArgs& args) override;
- void RecordFrameTimingEvents(
- scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events,
- scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events)
- override {}
+ void ReportFixedRasterScaleUseCounters(
+ bool has_blurry_content,
+ bool has_potential_performance_regression) override {}
// cc::LayerTreeHostSingleThreadClient implementation.
void DidPostSwapBuffers() override;
@@ -351,15 +350,13 @@ class COMPOSITOR_EXPORT Compositor
base::ObserverList<CompositorObserver, true> observer_list_;
base::ObserverList<CompositorAnimationObserver> animation_observer_list_;
- base::ObserverList<CompositorBeginFrameObserver, true>
- begin_frame_observer_list_;
gfx::AcceleratedWidget widget_;
bool widget_valid_;
bool output_surface_requested_;
- scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_;
+ std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_;
scoped_refptr<cc::Layer> root_web_layer_;
- scoped_ptr<cc::LayerTreeHost> host_;
+ std::unique_ptr<cc::LayerTreeHost> host_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
// The manager of vsync parameters for this compositor.
@@ -378,9 +375,6 @@ class COMPOSITOR_EXPORT Compositor
LayerAnimatorCollection layer_animator_collection_;
scoped_refptr<cc::AnimationTimeline> animation_timeline_;
- // Used to send to any new CompositorBeginFrameObserver immediately.
- cc::BeginFrameArgs missed_begin_frame_args_;
-
base::WeakPtrFactory<Compositor> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(Compositor);
diff --git a/chromium/ui/compositor/compositor_unittest.cc b/chromium/ui/compositor/compositor_unittest.cc
index 50180ad1edb..4c76aceb132 100644
--- a/chromium/ui/compositor/compositor_unittest.cc
+++ b/chromium/ui/compositor/compositor_unittest.cc
@@ -4,7 +4,7 @@
#include "base/macros.h"
#include "base/run_loop.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "cc/output/begin_frame_args.h"
#include "cc/test/begin_frame_args_test.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -24,11 +24,6 @@ ACTION_P2(RemoveObserver, compositor, observer) {
compositor->RemoveBeginFrameObserver(observer);
}
-class MockCompositorBeginFrameObserver : public CompositorBeginFrameObserver {
- public:
- MOCK_METHOD1(OnSendBeginFrame, void(const cc::BeginFrameArgs&));
-};
-
// Test fixture for tests that require a ui::Compositor with a real task
// runner.
class CompositorTest : public testing::Test {
@@ -56,7 +51,7 @@ class CompositorTest : public testing::Test {
private:
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
- scoped_ptr<ui::Compositor> compositor_;
+ std::unique_ptr<ui::Compositor> compositor_;
DISALLOW_COPY_AND_ASSIGN(CompositorTest);
};
@@ -91,109 +86,6 @@ TEST_F(CompositorTest, LocksTimeOut) {
}
}
-TEST_F(CompositorTest, AddAndRemoveBeginFrameObserver) {
- cc::BeginFrameArgs args =
- cc::CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE,
- base::TimeTicks::FromInternalValue(33));
-
- MockCompositorBeginFrameObserver test_observer;
- MockCompositorBeginFrameObserver test_observer2;
-
- // Add a single observer.
- compositor()->AddBeginFrameObserver(&test_observer);
- Mock::VerifyAndClearExpectations(&test_observer);
-
- // When |missed_begin_frame_args_| is sent, its type is set to MISSED.
- cc::BeginFrameArgs expected_args(args);
- cc::BeginFrameArgs expected_missed_args(args);
- expected_missed_args.type = cc::BeginFrameArgs::MISSED;
-
- // Simulate to trigger new BeginFrame by using |args|.
- EXPECT_CALL(test_observer, OnSendBeginFrame(expected_args));
- compositor()->SendBeginFramesToChildren(args);
- Mock::VerifyAndClearExpectations(&test_observer);
-
- // When new observer is added, Compositor immediately calls OnSendBeginFrame
- // with |missed_begin_frame_args_|.
- EXPECT_CALL(test_observer2, OnSendBeginFrame(expected_missed_args));
- compositor()->AddBeginFrameObserver(&test_observer2);
- Mock::VerifyAndClearExpectations(&test_observer);
- Mock::VerifyAndClearExpectations(&test_observer2);
-
- // When |test_observer2| is removed and added again, it will be called again.
- EXPECT_CALL(test_observer2, OnSendBeginFrame(expected_missed_args));
- compositor()->RemoveBeginFrameObserver(&test_observer2);
- compositor()->AddBeginFrameObserver(&test_observer2);
- Mock::VerifyAndClearExpectations(&test_observer2);
-
- // When all observer is removed, |missed_begin_frame_args_| is invalidated.
- // So, it is not used for newly added observer.
- EXPECT_CALL(test_observer2, OnSendBeginFrame(_)).Times(0);
- compositor()->RemoveBeginFrameObserver(&test_observer);
- compositor()->RemoveBeginFrameObserver(&test_observer2);
- compositor()->SendBeginFramesToChildren(args);
- compositor()->AddBeginFrameObserver(&test_observer2);
- Mock::VerifyAndClearExpectations(&test_observer2);
-
- compositor()->RemoveBeginFrameObserver(&test_observer2);
-}
-
-TEST_F(CompositorTest, RemoveBeginFrameObserverWhileSendingBeginFrame) {
- cc::BeginFrameArgs args = cc::CreateBeginFrameArgsForTesting(
- BEGINFRAME_FROM_HERE, base::TimeTicks::FromInternalValue(33));
-
- cc::BeginFrameArgs expected_args(args);
- cc::BeginFrameArgs expected_missed_args(args);
- expected_missed_args.type = cc::BeginFrameArgs::MISSED;
-
- // Add both observers, and simulate removal of |test_observer2| during
- // BeginFrame dispatch (implicitly triggered when the observer is added).
- MockCompositorBeginFrameObserver test_observer;
- MockCompositorBeginFrameObserver test_observer2;
- EXPECT_CALL(test_observer, OnSendBeginFrame(expected_args));
- EXPECT_CALL(test_observer2, OnSendBeginFrame(expected_missed_args))
- .WillOnce(RemoveObserver(compositor(), &test_observer2));
-
- // When a new observer is added, Compositor immediately calls OnSendBeginFrame
- // with |missed_begin_frame_args_|.
- compositor()->AddBeginFrameObserver(&test_observer);
- compositor()->SendBeginFramesToChildren(args);
- compositor()->AddBeginFrameObserver(&test_observer2);
- Mock::VerifyAndClearExpectations(&test_observer);
- Mock::VerifyAndClearExpectations(&test_observer2);
-
- // |test_observer2| was removed during the previous implicit BeginFrame
- // dispatch, and should not get the new frame.
- expected_args.type = cc::BeginFrameArgs::NORMAL;
- EXPECT_CALL(test_observer, OnSendBeginFrame(expected_args));
- EXPECT_CALL(test_observer2, OnSendBeginFrame(_)).Times(0);
- compositor()->SendBeginFramesToChildren(args);
- Mock::VerifyAndClearExpectations(&test_observer);
- Mock::VerifyAndClearExpectations(&test_observer2);
-
- // Now remove |test_observer| during explicit BeginFrame dispatch.
- EXPECT_CALL(test_observer, OnSendBeginFrame(expected_args))
- .WillOnce(RemoveObserver(compositor(), &test_observer));
- EXPECT_CALL(test_observer2, OnSendBeginFrame(_)).Times(0);
- compositor()->SendBeginFramesToChildren(args);
- Mock::VerifyAndClearExpectations(&test_observer);
- Mock::VerifyAndClearExpectations(&test_observer2);
-
- // No observers should get the new frame.
- EXPECT_CALL(test_observer, OnSendBeginFrame(_)).Times(0);
- EXPECT_CALL(test_observer2, OnSendBeginFrame(_)).Times(0);
- compositor()->SendBeginFramesToChildren(args);
- Mock::VerifyAndClearExpectations(&test_observer);
- Mock::VerifyAndClearExpectations(&test_observer2);
-
- // Adding a new observer should not trigger a missed frame, as the
- // previous frame had no observers.
- EXPECT_CALL(test_observer, OnSendBeginFrame(_)).Times(0);
- compositor()->AddBeginFrameObserver(&test_observer);
- compositor()->RemoveBeginFrameObserver(&test_observer);
- Mock::VerifyAndClearExpectations(&test_observer);
-}
-
TEST_F(CompositorTest, ReleaseWidgetWithOutputSurfaceNeverCreated) {
compositor()->SetVisible(false);
EXPECT_EQ(gfx::kNullAcceleratedWidget,
@@ -202,8 +94,15 @@ TEST_F(CompositorTest, ReleaseWidgetWithOutputSurfaceNeverCreated) {
compositor()->SetVisible(true);
}
-TEST_F(CompositorTest, CreateAndReleaseOutputSurface) {
- scoped_ptr<Layer> root_layer(new Layer(ui::LAYER_SOLID_COLOR));
+#if defined(OS_WIN)
+// TODO(crbug.com/608436): Flaky on windows trybots
+#define MAYBE_CreateAndReleaseOutputSurface \
+ DISABLED_CreateAndReleaseOutputSurface
+#else
+#define MAYBE_CreateAndReleaseOutputSurface CreateAndReleaseOutputSurface
+#endif
+TEST_F(CompositorTest, MAYBE_CreateAndReleaseOutputSurface) {
+ std::unique_ptr<Layer> root_layer(new Layer(ui::LAYER_SOLID_COLOR));
root_layer->SetBounds(gfx::Rect(10, 10));
compositor()->SetRootLayer(root_layer.get());
compositor()->SetScaleAndSize(1.0f, gfx::Size(10, 10));
diff --git a/chromium/ui/compositor/debug_utils.cc b/chromium/ui/compositor/debug_utils.cc
index 3d0d42dd9aa..0fa6da712ae 100644
--- a/chromium/ui/compositor/debug_utils.cc
+++ b/chromium/ui/compositor/debug_utils.cc
@@ -14,15 +14,12 @@
#include <string>
#include "base/logging.h"
-#include "base/strings/utf_string_conversions.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/interpolated_transform.h"
#include "ui/gfx/transform.h"
-using base::UTF8ToWide;
-
namespace ui {
namespace {
@@ -30,79 +27,79 @@ namespace {
void PrintLayerHierarchyImp(const Layer* layer,
int indent,
gfx::Point mouse_location,
- std::wostringstream* out) {
+ std::ostringstream* out) {
std::string indent_str(indent, ' ');
layer->transform().TransformPointReverse(&mouse_location);
bool mouse_inside_layer_bounds = layer->bounds().Contains(mouse_location);
mouse_location.Offset(-layer->bounds().x(), -layer->bounds().y());
- *out << UTF8ToWide(indent_str);
+ *out << indent_str;
if (mouse_inside_layer_bounds)
- *out << L'*';
+ *out << '*';
else
- *out << L' ';
+ *out << ' ';
- *out << UTF8ToWide(layer->name()) << L' ' << layer;
+ *out << layer->name() << ' ' << layer;
switch (layer->type()) {
case ui::LAYER_NOT_DRAWN:
- *out << L" not_drawn";
+ *out << " not_drawn";
break;
case ui::LAYER_TEXTURED:
- *out << L" textured";
+ *out << " textured";
if (layer->fills_bounds_opaquely())
- *out << L" opaque";
+ *out << " opaque";
break;
case ui::LAYER_SOLID_COLOR:
- *out << L" solid";
+ *out << " solid";
break;
case ui::LAYER_NINE_PATCH:
- *out << L" nine_patch";
+ *out << " nine_patch";
break;
}
if (!layer->visible())
- *out << L" !visible";
+ *out << " !visible";
std::string property_indent_str(indent+3, ' ');
- *out << L'\n' << UTF8ToWide(property_indent_str);
- *out << L"bounds: " << layer->bounds().x() << L',' << layer->bounds().y();
- *out << L' ' << layer->bounds().width() << L'x' << layer->bounds().height();
+ *out << '\n' << property_indent_str;
+ *out << "bounds: " << layer->bounds().x() << ',' << layer->bounds().y();
+ *out << ' ' << layer->bounds().width() << 'x' << layer->bounds().height();
if (!layer->subpixel_position_offset().IsZero())
- *out << " " << UTF8ToWide(layer->subpixel_position_offset().ToString());
+ *out << " " << layer->subpixel_position_offset().ToString();
const ui::Layer* mask = const_cast<ui::Layer*>(layer)->layer_mask_layer();
if (mask) {
- *out << L'\n' << UTF8ToWide(property_indent_str);
- *out << L"mask layer: " << std::setprecision(2)
- << UTF8ToWide(mask->bounds().ToString())
- << UTF8ToWide(mask->subpixel_position_offset().ToString());
+ *out << '\n' << property_indent_str;
+ *out << "mask layer: " << std::setprecision(2)
+ << mask->bounds().ToString()
+ << mask->subpixel_position_offset().ToString();
}
if (layer->opacity() != 1.0f) {
- *out << L'\n' << UTF8ToWide(property_indent_str);
- *out << L"opacity: " << std::setprecision(2) << layer->opacity();
+ *out << '\n' << property_indent_str;
+ *out << "opacity: " << std::setprecision(2) << layer->opacity();
}
gfx::DecomposedTransform decomp;
if (!layer->transform().IsIdentity() &&
gfx::DecomposeTransform(&decomp, layer->transform())) {
- *out << L'\n' << UTF8ToWide(property_indent_str);
- *out << L"translation: " << std::fixed << decomp.translate[0];
- *out << L", " << decomp.translate[1];
+ *out << '\n' << property_indent_str;
+ *out << "translation: " << std::fixed << decomp.translate[0];
+ *out << ", " << decomp.translate[1];
- *out << L'\n' << UTF8ToWide(property_indent_str);
- *out << L"rotation: ";
+ *out << '\n' << property_indent_str;
+ *out << "rotation: ";
*out << std::acos(decomp.quaternion[3]) * 360.0 / M_PI;
- *out << L'\n' << UTF8ToWide(property_indent_str);
- *out << L"scale: " << decomp.scale[0];
- *out << L", " << decomp.scale[1];
+ *out << '\n' << property_indent_str;
+ *out << "scale: " << decomp.scale[0];
+ *out << ", " << decomp.scale[1];
}
- *out << L'\n';
+ *out << '\n';
for (size_t i = 0, count = layer->children().size(); i < count; ++i) {
PrintLayerHierarchyImp(
@@ -113,8 +110,8 @@ void PrintLayerHierarchyImp(const Layer* layer,
} // namespace
void PrintLayerHierarchy(const Layer* layer, gfx::Point mouse_location) {
- std::wostringstream out;
- out << L"Layer hierarchy:\n";
+ std::ostringstream out;
+ out << "Layer hierarchy:\n";
PrintLayerHierarchyImp(layer, 0, mouse_location, &out);
// Error so logs can be collected from end-users.
LOG(ERROR) << out.str();
diff --git a/chromium/ui/compositor/dip_util.cc b/chromium/ui/compositor/dip_util.cc
index 13930518543..f7290e05c49 100644
--- a/chromium/ui/compositor/dip_util.cc
+++ b/chromium/ui/compositor/dip_util.cc
@@ -9,7 +9,6 @@
#include "ui/compositor/compositor.h"
#include "ui/compositor/compositor_switches.h"
#include "ui/compositor/layer.h"
-#include "ui/gfx/display.h"
#include "ui/gfx/geometry/dip_util.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_conversions.h"
diff --git a/chromium/ui/compositor/float_animation_curve_adapter.cc b/chromium/ui/compositor/float_animation_curve_adapter.cc
index d40d7018801..df1f96ee6bf 100644
--- a/chromium/ui/compositor/float_animation_curve_adapter.cc
+++ b/chromium/ui/compositor/float_animation_curve_adapter.cc
@@ -4,6 +4,7 @@
#include "ui/compositor/float_animation_curve_adapter.h"
+#include "base/memory/ptr_util.h"
#include "cc/base/time_util.h"
namespace ui {
@@ -23,8 +24,8 @@ base::TimeDelta FloatAnimationCurveAdapter::Duration() const {
return duration_;
}
-scoped_ptr<cc::AnimationCurve> FloatAnimationCurveAdapter::Clone() const {
- return make_scoped_ptr(new FloatAnimationCurveAdapter(
+std::unique_ptr<cc::AnimationCurve> FloatAnimationCurveAdapter::Clone() const {
+ return base::WrapUnique(new FloatAnimationCurveAdapter(
tween_type_, initial_value_, target_value_, duration_));
}
diff --git a/chromium/ui/compositor/float_animation_curve_adapter.h b/chromium/ui/compositor/float_animation_curve_adapter.h
index dc665d4bcf2..b6337061748 100644
--- a/chromium/ui/compositor/float_animation_curve_adapter.h
+++ b/chromium/ui/compositor/float_animation_curve_adapter.h
@@ -5,6 +5,8 @@
#ifndef UI_COMPOSITOR_FLOAT_ANIMATION_CURVE_ADAPTER_H_
#define UI_COMPOSITOR_FLOAT_ANIMATION_CURVE_ADAPTER_H_
+#include <memory>
+
#include "base/time/time.h"
#include "cc/animation/animation_curve.h"
#include "ui/gfx/animation/tween.h"
@@ -22,7 +24,7 @@ class FloatAnimationCurveAdapter : public cc::FloatAnimationCurve {
// FloatAnimationCurve implementation.
base::TimeDelta Duration() const override;
- scoped_ptr<cc::AnimationCurve> Clone() const override;
+ std::unique_ptr<cc::AnimationCurve> Clone() const override;
float GetValue(base::TimeDelta t) const override;
private:
diff --git a/chromium/ui/compositor/layer.cc b/chromium/ui/compositor/layer.cc
index 0f83cb60001..cf428675604 100644
--- a/chromium/ui/compositor/layer.cc
+++ b/chromium/ui/compositor/layer.cc
@@ -5,13 +5,14 @@
#include "ui/compositor/layer.h"
#include <algorithm>
+#include <memory>
#include <utility>
#include "base/auto_reset.h"
#include "base/command_line.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/trace_event/trace_event.h"
#include "cc/layers/nine_patch_layer.h"
#include "cc/layers/picture_layer.h"
@@ -30,7 +31,6 @@
#include "ui/compositor/paint_context.h"
#include "ui/gfx/animation/animation.h"
#include "ui/gfx/canvas.h"
-#include "ui/gfx/display.h"
#include "ui/gfx/geometry/point3_f.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
@@ -53,7 +53,6 @@ Layer::Layer()
compositor_(NULL),
parent_(NULL),
visible_(true),
- force_render_surface_(false),
fills_bounds_opaquely_(true),
fills_bounds_completely_(false),
background_blur_radius_(0),
@@ -77,7 +76,6 @@ Layer::Layer(LayerType type)
compositor_(NULL),
parent_(NULL),
visible_(true),
- force_render_surface_(false),
fills_bounds_opaquely_(true),
fills_bounds_completely_(false),
background_blur_radius_(0),
@@ -354,7 +352,7 @@ void Layer::SetBackgroundZoom(float zoom, int inset) {
SetLayerBackgroundFilters();
}
-void Layer::SetAlphaShape(scoped_ptr<SkRegion> region) {
+void Layer::SetAlphaShape(std::unique_ptr<SkRegion> region) {
alpha_shape_ = std::move(region);
SetLayerFilters();
@@ -508,7 +506,6 @@ void Layer::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) {
cc_layer_->SetLayerClient(this);
cc_layer_->SetTransformOrigin(gfx::Point3F());
cc_layer_->SetContentsOpaque(fills_bounds_opaquely_);
- cc_layer_->SetForceRenderSurface(force_render_surface_);
cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN);
cc_layer_->SetHideLayerAndSubtree(!visible_);
@@ -528,7 +525,7 @@ void Layer::SwitchCCLayerForTest() {
void Layer::SetTextureMailbox(
const cc::TextureMailbox& mailbox,
- scoped_ptr<cc::SingleReleaseCallback> release_callback,
+ std::unique_ptr<cc::SingleReleaseCallback> release_callback,
gfx::Size texture_size_in_dip) {
DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR);
DCHECK(mailbox.IsValid());
@@ -569,6 +566,11 @@ bool Layer::TextureFlipped() const {
return texture_layer_->flipped();
}
+void Layer::SetTextureAlpha(float alpha) {
+ DCHECK(texture_layer_.get());
+ texture_layer_->SetVertexOpacity(alpha, alpha, alpha, alpha);
+}
+
void Layer::SetShowSurface(
cc::SurfaceId surface_id,
const cc::SurfaceLayer::SatisfyCallback& satisfy_callback,
@@ -670,9 +672,9 @@ void Layer::SendDamagedRects() {
for (cc::Region::Iterator iter(damaged_region_); iter.has_rect(); iter.next())
cc_layer_->SetNeedsDisplayRect(iter.rect());
-}
-void Layer::ClearDamagedRects() {
+ if (content_layer_)
+ paint_region_.Union(damaged_region_);
damaged_region_.Clear();
}
@@ -723,7 +725,8 @@ void Layer::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) {
delegate_->OnDelegatedFrameDamage(damage_rect_in_dip);
}
-void Layer::RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) {
+void Layer::RequestCopyOfOutput(
+ std::unique_ptr<cc::CopyOutputRequest> request) {
cc_layer_->RequestCopyOfOutput(std::move(request));
}
@@ -736,8 +739,8 @@ scoped_refptr<cc::DisplayItemList> Layer::PaintContentsToDisplayList(
TRACE_EVENT1("ui", "Layer::PaintContentsToDisplayList", "name", name_);
gfx::Rect local_bounds(bounds().size());
gfx::Rect invalidation(
- gfx::IntersectRects(damaged_region_.bounds(), local_bounds));
- ClearDamagedRects();
+ gfx::IntersectRects(paint_region_.bounds(), local_bounds));
+ paint_region_.Clear();
cc::DisplayItemListSettings settings;
settings.use_cached_picture = false;
scoped_refptr<cc::DisplayItemList> display_list =
@@ -760,7 +763,7 @@ size_t Layer::GetApproximateUnsharedMemoryUsage() const {
bool Layer::PrepareTextureMailbox(
cc::TextureMailbox* mailbox,
- scoped_ptr<cc::SingleReleaseCallback>* release_callback,
+ std::unique_ptr<cc::SingleReleaseCallback>* release_callback,
bool use_shared_memory) {
if (!mailbox_release_callback_)
return false;
@@ -769,14 +772,6 @@ bool Layer::PrepareTextureMailbox(
return true;
}
-void Layer::SetForceRenderSurface(bool force) {
- if (force_render_surface_ == force)
- return;
-
- force_render_surface_ = force;
- cc_layer_->SetForceRenderSurface(force_render_surface_);
-}
-
class LayerDebugInfo : public base::trace_event::ConvertableToTraceFormat {
public:
explicit LayerDebugInfo(const std::string& name) : name_(name) {}
@@ -791,9 +786,9 @@ class LayerDebugInfo : public base::trace_event::ConvertableToTraceFormat {
std::string name_;
};
-scoped_ptr<base::trace_event::ConvertableToTraceFormat> Layer::TakeDebugInfo(
- cc::Layer* layer) {
- return make_scoped_ptr(new LayerDebugInfo(name_));
+std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
+Layer::TakeDebugInfo(cc::Layer* layer) {
+ return base::WrapUnique(new LayerDebugInfo(name_));
}
void Layer::CollectAnimators(
diff --git a/chromium/ui/compositor/layer.h b/chromium/ui/compositor/layer.h
index 2dcb9c765be..b0ee9a948fb 100644
--- a/chromium/ui/compositor/layer.h
+++ b/chromium/ui/compositor/layer.h
@@ -7,13 +7,13 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include <vector>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "cc/base/region.h"
#include "cc/layers/content_layer_client.h"
@@ -212,7 +212,7 @@ class COMPOSITOR_EXPORT Layer
// Set the shape of this layer.
SkRegion* alpha_shape() const { return alpha_shape_.get(); }
- void SetAlphaShape(scoped_ptr<SkRegion> region);
+ void SetAlphaShape(std::unique_ptr<SkRegion> region);
// Invert the layer.
bool layer_inverted() const { return layer_inverted_; }
@@ -273,13 +273,23 @@ class COMPOSITOR_EXPORT Layer
// Set new TextureMailbox for this layer. Note that |mailbox| may hold a
// shared memory resource or an actual mailbox for a texture.
- void SetTextureMailbox(const cc::TextureMailbox& mailbox,
- scoped_ptr<cc::SingleReleaseCallback> release_callback,
- gfx::Size texture_size_in_dip);
+ void SetTextureMailbox(
+ const cc::TextureMailbox& mailbox,
+ std::unique_ptr<cc::SingleReleaseCallback> release_callback,
+ gfx::Size texture_size_in_dip);
void SetTextureSize(gfx::Size texture_size_in_dip);
void SetTextureFlipped(bool flipped);
bool TextureFlipped() const;
+ // The alpha value applied to the whole texture. The effective value of each
+ // pixel is computed as:
+ // pixel.a = pixel.a * alpha.
+ // Note: This is different from SetOpacity() as it only applies to the
+ // texture and child layers are unaffected.
+ // TODO(reveman): Remove once components/exo code is using SetShowSurface.
+ // crbug.com/610086
+ void SetTextureAlpha(float alpha);
+
// Begins showing content from a surface with a particular id.
void SetShowSurface(cc::SurfaceId surface_id,
const cc::SurfaceLayer::SatisfyCallback& satisfy_callback,
@@ -318,7 +328,6 @@ class COMPOSITOR_EXPORT Layer
// Uses damaged rectangles recorded in |damaged_region_| to invalidate the
// |cc_layer_|.
void SendDamagedRects();
- void ClearDamagedRects();
const cc::Region& damaged_region() const { return damaged_region_; }
@@ -335,7 +344,7 @@ class COMPOSITOR_EXPORT Layer
void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip);
// Requets a copy of the layer's output as a texture or bitmap.
- void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request);
+ void RequestCopyOfOutput(std::unique_ptr<cc::CopyOutputRequest> request);
// ContentLayerClient
gfx::Rect PaintableRegion() override;
@@ -349,18 +358,13 @@ class COMPOSITOR_EXPORT Layer
// TextureLayerClient
bool PrepareTextureMailbox(
cc::TextureMailbox* mailbox,
- scoped_ptr<cc::SingleReleaseCallback>* release_callback,
+ std::unique_ptr<cc::SingleReleaseCallback>* release_callback,
bool use_shared_memory) override;
float device_scale_factor() const { return device_scale_factor_; }
- // Forces a render surface to be used on this layer. This has no positive
- // impact, and is only used for benchmarking/testing purpose.
- void SetForceRenderSurface(bool force);
- bool force_render_surface() const { return force_render_surface_; }
-
// LayerClient
- scoped_ptr<base::trace_event::ConvertableToTraceFormat> TakeDebugInfo(
+ std::unique_ptr<base::trace_event::ConvertableToTraceFormat> TakeDebugInfo(
cc::Layer* layer) override;
// Whether this layer has animations waiting to get sent to its cc::Layer.
@@ -369,6 +373,10 @@ class COMPOSITOR_EXPORT Layer
// Triggers a call to SwitchToLayer.
void SwitchCCLayerForTest();
+ const cc::Region& damaged_region_for_testing() const {
+ return damaged_region_;
+ }
+
private:
friend class LayerOwner;
@@ -436,14 +444,16 @@ class COMPOSITOR_EXPORT Layer
// Visibility of this layer. See SetVisible/IsDrawn for more details.
bool visible_;
- bool force_render_surface_;
-
bool fills_bounds_opaquely_;
bool fills_bounds_completely_;
+ // Union of damaged rects, in layer space, that SetNeedsDisplayRect should
+ // be called on.
+ cc::Region damaged_region_;
+
// Union of damaged rects, in layer space, to be used when compositor is ready
// to paint the content.
- cc::Region damaged_region_;
+ cc::Region paint_region_;
int background_blur_radius_;
@@ -469,7 +479,7 @@ class COMPOSITOR_EXPORT Layer
int zoom_inset_;
// Shape of the window.
- scoped_ptr<SkRegion> alpha_shape_;
+ std::unique_ptr<SkRegion> alpha_shape_;
std::string name_;
@@ -501,7 +511,7 @@ class COMPOSITOR_EXPORT Layer
// The callback to release the mailbox. This is only set after
// SetTextureMailbox is called, before we give it to the TextureLayer.
- scoped_ptr<cc::SingleReleaseCallback> mailbox_release_callback_;
+ std::unique_ptr<cc::SingleReleaseCallback> mailbox_release_callback_;
// The size of the frame or texture in DIP, set when SetShowDelegatedContent
// or SetTextureMailbox was called.
diff --git a/chromium/ui/compositor/layer_animation_element.cc b/chromium/ui/compositor/layer_animation_element.cc
index edf5bdc89fd..2e5d98144b4 100644
--- a/chromium/ui/compositor/layer_animation_element.cc
+++ b/chromium/ui/compositor/layer_animation_element.cc
@@ -109,7 +109,7 @@ class InterpolatedTransformTransition : public LayerAnimationElement {
void OnAbort(LayerAnimationDelegate* delegate) override {}
private:
- scoped_ptr<InterpolatedTransform> interpolated_transform_;
+ std::unique_ptr<InterpolatedTransform> interpolated_transform_;
DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformTransition);
};
@@ -332,7 +332,7 @@ class ThreadedLayerAnimationElement : public LayerAnimationElement {
}
~ThreadedLayerAnimationElement() override {}
- bool IsThreaded() const override { return (duration() != base::TimeDelta()); }
+ bool IsThreaded() const override { return !duration().is_zero(); }
protected:
explicit ThreadedLayerAnimationElement(const LayerAnimationElement& element)
@@ -370,7 +370,7 @@ class ThreadedLayerAnimationElement : public LayerAnimationElement {
return;
}
set_effective_start_time(base::TimeTicks());
- scoped_ptr<cc::Animation> animation = CreateCCAnimation();
+ std::unique_ptr<cc::Animation> animation = CreateCCAnimation();
animation->set_needs_synchronized_start_time(true);
LayerThreadedAnimationDelegate* threaded =
@@ -381,7 +381,7 @@ class ThreadedLayerAnimationElement : public LayerAnimationElement {
virtual void OnEnd(LayerAnimationDelegate* delegate) = 0;
- virtual scoped_ptr<cc::Animation> CreateCCAnimation() = 0;
+ virtual std::unique_ptr<cc::Animation> CreateCCAnimation() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(ThreadedLayerAnimationElement);
@@ -417,13 +417,11 @@ class ThreadedOpacityTransition : public ThreadedLayerAnimationElement {
delegate->SetOpacityFromAnimation(target_);
}
- scoped_ptr<cc::Animation> CreateCCAnimation() override {
- scoped_ptr<cc::AnimationCurve> animation_curve(
- new FloatAnimationCurveAdapter(tween_type(),
- start_,
- target_,
+ std::unique_ptr<cc::Animation> CreateCCAnimation() override {
+ std::unique_ptr<cc::AnimationCurve> animation_curve(
+ new FloatAnimationCurveAdapter(tween_type(), start_, target_,
duration()));
- scoped_ptr<cc::Animation> animation(cc::Animation::Create(
+ std::unique_ptr<cc::Animation> animation(cc::Animation::Create(
std::move(animation_curve), animation_id(), animation_group_id(),
cc::TargetProperty::OPACITY));
return animation;
@@ -470,13 +468,11 @@ class ThreadedTransformTransition : public ThreadedLayerAnimationElement {
delegate->SetTransformFromAnimation(target_);
}
- scoped_ptr<cc::Animation> CreateCCAnimation() override {
- scoped_ptr<cc::AnimationCurve> animation_curve(
- new TransformAnimationCurveAdapter(tween_type(),
- start_,
- target_,
+ std::unique_ptr<cc::Animation> CreateCCAnimation() override {
+ std::unique_ptr<cc::AnimationCurve> animation_curve(
+ new TransformAnimationCurveAdapter(tween_type(), start_, target_,
duration()));
- scoped_ptr<cc::Animation> animation(cc::Animation::Create(
+ std::unique_ptr<cc::Animation> animation(cc::Animation::Create(
std::move(animation_curve), animation_id(), animation_group_id(),
cc::TargetProperty::TRANSFORM));
return animation;
@@ -547,8 +543,8 @@ class InverseTransformTransition : public ThreadedLayerAnimationElement {
delegate->SetTransformFromAnimation(computed_target_transform_);
}
- scoped_ptr<cc::Animation> CreateCCAnimation() override {
- scoped_ptr<cc::Animation> animation(cc::Animation::Create(
+ std::unique_ptr<cc::Animation> CreateCCAnimation() override {
+ std::unique_ptr<cc::Animation> animation(cc::Animation::Create(
animation_curve_->Clone(), animation_id(), animation_group_id(),
cc::TargetProperty::TRANSFORM));
return animation;
@@ -590,7 +586,7 @@ class InverseTransformTransition : public ThreadedLayerAnimationElement {
const gfx::Transform base_transform_;
gfx::Transform base_target_;
- scoped_ptr<cc::AnimationCurve> animation_curve_;
+ std::unique_ptr<cc::AnimationCurve> animation_curve_;
const ThreadedTransformTransition* const uninverted_transition_;
diff --git a/chromium/ui/compositor/layer_animation_element_unittest.cc b/chromium/ui/compositor/layer_animation_element_unittest.cc
index bc2b1e1c828..6acd9d61ff0 100644
--- a/chromium/ui/compositor/layer_animation_element_unittest.cc
+++ b/chromium/ui/compositor/layer_animation_element_unittest.cc
@@ -4,8 +4,9 @@
#include "ui/compositor/layer_animation_element.h"
+#include <memory>
+
#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/compositor/layer_animation_delegate.h"
@@ -61,7 +62,7 @@ TEST(LayerAnimationElementTest, TransformElement) {
base::TimeTicks effective_start_time;
base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- scoped_ptr<LayerAnimationElement> element(
+ std::unique_ptr<LayerAnimationElement> element(
LayerAnimationElement::CreateTransformElement(target_transform, delta));
element->set_animation_group_id(1);
@@ -101,10 +102,10 @@ TEST(LayerAnimationElementTest, InverseElementDurationNoScale) {
gfx::Transform transform;
base::TimeDelta delta;
- scoped_ptr<LayerAnimationElement> base_element(
+ std::unique_ptr<LayerAnimationElement> base_element(
LayerAnimationElement::CreateTransformElement(transform, delta));
- scoped_ptr<LayerAnimationElement> inverse_element(
+ std::unique_ptr<LayerAnimationElement> inverse_element(
LayerAnimationElement::CreateInverseTransformElement(transform,
base_element.get()));
EXPECT_EQ(base_element->duration(), inverse_element->duration());
@@ -117,10 +118,10 @@ TEST(LayerAnimationElementTest, InverseElementDurationScaled) {
ScopedAnimationDurationScaleMode faster_duration(
ScopedAnimationDurationScaleMode::FAST_DURATION);
- scoped_ptr<LayerAnimationElement> base_element(
+ std::unique_ptr<LayerAnimationElement> base_element(
LayerAnimationElement::CreateTransformElement(transform, delta));
- scoped_ptr<LayerAnimationElement> inverse_element(
+ std::unique_ptr<LayerAnimationElement> inverse_element(
LayerAnimationElement::CreateInverseTransformElement(transform,
base_element.get()));
EXPECT_EQ(base_element->duration(), inverse_element->duration());
@@ -136,9 +137,9 @@ TEST(LayerAnimationElementTest, InverseElementTargetCalculation) {
transform.Scale3d(2.0, 2.0, 2.0);
- scoped_ptr<LayerAnimationElement> base_element(
+ std::unique_ptr<LayerAnimationElement> base_element(
LayerAnimationElement::CreateTransformElement(transform, delta));
- scoped_ptr<LayerAnimationElement> inverse_element(
+ std::unique_ptr<LayerAnimationElement> inverse_element(
LayerAnimationElement::CreateInverseTransformElement(identity,
base_element.get()));
@@ -169,7 +170,7 @@ TEST(LayerAnimationElementTest, BoundsElement) {
base::TimeTicks start_time;
base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- scoped_ptr<LayerAnimationElement> element(
+ std::unique_ptr<LayerAnimationElement> element(
LayerAnimationElement::CreateBoundsElement(target, delta));
for (int i = 0; i < 2; ++i) {
@@ -205,7 +206,7 @@ TEST(LayerAnimationElementTest, OpacityElement) {
base::TimeTicks start_time;
base::TimeTicks effective_start_time;
base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- scoped_ptr<LayerAnimationElement> element(
+ std::unique_ptr<LayerAnimationElement> element(
LayerAnimationElement::CreateOpacityElement(target, delta));
for (int i = 0; i < 2; ++i) {
@@ -245,7 +246,7 @@ TEST(LayerAnimationElementTest, VisibilityElement) {
bool target = false;
base::TimeTicks start_time;
base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- scoped_ptr<LayerAnimationElement> element(
+ std::unique_ptr<LayerAnimationElement> element(
LayerAnimationElement::CreateVisibilityElement(target, delta));
for (int i = 0; i < 2; ++i) {
@@ -280,7 +281,7 @@ TEST(LayerAnimationElementTest, BrightnessElement) {
float target = 1.0;
base::TimeTicks start_time;
base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- scoped_ptr<LayerAnimationElement> element(
+ std::unique_ptr<LayerAnimationElement> element(
LayerAnimationElement::CreateBrightnessElement(target, delta));
for (int i = 0; i < 2; ++i) {
@@ -315,7 +316,7 @@ TEST(LayerAnimationElementTest, GrayscaleElement) {
float target = 1.0;
base::TimeTicks start_time;
base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- scoped_ptr<LayerAnimationElement> element(
+ std::unique_ptr<LayerAnimationElement> element(
LayerAnimationElement::CreateGrayscaleElement(target, delta));
for (int i = 0; i < 2; ++i) {
@@ -352,7 +353,7 @@ TEST(LayerAnimationElementTest, PauseElement) {
base::TimeTicks start_time;
base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- scoped_ptr<LayerAnimationElement> element(
+ std::unique_ptr<LayerAnimationElement> element(
LayerAnimationElement::CreatePauseElement(properties, delta));
TestLayerAnimationDelegate delegate;
@@ -391,7 +392,7 @@ TEST(LayerAnimationElementTest, AbortOpacityElement) {
base::TimeTicks start_time;
base::TimeTicks effective_start_time;
base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- scoped_ptr<LayerAnimationElement> element(
+ std::unique_ptr<LayerAnimationElement> element(
LayerAnimationElement::CreateOpacityElement(target, delta));
// Choose a non-linear Tween type.
@@ -430,7 +431,7 @@ TEST(LayerAnimationElementTest, AbortTransformElement) {
base::TimeTicks start_time;
base::TimeTicks effective_start_time;
base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- scoped_ptr<LayerAnimationElement> element(
+ std::unique_ptr<LayerAnimationElement> element(
LayerAnimationElement::CreateTransformElement(target_transform, delta));
// Choose a non-linear Tween type.
diff --git a/chromium/ui/compositor/layer_animation_sequence.cc b/chromium/ui/compositor/layer_animation_sequence.cc
index f71728d670c..041bdbeea8e 100644
--- a/chromium/ui/compositor/layer_animation_sequence.cc
+++ b/chromium/ui/compositor/layer_animation_sequence.cc
@@ -212,17 +212,19 @@ void LayerAnimationSequence::RemoveObserver(LayerAnimationObserver* observer) {
}
void LayerAnimationSequence::OnThreadedAnimationStarted(
- const cc::AnimationEvent& event) {
- if (elements_.empty() || event.group_id != animation_group_id_)
+ base::TimeTicks monotonic_time,
+ cc::TargetProperty::Type target_property,
+ int group_id) {
+ if (elements_.empty() || group_id != animation_group_id_)
return;
size_t current_index = last_element_ % elements_.size();
LayerAnimationElement::AnimatableProperties element_properties =
elements_[current_index]->properties();
LayerAnimationElement::AnimatableProperty event_property =
- LayerAnimationElement::ToAnimatableProperty(event.target_property);
+ LayerAnimationElement::ToAnimatableProperty(target_property);
DCHECK(element_properties & event_property);
- elements_[current_index]->set_effective_start_time(event.monotonic_time);
+ elements_[current_index]->set_effective_start_time(monotonic_time);
}
void LayerAnimationSequence::OnScheduled() {
diff --git a/chromium/ui/compositor/layer_animation_sequence.h b/chromium/ui/compositor/layer_animation_sequence.h
index 1cd1a9fc350..e050439da7e 100644
--- a/chromium/ui/compositor/layer_animation_sequence.h
+++ b/chromium/ui/compositor/layer_animation_sequence.h
@@ -18,10 +18,6 @@
#include "ui/compositor/compositor_export.h"
#include "ui/compositor/layer_animation_element.h"
-namespace cc {
-struct AnimationEvent;
-}
-
namespace ui {
class LayerAnimationDelegate;
@@ -120,7 +116,9 @@ class COMPOSITOR_EXPORT LayerAnimationSequence
void RemoveObserver(LayerAnimationObserver* observer);
// Called when a threaded animation is actually started.
- void OnThreadedAnimationStarted(const cc::AnimationEvent& event);
+ void OnThreadedAnimationStarted(base::TimeTicks monotonic_time,
+ cc::TargetProperty::Type target_property,
+ int group_id);
// Called when the animator schedules this sequence.
void OnScheduled();
diff --git a/chromium/ui/compositor/layer_animation_sequence_unittest.cc b/chromium/ui/compositor/layer_animation_sequence_unittest.cc
index 0a62ddb8d5b..9222046fb28 100644
--- a/chromium/ui/compositor/layer_animation_sequence_unittest.cc
+++ b/chromium/ui/compositor/layer_animation_sequence_unittest.cc
@@ -4,10 +4,10 @@
#include "ui/compositor/layer_animation_sequence.h"
+#include <memory>
+
#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
-#include "cc/animation/animation_events.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/compositor/layer_animation_delegate.h"
#include "ui/compositor/layer_animation_element.h"
@@ -92,9 +92,9 @@ TEST(LayerAnimationSequenceTest, SingleThreadedElement) {
sequence.Progress(start_time, &delegate);
EXPECT_FLOAT_EQ(start, sequence.last_progressed_fraction());
effective_start = start_time + delta;
- sequence.OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0, sequence.animation_group_id(),
- cc::TargetProperty::OPACITY, effective_start));
+ sequence.OnThreadedAnimationStarted(effective_start,
+ cc::TargetProperty::OPACITY,
+ sequence.animation_group_id());
sequence.Progress(effective_start + delta/2, &delegate);
EXPECT_FLOAT_EQ(middle, sequence.last_progressed_fraction());
EXPECT_TRUE(sequence.IsFinished(effective_start + delta));
@@ -146,9 +146,9 @@ TEST(LayerAnimationSequenceTest, MultipleElement) {
EXPECT_FLOAT_EQ(0.0, sequence.last_progressed_fraction());
opacity_effective_start = start_time + delta;
EXPECT_EQ(starting_group_id, sequence.animation_group_id());
- sequence.OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0, sequence.animation_group_id(),
- cc::TargetProperty::OPACITY, opacity_effective_start));
+ sequence.OnThreadedAnimationStarted(opacity_effective_start,
+ cc::TargetProperty::OPACITY,
+ sequence.animation_group_id());
sequence.Progress(opacity_effective_start + delta/2, &delegate);
EXPECT_FLOAT_EQ(0.5, sequence.last_progressed_fraction());
sequence.Progress(opacity_effective_start + delta, &delegate);
@@ -174,9 +174,9 @@ TEST(LayerAnimationSequenceTest, MultipleElement) {
EXPECT_FLOAT_EQ(0.0, sequence.last_progressed_fraction());
transform_effective_start = opacity_effective_start + 3 * delta;
EXPECT_NE(starting_group_id, sequence.animation_group_id());
- sequence.OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0, sequence.animation_group_id(),
- cc::TargetProperty::TRANSFORM, transform_effective_start));
+ sequence.OnThreadedAnimationStarted(transform_effective_start,
+ cc::TargetProperty::TRANSFORM,
+ sequence.animation_group_id());
sequence.Progress(transform_effective_start + delta/2, &delegate);
EXPECT_FLOAT_EQ(0.5, sequence.last_progressed_fraction());
EXPECT_TRUE(sequence.IsFinished(transform_effective_start + delta));
diff --git a/chromium/ui/compositor/layer_animator.cc b/chromium/ui/compositor/layer_animator.cc
index 265a568ef45..b3474964bcf 100644
--- a/chromium/ui/compositor/layer_animator.cc
+++ b/chromium/ui/compositor/layer_animator.cc
@@ -6,17 +6,15 @@
#include <stddef.h>
+#include <memory>
+
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/trace_event/trace_event.h"
-#include "cc/animation/animation_events.h"
#include "cc/animation/animation_host.h"
#include "cc/animation/animation_id_provider.h"
#include "cc/animation/animation_player.h"
-#include "cc/animation/animation_registrar.h"
#include "cc/animation/animation_timeline.h"
#include "cc/animation/element_animations.h"
-#include "cc/animation/layer_animation_controller.h"
#include "cc/output/begin_frame_args.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
@@ -87,26 +85,26 @@ LayerAnimator* LayerAnimator::CreateImplicitAnimator() {
// It is worth noting that SetFoo avoids invoking the usual animation machinery
// if the transition duration is zero -- in this case we just set the property
// on the layer animation delegate immediately.
-#define ANIMATED_PROPERTY(type, property, name, member_type, member) \
-void LayerAnimator::Set##name(type value) { \
- base::TimeDelta duration = GetTransitionDuration(); \
- if (duration == base::TimeDelta() && delegate() && \
- (preemption_strategy_ != ENQUEUE_NEW_ANIMATION)) { \
- StopAnimatingProperty(LayerAnimationElement::property); \
- delegate()->Set##name##FromAnimation(value); \
- return; \
- } \
- scoped_ptr<LayerAnimationElement> element( \
- LayerAnimationElement::Create##name##Element(value, duration)); \
- element->set_tween_type(tween_type_); \
- StartAnimation(new LayerAnimationSequence(element.release())); \
-} \
- \
-member_type LayerAnimator::GetTarget##name() const { \
- LayerAnimationElement::TargetValue target(delegate()); \
- GetTargetValue(&target); \
- return target.member; \
-}
+#define ANIMATED_PROPERTY(type, property, name, member_type, member) \
+ void LayerAnimator::Set##name(type value) { \
+ base::TimeDelta duration = GetTransitionDuration(); \
+ if (duration.is_zero() && delegate() && \
+ (preemption_strategy_ != ENQUEUE_NEW_ANIMATION)) { \
+ StopAnimatingProperty(LayerAnimationElement::property); \
+ delegate()->Set##name##FromAnimation(value); \
+ return; \
+ } \
+ std::unique_ptr<LayerAnimationElement> element( \
+ LayerAnimationElement::Create##name##Element(value, duration)); \
+ element->set_tween_type(tween_type_); \
+ StartAnimation(new LayerAnimationSequence(element.release())); \
+ } \
+ \
+ member_type LayerAnimator::GetTarget##name() const { \
+ LayerAnimationElement::TargetValue target(delegate()); \
+ GetTargetValue(&target); \
+ return target.member; \
+ }
ANIMATED_PROPERTY(
const gfx::Transform&, TRANSFORM, Transform, gfx::Transform, transform);
@@ -137,8 +135,8 @@ void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) {
}
void LayerAnimator::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) {
- // Release LAC state for old layer.
- animation_controller_state_ = nullptr;
+ // Release ElementAnimations state for old layer.
+ element_animations_state_ = nullptr;
if (delegate_)
DetachLayerFromAnimationPlayer();
@@ -154,65 +152,62 @@ void LayerAnimator::SetCompositor(Compositor* compositor) {
DCHECK(delegate_->GetCcLayer());
- // Register LAC so ElementAnimations picks it up via
- // AnimationRegistrar::GetAnimationControllerForId.
- if (animation_controller_state_) {
- DCHECK_EQ(animation_controller_state_->id(),
+ // Register ElementAnimations so it will be picked up by
+ // AnimationHost::RegisterPlayerForLayer via
+ // AnimationHost::GetElementAnimationsForLayerId.
+ if (element_animations_state_) {
+ DCHECK_EQ(element_animations_state_->element_id(),
delegate_->GetCcLayer()->id());
- timeline->animation_host()
- ->animation_registrar()
- ->RegisterAnimationController(animation_controller_state_.get());
+ timeline->animation_host()->RegisterElementAnimations(
+ element_animations_state_.get());
}
timeline->AttachPlayer(animation_player_);
AttachLayerToAnimationPlayer(delegate_->GetCcLayer()->id());
- // Release LAC (it is referenced in ElementAnimations).
- animation_controller_state_ = nullptr;
+ // Release ElementAnimations state.
+ element_animations_state_ = nullptr;
}
void LayerAnimator::ResetCompositor(Compositor* compositor) {
DCHECK(compositor);
- // Store a reference to LAC if any so it may be picked up in SetCompositor.
- if (animation_player_->element_animations()) {
- animation_controller_state_ =
- animation_player_->element_animations()->layer_animation_controller();
+ cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline();
+ DCHECK(timeline);
+
+ const int layer_id = animation_player_->element_id();
+
+ // Store a reference to ElementAnimations (if any)
+ // so it may be picked up in LayerAnimator::SetCompositor.
+ if (layer_id) {
+ element_animations_state_ =
+ timeline->animation_host()->GetElementAnimationsForElementId(layer_id);
}
DetachLayerFromAnimationPlayer();
- cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline();
- DCHECK(timeline);
timeline->DetachPlayer(animation_player_);
}
void LayerAnimator::AttachLayerToAnimationPlayer(int layer_id) {
- if (!animation_player_->layer_id())
- animation_player_->AttachLayer(layer_id);
+ if (!animation_player_->element_id())
+ animation_player_->AttachElement(layer_id);
else
- DCHECK_EQ(animation_player_->layer_id(), layer_id);
+ DCHECK_EQ(animation_player_->element_id(), layer_id);
- if (animation_player_->element_animations()) {
- animation_player_->element_animations()
- ->layer_animation_controller()
- ->AddEventObserver(this);
- }
+ animation_player_->set_animation_delegate(this);
}
void LayerAnimator::DetachLayerFromAnimationPlayer() {
- if (animation_player_->element_animations()) {
- animation_player_->element_animations()
- ->layer_animation_controller()
- ->RemoveEventObserver(this);
- }
+ animation_player_->set_animation_delegate(nullptr);
- if (animation_player_->layer_id())
- animation_player_->DetachLayer();
+ if (animation_player_->element_id())
+ animation_player_->DetachElement();
}
-void LayerAnimator::AddThreadedAnimation(scoped_ptr<cc::Animation> animation) {
+void LayerAnimator::AddThreadedAnimation(
+ std::unique_ptr<cc::Animation> animation) {
animation_player_->AddAnimation(std::move(animation));
}
@@ -408,23 +403,26 @@ void LayerAnimator::RemoveObserver(LayerAnimationObserver* observer) {
}
void LayerAnimator::OnThreadedAnimationStarted(
- const cc::AnimationEvent& event) {
+ base::TimeTicks monotonic_time,
+ cc::TargetProperty::Type target_property,
+ int group_id) {
LayerAnimationElement::AnimatableProperty property =
- LayerAnimationElement::ToAnimatableProperty(event.target_property);
+ LayerAnimationElement::ToAnimatableProperty(target_property);
RunningAnimation* running = GetRunningAnimation(property);
if (!running)
return;
DCHECK(running->is_sequence_alive());
- if (running->sequence()->animation_group_id() != event.group_id)
+ if (running->sequence()->animation_group_id() != group_id)
return;
- running->sequence()->OnThreadedAnimationStarted(event);
+ running->sequence()->OnThreadedAnimationStarted(monotonic_time,
+ target_property, group_id);
if (!running->sequence()->waiting_for_group_start())
return;
- base::TimeTicks start_time = event.monotonic_time;
+ base::TimeTicks start_time = monotonic_time;
running->sequence()->set_waiting_for_group_start(false);
@@ -435,7 +433,7 @@ void LayerAnimator::OnThreadedAnimationStarted(
iter != running_animations_.end(); ++iter) {
// Ensure that each sequence is only Started once, regardless of the
// number of sequences in the group that have threaded first elements.
- if (((*iter).sequence()->animation_group_id() == event.group_id) &&
+ if (((*iter).sequence()->animation_group_id() == group_id) &&
!(*iter).sequence()->IsFirstElementThreaded() &&
(*iter).sequence()->waiting_for_group_start()) {
(*iter).sequence()->set_start_time(start_time);
@@ -616,7 +614,7 @@ LayerAnimationSequence* LayerAnimator::RemoveAnimation(
void LayerAnimator::FinishAnimation(
LayerAnimationSequence* sequence, bool abort) {
scoped_refptr<LayerAnimator> retain(this);
- scoped_ptr<LayerAnimationSequence> removed(RemoveAnimation(sequence));
+ std::unique_ptr<LayerAnimationSequence> removed(RemoveAnimation(sequence));
if (abort)
sequence->Abort(delegate());
else
@@ -640,7 +638,7 @@ void LayerAnimator::FinishAnyAnimationWithZeroDuration() {
if (running_animations_copy[i].sequence()->IsFinished(
running_animations_copy[i].sequence()->start_time())) {
SAFE_INVOKE_VOID(ProgressAnimationToEnd, running_animations_copy[i]);
- scoped_ptr<LayerAnimationSequence> removed(
+ std::unique_ptr<LayerAnimationSequence> removed(
SAFE_INVOKE_PTR(RemoveAnimation, running_animations_copy[i]));
}
}
@@ -692,7 +690,7 @@ void LayerAnimator::RemoveAllAnimationsWithACommonProperty(
if (running_animations_copy[i].sequence()->HasConflictingProperty(
sequence->properties())) {
- scoped_ptr<LayerAnimationSequence> removed(
+ std::unique_ptr<LayerAnimationSequence> removed(
SAFE_INVOKE_PTR(RemoveAnimation, running_animations_copy[i]));
if (abort)
running_animations_copy[i].sequence()->Abort(delegate());
@@ -713,7 +711,7 @@ void LayerAnimator::RemoveAllAnimationsWithACommonProperty(
continue;
if (sequences[i]->HasConflictingProperty(sequence->properties())) {
- scoped_ptr<LayerAnimationSequence> removed(
+ std::unique_ptr<LayerAnimationSequence> removed(
RemoveAnimation(sequences[i].get()));
if (abort)
sequences[i]->Abort(delegate());
@@ -930,7 +928,7 @@ void LayerAnimator::ClearAnimationsInternal() {
if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i]))
continue;
- scoped_ptr<LayerAnimationSequence> removed(
+ std::unique_ptr<LayerAnimationSequence> removed(
RemoveAnimation(running_animations_copy[i].sequence()));
if (removed.get())
removed->Abort(delegate());
@@ -955,8 +953,11 @@ LayerAnimatorCollection* LayerAnimator::GetLayerAnimatorCollection() {
return delegate_ ? delegate_->GetLayerAnimatorCollection() : NULL;
}
-void LayerAnimator::OnAnimationStarted(const cc::AnimationEvent& event) {
- OnThreadedAnimationStarted(event);
+void LayerAnimator::NotifyAnimationStarted(
+ base::TimeTicks monotonic_time,
+ cc::TargetProperty::Type target_property,
+ int group) {
+ OnThreadedAnimationStarted(monotonic_time, target_property, group);
}
LayerAnimator::RunningAnimation::RunningAnimation(
diff --git a/chromium/ui/compositor/layer_animator.h b/chromium/ui/compositor/layer_animator.h
index 48e8a1e0ab4..e07de31f920 100644
--- a/chromium/ui/compositor/layer_animator.h
+++ b/chromium/ui/compositor/layer_animator.h
@@ -15,7 +15,8 @@
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
#include "base/time/time.h"
-#include "cc/animation/layer_animation_event_observer.h"
+#include "cc/animation/animation_delegate.h"
+#include "cc/animation/target_property.h"
#include "ui/compositor/compositor_export.h"
#include "ui/compositor/layer_animation_element.h"
#include "ui/compositor/layer_threaded_animation_delegate.h"
@@ -25,8 +26,8 @@ namespace cc {
class Animation;
class AnimationPlayer;
class AnimationTimeline;
+class ElementAnimations;
class Layer;
-class LayerAnimationController;
}
namespace gfx {
@@ -56,7 +57,7 @@ class ScopedLayerAnimationSettings;
class COMPOSITOR_EXPORT LayerAnimator
: public base::RefCounted<LayerAnimator>,
public LayerThreadedAnimationDelegate,
- NON_EXPORTED_BASE(public cc::LayerAnimationEventObserver) {
+ NON_EXPORTED_BASE(public cc::AnimationDelegate) {
public:
enum PreemptionStrategy {
IMMEDIATELY_SET_NEW_TARGET,
@@ -196,7 +197,9 @@ class COMPOSITOR_EXPORT LayerAnimator
void RemoveObserver(LayerAnimationObserver* observer);
// Called when a threaded animation is actually started.
- void OnThreadedAnimationStarted(const cc::AnimationEvent& event);
+ void OnThreadedAnimationStarted(base::TimeTicks monotonic_time,
+ cc::TargetProperty::Type target_property,
+ int group_id);
// This determines how implicit animations will be tweened. This has no
// effect on animations that are explicitly started or scheduled. The default
@@ -339,11 +342,24 @@ class COMPOSITOR_EXPORT LayerAnimator
LayerAnimatorCollection* GetLayerAnimatorCollection();
- // LayerAnimationEventObserver
- void OnAnimationStarted(const cc::AnimationEvent& event) override;
+ // cc::AnimationDelegate implementation.
+ void NotifyAnimationStarted(base::TimeTicks monotonic_time,
+ cc::TargetProperty::Type target_property,
+ int group_id) override;
+ void NotifyAnimationFinished(base::TimeTicks monotonic_time,
+ cc::TargetProperty::Type target_property,
+ int group_id) override {}
+ void NotifyAnimationAborted(base::TimeTicks monotonic_time,
+ cc::TargetProperty::Type target_property,
+ int group_id) override {}
+ void NotifyAnimationTakeover(
+ base::TimeTicks monotonic_time,
+ cc::TargetProperty::Type target_property,
+ double animation_start_time,
+ std::unique_ptr<cc::AnimationCurve> curve) override {}
// Implementation of LayerThreadedAnimationDelegate.
- void AddThreadedAnimation(scoped_ptr<cc::Animation> animation) override;
+ void AddThreadedAnimation(std::unique_ptr<cc::Animation> animation) override;
void RemoveThreadedAnimation(int animation_id) override;
void AttachLayerToAnimationPlayer(int layer_id);
@@ -392,10 +408,10 @@ class COMPOSITOR_EXPORT LayerAnimator
// aborted.
base::ObserverList<LayerAnimationObserver> observers_;
- // We store a state of LayerAnimationController here to save it in
+ // We store a state of ElementAnimations here to save it in
// ResetCompositor/SetCompositor scope.
// TODO(loyso): Remove it. crbug.com/592873.
- scoped_refptr<cc::LayerAnimationController> animation_controller_state_;
+ scoped_refptr<cc::ElementAnimations> element_animations_state_;
DISALLOW_COPY_AND_ASSIGN(LayerAnimator);
};
diff --git a/chromium/ui/compositor/layer_animator_unittest.cc b/chromium/ui/compositor/layer_animator_unittest.cc
index b4afb64cd25..6367b58f4c5 100644
--- a/chromium/ui/compositor/layer_animator_unittest.cc
+++ b/chromium/ui/compositor/layer_animator_unittest.cc
@@ -4,12 +4,12 @@
#include "ui/compositor/layer_animator.h"
+#include <memory>
+
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
-#include "cc/animation/animation_events.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_delegate.h"
@@ -371,11 +371,10 @@ TEST(LayerAnimatorTest, ScheduleThreadedAnimationThatCanRunImmediately) {
base::TimeTicks start_time = test_controller.animator()->last_step_time();
base::TimeTicks effective_start = start_time + delta;
- test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0,
+ test_controller.animator()->OnThreadedAnimationStarted(
+ effective_start, cc::TargetProperty::OPACITY,
test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)
- ->animation_group_id(),
- cc::TargetProperty::OPACITY, effective_start));
+ ->animation_group_id());
animator->Step(effective_start + delta / 2);
@@ -480,11 +479,10 @@ TEST(LayerAnimatorTest, ScheduleThreadedAndNonThreadedAnimations) {
base::TimeTicks start_time = test_controller.animator()->last_step_time();
base::TimeTicks effective_start = start_time + delta;
- test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0,
+ test_controller.animator()->OnThreadedAnimationStarted(
+ effective_start, cc::TargetProperty::OPACITY,
test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)
- ->animation_group_id(),
- cc::TargetProperty::OPACITY, effective_start));
+ ->animation_group_id());
animator->Step(effective_start + delta / 2);
@@ -579,10 +577,9 @@ TEST(LayerAnimatorTest, ScheduleBlockedAnimation) {
LayerAnimationElement::CreateGrayscaleElement(target_grayscale,
delta)));
- scoped_ptr<LayerAnimationSequence> bounds_and_grayscale(
- new LayerAnimationSequence(
- LayerAnimationElement::CreateGrayscaleElement(start_grayscale,
- delta)));
+ std::unique_ptr<LayerAnimationSequence> bounds_and_grayscale(
+ new LayerAnimationSequence(LayerAnimationElement::CreateGrayscaleElement(
+ start_grayscale, delta)));
bounds_and_grayscale->AddElement(
LayerAnimationElement::CreateBoundsElement(target_bounds, delta));
@@ -742,11 +739,10 @@ TEST(LayerAnimatorTest, StartThreadedAnimationThatCanRunImmediately) {
base::TimeTicks start_time = test_controller.animator()->last_step_time();
base::TimeTicks effective_start = start_time + delta;
- test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0,
+ test_controller.animator()->OnThreadedAnimationStarted(
+ effective_start, cc::TargetProperty::OPACITY,
test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)
- ->animation_group_id(),
- cc::TargetProperty::OPACITY, effective_start));
+ ->animation_group_id());
animator->Step(effective_start + delta / 2);
@@ -866,11 +862,10 @@ TEST(LayerAnimatorTest, PreemptThreadedByImmediatelyAnimatingToNewTarget) {
base::TimeTicks start_time = test_controller.animator()->last_step_time();
base::TimeTicks effective_start = start_time + delta;
- test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0,
+ test_controller.animator()->OnThreadedAnimationStarted(
+ effective_start, cc::TargetProperty::OPACITY,
test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)
- ->animation_group_id(),
- cc::TargetProperty::OPACITY, effective_start));
+ ->animation_group_id());
animator->Step(effective_start + delta / 2);
@@ -889,11 +884,10 @@ TEST(LayerAnimatorTest, PreemptThreadedByImmediatelyAnimatingToNewTarget) {
base::TimeTicks second_effective_start = effective_start + delta;
- test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0,
+ test_controller.animator()->OnThreadedAnimationStarted(
+ second_effective_start, cc::TargetProperty::OPACITY,
test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)
- ->animation_group_id(),
- cc::TargetProperty::OPACITY, second_effective_start));
+ ->animation_group_id());
animator->Step(second_effective_start + delta / 2);
@@ -1189,11 +1183,10 @@ TEST(LayerAnimatorTest, MultiPreemptThreadedByImmediatelyAnimatingToNewTarget) {
base::TimeTicks start_time = test_controller.animator()->last_step_time();
base::TimeTicks effective_start = start_time + delta;
- test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0,
+ test_controller.animator()->OnThreadedAnimationStarted(
+ effective_start, cc::TargetProperty::OPACITY,
test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)
- ->animation_group_id(),
- cc::TargetProperty::OPACITY, effective_start));
+ ->animation_group_id());
animator->Step(effective_start + delta / 2);
@@ -1217,11 +1210,10 @@ TEST(LayerAnimatorTest, MultiPreemptThreadedByImmediatelyAnimatingToNewTarget) {
base::TimeTicks second_effective_start = effective_start + delta;
- test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0,
+ test_controller.animator()->OnThreadedAnimationStarted(
+ second_effective_start, cc::TargetProperty::OPACITY,
test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)
- ->animation_group_id(),
- cc::TargetProperty::OPACITY, second_effective_start));
+ ->animation_group_id());
animator->Step(second_effective_start + delta / 2);
@@ -1387,10 +1379,9 @@ TEST(LayerAnimatorTest, CyclicSequences) {
delegate.SetBrightnessFromAnimation(start_brightness);
- scoped_ptr<LayerAnimationSequence> sequence(
- new LayerAnimationSequence(
- LayerAnimationElement::CreateBrightnessElement(target_brightness,
- delta)));
+ std::unique_ptr<LayerAnimationSequence> sequence(
+ new LayerAnimationSequence(LayerAnimationElement::CreateBrightnessElement(
+ target_brightness, delta)));
sequence->AddElement(
LayerAnimationElement::CreateBrightnessElement(start_brightness, delta));
@@ -1447,9 +1438,8 @@ TEST(LayerAnimatorTest, ThreadedCyclicSequences) {
delegate.SetOpacityFromAnimation(start_opacity);
- scoped_ptr<LayerAnimationSequence> sequence(
- new LayerAnimationSequence(
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta)));
+ std::unique_ptr<LayerAnimationSequence> sequence(new LayerAnimationSequence(
+ LayerAnimationElement::CreateOpacityElement(target_opacity, delta)));
sequence->AddElement(
LayerAnimationElement::CreateOpacityElement(start_opacity, delta));
@@ -1461,22 +1451,20 @@ TEST(LayerAnimatorTest, ThreadedCyclicSequences) {
base::TimeTicks start_time = test_controller.animator()->last_step_time();
base::TimeTicks effective_start = start_time + delta;
- test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0,
+ test_controller.animator()->OnThreadedAnimationStarted(
+ effective_start, cc::TargetProperty::OPACITY,
test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)
- ->animation_group_id(),
- cc::TargetProperty::OPACITY, effective_start));
+ ->animation_group_id());
animator->Step(effective_start + delta);
EXPECT_TRUE(test_controller.animator()->is_animating());
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity);
base::TimeTicks second_effective_start = effective_start + 2 * delta;
- test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0,
+ test_controller.animator()->OnThreadedAnimationStarted(
+ second_effective_start, cc::TargetProperty::OPACITY,
test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)
- ->animation_group_id(),
- cc::TargetProperty::OPACITY, second_effective_start));
+ ->animation_group_id());
animator->Step(second_effective_start + delta);
@@ -1484,22 +1472,20 @@ TEST(LayerAnimatorTest, ThreadedCyclicSequences) {
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity);
base::TimeTicks third_effective_start = second_effective_start + 2 * delta;
- test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0,
+ test_controller.animator()->OnThreadedAnimationStarted(
+ third_effective_start, cc::TargetProperty::OPACITY,
test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)
- ->animation_group_id(),
- cc::TargetProperty::OPACITY, third_effective_start));
+ ->animation_group_id());
animator->Step(third_effective_start + delta);
EXPECT_TRUE(test_controller.animator()->is_animating());
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity);
base::TimeTicks fourth_effective_start = third_effective_start + 2 * delta;
- test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0,
+ test_controller.animator()->OnThreadedAnimationStarted(
+ fourth_effective_start, cc::TargetProperty::OPACITY,
test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)
- ->animation_group_id(),
- cc::TargetProperty::OPACITY, fourth_effective_start));
+ ->animation_group_id());
// Skip ahead by a lot.
animator->Step(fourth_effective_start + 1000 * delta);
@@ -1508,11 +1494,10 @@ TEST(LayerAnimatorTest, ThreadedCyclicSequences) {
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity);
base::TimeTicks fifth_effective_start = fourth_effective_start + 1001 * delta;
- test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent(
- cc::AnimationEvent::STARTED, 0,
+ test_controller.animator()->OnThreadedAnimationStarted(
+ fifth_effective_start, cc::TargetProperty::OPACITY,
test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)
- ->animation_group_id(),
- cc::TargetProperty::OPACITY, fifth_effective_start));
+ ->animation_group_id());
// Skip ahead by a lot.
animator->Step(fifth_effective_start + 999 * delta);
@@ -1738,7 +1723,7 @@ TEST(LayerAnimatorTest, RemoveObserverShouldRemoveFromSequences) {
TEST(LayerAnimatorTest, ObserverReleasedBeforeAnimationSequenceEnds) {
TestLayerAnimationDelegate delegate;
- scoped_ptr<TestLayerAnimationObserver> observer(
+ std::unique_ptr<TestLayerAnimationObserver> observer(
new TestLayerAnimationObserver);
scoped_refptr<LayerAnimator> animator(
CreateDefaultTestAnimator(&delegate, observer.get()));
@@ -1853,7 +1838,7 @@ TEST(LayerAnimatorTest, ObserverDeletesAnimationsOnEnd) {
base::TimeDelta halfway_delta = base::TimeDelta::FromSeconds(2);
base::TimeDelta bounds_delta = base::TimeDelta::FromSeconds(3);
- scoped_ptr<DeletingLayerAnimationObserver> observer(
+ std::unique_ptr<DeletingLayerAnimationObserver> observer(
new DeletingLayerAnimationObserver(animator.get()));
animator->AddObserver(observer.get());
@@ -1960,7 +1945,7 @@ TEST(LayerAnimatorTest, ObserverDeletesAnimationsOnAbort) {
delegate.SetBrightnessFromAnimation(start_brightness);
delegate.SetBoundsFromAnimation(start_bounds);
- scoped_ptr<DeletingLayerAnimationObserver> observer(
+ std::unique_ptr<DeletingLayerAnimationObserver> observer(
new DeletingLayerAnimationObserver(animator.get()));
animator->AddObserver(observer.get());
@@ -2001,9 +1986,8 @@ TEST(LayerAnimatorTest, SettingPropertyDuringAnAnimation) {
delegate.SetOpacityFromAnimation(start_opacity);
- scoped_ptr<LayerAnimationSequence> sequence(
- new LayerAnimationSequence(
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta)));
+ std::unique_ptr<LayerAnimationSequence> sequence(new LayerAnimationSequence(
+ LayerAnimationElement::CreateOpacityElement(target_opacity, delta)));
animator->StartAnimation(sequence.release());
@@ -2036,7 +2020,7 @@ TEST(LayerAnimatorTest, ImmediatelySettingNewTargetDoesNotLeak) {
int num_live_instances = 0;
base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- scoped_ptr<TestLayerAnimationSequence> sequence(
+ std::unique_ptr<TestLayerAnimationSequence> sequence(
new TestLayerAnimationSequence(
LayerAnimationElement::CreateBoundsElement(target_bounds, delta),
&num_live_instances));
@@ -2226,13 +2210,13 @@ public:
}
private:
- scoped_ptr<AnimatorOwner> animator_owner_;
- bool delete_on_animation_ended_;
- bool delete_on_animation_aborted_;
- bool delete_on_animation_scheduled_;
- bool* was_deleted_;
+ std::unique_ptr<AnimatorOwner> animator_owner_;
+ bool delete_on_animation_ended_;
+ bool delete_on_animation_aborted_;
+ bool delete_on_animation_scheduled_;
+ bool* was_deleted_;
- DISALLOW_COPY_AND_ASSIGN(DeletingObserver);
+ DISALLOW_COPY_AND_ASSIGN(DeletingObserver);
};
TEST(LayerAnimatorTest, ObserverDeletesAnimatorAfterFinishingAnimation) {
@@ -2479,7 +2463,7 @@ TEST(LayerAnimatorTest, AnimatorStartedCorrectly) {
}
TEST(LayerAnimatorTest, AnimatorRemovedFromCollectionWhenLayerIsDestroyed) {
- scoped_ptr<Layer> layer(new Layer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> layer(new Layer(LAYER_TEXTURED));
LayerAnimatorTestController test_controller(layer->GetAnimator());
scoped_refptr<LayerAnimator> animator = test_controller.animator();
CollectionLayerAnimationDelegate collection_delegate;
@@ -2504,9 +2488,9 @@ TEST(LayerAnimatorTest, LayerMovedBetweenCompositorsDuringAnimation) {
ui::ContextFactory* context_factory =
InitializeContextFactoryForTests(enable_pixel_output);
const gfx::Rect bounds(10, 10, 100, 100);
- scoped_ptr<TestCompositorHost> host_1(
+ std::unique_ptr<TestCompositorHost> host_1(
TestCompositorHost::Create(bounds, context_factory));
- scoped_ptr<TestCompositorHost> host_2(
+ std::unique_ptr<TestCompositorHost> host_2(
TestCompositorHost::Create(bounds, context_factory));
host_1->Show();
host_2->Show();
@@ -2552,7 +2536,7 @@ TEST(LayerAnimatorTest, ThreadedAnimationSurvivesIfLayerRemovedAdded) {
ui::ContextFactory* context_factory =
InitializeContextFactoryForTests(enable_pixel_output);
const gfx::Rect bounds(10, 10, 100, 100);
- scoped_ptr<TestCompositorHost> host(
+ std::unique_ptr<TestCompositorHost> host(
TestCompositorHost::Create(bounds, context_factory));
host->Show();
@@ -2608,7 +2592,7 @@ class LayerOwnerAnimationObserver : public LayerAnimationObserver {
void OnLayerAnimationScheduled(LayerAnimationSequence* sequence) override {}
private:
- scoped_ptr<Layer> animator_layer_;
+ std::unique_ptr<Layer> animator_layer_;
DISALLOW_COPY_AND_ASSIGN(LayerOwnerAnimationObserver);
};
diff --git a/chromium/ui/compositor/layer_owner.cc b/chromium/ui/compositor/layer_owner.cc
index 44bb322ff6c..9fe0b96b6c3 100644
--- a/chromium/ui/compositor/layer_owner.cc
+++ b/chromium/ui/compositor/layer_owner.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "base/memory/ptr_util.h"
#include "ui/compositor/layer_owner_delegate.h"
namespace ui {
@@ -23,14 +24,14 @@ void LayerOwner::SetLayer(Layer* layer) {
layer_->owner_ = this;
}
-scoped_ptr<Layer> LayerOwner::AcquireLayer() {
+std::unique_ptr<Layer> LayerOwner::AcquireLayer() {
if (layer_owner_)
layer_owner_->owner_ = NULL;
return std::move(layer_owner_);
}
-scoped_ptr<Layer> LayerOwner::RecreateLayer() {
- scoped_ptr<ui::Layer> old_layer(AcquireLayer());
+std::unique_ptr<Layer> LayerOwner::RecreateLayer() {
+ std::unique_ptr<ui::Layer> old_layer(AcquireLayer());
if (!old_layer)
return old_layer;
@@ -54,7 +55,7 @@ scoped_ptr<Layer> LayerOwner::RecreateLayer() {
new_layer->SetColor(old_layer->GetTargetColor());
SkRegion* alpha_shape = old_layer->alpha_shape();
if (alpha_shape)
- new_layer->SetAlphaShape(make_scoped_ptr(new SkRegion(*alpha_shape)));
+ new_layer->SetAlphaShape(base::WrapUnique(new SkRegion(*alpha_shape)));
if (old_layer->parent()) {
// Install new layer as a sibling of the old layer, stacked below it.
diff --git a/chromium/ui/compositor/layer_owner.h b/chromium/ui/compositor/layer_owner.h
index 5e19df451fc..fd0606c442b 100644
--- a/chromium/ui/compositor/layer_owner.h
+++ b/chromium/ui/compositor/layer_owner.h
@@ -5,9 +5,10 @@
#ifndef UI_COMPOSITOR_LAYER_OWNER_H_
#define UI_COMPOSITOR_LAYER_OWNER_H_
+#include <memory>
+
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "ui/compositor/compositor_export.h"
#include "ui/compositor/layer.h"
@@ -27,14 +28,14 @@ class COMPOSITOR_EXPORT LayerOwner {
// function, and the caller is then responsible for disposing of the layer
// once any animation completes. Note that layer() will remain valid until the
// end of ~LayerOwner().
- scoped_ptr<Layer> AcquireLayer();
+ std::unique_ptr<Layer> AcquireLayer();
// Asks the owner to recreate the layer, returning the old Layer. NULL is
// returned if there is no existing layer, or recreate is not supported.
//
// This does not recurse. Existing children of the layer are moved to the new
// layer.
- virtual scoped_ptr<Layer> RecreateLayer();
+ virtual std::unique_ptr<Layer> RecreateLayer();
ui::Layer* layer() { return layer_; }
const ui::Layer* layer() const { return layer_; }
@@ -54,7 +55,7 @@ class COMPOSITOR_EXPORT LayerOwner {
// |layer_owner_| will be NULL. The reason for releasing ownership is that
// the client may wish to animate the layer beyond the lifetime of the owner,
// e.g. fading it out when it is destroyed.
- scoped_ptr<Layer> layer_owner_;
+ std::unique_ptr<Layer> layer_owner_;
Layer* layer_;
LayerOwnerDelegate* layer_owner_delegate_;
diff --git a/chromium/ui/compositor/layer_owner_unittest.cc b/chromium/ui/compositor/layer_owner_unittest.cc
index 69216aa9c14..cdffd2a5aca 100644
--- a/chromium/ui/compositor/layer_owner_unittest.cc
+++ b/chromium/ui/compositor/layer_owner_unittest.cc
@@ -56,7 +56,7 @@ class LayerOwnerTestWithCompositor : public testing::Test {
ui::Compositor* compositor() { return compositor_.get(); }
private:
- scoped_ptr<ui::Compositor> compositor_;
+ std::unique_ptr<ui::Compositor> compositor_;
DISALLOW_COPY_AND_ASSIGN(LayerOwnerTestWithCompositor);
};
@@ -102,7 +102,7 @@ TEST(LayerOwnerTest, RecreateLayerHonorsAnimationTargets) {
EXPECT_EQ(1.0f, layer->opacity());
EXPECT_EQ(SK_ColorRED, layer->background_color());
- scoped_ptr<Layer> old_layer(owner.RecreateLayer());
+ std::unique_ptr<Layer> old_layer(owner.RecreateLayer());
EXPECT_FALSE(owner.layer()->visible());
EXPECT_EQ(0.0f, owner.layer()->opacity());
EXPECT_EQ(SK_ColorGREEN, owner.layer()->background_color());
@@ -126,7 +126,7 @@ TEST(LayerOwnerTest, RecreateLayerSolidColorWithChangedCCLayerHonorsTargets) {
EXPECT_EQ(transparent, layer->background_color());
EXPECT_EQ(transparent, layer->GetTargetColor());
- scoped_ptr<Layer> old_layer(owner.RecreateLayer());
+ std::unique_ptr<Layer> old_layer(owner.RecreateLayer());
EXPECT_FALSE(owner.layer()->fills_bounds_opaquely());
EXPECT_EQ(transparent, owner.layer()->background_color());
EXPECT_EQ(transparent, owner.layer()->GetTargetColor());
@@ -137,7 +137,7 @@ TEST(LayerOwnerTest, RecreateRootLayerWithNullCompositor) {
Layer* layer = new Layer;
owner.SetLayer(layer);
- scoped_ptr<Layer> layer_copy = owner.RecreateLayer();
+ std::unique_ptr<Layer> layer_copy = owner.RecreateLayer();
EXPECT_EQ(nullptr, owner.layer()->GetCompositor());
EXPECT_EQ(nullptr, layer_copy->GetCompositor());
@@ -149,11 +149,11 @@ TEST(LayerOwnerTest, InvertPropertyRemainSameWithRecreateLayer) {
owner.SetLayer(layer);
layer->SetLayerInverted(true);
- scoped_ptr<Layer> old_layer1 = owner.RecreateLayer();
+ std::unique_ptr<Layer> old_layer1 = owner.RecreateLayer();
EXPECT_EQ(old_layer1->layer_inverted(), owner.layer()->layer_inverted());
old_layer1->SetLayerInverted(false);
- scoped_ptr<Layer> old_layer2 = owner.RecreateLayer();
+ std::unique_ptr<Layer> old_layer2 = owner.RecreateLayer();
EXPECT_EQ(old_layer2->layer_inverted(), owner.layer()->layer_inverted());
}
@@ -168,7 +168,7 @@ TEST(LayerOwnerTest, RecreateLayerWithTransform) {
layer->SetTransform(transform);
- scoped_ptr<Layer> old_layer1 = owner.RecreateLayer();
+ std::unique_ptr<Layer> old_layer1 = owner.RecreateLayer();
// Both new layer and original layer have the same transform.
EXPECT_EQ(transform, old_layer1->GetTargetTransform());
EXPECT_EQ(transform, owner.layer()->GetTargetTransform());
@@ -177,7 +177,7 @@ TEST(LayerOwnerTest, RecreateLayerWithTransform) {
// should not affect the owner's.
owner.layer()->SetTransform(gfx::Transform());
EXPECT_EQ(transform, old_layer1->GetTargetTransform());
- scoped_ptr<Layer> old_layer2 = owner.RecreateLayer();
+ std::unique_ptr<Layer> old_layer2 = owner.RecreateLayer();
EXPECT_TRUE(old_layer2->GetTargetTransform().IsIdentity());
EXPECT_TRUE(owner.layer()->GetTargetTransform().IsIdentity());
}
@@ -189,7 +189,7 @@ TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerWithCompositor) {
compositor()->SetRootLayer(layer);
- scoped_ptr<Layer> layer_copy = owner.RecreateLayer();
+ std::unique_ptr<Layer> layer_copy = owner.RecreateLayer();
EXPECT_EQ(compositor(), owner.layer()->GetCompositor());
EXPECT_EQ(owner.layer(), compositor()->root_layer());
@@ -205,15 +205,15 @@ TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerDuringAnimation) {
owner.SetLayer(layer);
compositor()->SetRootLayer(layer);
- scoped_ptr<Layer> child(new Layer);
+ std::unique_ptr<Layer> child(new Layer);
child->SetBounds(gfx::Rect(0, 0, 100, 100));
layer->Add(child.get());
// This observer checks that the compositor of |child| is not null upon
// animation completion.
- scoped_ptr<TestLayerAnimationObserver> observer(
+ std::unique_ptr<TestLayerAnimationObserver> observer(
new TestLayerAnimationObserver(child.get()));
- scoped_ptr<ui::ScopedAnimationDurationScaleMode> long_duration_animation(
+ std::unique_ptr<ui::ScopedAnimationDurationScaleMode> long_duration_animation(
new ui::ScopedAnimationDurationScaleMode(
ui::ScopedAnimationDurationScaleMode::SLOW_DURATION));
{
@@ -225,14 +225,14 @@ TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerDuringAnimation) {
child->SetTransform(transform);
}
- scoped_ptr<Layer> layer_copy = owner.RecreateLayer();
+ std::unique_ptr<Layer> layer_copy = owner.RecreateLayer();
}
// Tests that recreating a non-root layer, while one of its children is
// animating, properly updates the compositor. So that compositor is not null
// for observers of animations being cancelled.
TEST_F(LayerOwnerTestWithCompositor, RecreateNonRootLayerDuringAnimation) {
- scoped_ptr<Layer> root_layer(new Layer);
+ std::unique_ptr<Layer> root_layer(new Layer);
compositor()->SetRootLayer(root_layer.get());
LayerOwner owner;
@@ -240,15 +240,15 @@ TEST_F(LayerOwnerTestWithCompositor, RecreateNonRootLayerDuringAnimation) {
owner.SetLayer(layer);
root_layer->Add(layer);
- scoped_ptr<Layer> child(new Layer);
+ std::unique_ptr<Layer> child(new Layer);
child->SetBounds(gfx::Rect(0, 0, 100, 100));
layer->Add(child.get());
// This observer checks that the compositor of |child| is not null upon
// animation completion.
- scoped_ptr<TestLayerAnimationObserver> observer(
+ std::unique_ptr<TestLayerAnimationObserver> observer(
new TestLayerAnimationObserver(child.get()));
- scoped_ptr<ui::ScopedAnimationDurationScaleMode> long_duration_animation(
+ std::unique_ptr<ui::ScopedAnimationDurationScaleMode> long_duration_animation(
new ui::ScopedAnimationDurationScaleMode(
ui::ScopedAnimationDurationScaleMode::SLOW_DURATION));
{
@@ -260,13 +260,13 @@ TEST_F(LayerOwnerTestWithCompositor, RecreateNonRootLayerDuringAnimation) {
child->SetTransform(transform);
}
- scoped_ptr<Layer> layer_copy = owner.RecreateLayer();
+ std::unique_ptr<Layer> layer_copy = owner.RecreateLayer();
}
// Tests that if LayerOwner-derived class destroys layer, then
// LayerAnimator's player becomes detached from compositor timeline.
TEST_F(LayerOwnerTestWithCompositor, DetachTimelineOnAnimatorDeletion) {
- scoped_ptr<Layer> root_layer(new Layer);
+ std::unique_ptr<Layer> root_layer(new Layer);
compositor()->SetRootLayer(root_layer.get());
LayerOwnerForTesting owner;
@@ -289,7 +289,7 @@ TEST_F(LayerOwnerTestWithCompositor, DetachTimelineOnAnimatorDeletion) {
// then LayerAnimator's player becomes attached to timeline.
TEST_F(LayerOwnerTestWithCompositor,
AttachTimelineIfAnimatorCreatedAfterSetCompositor) {
- scoped_ptr<Layer> root_layer(new Layer);
+ std::unique_ptr<Layer> root_layer(new Layer);
compositor()->SetRootLayer(root_layer.get());
LayerOwner owner;
diff --git a/chromium/ui/compositor/layer_threaded_animation_delegate.h b/chromium/ui/compositor/layer_threaded_animation_delegate.h
index b921077e443..4fcf7f332ec 100644
--- a/chromium/ui/compositor/layer_threaded_animation_delegate.h
+++ b/chromium/ui/compositor/layer_threaded_animation_delegate.h
@@ -5,7 +5,8 @@
#ifndef UI_COMPOSITOR_LAYER_THREADED_ANIMATION_DELEGATE_H_
#define UI_COMPOSITOR_LAYER_THREADED_ANIMATION_DELEGATE_H_
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "cc/animation/animation.h"
#include "ui/compositor/compositor_export.h"
@@ -14,7 +15,8 @@ namespace ui {
// Attach CC animations using this interface.
class COMPOSITOR_EXPORT LayerThreadedAnimationDelegate {
public:
- virtual void AddThreadedAnimation(scoped_ptr<cc::Animation> animation) = 0;
+ virtual void AddThreadedAnimation(
+ std::unique_ptr<cc::Animation> animation) = 0;
virtual void RemoveThreadedAnimation(int animation_id) = 0;
protected:
diff --git a/chromium/ui/compositor/layer_unittest.cc b/chromium/ui/compositor/layer_unittest.cc
index c62177833f2..1c8d97976f1 100644
--- a/chromium/ui/compositor/layer_unittest.cc
+++ b/chromium/ui/compositor/layer_unittest.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
+#include <memory>
#include <utility>
#include "base/bind.h"
@@ -14,7 +15,7 @@
#include "base/files/file_util.h"
#include "base/json/json_reader.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
@@ -151,7 +152,7 @@ class LayerWithRealCompositorTest : public testing::Test {
void ReadPixels(SkBitmap* bitmap, gfx::Rect source_rect) {
scoped_refptr<ReadbackHolder> holder(new ReadbackHolder);
- scoped_ptr<cc::CopyOutputRequest> request =
+ std::unique_ptr<cc::CopyOutputRequest> request =
cc::CopyOutputRequest::CreateBitmapRequest(
base::Bind(&ReadbackHolder::OutputRequestCallback, holder));
request->set_area(source_rect);
@@ -199,7 +200,7 @@ class LayerWithRealCompositorTest : public testing::Test {
public:
ReadbackHolder() : run_loop_(new base::RunLoop) {}
- void OutputRequestCallback(scoped_ptr<cc::CopyOutputResult> result) {
+ void OutputRequestCallback(std::unique_ptr<cc::CopyOutputResult> result) {
result_ = result->TakeBitmap();
run_loop_->Quit();
}
@@ -213,11 +214,11 @@ class LayerWithRealCompositorTest : public testing::Test {
virtual ~ReadbackHolder() {}
- scoped_ptr<SkBitmap> result_;
- scoped_ptr<base::RunLoop> run_loop_;
+ std::unique_ptr<SkBitmap> result_;
+ std::unique_ptr<base::RunLoop> run_loop_;
};
- scoped_ptr<TestCompositorHost> compositor_host_;
+ std::unique_ptr<TestCompositorHost> compositor_host_;
// The root directory for test files.
base::FilePath test_data_directory_;
@@ -411,8 +412,8 @@ class TestCompositorAnimationObserver : public CompositorAnimationObserver {
} // namespace
TEST_F(LayerWithRealCompositorTest, Draw) {
- scoped_ptr<Layer> layer(CreateColorLayer(SK_ColorRED,
- gfx::Rect(20, 20, 50, 50)));
+ std::unique_ptr<Layer> layer(
+ CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 50, 50)));
DrawTree(layer.get());
}
@@ -423,14 +424,14 @@ TEST_F(LayerWithRealCompositorTest, Draw) {
// +-- L4 - magenta
//
TEST_F(LayerWithRealCompositorTest, Hierarchy) {
- scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
- gfx::Rect(20, 20, 400, 400)));
- scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE,
- gfx::Rect(10, 10, 350, 350)));
- scoped_ptr<Layer> l3(CreateColorLayer(SK_ColorYELLOW,
- gfx::Rect(5, 5, 25, 25)));
- scoped_ptr<Layer> l4(CreateColorLayer(SK_ColorMAGENTA,
- gfx::Rect(300, 300, 100, 100)));
+ std::unique_ptr<Layer> l1(
+ CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 400, 400)));
+ std::unique_ptr<Layer> l2(
+ CreateColorLayer(SK_ColorBLUE, gfx::Rect(10, 10, 350, 350)));
+ std::unique_ptr<Layer> l3(
+ CreateColorLayer(SK_ColorYELLOW, gfx::Rect(5, 5, 25, 25)));
+ std::unique_ptr<Layer> l4(
+ CreateColorLayer(SK_ColorMAGENTA, gfx::Rect(300, 300, 100, 100)));
l1->Add(l2.get());
l1->Add(l4.get());
@@ -505,7 +506,7 @@ class LayerWithDelegateTest : public testing::Test {
}
private:
- scoped_ptr<TestCompositorHost> compositor_host_;
+ std::unique_ptr<TestCompositorHost> compositor_host_;
DISALLOW_COPY_AND_ASSIGN(LayerWithDelegateTest);
};
@@ -515,7 +516,7 @@ void ReturnMailbox(bool* run, const gpu::SyncToken& sync_token, bool is_lost) {
}
TEST(LayerStandaloneTest, ReleaseMailboxOnDestruction) {
- scoped_ptr<Layer> layer(new Layer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> layer(new Layer(LAYER_TEXTURED));
bool callback_run = false;
cc::TextureMailbox mailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), 0);
layer->SetTextureMailbox(mailbox,
@@ -530,10 +531,10 @@ TEST(LayerStandaloneTest, ReleaseMailboxOnDestruction) {
// L1
// +-- L2
TEST_F(LayerWithDelegateTest, ConvertPointToLayer_Simple) {
- scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
- gfx::Rect(20, 20, 400, 400)));
- scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE,
- gfx::Rect(10, 10, 350, 350)));
+ std::unique_ptr<Layer> l1(
+ CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 400, 400)));
+ std::unique_ptr<Layer> l2(
+ CreateColorLayer(SK_ColorBLUE, gfx::Rect(10, 10, 350, 350)));
l1->Add(l2.get());
DrawTree(l1.get());
@@ -552,12 +553,12 @@ TEST_F(LayerWithDelegateTest, ConvertPointToLayer_Simple) {
// +-- L2
// +-- L3
TEST_F(LayerWithDelegateTest, ConvertPointToLayer_Medium) {
- scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
- gfx::Rect(20, 20, 400, 400)));
- scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE,
- gfx::Rect(10, 10, 350, 350)));
- scoped_ptr<Layer> l3(CreateColorLayer(SK_ColorYELLOW,
- gfx::Rect(10, 10, 100, 100)));
+ std::unique_ptr<Layer> l1(
+ CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 400, 400)));
+ std::unique_ptr<Layer> l2(
+ CreateColorLayer(SK_ColorBLUE, gfx::Rect(10, 10, 350, 350)));
+ std::unique_ptr<Layer> l3(
+ CreateColorLayer(SK_ColorYELLOW, gfx::Rect(10, 10, 100, 100)));
l1->Add(l2.get());
l2->Add(l3.get());
DrawTree(l1.get());
@@ -577,7 +578,7 @@ TEST_F(LayerWithRealCompositorTest, Delegate) {
// This test makes sure that whenever paint happens at a layer, its layer
// delegate gets the paint, which in this test update its color and
// |color_index|.
- scoped_ptr<Layer> l1(
+ std::unique_ptr<Layer> l1(
CreateColorLayer(SK_ColorBLACK, gfx::Rect(20, 20, 400, 400)));
GetCompositor()->SetRootLayer(l1.get());
WaitForDraw();
@@ -606,12 +607,12 @@ TEST_F(LayerWithRealCompositorTest, Delegate) {
}
TEST_F(LayerWithRealCompositorTest, DrawTree) {
- scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
- gfx::Rect(20, 20, 400, 400)));
- scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE,
- gfx::Rect(10, 10, 350, 350)));
- scoped_ptr<Layer> l3(CreateColorLayer(SK_ColorYELLOW,
- gfx::Rect(10, 10, 100, 100)));
+ std::unique_ptr<Layer> l1(
+ CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 400, 400)));
+ std::unique_ptr<Layer> l2(
+ CreateColorLayer(SK_ColorBLUE, gfx::Rect(10, 10, 350, 350)));
+ std::unique_ptr<Layer> l3(
+ CreateColorLayer(SK_ColorYELLOW, gfx::Rect(10, 10, 100, 100)));
l1->Add(l2.get());
l2->Add(l3.get());
@@ -640,13 +641,13 @@ TEST_F(LayerWithRealCompositorTest, DrawTree) {
// +-- L4 - magenta
//
TEST_F(LayerWithRealCompositorTest, HierarchyNoTexture) {
- scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
- gfx::Rect(20, 20, 400, 400)));
- scoped_ptr<Layer> l2(CreateNoTextureLayer(gfx::Rect(10, 10, 350, 350)));
- scoped_ptr<Layer> l3(CreateColorLayer(SK_ColorYELLOW,
- gfx::Rect(5, 5, 25, 25)));
- scoped_ptr<Layer> l4(CreateColorLayer(SK_ColorMAGENTA,
- gfx::Rect(300, 300, 100, 100)));
+ std::unique_ptr<Layer> l1(
+ CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 400, 400)));
+ std::unique_ptr<Layer> l2(CreateNoTextureLayer(gfx::Rect(10, 10, 350, 350)));
+ std::unique_ptr<Layer> l3(
+ CreateColorLayer(SK_ColorYELLOW, gfx::Rect(5, 5, 25, 25)));
+ std::unique_ptr<Layer> l4(
+ CreateColorLayer(SK_ColorMAGENTA, gfx::Rect(300, 300, 100, 100)));
l1->Add(l2.get());
l1->Add(l4.get());
@@ -705,22 +706,22 @@ class LayerWithNullDelegateTest : public LayerWithDelegateTest {
}
private:
- scoped_ptr<NullLayerDelegate> default_layer_delegate_;
+ std::unique_ptr<NullLayerDelegate> default_layer_delegate_;
DISALLOW_COPY_AND_ASSIGN(LayerWithNullDelegateTest);
};
TEST_F(LayerWithNullDelegateTest, EscapedDebugNames) {
- scoped_ptr<Layer> layer(CreateLayer(LAYER_NOT_DRAWN));
+ std::unique_ptr<Layer> layer(CreateLayer(LAYER_NOT_DRAWN));
std::string name = "\"\'\\/\b\f\n\r\t\n";
layer->set_name(name);
- scoped_ptr<base::trace_event::ConvertableToTraceFormat> debug_info(
+ std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info(
layer->TakeDebugInfo(layer->cc_layer_for_testing()));
EXPECT_TRUE(debug_info.get());
std::string json;
debug_info->AppendAsTraceFormat(&json);
base::JSONReader json_reader;
- scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(json));
+ std::unique_ptr<base::Value> debug_info_value(json_reader.ReadToValue(json));
EXPECT_TRUE(debug_info_value);
EXPECT_TRUE(debug_info_value->IsType(base::Value::TYPE_DICTIONARY));
base::DictionaryValue* dictionary = 0;
@@ -731,16 +732,14 @@ TEST_F(LayerWithNullDelegateTest, EscapedDebugNames) {
}
TEST_F(LayerWithNullDelegateTest, SwitchLayerPreservesCCLayerState) {
- scoped_ptr<Layer> l1(CreateLayer(LAYER_SOLID_COLOR));
+ std::unique_ptr<Layer> l1(CreateLayer(LAYER_SOLID_COLOR));
l1->SetFillsBoundsOpaquely(true);
- l1->SetForceRenderSurface(true);
l1->SetVisible(false);
l1->SetBounds(gfx::Rect(4, 5));
EXPECT_EQ(gfx::Point3F(), l1->cc_layer_for_testing()->transform_origin());
EXPECT_TRUE(l1->cc_layer_for_testing()->DrawsContent());
EXPECT_TRUE(l1->cc_layer_for_testing()->contents_opaque());
- EXPECT_TRUE(l1->cc_layer_for_testing()->force_render_surface());
EXPECT_TRUE(l1->cc_layer_for_testing()->hide_layer_and_subtree());
EXPECT_EQ(gfx::Size(4, 5), l1->cc_layer_for_testing()->bounds());
@@ -757,7 +756,6 @@ TEST_F(LayerWithNullDelegateTest, SwitchLayerPreservesCCLayerState) {
EXPECT_EQ(gfx::Point3F(), l1->cc_layer_for_testing()->transform_origin());
EXPECT_TRUE(l1->cc_layer_for_testing()->DrawsContent());
EXPECT_TRUE(l1->cc_layer_for_testing()->contents_opaque());
- EXPECT_TRUE(l1->cc_layer_for_testing()->force_render_surface());
EXPECT_TRUE(l1->cc_layer_for_testing()->hide_layer_and_subtree());
EXPECT_EQ(gfx::Size(4, 5), l1->cc_layer_for_testing()->bounds());
EXPECT_FALSE(callback1_run);
@@ -775,7 +773,6 @@ TEST_F(LayerWithNullDelegateTest, SwitchLayerPreservesCCLayerState) {
EXPECT_EQ(gfx::Point3F(), l1->cc_layer_for_testing()->transform_origin());
EXPECT_TRUE(l1->cc_layer_for_testing()->DrawsContent());
EXPECT_TRUE(l1->cc_layer_for_testing()->contents_opaque());
- EXPECT_TRUE(l1->cc_layer_for_testing()->force_render_surface());
EXPECT_TRUE(l1->cc_layer_for_testing()->hide_layer_and_subtree());
EXPECT_EQ(gfx::Size(4, 5), l1->cc_layer_for_testing()->bounds());
EXPECT_TRUE(callback2_run);
@@ -794,7 +791,6 @@ TEST_F(LayerWithNullDelegateTest, SwitchLayerPreservesCCLayerState) {
EXPECT_EQ(gfx::Point3F(), l1->cc_layer_for_testing()->transform_origin());
EXPECT_TRUE(l1->cc_layer_for_testing()->DrawsContent());
EXPECT_TRUE(l1->cc_layer_for_testing()->contents_opaque());
- EXPECT_TRUE(l1->cc_layer_for_testing()->force_render_surface());
EXPECT_TRUE(l1->cc_layer_for_testing()->hide_layer_and_subtree());
EXPECT_EQ(gfx::Size(4, 5), l1->cc_layer_for_testing()->bounds());
EXPECT_FALSE(callback3_run);
@@ -805,9 +801,9 @@ TEST_F(LayerWithNullDelegateTest, SwitchLayerPreservesCCLayerState) {
// Various visibile/drawn assertions.
TEST_F(LayerWithNullDelegateTest, Visibility) {
- scoped_ptr<Layer> l1(new Layer(LAYER_TEXTURED));
- scoped_ptr<Layer> l2(new Layer(LAYER_TEXTURED));
- scoped_ptr<Layer> l3(new Layer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> l1(new Layer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> l2(new Layer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> l3(new Layer(LAYER_TEXTURED));
l1->Add(l2.get());
l2->Add(l3.get());
@@ -855,10 +851,10 @@ TEST_F(LayerWithNullDelegateTest, Visibility) {
// Checks that stacking-related methods behave as advertised.
TEST_F(LayerWithNullDelegateTest, Stacking) {
- scoped_ptr<Layer> root(new Layer(LAYER_NOT_DRAWN));
- scoped_ptr<Layer> l1(new Layer(LAYER_TEXTURED));
- scoped_ptr<Layer> l2(new Layer(LAYER_TEXTURED));
- scoped_ptr<Layer> l3(new Layer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> root(new Layer(LAYER_NOT_DRAWN));
+ std::unique_ptr<Layer> l1(new Layer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> l2(new Layer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> l3(new Layer(LAYER_TEXTURED));
l1->set_name("1");
l2->set_name("2");
l3->set_name("3");
@@ -914,7 +910,7 @@ TEST_F(LayerWithNullDelegateTest, Stacking) {
// Verifies SetBounds triggers the appropriate painting/drawing.
TEST_F(LayerWithNullDelegateTest, SetBoundsSchedulesPaint) {
- scoped_ptr<Layer> l1(CreateTextureLayer(gfx::Rect(0, 0, 200, 200)));
+ std::unique_ptr<Layer> l1(CreateTextureLayer(gfx::Rect(0, 0, 200, 200)));
compositor()->SetRootLayer(l1.get());
Draw();
@@ -930,6 +926,33 @@ TEST_F(LayerWithNullDelegateTest, SetBoundsSchedulesPaint) {
WaitForDraw();
}
+static void EmptyReleaseCallback(const gpu::SyncToken& sync_token,
+ bool is_lost) {}
+
+// Checks that the damage rect for a TextureLayer is empty after a commit.
+TEST_F(LayerWithNullDelegateTest, EmptyDamagedRect) {
+ std::unique_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR));
+ cc::TextureMailbox mailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), 0);
+ root->SetTextureMailbox(mailbox, cc::SingleReleaseCallback::Create(
+ base::Bind(EmptyReleaseCallback)),
+ gfx::Size(10, 10));
+ compositor()->SetRootLayer(root.get());
+
+ root->SetBounds(gfx::Rect(0, 0, 10, 10));
+ root->SetVisible(true);
+ WaitForCommit();
+
+ gfx::Rect damaged_rect(0, 0, 5, 5);
+ root->SchedulePaint(damaged_rect);
+ EXPECT_EQ(damaged_rect, root->damaged_region_for_testing().bounds());
+ WaitForCommit();
+ EXPECT_TRUE(root->damaged_region_for_testing().IsEmpty());
+
+ compositor()->SetRootLayer(nullptr);
+ root.reset();
+ WaitForCommit();
+}
+
void ExpectRgba(int x, int y, SkColor expected_color, SkColor actual_color) {
EXPECT_EQ(expected_color, actual_color)
<< "Pixel error at x=" << x << " y=" << y << "; "
@@ -956,11 +979,10 @@ TEST_F(LayerWithRealCompositorTest, DrawPixels) {
int blue_height = 10;
- scoped_ptr<Layer> layer(
+ std::unique_ptr<Layer> layer(
CreateColorLayer(SK_ColorRED, gfx::Rect(viewport_size)));
- scoped_ptr<Layer> layer2(
- CreateColorLayer(SK_ColorBLUE,
- gfx::Rect(0, 0, viewport_size.width(), blue_height)));
+ std::unique_ptr<Layer> layer2(CreateColorLayer(
+ SK_ColorBLUE, gfx::Rect(0, 0, viewport_size.width(), blue_height)));
layer->Add(layer2.get());
@@ -993,9 +1015,9 @@ TEST_F(LayerWithRealCompositorTest, DrawAlphaBlendedPixels) {
SkColor blue_with_alpha = SkColorSetARGBInline(40, 10, 20, 200);
SkColor blend_color = SkColorSetARGBInline(255, 216, 3, 32);
- scoped_ptr<Layer> background_layer(
+ std::unique_ptr<Layer> background_layer(
CreateColorLayer(SK_ColorRED, gfx::Rect(viewport_size)));
- scoped_ptr<Layer> foreground_layer(
+ std::unique_ptr<Layer> foreground_layer(
CreateColorLayer(blue_with_alpha, gfx::Rect(viewport_size)));
// This must be set to false for layers with alpha to be blended correctly.
@@ -1030,15 +1052,15 @@ TEST_F(LayerWithRealCompositorTest, DrawAlphaThresholdFilterPixels) {
SkColor blue_with_alpha = SkColorSetARGBInline(40, 0, 0, 255);
SkColor blend_color = SkColorSetARGBInline(255, 215, 0, 40);
- scoped_ptr<Layer> background_layer(
+ std::unique_ptr<Layer> background_layer(
CreateColorLayer(SK_ColorRED, gfx::Rect(viewport_size)));
- scoped_ptr<Layer> foreground_layer(
+ std::unique_ptr<Layer> foreground_layer(
CreateColorLayer(blue_with_alpha, gfx::Rect(viewport_size)));
// Add a shape to restrict the visible part of the layer.
SkRegion shape;
shape.setRect(0, 0, viewport_size.width(), blue_height);
- foreground_layer->SetAlphaShape(make_scoped_ptr(new SkRegion(shape)));
+ foreground_layer->SetAlphaShape(base::WrapUnique(new SkRegion(shape)));
foreground_layer->SetFillsBoundsOpaquely(false);
@@ -1062,10 +1084,10 @@ TEST_F(LayerWithRealCompositorTest, DrawAlphaThresholdFilterPixels) {
// Checks the logic around Compositor::SetRootLayer and Layer::SetCompositor.
TEST_F(LayerWithRealCompositorTest, SetRootLayer) {
Compositor* compositor = GetCompositor();
- scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
- gfx::Rect(20, 20, 400, 400)));
- scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE,
- gfx::Rect(10, 10, 350, 350)));
+ std::unique_ptr<Layer> l1(
+ CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 400, 400)));
+ std::unique_ptr<Layer> l2(
+ CreateColorLayer(SK_ColorBLUE, gfx::Rect(10, 10, 350, 350)));
EXPECT_EQ(NULL, l1->GetCompositor());
EXPECT_EQ(NULL, l2->GetCompositor());
@@ -1093,10 +1115,10 @@ TEST_F(LayerWithRealCompositorTest, SetRootLayer) {
// - Whenever SetBounds, SetOpacity or SetTransform are called.
// TODO(vollick): could be reorganized into compositor_unittest.cc
TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
- scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
- gfx::Rect(20, 20, 400, 400)));
- scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE,
- gfx::Rect(10, 10, 350, 350)));
+ std::unique_ptr<Layer> l1(
+ CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 400, 400)));
+ std::unique_ptr<Layer> l2(
+ CreateColorLayer(SK_ColorBLUE, gfx::Rect(10, 10, 350, 350)));
l1->Add(l2.get());
TestCompositorObserver observer;
GetCompositor()->AddObserver(&observer);
@@ -1173,14 +1195,14 @@ TEST_F(LayerWithRealCompositorTest, ModifyHierarchy) {
// +-l11
// | +-l21
// +-l12
- scoped_ptr<Layer> l0(CreateColorLayer(SK_ColorRED,
- gfx::Rect(0, 0, 50, 50)));
- scoped_ptr<Layer> l11(CreateColorLayer(SK_ColorGREEN,
- gfx::Rect(0, 0, 25, 25)));
- scoped_ptr<Layer> l21(CreateColorLayer(SK_ColorMAGENTA,
- gfx::Rect(0, 0, 15, 15)));
- scoped_ptr<Layer> l12(CreateColorLayer(SK_ColorBLUE,
- gfx::Rect(10, 10, 25, 25)));
+ std::unique_ptr<Layer> l0(
+ CreateColorLayer(SK_ColorRED, gfx::Rect(0, 0, 50, 50)));
+ std::unique_ptr<Layer> l11(
+ CreateColorLayer(SK_ColorGREEN, gfx::Rect(0, 0, 25, 25)));
+ std::unique_ptr<Layer> l21(
+ CreateColorLayer(SK_ColorMAGENTA, gfx::Rect(0, 0, 15, 15)));
+ std::unique_ptr<Layer> l12(
+ CreateColorLayer(SK_ColorBLUE, gfx::Rect(10, 10, 25, 25)));
base::FilePath ref_img1 =
test_data_directory().AppendASCII("ModifyHierarchy1.png");
@@ -1240,10 +1262,10 @@ TEST_F(LayerWithRealCompositorTest, Opacity) {
// l0
// +-l11
- scoped_ptr<Layer> l0(CreateColorLayer(SK_ColorRED,
- gfx::Rect(0, 0, 50, 50)));
- scoped_ptr<Layer> l11(CreateColorLayer(SK_ColorGREEN,
- gfx::Rect(0, 0, 25, 25)));
+ std::unique_ptr<Layer> l0(
+ CreateColorLayer(SK_ColorRED, gfx::Rect(0, 0, 50, 50)));
+ std::unique_ptr<Layer> l11(
+ CreateColorLayer(SK_ColorGREEN, gfx::Rect(0, 0, 25, 25)));
base::FilePath ref_img = test_data_directory().AppendASCII("Opacity.png");
@@ -1314,11 +1336,11 @@ class SchedulePaintLayerDelegate : public LayerDelegate {
// Verifies that if SchedulePaint is invoked during painting the layer is still
// marked dirty.
TEST_F(LayerWithDelegateTest, SchedulePaintFromOnPaintLayer) {
- scoped_ptr<Layer> root(CreateColorLayer(SK_ColorRED,
- gfx::Rect(0, 0, 500, 500)));
+ std::unique_ptr<Layer> root(
+ CreateColorLayer(SK_ColorRED, gfx::Rect(0, 0, 500, 500)));
SchedulePaintLayerDelegate child_delegate;
- scoped_ptr<Layer> child(CreateColorLayer(SK_ColorBLUE,
- gfx::Rect(0, 0, 200, 200)));
+ std::unique_ptr<Layer> child(
+ CreateColorLayer(SK_ColorBLUE, gfx::Rect(0, 0, 200, 200)));
child_delegate.set_layer(child.get());
root->Add(child.get());
@@ -1343,15 +1365,15 @@ TEST_F(LayerWithDelegateTest, SchedulePaintFromOnPaintLayer) {
}
TEST_F(LayerWithRealCompositorTest, ScaleUpDown) {
- scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE,
- gfx::Rect(10, 20, 200, 220)));
+ std::unique_ptr<Layer> root(
+ CreateColorLayer(SK_ColorWHITE, gfx::Rect(10, 20, 200, 220)));
TestLayerDelegate root_delegate;
root_delegate.AddColor(SK_ColorWHITE);
root->set_delegate(&root_delegate);
root_delegate.set_layer_bounds(root->bounds());
- scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE,
- gfx::Rect(10, 20, 140, 180)));
+ std::unique_ptr<Layer> l1(
+ CreateColorLayer(SK_ColorWHITE, gfx::Rect(10, 20, 140, 180)));
TestLayerDelegate l1_delegate;
l1_delegate.AddColor(SK_ColorWHITE);
l1->set_delegate(&l1_delegate);
@@ -1411,10 +1433,10 @@ TEST_F(LayerWithRealCompositorTest, ScaleUpDown) {
}
TEST_F(LayerWithRealCompositorTest, ScaleReparent) {
- scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE,
- gfx::Rect(10, 20, 200, 220)));
- scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE,
- gfx::Rect(10, 20, 140, 180)));
+ std::unique_ptr<Layer> root(
+ CreateColorLayer(SK_ColorWHITE, gfx::Rect(10, 20, 200, 220)));
+ std::unique_ptr<Layer> l1(
+ CreateColorLayer(SK_ColorWHITE, gfx::Rect(10, 20, 140, 180)));
TestLayerDelegate l1_delegate;
l1_delegate.AddColor(SK_ColorWHITE);
l1->set_delegate(&l1_delegate);
@@ -1451,9 +1473,10 @@ TEST_F(LayerWithRealCompositorTest, ScaleReparent) {
// - if just a move, then no painting should happen.
// - if a resize, the layer should be repainted.
TEST_F(LayerWithDelegateTest, SetBoundsWhenInvisible) {
- scoped_ptr<Layer> root(CreateNoTextureLayer(gfx::Rect(0, 0, 1000, 1000)));
+ std::unique_ptr<Layer> root(
+ CreateNoTextureLayer(gfx::Rect(0, 0, 1000, 1000)));
- scoped_ptr<Layer> child(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> child(CreateLayer(LAYER_TEXTURED));
child->SetBounds(gfx::Rect(0, 0, 500, 500));
DrawTreeLayerDelegate delegate(child->bounds());
child->set_delegate(&delegate);
@@ -1495,8 +1518,9 @@ void FakeRequireCallback(cc::SurfaceId, cc::SurfaceSequence) {}
} // namespace
TEST_F(LayerWithDelegateTest, ExternalContent) {
- scoped_ptr<Layer> root(CreateNoTextureLayer(gfx::Rect(0, 0, 1000, 1000)));
- scoped_ptr<Layer> child(CreateLayer(LAYER_SOLID_COLOR));
+ std::unique_ptr<Layer> root(
+ CreateNoTextureLayer(gfx::Rect(0, 0, 1000, 1000)));
+ std::unique_ptr<Layer> child(CreateLayer(LAYER_SOLID_COLOR));
child->SetBounds(gfx::Rect(0, 0, 10, 10));
child->SetVisible(true);
@@ -1527,7 +1551,7 @@ TEST_F(LayerWithDelegateTest, ExternalContent) {
// Verifies that layer filters still attached after changing implementation
// layer.
TEST_F(LayerWithDelegateTest, LayerFiltersSurvival) {
- scoped_ptr<Layer> layer(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> layer(CreateLayer(LAYER_TEXTURED));
layer->SetBounds(gfx::Rect(0, 0, 10, 10));
EXPECT_TRUE(layer->cc_layer_for_testing());
EXPECT_EQ(0u, layer->cc_layer_for_testing()->filters().size());
@@ -1549,9 +1573,9 @@ TEST_F(LayerWithDelegateTest, LayerFiltersSurvival) {
// Tests Layer::AddThreadedAnimation and Layer::RemoveThreadedAnimation.
TEST_F(LayerWithRealCompositorTest, AddRemoveThreadedAnimations) {
- scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
- scoped_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED));
- scoped_ptr<Layer> l2(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> l2(CreateLayer(LAYER_TEXTURED));
l1->SetAnimator(LayerAnimator::CreateImplicitAnimator());
l2->SetAnimator(LayerAnimator::CreateImplicitAnimator());
@@ -1596,8 +1620,8 @@ TEST_F(LayerWithRealCompositorTest, AddRemoveThreadedAnimations) {
// Tests that in-progress threaded animations complete when a Layer's
// cc::Layer changes.
TEST_F(LayerWithRealCompositorTest, SwitchCCLayerAnimations) {
- scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
- scoped_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED));
GetCompositor()->SetRootLayer(root.get());
root->Add(l1.get());
@@ -1619,7 +1643,7 @@ TEST_F(LayerWithRealCompositorTest, SwitchCCLayerAnimations) {
// opaqueness and color set while not animating, are maintained.
TEST_F(LayerWithRealCompositorTest, SwitchCCLayerSolidColorNotAnimating) {
SkColor transparent = SK_ColorTRANSPARENT;
- scoped_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR));
+ std::unique_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR));
GetCompositor()->SetRootLayer(root.get());
root->SetFillsBoundsOpaquely(false);
root->SetColor(transparent);
@@ -1645,14 +1669,14 @@ TEST_F(LayerWithRealCompositorTest, SwitchCCLayerSolidColorNotAnimating) {
// targets are maintained.
TEST_F(LayerWithRealCompositorTest, SwitchCCLayerSolidColorWhileAnimating) {
SkColor transparent = SK_ColorTRANSPARENT;
- scoped_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR));
+ std::unique_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR));
GetCompositor()->SetRootLayer(root.get());
root->SetColor(SK_ColorBLACK);
EXPECT_TRUE(root->fills_bounds_opaquely());
EXPECT_EQ(SK_ColorBLACK, root->GetTargetColor());
- scoped_ptr<ui::ScopedAnimationDurationScaleMode> long_duration_animation(
+ std::unique_ptr<ui::ScopedAnimationDurationScaleMode> long_duration_animation(
new ui::ScopedAnimationDurationScaleMode(
ui::ScopedAnimationDurationScaleMode::SLOW_DURATION));
{
@@ -1689,8 +1713,9 @@ TEST_F(LayerWithRealCompositorTest, SwitchCCLayerSolidColorWhileAnimating) {
// Tests that the animators in the layer tree is added to the
// animator-collection when the root-layer is set to the compositor.
TEST_F(LayerWithDelegateTest, RootLayerAnimatorsInCompositor) {
- scoped_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR));
- scoped_ptr<Layer> child(CreateColorLayer(SK_ColorRED, gfx::Rect(10, 10)));
+ std::unique_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR));
+ std::unique_ptr<Layer> child(
+ CreateColorLayer(SK_ColorRED, gfx::Rect(10, 10)));
child->SetAnimator(LayerAnimator::CreateImplicitAnimator());
child->SetOpacity(0.5f);
root->Add(child.get());
@@ -1703,10 +1728,10 @@ TEST_F(LayerWithDelegateTest, RootLayerAnimatorsInCompositor) {
// Tests that adding/removing a layer adds/removes the animator from its entire
// subtree from the compositor's animator-collection.
TEST_F(LayerWithDelegateTest, AddRemoveLayerUpdatesAnimatorsFromSubtree) {
- scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
- scoped_ptr<Layer> child(CreateLayer(LAYER_TEXTURED));
- scoped_ptr<Layer> grandchild(CreateColorLayer(SK_ColorRED,
- gfx::Rect(10, 10)));
+ std::unique_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> child(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> grandchild(
+ CreateColorLayer(SK_ColorRED, gfx::Rect(10, 10)));
root->Add(child.get());
child->Add(grandchild.get());
compositor()->SetRootLayer(root.get());
@@ -1723,8 +1748,8 @@ TEST_F(LayerWithDelegateTest, AddRemoveLayerUpdatesAnimatorsFromSubtree) {
}
TEST_F(LayerWithDelegateTest, DestroyingLayerRemovesTheAnimatorFromCollection) {
- scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
- scoped_ptr<Layer> child(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> child(CreateLayer(LAYER_TEXTURED));
root->Add(child.get());
compositor()->SetRootLayer(root.get());
@@ -1764,9 +1789,9 @@ class LayerRemovingLayerAnimationObserver : public LayerAnimationObserver {
// Verifies that empty LayerAnimators are not left behind when removing child
// Layers that own an empty LayerAnimator. See http://crbug.com/552037.
TEST_F(LayerWithDelegateTest, NonAnimatingAnimatorsAreRemovedFromCollection) {
- scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
- scoped_ptr<Layer> parent(CreateLayer(LAYER_TEXTURED));
- scoped_ptr<Layer> child(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> parent(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> child(CreateLayer(LAYER_TEXTURED));
root->Add(parent.get());
parent->Add(child.get());
compositor()->SetRootLayer(root.get());
@@ -1798,9 +1823,9 @@ std::string Vector2dFTo100thPercisionString(const gfx::Vector2dF& vector) {
} // namespace
TEST_F(LayerWithRealCompositorTest, SnapLayerToPixels) {
- scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
- scoped_ptr<Layer> c1(CreateLayer(LAYER_TEXTURED));
- scoped_ptr<Layer> c11(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> c1(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> c11(CreateLayer(LAYER_TEXTURED));
GetCompositor()->SetScaleAndSize(1.25f, gfx::Size(100, 100));
GetCompositor()->SetRootLayer(root.get());
@@ -1853,7 +1878,7 @@ class FrameDamageCheckingDelegate : public TestLayerDelegate {
};
TEST(LayerDelegateTest, DelegatedFrameDamage) {
- scoped_ptr<Layer> layer(new Layer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> layer(new Layer(LAYER_TEXTURED));
gfx::Rect damage_rect(2, 1, 5, 3);
FrameDamageCheckingDelegate delegate;
@@ -1869,7 +1894,7 @@ TEST(LayerDelegateTest, DelegatedFrameDamage) {
}
TEST_F(LayerWithRealCompositorTest, CompositorAnimationObserverTest) {
- scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
+ std::unique_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
root->SetAnimator(LayerAnimator::CreateImplicitAnimator());
diff --git a/chromium/ui/compositor/paint_context.h b/chromium/ui/compositor/paint_context.h
index 3473f236414..af69f7084f6 100644
--- a/chromium/ui/compositor/paint_context.h
+++ b/chromium/ui/compositor/paint_context.h
@@ -5,9 +5,10 @@
#ifndef UI_COMPOSITOR_PAINT_CONTEXT_H_
#define UI_COMPOSITOR_PAINT_CONTEXT_H_
+#include <memory>
+
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "ui/compositor/compositor_export.h"
#include "ui/gfx/geometry/rect.h"
@@ -89,7 +90,7 @@ class COMPOSITOR_EXPORT PaintContext {
gfx::Rect ToLayerSpaceRect(const gfx::Rect& rect) const;
cc::DisplayItemList* list_;
- scoped_ptr<SkPictureRecorder> owned_recorder_;
+ std::unique_ptr<SkPictureRecorder> owned_recorder_;
// A pointer to the |owned_recorder_| in this PaintContext, or in another one
// which this was copied from. We expect a copied-from PaintContext to outlive
// copies made from it.
diff --git a/chromium/ui/compositor/paint_recorder.cc b/chromium/ui/compositor/paint_recorder.cc
index 163a7a77908..76ea8ff2441 100644
--- a/chromium/ui/compositor/paint_recorder.cc
+++ b/chromium/ui/compositor/paint_recorder.cc
@@ -7,6 +7,7 @@
#include "cc/playback/display_item_list.h"
#include "cc/playback/drawing_display_item.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
+#include "third_party/skia/include/core/SkRefCnt.h"
#include "ui/compositor/paint_cache.h"
#include "ui/compositor/paint_context.h"
#include "ui/gfx/skia_util.h"
@@ -20,8 +21,8 @@ PaintRecorder::PaintRecorder(const PaintContext& context,
// The SkCanvas reference returned by beginRecording is shared with
// the recorder_ so no need to store a RefPtr to it on this class, we just
// store the gfx::Canvas.
- canvas_(skia::SharePtr(context.recorder_->beginRecording(
- gfx::RectToSkRect(gfx::Rect(recording_size)))),
+ canvas_(sk_ref_sp(context.recorder_->beginRecording(
+ gfx::RectToSkRect(gfx::Rect(recording_size)))),
context.device_scale_factor_),
cache_(cache),
bounds_in_layer_(context.ToLayerSpaceBounds(recording_size)) {
diff --git a/chromium/ui/compositor/paint_recorder.h b/chromium/ui/compositor/paint_recorder.h
index b733f8731e5..2a96e0b234f 100644
--- a/chromium/ui/compositor/paint_recorder.h
+++ b/chromium/ui/compositor/paint_recorder.h
@@ -5,9 +5,9 @@
#ifndef UI_COMPOSITOR_PAINT_RECORDER_H_
#define UI_COMPOSITOR_PAINT_RECORDER_H_
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
-#include "skia/ext/refptr.h"
#include "ui/compositor/compositor_export.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/rect.h"
diff --git a/chromium/ui/compositor/scoped_layer_animation_settings.cc b/chromium/ui/compositor/scoped_layer_animation_settings.cc
index 2b3211ae8a9..912d8bd5ff5 100644
--- a/chromium/ui/compositor/scoped_layer_animation_settings.cc
+++ b/chromium/ui/compositor/scoped_layer_animation_settings.cc
@@ -43,8 +43,8 @@ class InvertingObserver : public ImplicitAnimationObserver {
<< "Must set base layer with ScopedLayerAnimationSettings::"
<< "SetInverslyAnimatedBaseLayer";
gfx::Transform base_transform = base_layer_->transform();
- scoped_ptr<LayerAnimationElement> inverse = GetInverseElement(sequence,
- base_transform);
+ std::unique_ptr<LayerAnimationElement> inverse =
+ GetInverseElement(sequence, base_transform);
for (std::vector<Layer*>::const_iterator i =
inverse_layers_.begin(); i != inverse_layers_.end(); ++i) {
@@ -54,22 +54,22 @@ class InvertingObserver : public ImplicitAnimationObserver {
}
}
private:
- scoped_ptr<LayerAnimationElement> GetInverseElement(
- LayerAnimationSequence* sequence,
- gfx::Transform base) const {
- const size_t expected_size = 1;
- DCHECK_EQ(expected_size, sequence->size()) <<
- "Inverse supported only for single element sequences.";
-
- LayerAnimationElement* element = sequence->FirstElement();
- DCHECK_EQ(static_cast<LayerAnimationElement::AnimatableProperties>(
- LayerAnimationElement::TRANSFORM),
- element->properties())
- << "Only transform animations are currently invertible.";
-
- scoped_ptr<LayerAnimationElement> to_return(
- LayerAnimationElement::CreateInverseTransformElement(base, element));
- return to_return;
+ std::unique_ptr<LayerAnimationElement> GetInverseElement(
+ LayerAnimationSequence* sequence,
+ gfx::Transform base) const {
+ const size_t expected_size = 1;
+ DCHECK_EQ(expected_size, sequence->size())
+ << "Inverse supported only for single element sequences.";
+
+ LayerAnimationElement* element = sequence->FirstElement();
+ DCHECK_EQ(static_cast<LayerAnimationElement::AnimatableProperties>(
+ LayerAnimationElement::TRANSFORM),
+ element->properties())
+ << "Only transform animations are currently invertible.";
+
+ std::unique_ptr<LayerAnimationElement> to_return(
+ LayerAnimationElement::CreateInverseTransformElement(base, element));
+ return to_return;
}
Layer* base_layer_;
diff --git a/chromium/ui/compositor/scoped_layer_animation_settings.h b/chromium/ui/compositor/scoped_layer_animation_settings.h
index 22e547b221d..9cb84641d74 100644
--- a/chromium/ui/compositor/scoped_layer_animation_settings.h
+++ b/chromium/ui/compositor/scoped_layer_animation_settings.h
@@ -60,7 +60,7 @@ class COMPOSITOR_EXPORT ScopedLayerAnimationSettings {
gfx::Tween::Type old_tween_type_;
LayerAnimator::PreemptionStrategy old_preemption_strategy_;
std::set<ImplicitAnimationObserver*> observers_;
- scoped_ptr<InvertingObserver> inverse_observer_;
+ std::unique_ptr<InvertingObserver> inverse_observer_;
DISALLOW_COPY_AND_ASSIGN(ScopedLayerAnimationSettings);
};
diff --git a/chromium/ui/compositor/test/test_compositor_host_ozone.cc b/chromium/ui/compositor/test/test_compositor_host_ozone.cc
index c5c7f6db110..1a4ecd94c4c 100644
--- a/chromium/ui/compositor/test/test_compositor_host_ozone.cc
+++ b/chromium/ui/compositor/test/test_compositor_host_ozone.cc
@@ -4,13 +4,14 @@
#include "ui/compositor/test/test_compositor_host.h"
+#include <memory>
+
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "ui/compositor/compositor.h"
#include "ui/gfx/geometry/rect.h"
@@ -29,8 +30,6 @@ class TestCompositorHostOzone : public TestCompositorHost {
gfx::Rect bounds_;
- ui::ContextFactory* context_factory_;
-
ui::Compositor compositor_;
DISALLOW_COPY_AND_ASSIGN(TestCompositorHostOzone);
@@ -40,7 +39,6 @@ TestCompositorHostOzone::TestCompositorHostOzone(
const gfx::Rect& bounds,
ui::ContextFactory* context_factory)
: bounds_(bounds),
- context_factory_(context_factory),
compositor_(context_factory, base::ThreadTaskRunnerHandle::Get()) {}
TestCompositorHostOzone::~TestCompositorHostOzone() {}
diff --git a/chromium/ui/compositor/transform_animation_curve_adapter.cc b/chromium/ui/compositor/transform_animation_curve_adapter.cc
index c3f2a31bf50..8978912a51a 100644
--- a/chromium/ui/compositor/transform_animation_curve_adapter.cc
+++ b/chromium/ui/compositor/transform_animation_curve_adapter.cc
@@ -4,6 +4,7 @@
#include "ui/compositor/transform_animation_curve_adapter.h"
+#include "base/memory/ptr_util.h"
#include "cc/base/time_util.h"
namespace ui {
@@ -31,8 +32,9 @@ base::TimeDelta TransformAnimationCurveAdapter::Duration() const {
return duration_;
}
-scoped_ptr<cc::AnimationCurve> TransformAnimationCurveAdapter::Clone() const {
- return make_scoped_ptr(new TransformAnimationCurveAdapter(
+std::unique_ptr<cc::AnimationCurve> TransformAnimationCurveAdapter::Clone()
+ const {
+ return base::WrapUnique(new TransformAnimationCurveAdapter(
tween_type_, initial_value_, target_value_, duration_));
}
@@ -108,8 +110,9 @@ base::TimeDelta InverseTransformCurveAdapter::Duration() const {
return duration_;
}
-scoped_ptr<cc::AnimationCurve> InverseTransformCurveAdapter::Clone() const {
- return make_scoped_ptr(
+std::unique_ptr<cc::AnimationCurve> InverseTransformCurveAdapter::Clone()
+ const {
+ return base::WrapUnique(
new InverseTransformCurveAdapter(base_curve_, initial_value_, duration_));
}
diff --git a/chromium/ui/compositor/transform_animation_curve_adapter.h b/chromium/ui/compositor/transform_animation_curve_adapter.h
index 69332414793..b8840a035ca 100644
--- a/chromium/ui/compositor/transform_animation_curve_adapter.h
+++ b/chromium/ui/compositor/transform_animation_curve_adapter.h
@@ -5,6 +5,8 @@
#ifndef UI_COMPOSITOR_TRANSFORM_ANIMATION_CURVE_ADAPTER_H_
#define UI_COMPOSITOR_TRANSFORM_ANIMATION_CURVE_ADAPTER_H_
+#include <memory>
+
#include "base/macros.h"
#include "base/time/time.h"
#include "cc/animation/animation_curve.h"
@@ -29,7 +31,7 @@ class COMPOSITOR_EXPORT TransformAnimationCurveAdapter
// TransformAnimationCurve implementation.
base::TimeDelta Duration() const override;
- scoped_ptr<AnimationCurve> Clone() const override;
+ std::unique_ptr<AnimationCurve> Clone() const override;
gfx::Transform GetValue(base::TimeDelta t) const override;
bool AnimatedBoundsForBox(const gfx::BoxF& box,
gfx::BoxF* bounds) const override;
@@ -62,7 +64,7 @@ class COMPOSITOR_EXPORT InverseTransformCurveAdapter
~InverseTransformCurveAdapter() override;
base::TimeDelta Duration() const override;
- scoped_ptr<AnimationCurve> Clone() const override;
+ std::unique_ptr<AnimationCurve> Clone() const override;
gfx::Transform GetValue(base::TimeDelta t) const override;
bool AnimatedBoundsForBox(const gfx::BoxF& box,
gfx::BoxF* bounds) const override;