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

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: Rebase. 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
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 20 matching lines...) Expand all
31 #include "core/dom/LayoutTreeBuilderTraversal.h" 31 #include "core/dom/LayoutTreeBuilderTraversal.h"
32 #include "core/dom/Node.h" 32 #include "core/dom/Node.h"
33 #include "core/frame/FrameView.h" 33 #include "core/frame/FrameView.h"
34 #include "core/frame/LocalFrame.h" 34 #include "core/frame/LocalFrame.h"
35 #include "core/layout/LayoutBoxModelObject.h" 35 #include "core/layout/LayoutBoxModelObject.h"
36 #include "core/layout/LayoutObject.h" 36 #include "core/layout/LayoutObject.h"
37 #include "core/layout/LayoutView.h" 37 #include "core/layout/LayoutView.h"
38 #include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h" 38 #include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h"
39 #include "core/style/ShadowData.h" 39 #include "core/style/ShadowData.h"
40 #include "core/paint/DeprecatedPaintLayer.h" 40 #include "core/paint/DeprecatedPaintLayer.h"
41 #include "platform/RuntimeEnabledFeatures.h"
41 #include "platform/graphics/Color.h" 42 #include "platform/graphics/Color.h"
42 #include "platform/graphics/paint/DrawingRecorder.h" 43 #include "platform/graphics/paint/DrawingRecorder.h"
43 #include "public/platform/Platform.h" 44 #include "public/platform/Platform.h"
44 #include "public/platform/WebCompositorAnimationCurve.h" 45 #include "public/platform/WebCompositorAnimationCurve.h"
45 #include "public/platform/WebCompositorSupport.h" 46 #include "public/platform/WebCompositorSupport.h"
46 #include "public/platform/WebDisplayItemList.h" 47 #include "public/platform/WebDisplayItemList.h"
47 #include "public/platform/WebFloatAnimationCurve.h" 48 #include "public/platform/WebFloatAnimationCurve.h"
48 #include "public/platform/WebFloatPoint.h" 49 #include "public/platform/WebFloatPoint.h"
49 #include "public/platform/WebRect.h" 50 #include "public/platform/WebRect.h"
50 #include "public/platform/WebSize.h" 51 #include "public/platform/WebSize.h"
(...skipping 19 matching lines...) Expand all
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();
79 m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this)); 80 m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this));
80 owningWebViewImpl->registerForAnimations(m_contentLayer->layer());
81 m_clipLayer = adoptPtr(compositorSupport->createLayer()); 81 m_clipLayer = adoptPtr(compositorSupport->createLayer());
82 m_clipLayer->setTransformOrigin(WebFloatPoint3D()); 82 m_clipLayer->setTransformOrigin(WebFloatPoint3D());
83 m_clipLayer->addChild(m_contentLayer->layer()); 83 m_clipLayer->addChild(m_contentLayer->layer());
84 m_contentLayer->layer()->setAnimationDelegate(this); 84 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() && Platfor m::current()->compositorSupport()) {
chrishtr 2015/07/13 21:20:52 When would compositorSupport() be null?
loyso (OOO) 2015/07/14 00:59:04 We can assert that it can't be null here. I'll fix
chrishtr 2015/07/14 18:34:00 Also change the interface to return a reference ra
loyso (OOO) 2015/07/15 02:04:36 We have so many calls to this function throughout
chrishtr 2015/07/15 14:25:14 Ok please add the assert at least then.
loyso (OOO) 2015/07/21 01:19:07 Done.
85 m_compositorPlayer = adoptPtr(Platform::current()->compositorSupport()-> createAnimationPlayer());
86 ASSERT(m_compositorPlayer);
87 m_compositorPlayer->setAnimationDelegate(this);
88 m_owningWebViewImpl->linkHighlightsTimeline()->playerAttached(*this);
89 m_compositorPlayer->attachLayer(m_contentLayer->layer());
90 } else {
91 owningWebViewImpl->registerForAnimations(m_contentLayer->layer());
92 m_contentLayer->layer()->setAnimationDelegate(this);
93 }
85 m_contentLayer->layer()->setDrawsContent(true); 94 m_contentLayer->layer()->setDrawsContent(true);
86 m_contentLayer->layer()->setOpacity(1); 95 m_contentLayer->layer()->setOpacity(1);
87 m_geometryNeedsUpdate = true; 96 m_geometryNeedsUpdate = true;
88 updateGeometry(); 97 updateGeometry();
89 } 98 }
90 99
91 LinkHighlight::~LinkHighlight() 100 LinkHighlight::~LinkHighlight()
92 { 101 {
102 if (m_compositorPlayer) {
103 m_compositorPlayer->detachLayer();
104 m_owningWebViewImpl->linkHighlightsTimeline()->playerDestroyed(*this);
105 m_compositorPlayer->setAnimationDelegate(nullptr);
106 }
107 m_compositorPlayer.clear();
108
93 clearGraphicsLayerLinkHighlightPointer(); 109 clearGraphicsLayerLinkHighlightPointer();
94 releaseResources(); 110 releaseResources();
95 } 111 }
96 112
97 WebContentLayer* LinkHighlight::contentLayer() 113 WebContentLayer* LinkHighlight::contentLayer()
98 { 114 {
99 return m_contentLayer.get(); 115 return m_contentLayer.get();
100 } 116 }
101 117
102 WebLayer* LinkHighlight::clipLayer() 118 WebLayer* LinkHighlight::clipLayer()
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(compositorSupport->createFlo atAnimationCurve()); 298 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(compositorSupport->createFlo atAnimationCurve());
283 299
284 curve->add(WebFloatKeyframe(0, startOpacity)); 300 curve->add(WebFloatKeyframe(0, startOpacity));
285 // Make sure we have displayed for at least minPreFadeDuration before starti ng to fade out. 301 // 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)); 302 float extraDurationRequired = std::max(0.f, minPreFadeDuration - static_cast <float>(monotonicallyIncreasingTime() - m_startTime));
287 if (extraDurationRequired) 303 if (extraDurationRequired)
288 curve->add(WebFloatKeyframe(extraDurationRequired, startOpacity)); 304 curve->add(WebFloatKeyframe(extraDurationRequired, startOpacity));
289 // For layout tests we don't fade out. 305 // For layout tests we don't fade out.
290 curve->add(WebFloatKeyframe(fadeDuration + extraDurationRequired, layoutTest Mode() ? startOpacity : 0)); 306 curve->add(WebFloatKeyframe(fadeDuration + extraDurationRequired, layoutTest Mode() ? startOpacity : 0));
291 307
292 OwnPtr<WebCompositorAnimation> animation = adoptPtr(compositorSupport->creat eAnimation(*curve, WebCompositorAnimation::TargetPropertyOpacity)); 308 OwnPtr<WebCompositorAnimation> animation = adoptPtr(compositorSupport->creat eAnimation(*curve, WebCompositorAnimation::TargetPropertyOpacity));
chrishtr 2015/07/13 21:20:52 Why even put it in an OwnPtr if you are going to l
loyso (OOO) 2015/07/14 00:59:04 1) This is how we mark ownership over this animati
chrishtr 2015/07/14 18:34:00 I agree that unifying after the blink/chromium mer
loyso (OOO) 2015/07/21 01:19:07 Acknowledged.
293 309
294 m_contentLayer->layer()->setDrawsContent(true); 310 m_contentLayer->layer()->setDrawsContent(true);
295 m_contentLayer->layer()->addAnimation(animation.leakPtr()); 311 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled())
312 m_compositorPlayer->addAnimation(animation.leakPtr());
313 else
314 m_contentLayer->layer()->addAnimation(animation.leakPtr());
296 315
297 invalidate(); 316 invalidate();
298 m_owningWebViewImpl->scheduleAnimation(); 317 m_owningWebViewImpl->scheduleAnimation();
299 } 318 }
300 319
301 void LinkHighlight::clearGraphicsLayerLinkHighlightPointer() 320 void LinkHighlight::clearGraphicsLayerLinkHighlightPointer()
302 { 321 {
303 if (m_currentGraphicsLayer) { 322 if (m_currentGraphicsLayer) {
304 m_currentGraphicsLayer->removeLinkHighlight(this); 323 m_currentGraphicsLayer->removeLinkHighlight(this);
305 m_currentGraphicsLayer = 0; 324 m_currentGraphicsLayer = 0;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 { 373 {
355 // Make sure we update geometry on the next callback from WebViewImpl::layou t(). 374 // Make sure we update geometry on the next callback from WebViewImpl::layou t().
356 m_geometryNeedsUpdate = true; 375 m_geometryNeedsUpdate = true;
357 } 376 }
358 377
359 WebLayer* LinkHighlight::layer() 378 WebLayer* LinkHighlight::layer()
360 { 379 {
361 return clipLayer(); 380 return clipLayer();
362 } 381 }
363 382
383 WebCompositorAnimationPlayer* LinkHighlight::compositorPlayer() const
384 {
385 return m_compositorPlayer.get();
386 }
387
364 } // namespace blink 388 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/LinkHighlight.h ('k') | Source/web/WebViewImpl.h » ('j') | Source/web/WebViewImpl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698