summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorloyso <loyso@chromium.org>2016-03-02 16:11:51 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-03 00:13:49 +0000
commit5311049ef3f3948c515f317057a259518e41410e (patch)
tree2bd1ddaf30849a304b642c28584c3d5e0127e7e2
parent7f6bf6199c312993c7e4ccaa5e477576d87fa704 (diff)
downloadchromium_src-5311049ef3f3948c515f317057a259518e41410e.zip
chromium_src-5311049ef3f3948c515f317057a259518e41410e.tar.gz
chromium_src-5311049ef3f3948c515f317057a259518e41410e.tar.bz2
CC Animation: Erase old animation system in UI Compositor.
Basically, specialize all the code as if use_compositor_animation_timelines is always true. Next CL: Erase cc::LayerSettings everywhere. BUG=575041 Review URL: https://codereview.chromium.org/1749573002 Cr-Commit-Position: refs/heads/master@{#378886}
-rw-r--r--chrome/app/generated_resources.grd9
-rw-r--r--chrome/browser/about_flags.cc7
-rw-r--r--chrome/browser/chromeos/login/chrome_restart_request.cc1
-rw-r--r--content/browser/compositor/gpu_process_transport_factory.cc1
-rw-r--r--ui/compositor/compositor.cc6
-rw-r--r--ui/compositor/compositor_switches.cc3
-rw-r--r--ui/compositor/compositor_switches.h1
-rw-r--r--ui/compositor/layer.cc93
-rw-r--r--ui/compositor/layer.h20
-rw-r--r--ui/compositor/layer_animator.cc6
-rw-r--r--ui/compositor/layer_owner_unittest.cc8
-rw-r--r--ui/compositor/test/in_process_context_factory.cc2
-rw-r--r--ui/compositor/test/test_layer_animation_delegate.cc3
-rw-r--r--ui/compositor/test/test_suite.cc2
14 files changed, 18 insertions, 144 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 157d37f..68527c3 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -14570,15 +14570,6 @@ Please check your email at <ph name="ACCOUNT_EMAIL">$2<ex>jane.doe@gmail.com</ex
Adjusts scroll position to prevent visible jumps when offscreen content changes.
</message>
- <if expr="not is_android">
- <message name="IDS_FLAGS_DISABLE_UI_COMPOSITOR_ANIMATION_TIMELINES" desc="Name of the 'Disable UI Compositor animation timelines' lab.">
- Disable UI compositor animation timelines
- </message>
- <message name="IDS_FLAGS_DISABLE_UI_COMPOSITOR_ANIMATION_TIMELINES_DESCRIPTION" desc="Description of the 'Disable UI Compositor animation timelines' lab.">
- Use old intrusive animation subsystem for composited animations in UI.
- </message>
- </if>
-
<if expr="is_android">
<message name="IDS_FLAGS_ENABLE_NTP_SNIPPETS_NAME" desc="Name for the flag to enable snippets on the New Tab page." translateable="false">
Show content snippets on the New Tab page
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index afc2989..9caafdc 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -1781,13 +1781,6 @@ const FeatureEntry kFeatureEntries[] = {
{"enable-scroll-anchoring", IDS_FLAGS_ENABLE_SCROLL_ANCHORING_NAME,
IDS_FLAGS_ENABLE_SCROLL_ANCHORING_DESCRIPTION, kOsAll,
FEATURE_VALUE_TYPE(features::kScrollAnchoring)},
-#if !defined(OS_ANDROID)
- {"ui-disable-compositor-animation-timelines",
- IDS_FLAGS_DISABLE_UI_COMPOSITOR_ANIMATION_TIMELINES,
- IDS_FLAGS_DISABLE_UI_COMPOSITOR_ANIMATION_TIMELINES_DESCRIPTION,
- kOsDesktop, SINGLE_DISABLE_VALUE_TYPE(
- switches::kUIDisableCompositorAnimationTimelines)},
-#endif // !defined(OS_ANDROID)
{"enable-audio-support-for-desktop-share",
IDS_FLAG_ENABLE_AUDIO_FOR_DESKTOP_SHARE,
IDS_FLAG_ENABLE_AUDIO_FOR_DESKTOP_SHARE_DESCRIPTION,
diff --git a/chrome/browser/chromeos/login/chrome_restart_request.cc b/chrome/browser/chromeos/login/chrome_restart_request.cc
index cbbd8c7..037af8c 100644
--- a/chrome/browser/chromeos/login/chrome_restart_request.cc
+++ b/chrome/browser/chromeos/login/chrome_restart_request.cc
@@ -147,7 +147,6 @@ void DeriveCommandLine(const GURL& start_url,
::switches::kTopChromeMD,
#endif
::switches::kTraceToConsole,
- ::switches::kUIDisableCompositorAnimationTimelines,
::switches::kUIDisablePartialSwap,
::switches::kUIPrioritizeInGpuProcess,
#if defined(USE_CRAS)
diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc
index eccd9dc..1aa6dd7 100644
--- a/content/browser/compositor/gpu_process_transport_factory.cc
+++ b/content/browser/compositor/gpu_process_transport_factory.cc
@@ -99,7 +99,6 @@ GpuProcessTransportFactory::GpuProcessTransportFactory()
: next_surface_id_namespace_(1u),
task_graph_runner_(new cc::SingleThreadTaskGraphRunner),
callback_factory_(this) {
- ui::Layer::InitializeUILayerSettings();
cc::SetClientNameForMetrics("Browser");
surface_manager_ = make_scoped_ptr(new cc::SurfaceManager);
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index e359f66..dd6e2b71 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -24,6 +24,7 @@
#include "cc/base/switches.h"
#include "cc/input/input_handler.h"
#include "cc/layers/layer.h"
+#include "cc/layers/layer_settings.h"
#include "cc/output/begin_frame_args.h"
#include "cc/output/context_provider.h"
#include "cc/output/latency_info_swap_promise.h"
@@ -87,7 +88,7 @@ Compositor::Compositor(ui::ContextFactory* context_factory,
compositor_lock_(NULL),
layer_animator_collection_(this),
weak_ptr_factory_(this) {
- root_web_layer_ = cc::Layer::Create(Layer::UILayerSettings());
+ root_web_layer_ = cc::Layer::Create(cc::LayerSettings());
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
@@ -172,9 +173,6 @@ Compositor::Compositor(ui::ContextFactory* context_factory,
// thread.
settings.image_decode_tasks_enabled = false;
- settings.use_compositor_animation_timelines = !command_line->HasSwitch(
- switches::kUIDisableCompositorAnimationTimelines);
-
#if !defined(OS_ANDROID)
// TODO(sohanjg): Revisit this memory usage in tile manager.
cc::ManagedMemoryPolicy policy(
diff --git a/ui/compositor/compositor_switches.cc b/ui/compositor/compositor_switches.cc
index 1a2c6ca..c8464dd 100644
--- a/ui/compositor/compositor_switches.cc
+++ b/ui/compositor/compositor_switches.cc
@@ -15,9 +15,6 @@ const char kEnableHardwareOverlays[] = "enable-hardware-overlays";
// Forces tests to produce pixel output when they normally wouldn't.
const char kEnablePixelOutputInTests[] = "enable-pixel-output-in-tests";
-const char kUIDisableCompositorAnimationTimelines[] =
- "ui-disable-compositor-animation-timelines";
-
// Disable partial swap which is needed for some OpenGL drivers / emulators.
const char kUIDisablePartialSwap[] = "ui-disable-partial-swap";
diff --git a/ui/compositor/compositor_switches.h b/ui/compositor/compositor_switches.h
index 929722a..62705ef 100644
--- a/ui/compositor/compositor_switches.h
+++ b/ui/compositor/compositor_switches.h
@@ -11,7 +11,6 @@ namespace switches {
COMPOSITOR_EXPORT extern const char kEnableHardwareOverlays[];
COMPOSITOR_EXPORT extern const char kEnablePixelOutputInTests[];
-COMPOSITOR_EXPORT extern const char kUIDisableCompositorAnimationTimelines[];
COMPOSITOR_EXPORT extern const char kUIDisablePartialSwap[];
COMPOSITOR_EXPORT extern const char kUIEnableRGBA4444Textures[];
COMPOSITOR_EXPORT extern const char kUIEnableZeroCopy[];
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index f2e0065..7622e2e 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -10,7 +10,6 @@
#include "base/auto_reset.h"
#include "base/command_line.h"
#include "base/json/json_writer.h"
-#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/trace_event/trace_event.h"
@@ -46,9 +45,6 @@ const ui::Layer* GetRoot(const ui::Layer* layer) {
return layer;
}
-base::LazyInstance<cc::LayerSettings> g_ui_layer_settings =
- LAZY_INSTANCE_INITIALIZER;
-
} // namespace
namespace ui {
@@ -120,19 +116,6 @@ Layer::~Layer() {
cc_layer_->RemoveFromParent();
}
-// static
-const cc::LayerSettings& Layer::UILayerSettings() {
- return g_ui_layer_settings.Get();
-}
-
-// static
-void Layer::InitializeUILayerSettings() {
- base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
- g_ui_layer_settings.Get().use_compositor_animation_timelines =
- !command_line->HasSwitch(
- switches::kUIDisableCompositorAnimationTimelines);
-}
-
const Compositor* Layer::GetCompositor() const {
return GetRoot(this)->compositor_;
}
@@ -155,7 +138,6 @@ void Layer::SetCompositor(Compositor* compositor,
root_layer->AddChild(cc_layer_);
SetCompositorForAnimatorsInTree(compositor);
- SendPendingThreadedAnimations();
}
void Layer::ResetCompositor() {
@@ -175,10 +157,8 @@ void Layer::Add(Layer* child) {
cc_layer_->AddChild(child->cc_layer_);
child->OnDeviceScaleFactorChanged(device_scale_factor_);
Compositor* compositor = GetCompositor();
- if (compositor) {
+ if (compositor)
child->SetCompositorForAnimatorsInTree(compositor);
- child->SendPendingThreadedAnimations();
- }
}
void Layer::Remove(Layer* child) {
@@ -536,15 +516,12 @@ void Layer::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) {
}
bool Layer::HasPendingThreadedAnimationsForTesting() const {
- if (UILayerSettings().use_compositor_animation_timelines)
- return animator_->HasPendingThreadedAnimationsForTesting();
- else
- return !pending_threaded_animations_.empty();
+ return animator_->HasPendingThreadedAnimationsForTesting();
}
void Layer::SwitchCCLayerForTest() {
scoped_refptr<cc::Layer> new_layer =
- cc::PictureLayer::Create(UILayerSettings(), this);
+ cc::PictureLayer::Create(cc::LayerSettings(), this);
SwitchToLayer(new_layer);
content_layer_ = new_layer;
}
@@ -558,7 +535,7 @@ void Layer::SetTextureMailbox(
DCHECK(release_callback);
if (!texture_layer_.get()) {
scoped_refptr<cc::TextureLayer> new_layer =
- cc::TextureLayer::CreateForMailbox(UILayerSettings(), this);
+ cc::TextureLayer::CreateForMailbox(cc::LayerSettings(), this);
new_layer->SetFlipped(true);
SwitchToLayer(new_layer);
texture_layer_ = new_layer;
@@ -602,7 +579,7 @@ void Layer::SetShowSurface(
DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR);
scoped_refptr<cc::SurfaceLayer> new_layer = cc::SurfaceLayer::Create(
- UILayerSettings(), satisfy_callback, require_callback);
+ cc::LayerSettings(), satisfy_callback, require_callback);
new_layer->SetSurfaceId(surface_id, scale, surface_size);
SwitchToLayer(new_layer);
surface_layer_ = new_layer;
@@ -618,7 +595,7 @@ void Layer::SetShowSolidColorContent() {
return;
scoped_refptr<cc::SolidColorLayer> new_layer =
- cc::SolidColorLayer::Create(UILayerSettings());
+ cc::SolidColorLayer::Create(cc::LayerSettings());
SwitchToLayer(new_layer);
solid_color_layer_ = new_layer;
@@ -971,36 +948,6 @@ float Layer::GetDeviceScaleFactor() const {
return device_scale_factor_;
}
-void Layer::AddThreadedAnimation(scoped_ptr<cc::Animation> animation) {
- DCHECK(cc_layer_);
- DCHECK(!UILayerSettings().use_compositor_animation_timelines);
- // Until this layer has a compositor (and hence cc_layer_ has a
- // LayerTreeHost), addAnimation will fail.
- if (GetCompositor()) {
- cc_layer_->AddAnimation(std::move(animation));
- } else {
- pending_threaded_animations_.push_back(std::move(animation));
- }
-}
-
-void Layer::RemoveThreadedAnimation(int animation_id) {
- DCHECK(cc_layer_);
- DCHECK(!UILayerSettings().use_compositor_animation_timelines);
- if (pending_threaded_animations_.size() == 0) {
- cc_layer_->RemoveAnimation(animation_id);
- return;
- }
-
- pending_threaded_animations_.erase(
- std::remove_if(
- pending_threaded_animations_.begin(),
- pending_threaded_animations_.end(),
- [animation_id](const scoped_ptr<cc::Animation>& animation) {
- return animation->id() == animation_id;
- }),
- pending_threaded_animations_.end());
-}
-
LayerAnimatorCollection* Layer::GetLayerAnimatorCollection() {
Compositor* compositor = GetCompositor();
return compositor ? compositor->layer_animator_collection() : NULL;
@@ -1011,37 +958,19 @@ cc::Layer* Layer::GetCcLayer() const {
}
LayerThreadedAnimationDelegate* Layer::GetThreadedAnimationDelegate() {
- if (UILayerSettings().use_compositor_animation_timelines) {
- DCHECK(animator_);
- return animator_.get();
- } else {
- return this;
- }
-}
-
-void Layer::SendPendingThreadedAnimations() {
- if (UILayerSettings().use_compositor_animation_timelines) {
- DCHECK(pending_threaded_animations_.empty());
- return;
- }
-
- for (auto& animation : pending_threaded_animations_)
- cc_layer_->AddAnimation(std::move(animation));
- pending_threaded_animations_.clear();
-
- for (auto* child : children_)
- child->SendPendingThreadedAnimations();
+ DCHECK(animator_);
+ return animator_.get();
}
void Layer::CreateCcLayer() {
if (type_ == LAYER_SOLID_COLOR) {
- solid_color_layer_ = cc::SolidColorLayer::Create(UILayerSettings());
+ solid_color_layer_ = cc::SolidColorLayer::Create(cc::LayerSettings());
cc_layer_ = solid_color_layer_.get();
} else if (type_ == LAYER_NINE_PATCH) {
- nine_patch_layer_ = cc::NinePatchLayer::Create(UILayerSettings());
+ nine_patch_layer_ = cc::NinePatchLayer::Create(cc::LayerSettings());
cc_layer_ = nine_patch_layer_.get();
} else {
- content_layer_ = cc::PictureLayer::Create(UILayerSettings(), this);
+ content_layer_ = cc::PictureLayer::Create(cc::LayerSettings(), this);
cc_layer_ = content_layer_.get();
}
cc_layer_->SetTransformOrigin(gfx::Point3F());
diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h
index 75567ff..2dcb9c76 100644
--- a/ui/compositor/layer.h
+++ b/ui/compositor/layer.h
@@ -27,7 +27,6 @@
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer_animation_delegate.h"
#include "ui/compositor/layer_delegate.h"
-#include "ui/compositor/layer_threaded_animation_delegate.h"
#include "ui/compositor/layer_type.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image_skia.h"
@@ -53,6 +52,7 @@ namespace ui {
class Compositor;
class LayerAnimator;
class LayerOwner;
+class LayerThreadedAnimationDelegate;
// Layer manages a texture, transform and a set of child Layers. Any View that
// has enabled layers ends up creating a Layer to manage the texture.
@@ -66,7 +66,6 @@ class LayerOwner;
// NULL, but the children are not deleted.
class COMPOSITOR_EXPORT Layer
: public LayerAnimationDelegate,
- public LayerThreadedAnimationDelegate,
NON_EXPORTED_BASE(public cc::ContentLayerClient),
NON_EXPORTED_BASE(public cc::TextureLayerClient),
NON_EXPORTED_BASE(public cc::LayerClient) {
@@ -75,9 +74,6 @@ class COMPOSITOR_EXPORT Layer
explicit Layer(LayerType type);
~Layer() override;
- static const cc::LayerSettings& UILayerSettings();
- static void InitializeUILayerSettings();
-
// Retrieves the Layer's compositor. The Layer will walk up its parent chain
// to locate it. Returns NULL if the Layer is not attached to a compositor.
Compositor* GetCompositor() {
@@ -406,10 +402,6 @@ class COMPOSITOR_EXPORT Layer
LayerThreadedAnimationDelegate* GetThreadedAnimationDelegate() override;
LayerAnimatorCollection* GetLayerAnimatorCollection() override;
- // Implementation of LayerThreadedAnimationDelegate.
- void AddThreadedAnimation(scoped_ptr<cc::Animation> animation) override;
- void RemoveThreadedAnimation(int animation_id) override;
-
// Creates a corresponding composited layer for |type_|.
void CreateCcLayer();
@@ -426,12 +418,6 @@ class COMPOSITOR_EXPORT Layer
// Cleanup |cc_layer_| and replaces it with |new_layer|.
void SwitchToLayer(scoped_refptr<cc::Layer> new_layer);
- // We cannot send animations to our cc_layer_ until we have been added to a
- // layer tree. Instead, we hold on to these animations in
- // pending_threaded_animations_, and expect SendPendingThreadedAnimations to
- // be called once we have been added to a tree.
- void SendPendingThreadedAnimations();
-
void SetCompositorForAnimatorsInTree(Compositor* compositor);
void ResetCompositorForAnimatorsInTree(Compositor* compositor);
@@ -493,10 +479,6 @@ class COMPOSITOR_EXPORT Layer
scoped_refptr<LayerAnimator> animator_;
- // Animations that are passed to AddThreadedAnimation before this layer is
- // added to a tree.
- std::vector<scoped_ptr<cc::Animation>> pending_threaded_animations_;
-
// Ownership of the layer is held through one of the strongly typed layer
// pointers, depending on which sort of layer this is.
scoped_refptr<cc::Layer> content_layer_;
diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc
index aee6812..7960200 100644
--- a/ui/compositor/layer_animator.cc
+++ b/ui/compositor/layer_animator.cc
@@ -54,10 +54,8 @@ LayerAnimator::LayerAnimator(base::TimeDelta transition_duration)
is_started_(false),
disable_timer_for_test_(false),
adding_animations_(false) {
- if (Layer::UILayerSettings().use_compositor_animation_timelines) {
- animation_player_ =
- cc::AnimationPlayer::Create(cc::AnimationIdProvider::NextPlayerId());
- }
+ animation_player_ =
+ cc::AnimationPlayer::Create(cc::AnimationIdProvider::NextPlayerId());
}
LayerAnimator::~LayerAnimator() {
diff --git a/ui/compositor/layer_owner_unittest.cc b/ui/compositor/layer_owner_unittest.cc
index afb6b94..8b6bf50 100644
--- a/ui/compositor/layer_owner_unittest.cc
+++ b/ui/compositor/layer_owner_unittest.cc
@@ -228,10 +228,6 @@ TEST_F(LayerOwnerTestWithCompositor, RecreateNonRootLayerDuringAnimation) {
// Tests that if LayerOwner-derived class destroys layer, then
// LayerAnimator's player becomes detached from compositor timeline.
TEST_F(LayerOwnerTestWithCompositor, DetachTimelineOnAnimatorDeletion) {
- // This test is meaningless if CC timelines disabled.
- if (!Layer::UILayerSettings().use_compositor_animation_timelines)
- return;
-
scoped_ptr<Layer> root_layer(new Layer);
compositor()->SetRootLayer(root_layer.get());
@@ -255,10 +251,6 @@ TEST_F(LayerOwnerTestWithCompositor, DetachTimelineOnAnimatorDeletion) {
// then LayerAnimator's player becomes attached to timeline.
TEST_F(LayerOwnerTestWithCompositor,
AttachTimelineIfAnimatorCreatedAfterSetCompositor) {
- // This test is meaningless if CC timelines disabled.
- if (!Layer::UILayerSettings().use_compositor_animation_timelines)
- return;
-
scoped_ptr<Layer> root_layer(new Layer);
compositor()->SetRootLayer(root_layer.get());
diff --git a/ui/compositor/test/in_process_context_factory.cc b/ui/compositor/test/in_process_context_factory.cc
index a7f8d0a..6d84255 100644
--- a/ui/compositor/test/in_process_context_factory.cc
+++ b/ui/compositor/test/in_process_context_factory.cc
@@ -94,8 +94,6 @@ InProcessContextFactory::InProcessContextFactory(
DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone)
<< "If running tests, ensure that main() is calling "
<< "gfx::GLSurfaceTestSupport::InitializeOneOff()";
-
- Layer::InitializeUILayerSettings();
}
InProcessContextFactory::~InProcessContextFactory() {
diff --git a/ui/compositor/test/test_layer_animation_delegate.cc b/ui/compositor/test/test_layer_animation_delegate.cc
index 7189725..bbad6f2 100644
--- a/ui/compositor/test/test_layer_animation_delegate.cc
+++ b/ui/compositor/test/test_layer_animation_delegate.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "cc/layers/layer_settings.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/test/test_layer_animation_delegate.h"
@@ -116,7 +117,7 @@ TestLayerAnimationDelegate::GetThreadedAnimationDelegate() {
}
void TestLayerAnimationDelegate::CreateCcLayer() {
- cc_layer_ = cc::Layer::Create(ui::Layer::UILayerSettings());
+ cc_layer_ = cc::Layer::Create(cc::LayerSettings());
}
void TestLayerThreadedAnimationDelegate::AddThreadedAnimation(
diff --git a/ui/compositor/test/test_suite.cc b/ui/compositor/test/test_suite.cc
index 3b38b6f..40e14d9 100644
--- a/ui/compositor/test/test_suite.cc
+++ b/ui/compositor/test/test_suite.cc
@@ -35,8 +35,6 @@ void CompositorTestSuite::Initialize() {
gfx::SetDefaultDeviceScaleFactor(1.0f);
#endif
- ui::Layer::InitializeUILayerSettings();
-
message_loop_.reset(new base::MessageLoopForUI);
}