Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1784)

Unified Diff: Source/web/LinkHighlight.cpp

Issue 1119763003: Animations: Port LinkHighlight to use compositor timelines. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix code review issues (add ASSERTs) Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/LinkHighlight.h ('k') | Source/web/WebViewImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/LinkHighlight.cpp
diff --git a/Source/web/LinkHighlight.cpp b/Source/web/LinkHighlight.cpp
index f61ce03a78b4e2bb1556f2dde096c888d52e161c..bf88ddec8b387aeefbf71ba03be72a25a1333257 100644
--- a/Source/web/LinkHighlight.cpp
+++ b/Source/web/LinkHighlight.cpp
@@ -37,6 +37,7 @@
#include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h"
#include "core/style/ShadowData.h"
#include "core/paint/DeprecatedPaintLayer.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/graphics/Color.h"
#include "platform/graphics/paint/DrawingRecorder.h"
#include "public/platform/Platform.h"
@@ -76,12 +77,21 @@ LinkHighlight::LinkHighlight(Node* node, WebViewImpl* owningWebViewImpl)
ASSERT(m_node);
ASSERT(owningWebViewImpl);
WebCompositorSupport* compositorSupport = Platform::current()->compositorSupport();
+ ASSERT(compositorSupport);
m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this));
- owningWebViewImpl->registerForAnimations(m_contentLayer->layer());
m_clipLayer = adoptPtr(compositorSupport->createLayer());
m_clipLayer->setTransformOrigin(WebFloatPoint3D());
m_clipLayer->addChild(m_contentLayer->layer());
- m_contentLayer->layer()->setAnimationDelegate(this);
+ if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) {
+ m_compositorPlayer = adoptPtr(compositorSupport->createAnimationPlayer());
+ ASSERT(m_compositorPlayer);
+ m_compositorPlayer->setAnimationDelegate(this);
+ m_owningWebViewImpl->linkHighlightsTimeline()->playerAttached(*this);
+ m_compositorPlayer->attachLayer(m_contentLayer->layer());
+ } else {
+ owningWebViewImpl->registerForAnimations(m_contentLayer->layer());
+ m_contentLayer->layer()->setAnimationDelegate(this);
+ }
m_contentLayer->layer()->setDrawsContent(true);
m_contentLayer->layer()->setOpacity(1);
m_geometryNeedsUpdate = true;
@@ -90,6 +100,13 @@ LinkHighlight::LinkHighlight(Node* node, WebViewImpl* owningWebViewImpl)
LinkHighlight::~LinkHighlight()
{
+ if (m_compositorPlayer) {
+ m_compositorPlayer->detachLayer();
+ m_owningWebViewImpl->linkHighlightsTimeline()->playerDestroyed(*this);
+ m_compositorPlayer->setAnimationDelegate(nullptr);
+ }
+ m_compositorPlayer.clear();
+
clearGraphicsLayerLinkHighlightPointer();
releaseResources();
}
@@ -292,7 +309,10 @@ void LinkHighlight::startHighlightAnimationIfNeeded()
OwnPtr<WebCompositorAnimation> animation = adoptPtr(compositorSupport->createAnimation(*curve, WebCompositorAnimation::TargetPropertyOpacity));
m_contentLayer->layer()->setDrawsContent(true);
- m_contentLayer->layer()->addAnimation(animation.leakPtr());
+ if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled())
+ m_compositorPlayer->addAnimation(animation.leakPtr());
+ else
+ m_contentLayer->layer()->addAnimation(animation.leakPtr());
invalidate();
m_owningWebViewImpl->scheduleAnimation();
@@ -361,4 +381,9 @@ WebLayer* LinkHighlight::layer()
return clipLayer();
}
+WebCompositorAnimationPlayer* LinkHighlight::compositorPlayer() const
+{
+ return m_compositorPlayer.get();
+}
+
} // namespace blink
« no previous file with comments | « Source/web/LinkHighlight.h ('k') | Source/web/WebViewImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698