Chromium Code Reviews| Index: third_party/WebKit/Source/platform/CompositorFactory.cpp |
| diff --git a/third_party/WebKit/Source/platform/CompositorFactory.cpp b/third_party/WebKit/Source/platform/CompositorFactory.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3e23d6a78ccec320edd4440685af5500c27466f7 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/CompositorFactory.cpp |
| @@ -0,0 +1,98 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "platform/CompositorFactory.h" |
| + |
| +#include "cc/animation/animation_player.h" |
| +#include "cc/animation/animation_timeline.h" |
| +#include "platform/animation/CompositorAnimation.h" |
| +#include "platform/animation/CompositorAnimationPlayer.h" |
| +#include "platform/animation/CompositorAnimationTimeline.h" |
| +#include "platform/animation/CompositorFilterAnimationCurve.h" |
| +#include "platform/animation/CompositorFloatAnimationCurve.h" |
| +#include "platform/animation/CompositorTransformAnimationCurve.h" |
| +#include "platform/animation/CompositorTransformOperations.h" |
| +#include "platform/graphics/CompositorFilterOperations.h" |
| + |
| +namespace blink { |
| + |
| +class CompositorFactoryImpl : public CompositorFactory { |
| +public: |
| + CompositorFilterAnimationCurve* createFilterAnimationCurve() override |
| + { |
| + return new CompositorFilterAnimationCurve(); |
| + } |
| + |
| + CompositorFloatAnimationCurve* createFloatAnimationCurve() override |
| + { |
| + return new CompositorFloatAnimationCurve(); |
| + } |
| + |
| + CompositorScrollOffsetAnimationCurve* createScrollOffsetAnimationCurve( |
| + WebFloatPoint targetValue, |
| + CompositorAnimationCurve::TimingFunctionType timingFunctionType, |
| + CompositorScrollOffsetAnimationCurve::ScrollDurationBehavior durationBehavior) |
| + { |
| + return new CompositorScrollOffsetAnimationCurve(targetValue, timingFunctionType, |
| + durationBehavior); |
| + } |
| + |
| + CompositorTransformAnimationCurve* createTransformAnimationCurve() override |
| + { |
| + return new CompositorTransformAnimationCurve(); |
| + } |
| + |
| + CompositorTransformOperations* createTransformOperations() override |
| + { |
| + return new CompositorTransformOperations(); |
| + } |
| + |
| + CompositorFilterOperations* createFilterOperations() override |
| + { |
| + return new CompositorFilterOperations(); |
| + } |
| + |
| + CompositorAnimation* createAnimation(const blink::CompositorAnimationCurve& curve, blink::CompositorAnimation::TargetProperty target, int groupId, int animationId) override |
| + { |
| + return new CompositorAnimation(curve, target, animationId, groupId); |
| + } |
| + |
| + CompositorAnimationPlayer* createAnimationPlayer() |
| + { |
| + return new CompositorAnimationPlayer(); |
| + } |
| + |
| + CompositorAnimationTimeline* createAnimationTimeline() |
| + { |
| + return new CompositorAnimationTimeline(); |
| + } |
| +}; |
| + |
| +static CompositorFactory* s_factory = 0; |
| + |
| +void CompositorFactory::initializeDefault() |
| +{ |
| + delete s_factory; |
| + s_factory = new CompositorFactoryImpl(); |
| +} |
| + |
| +void CompositorFactory::initializeForTesting(CompositorFactory* factory) |
|
jbroman
2016/01/29 15:29:18
Passing ownership through a raw pointer = :(.
loyso (OOO)
2016/02/01 05:31:32
Actually, I have CompositorFactoryMock-type pointe
jbroman
2016/02/01 15:44:36
The delete calls make this an owning pointer, and
|
| +{ |
| + delete s_factory; |
| + s_factory = factory; |
| +} |
| + |
| +void CompositorFactory::shutdown() |
| +{ |
| + delete s_factory; |
|
jbroman
2016/01/29 15:29:18
Why is it necessary to shut down this factory?
loyso (OOO)
2016/02/01 05:31:32
In this CL I want to preserve the behavior of Comp
|
| + s_factory = nullptr; |
| +} |
| + |
| +CompositorFactory& CompositorFactory::current() |
| +{ |
| + ASSERT(s_factory); |
|
jbroman
2016/01/29 15:29:18
How about something like:
// Does not assume owne
loyso (OOO)
2016/02/01 05:31:32
Technically, this is an extra conditional branch i
jbroman
2016/02/01 15:44:36
I'm not too worried about that (there's a lot of m
|
| + return *s_factory; |
| +} |
| + |
| +} // namespace blink |