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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « Source/web/LinkHighlight.h ('k') | Source/web/WebViewImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 19 matching lines...) Expand all
30 #include "core/dom/LayoutTreeBuilderTraversal.h" 30 #include "core/dom/LayoutTreeBuilderTraversal.h"
31 #include "core/dom/Node.h" 31 #include "core/dom/Node.h"
32 #include "core/frame/FrameView.h" 32 #include "core/frame/FrameView.h"
33 #include "core/frame/LocalFrame.h" 33 #include "core/frame/LocalFrame.h"
34 #include "core/layout/LayoutBoxModelObject.h" 34 #include "core/layout/LayoutBoxModelObject.h"
35 #include "core/layout/LayoutObject.h" 35 #include "core/layout/LayoutObject.h"
36 #include "core/layout/LayoutView.h" 36 #include "core/layout/LayoutView.h"
37 #include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h" 37 #include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h"
38 #include "core/style/ShadowData.h" 38 #include "core/style/ShadowData.h"
39 #include "core/paint/DeprecatedPaintLayer.h" 39 #include "core/paint/DeprecatedPaintLayer.h"
40 #include "platform/RuntimeEnabledFeatures.h"
40 #include "platform/graphics/Color.h" 41 #include "platform/graphics/Color.h"
41 #include "platform/graphics/paint/DrawingRecorder.h" 42 #include "platform/graphics/paint/DrawingRecorder.h"
42 #include "public/platform/Platform.h" 43 #include "public/platform/Platform.h"
43 #include "public/platform/WebCompositorAnimationCurve.h" 44 #include "public/platform/WebCompositorAnimationCurve.h"
44 #include "public/platform/WebCompositorSupport.h" 45 #include "public/platform/WebCompositorSupport.h"
45 #include "public/platform/WebDisplayItemList.h" 46 #include "public/platform/WebDisplayItemList.h"
46 #include "public/platform/WebFloatAnimationCurve.h" 47 #include "public/platform/WebFloatAnimationCurve.h"
47 #include "public/platform/WebFloatPoint.h" 48 #include "public/platform/WebFloatPoint.h"
48 #include "public/platform/WebRect.h" 49 #include "public/platform/WebRect.h"
49 #include "public/platform/WebSize.h" 50 #include "public/platform/WebSize.h"
(...skipping 19 matching lines...) Expand all
69 : m_node(node) 70 : m_node(node)
70 , m_owningWebViewImpl(owningWebViewImpl) 71 , m_owningWebViewImpl(owningWebViewImpl)
71 , m_currentGraphicsLayer(0) 72 , m_currentGraphicsLayer(0)
72 , m_geometryNeedsUpdate(false) 73 , m_geometryNeedsUpdate(false)
73 , m_isAnimating(false) 74 , m_isAnimating(false)
74 , m_startTime(monotonicallyIncreasingTime()) 75 , m_startTime(monotonicallyIncreasingTime())
75 { 76 {
76 ASSERT(m_node); 77 ASSERT(m_node);
77 ASSERT(owningWebViewImpl); 78 ASSERT(owningWebViewImpl);
78 WebCompositorSupport* compositorSupport = Platform::current()->compositorSup port(); 79 WebCompositorSupport* compositorSupport = Platform::current()->compositorSup port();
80 ASSERT(compositorSupport);
79 m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this)); 81 m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this));
80 owningWebViewImpl->registerForAnimations(m_contentLayer->layer());
81 m_clipLayer = adoptPtr(compositorSupport->createLayer()); 82 m_clipLayer = adoptPtr(compositorSupport->createLayer());
82 m_clipLayer->setTransformOrigin(WebFloatPoint3D()); 83 m_clipLayer->setTransformOrigin(WebFloatPoint3D());
83 m_clipLayer->addChild(m_contentLayer->layer()); 84 m_clipLayer->addChild(m_contentLayer->layer());
84 m_contentLayer->layer()->setAnimationDelegate(this); 85 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) {
86 m_compositorPlayer = adoptPtr(compositorSupport->createAnimationPlayer() );
87 ASSERT(m_compositorPlayer);
88 m_compositorPlayer->setAnimationDelegate(this);
89 m_owningWebViewImpl->linkHighlightsTimeline()->playerAttached(*this);
90 m_compositorPlayer->attachLayer(m_contentLayer->layer());
91 } else {
92 owningWebViewImpl->registerForAnimations(m_contentLayer->layer());
93 m_contentLayer->layer()->setAnimationDelegate(this);
94 }
85 m_contentLayer->layer()->setDrawsContent(true); 95 m_contentLayer->layer()->setDrawsContent(true);
86 m_contentLayer->layer()->setOpacity(1); 96 m_contentLayer->layer()->setOpacity(1);
87 m_geometryNeedsUpdate = true; 97 m_geometryNeedsUpdate = true;
88 updateGeometry(); 98 updateGeometry();
89 } 99 }
90 100
91 LinkHighlight::~LinkHighlight() 101 LinkHighlight::~LinkHighlight()
92 { 102 {
103 if (m_compositorPlayer) {
104 m_compositorPlayer->detachLayer();
105 m_owningWebViewImpl->linkHighlightsTimeline()->playerDestroyed(*this);
106 m_compositorPlayer->setAnimationDelegate(nullptr);
107 }
108 m_compositorPlayer.clear();
109
93 clearGraphicsLayerLinkHighlightPointer(); 110 clearGraphicsLayerLinkHighlightPointer();
94 releaseResources(); 111 releaseResources();
95 } 112 }
96 113
97 WebContentLayer* LinkHighlight::contentLayer() 114 WebContentLayer* LinkHighlight::contentLayer()
98 { 115 {
99 return m_contentLayer.get(); 116 return m_contentLayer.get();
100 } 117 }
101 118
102 WebLayer* LinkHighlight::clipLayer() 119 WebLayer* LinkHighlight::clipLayer()
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // Make sure we have displayed for at least minPreFadeDuration before starti ng to fade out. 302 // Make sure we have displayed for at least minPreFadeDuration before starti ng to fade out.
286 float extraDurationRequired = std::max(0.f, minPreFadeDuration - static_cast <float>(monotonicallyIncreasingTime() - m_startTime)); 303 float extraDurationRequired = std::max(0.f, minPreFadeDuration - static_cast <float>(monotonicallyIncreasingTime() - m_startTime));
287 if (extraDurationRequired) 304 if (extraDurationRequired)
288 curve->add(WebFloatKeyframe(extraDurationRequired, startOpacity)); 305 curve->add(WebFloatKeyframe(extraDurationRequired, startOpacity));
289 // For layout tests we don't fade out. 306 // For layout tests we don't fade out.
290 curve->add(WebFloatKeyframe(fadeDuration + extraDurationRequired, layoutTest Mode() ? startOpacity : 0)); 307 curve->add(WebFloatKeyframe(fadeDuration + extraDurationRequired, layoutTest Mode() ? startOpacity : 0));
291 308
292 OwnPtr<WebCompositorAnimation> animation = adoptPtr(compositorSupport->creat eAnimation(*curve, WebCompositorAnimation::TargetPropertyOpacity)); 309 OwnPtr<WebCompositorAnimation> animation = adoptPtr(compositorSupport->creat eAnimation(*curve, WebCompositorAnimation::TargetPropertyOpacity));
293 310
294 m_contentLayer->layer()->setDrawsContent(true); 311 m_contentLayer->layer()->setDrawsContent(true);
295 m_contentLayer->layer()->addAnimation(animation.leakPtr()); 312 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled())
313 m_compositorPlayer->addAnimation(animation.leakPtr());
314 else
315 m_contentLayer->layer()->addAnimation(animation.leakPtr());
296 316
297 invalidate(); 317 invalidate();
298 m_owningWebViewImpl->scheduleAnimation(); 318 m_owningWebViewImpl->scheduleAnimation();
299 } 319 }
300 320
301 void LinkHighlight::clearGraphicsLayerLinkHighlightPointer() 321 void LinkHighlight::clearGraphicsLayerLinkHighlightPointer()
302 { 322 {
303 if (m_currentGraphicsLayer) { 323 if (m_currentGraphicsLayer) {
304 m_currentGraphicsLayer->removeLinkHighlight(this); 324 m_currentGraphicsLayer->removeLinkHighlight(this);
305 m_currentGraphicsLayer = 0; 325 m_currentGraphicsLayer = 0;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 { 374 {
355 // Make sure we update geometry on the next callback from WebViewImpl::layou t(). 375 // Make sure we update geometry on the next callback from WebViewImpl::layou t().
356 m_geometryNeedsUpdate = true; 376 m_geometryNeedsUpdate = true;
357 } 377 }
358 378
359 WebLayer* LinkHighlight::layer() 379 WebLayer* LinkHighlight::layer()
360 { 380 {
361 return clipLayer(); 381 return clipLayer();
362 } 382 }
363 383
384 WebCompositorAnimationPlayer* LinkHighlight::compositorPlayer() const
385 {
386 return m_compositorPlayer.get();
387 }
388
364 } // namespace blink 389 } // namespace blink
OLDNEW
« 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