diff options
author | ajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-04 02:40:39 +0000 |
---|---|---|
committer | ajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-04 02:40:39 +0000 |
commit | d96c2381c3deb7f324f54d40539caaa29b16e991 (patch) | |
tree | 4511d907d52a0daf693441098cbae8f6af54e3cb /webkit/renderer/compositor_bindings | |
parent | aa4dbdd95eb1d743be598b801aae45c692472096 (diff) | |
download | chromium_src-d96c2381c3deb7f324f54d40539caaa29b16e991.zip chromium_src-d96c2381c3deb7f324f54d40539caaa29b16e991.tar.gz chromium_src-d96c2381c3deb7f324f54d40539caaa29b16e991.tar.bz2 |
Define WebFilterAnimationCurveImpl
This defines WebFilterAnimationCurveImpl, needed for sending
filter animations from Blink to cc.
BUG=181613
Review URL: https://codereview.chromium.org/25274005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226936 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/renderer/compositor_bindings')
6 files changed, 160 insertions, 0 deletions
diff --git a/webkit/renderer/compositor_bindings/compositor_bindings.gyp b/webkit/renderer/compositor_bindings/compositor_bindings.gyp index b8c1d41..d4a8113 100644 --- a/webkit/renderer/compositor_bindings/compositor_bindings.gyp +++ b/webkit/renderer/compositor_bindings/compositor_bindings.gyp @@ -55,6 +55,8 @@ 'web_external_bitmap_impl.h', 'web_external_texture_layer_impl.cc', 'web_external_texture_layer_impl.h', + 'web_filter_animation_curve_impl.cc', + 'web_filter_animation_curve_impl.h', 'web_filter_operations_impl.cc', 'web_filter_operations_impl.h', 'web_float_animation_curve_impl.cc', diff --git a/webkit/renderer/compositor_bindings/web_animation_impl.cc b/webkit/renderer/compositor_bindings/web_animation_impl.cc index 1c15bc3..9671f91 100644 --- a/webkit/renderer/compositor_bindings/web_animation_impl.cc +++ b/webkit/renderer/compositor_bindings/web_animation_impl.cc @@ -9,12 +9,14 @@ #include "cc/animation/animation_id_provider.h" #include "third_party/WebKit/public/platform/WebAnimation.h" #include "third_party/WebKit/public/platform/WebAnimationCurve.h" +#include "webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h" #include "webkit/renderer/compositor_bindings/web_float_animation_curve_impl.h" #include "webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.h" using cc::Animation; using cc::AnimationIdProvider; +using WebKit::WebAnimation; using WebKit::WebAnimationCurve; namespace webkit { @@ -43,6 +45,14 @@ WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& web_curve, curve = transform_curve_impl->CloneToAnimationCurve(); break; } +#if WEB_FILTER_ANIMATION_CURVE_IS_DEFINED + case WebAnimationCurve::AnimationCurveTypeFilter: { + const WebFilterAnimationCurveImpl* filter_curve_impl = + static_cast<const WebFilterAnimationCurveImpl*>(&web_curve); + curve = filter_curve_impl->CloneToAnimationCurve(); + break; + } +#endif } animation_ = Animation::Create( curve.Pass(), @@ -93,4 +103,17 @@ scoped_ptr<cc::Animation> WebAnimationImpl::CloneToAnimation() { return to_return.Pass(); } +#define COMPILE_ASSERT_MATCHING_ENUMS(webkit_name, cc_name) \ + COMPILE_ASSERT(static_cast<int>(webkit_name) == static_cast<int>(cc_name), \ + mismatching_enums) + +COMPILE_ASSERT_MATCHING_ENUMS( + WebAnimation::TargetPropertyTransform, Animation::Transform); +COMPILE_ASSERT_MATCHING_ENUMS( + WebAnimation::TargetPropertyOpacity, Animation::Opacity); +#if WEB_FILTER_ANIMATION_CURVE_IS_DEFINED +COMPILE_ASSERT_MATCHING_ENUMS( + WebAnimation::TargetPropertyFilter, Animation::Filter); +#endif + } // namespace webkit diff --git a/webkit/renderer/compositor_bindings/web_compositor_support_impl.cc b/webkit/renderer/compositor_bindings/web_compositor_support_impl.cc index 8fb7fbf..54f1f77 100644 --- a/webkit/renderer/compositor_bindings/web_compositor_support_impl.cc +++ b/webkit/renderer/compositor_bindings/web_compositor_support_impl.cc @@ -13,6 +13,7 @@ #include "webkit/renderer/compositor_bindings/web_animation_impl.h" #include "webkit/renderer/compositor_bindings/web_content_layer_impl.h" #include "webkit/renderer/compositor_bindings/web_external_texture_layer_impl.h" +#include "webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h" #include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h" #include "webkit/renderer/compositor_bindings/web_float_animation_curve_impl.h" #include "webkit/renderer/compositor_bindings/web_image_layer_impl.h" @@ -29,6 +30,9 @@ using WebKit::WebContentLayer; using WebKit::WebContentLayerClient; using WebKit::WebExternalTextureLayer; using WebKit::WebExternalTextureLayerClient; +#if WEB_FILTER_ANIMATION_CURVE_IS_DEFINED +using WebKit::WebFilterAnimationCurve; +#endif using WebKit::WebFilterOperations; using WebKit::WebFloatAnimationCurve; using WebKit::WebImageLayer; @@ -95,6 +99,13 @@ WebAnimation* WebCompositorSupportImpl::createAnimation( return new WebAnimationImpl(curve, target, animation_id, 0); } +#if WEB_FILTER_ANIMATION_CURVE_IS_DEFINED +WebFilterAnimationCurve* +WebCompositorSupportImpl::createFilterAnimationCurve() { + return new WebFilterAnimationCurveImpl(); +} +#endif + WebFloatAnimationCurve* WebCompositorSupportImpl::createFloatAnimationCurve() { return new WebFloatAnimationCurveImpl(); } diff --git a/webkit/renderer/compositor_bindings/web_compositor_support_impl.h b/webkit/renderer/compositor_bindings/web_compositor_support_impl.h index 8cf1dc1..b0ac4d81 100644 --- a/webkit/renderer/compositor_bindings/web_compositor_support_impl.h +++ b/webkit/renderer/compositor_bindings/web_compositor_support_impl.h @@ -7,6 +7,7 @@ #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop_proxy.h" +#include "third_party/WebKit/public/platform/WebAnimationCurve.h" #include "third_party/WebKit/public/platform/WebCompositorSupport.h" #include "third_party/WebKit/public/platform/WebLayer.h" #include "third_party/WebKit/public/platform/WebTransformOperations.h" @@ -41,6 +42,9 @@ class WebCompositorSupportImpl : public WebKit::WebCompositorSupport { const WebKit::WebAnimationCurve& curve, WebKit::WebAnimation::TargetProperty target, int animation_id); +#if WEB_FILTER_ANIMATION_CURVE_IS_DEFINED + virtual WebKit::WebFilterAnimationCurve* createFilterAnimationCurve(); +#endif virtual WebKit::WebFloatAnimationCurve* createFloatAnimationCurve(); virtual WebKit::WebTransformAnimationCurve* createTransformAnimationCurve(); virtual WebKit::WebTransformOperations* createTransformOperations(); diff --git a/webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.cc b/webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.cc new file mode 100644 index 0000000..f35cff6 --- /dev/null +++ b/webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.cc @@ -0,0 +1,64 @@ +// Copyright 2013 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 "webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h" + +#if WEB_FILTER_ANIMATION_CURVE_IS_DEFINED + +#include "cc/animation/keyframed_animation_curve.h" +#include "cc/animation/timing_function.h" +#include "cc/output/filter_operations.h" +#include "webkit/renderer/compositor_bindings/web_animation_curve_common.h" +#include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h" + +using WebKit::WebFilterKeyframe; + +namespace webkit { + +WebFilterAnimationCurveImpl::WebFilterAnimationCurveImpl() + : curve_(cc::KeyframedFilterAnimationCurve::Create()) {} + +WebFilterAnimationCurveImpl::~WebFilterAnimationCurveImpl() {} + +WebKit::WebAnimationCurve::AnimationCurveType +WebFilterAnimationCurveImpl::type() const { + return WebAnimationCurve::AnimationCurveTypeFilter; +} + +void WebFilterAnimationCurveImpl::add(const WebFilterKeyframe& keyframe) { + add(keyframe, TimingFunctionTypeEase); +} + +void WebFilterAnimationCurveImpl::add(const WebFilterKeyframe& keyframe, + TimingFunctionType type) { + const cc::FilterOperations& filter_operations = + static_cast<const webkit::WebFilterOperationsImpl&>(keyframe.value()) + .AsFilterOperations(); + curve_->AddKeyframe(cc::FilterKeyframe::Create( + keyframe.time(), filter_operations, CreateTimingFunction(type))); +} + +void WebFilterAnimationCurveImpl::add(const WebFilterKeyframe& keyframe, + double x1, + double y1, + double x2, + double y2) { + const cc::FilterOperations& filter_operations = + static_cast<const webkit::WebFilterOperationsImpl&>(keyframe.value()) + .AsFilterOperations(); + curve_->AddKeyframe(cc::FilterKeyframe::Create( + keyframe.time(), + filter_operations, + cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2) + .PassAs<cc::TimingFunction>())); +} + +scoped_ptr<cc::AnimationCurve> +WebFilterAnimationCurveImpl::CloneToAnimationCurve() const { + return curve_->Clone(); +} + +} // namespace webkit + +#endif // WEB_FILTER_ANIMATION_CURVE_IS_DEFINED diff --git a/webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h b/webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h new file mode 100644 index 0000000..4c0675a --- /dev/null +++ b/webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h @@ -0,0 +1,56 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_FILTER_ANIMATION_CURVE_IMPL_H_ +#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_FILTER_ANIMATION_CURVE_IMPL_H_ + +#include "third_party/WebKit/public/platform/WebAnimationCurve.h" + +#if WEB_FILTER_ANIMATION_CURVE_IS_DEFINED + +#include "base/memory/scoped_ptr.h" +#include "third_party/WebKit/public/platform/WebFilterAnimationCurve.h" +#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h" + +namespace cc { +class AnimationCurve; +class KeyframedFilterAnimationCurve; +} + +namespace WebKit { class WebFilterKeyframe; } + +namespace webkit { + +class WebFilterAnimationCurveImpl + : public WebKit::WebFilterAnimationCurve { + public: + WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebFilterAnimationCurveImpl(); + virtual ~WebFilterAnimationCurveImpl(); + + // WebKit::WebAnimationCurve implementation. + virtual AnimationCurveType type() const; + + // WebKit::WebFilterAnimationCurve implementation. + virtual void add(const WebKit::WebFilterKeyframe& keyframe); + virtual void add(const WebKit::WebFilterKeyframe& keyframe, + TimingFunctionType type); + virtual void add(const WebKit::WebFilterKeyframe& keyframe, + double x1, + double y1, + double x2, + double y2); + + scoped_ptr<cc::AnimationCurve> CloneToAnimationCurve() const; + + private: + scoped_ptr<cc::KeyframedFilterAnimationCurve> curve_; + + DISALLOW_COPY_AND_ASSIGN(WebFilterAnimationCurveImpl); +}; + +} // namespace webkit + +#endif // WEB_FILTER_ANIMATION_CURVE_IS_DEFINED + +#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_FILTER_ANIMATION_CURVE_IMPL_H_ |