OLD | NEW |
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 , m_isAnimating(false) | 74 , m_isAnimating(false) |
75 , m_startTime(monotonicallyIncreasingTime()) | 75 , m_startTime(monotonicallyIncreasingTime()) |
76 { | 76 { |
77 ASSERT(m_node); | 77 ASSERT(m_node); |
78 ASSERT(owningWebViewImpl); | 78 ASSERT(owningWebViewImpl); |
79 WebCompositorSupport* compositorSupport = Platform::current()->compositorSup
port(); | 79 WebCompositorSupport* compositorSupport = Platform::current()->compositorSup
port(); |
80 m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this)); | 80 m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this)); |
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 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() && Platfor
m::current()->compositorSupport()) { | 84 |
85 m_compositorPlayer = adoptPtr(Platform::current()->compositorSupport()->
createAnimationPlayer()); | 85 m_compositorPlayer = adoptPtr(Platform::current()->compositorSupport()->crea
teAnimationPlayer()); |
86 ASSERT(m_compositorPlayer); | 86 ASSERT(m_compositorPlayer); |
87 m_compositorPlayer->setAnimationDelegate(this); | 87 m_compositorPlayer->setAnimationDelegate(this); |
88 m_owningWebViewImpl->linkHighlightsTimeline()->playerAttached(*this); | 88 m_owningWebViewImpl->linkHighlightsTimeline()->playerAttached(*this); |
89 m_compositorPlayer->attachLayer(m_contentLayer->layer()); | 89 m_compositorPlayer->attachLayer(m_contentLayer->layer()); |
90 } else { | 90 |
91 owningWebViewImpl->registerForAnimations(m_contentLayer->layer()); | |
92 m_contentLayer->layer()->setAnimationDelegate(this); | |
93 } | |
94 m_contentLayer->layer()->setDrawsContent(true); | 91 m_contentLayer->layer()->setDrawsContent(true); |
95 m_contentLayer->layer()->setOpacity(1); | 92 m_contentLayer->layer()->setOpacity(1); |
96 m_geometryNeedsUpdate = true; | 93 m_geometryNeedsUpdate = true; |
97 updateGeometry(); | 94 updateGeometry(); |
98 } | 95 } |
99 | 96 |
100 LinkHighlight::~LinkHighlight() | 97 LinkHighlight::~LinkHighlight() |
101 { | 98 { |
102 if (m_compositorPlayer) { | 99 m_compositorPlayer->detachLayer(); |
103 m_compositorPlayer->detachLayer(); | 100 m_owningWebViewImpl->linkHighlightsTimeline()->playerDestroyed(*this); |
104 m_owningWebViewImpl->linkHighlightsTimeline()->playerDestroyed(*this); | 101 m_compositorPlayer->setAnimationDelegate(nullptr); |
105 m_compositorPlayer->setAnimationDelegate(nullptr); | |
106 } | |
107 m_compositorPlayer.clear(); | |
108 | 102 |
109 clearGraphicsLayerLinkHighlightPointer(); | 103 clearGraphicsLayerLinkHighlightPointer(); |
110 releaseResources(); | 104 releaseResources(); |
111 } | 105 } |
112 | 106 |
113 WebContentLayer* LinkHighlight::contentLayer() | 107 WebContentLayer* LinkHighlight::contentLayer() |
114 { | 108 { |
115 return m_contentLayer.get(); | 109 return m_contentLayer.get(); |
116 } | 110 } |
117 | 111 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // 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. |
308 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)); |
309 if (extraDurationRequired) | 303 if (extraDurationRequired) |
310 curve->add(WebFloatKeyframe(extraDurationRequired, startOpacity)); | 304 curve->add(WebFloatKeyframe(extraDurationRequired, startOpacity)); |
311 // For layout tests we don't fade out. | 305 // For layout tests we don't fade out. |
312 curve->add(WebFloatKeyframe(fadeDuration + extraDurationRequired, layoutTest
Mode() ? startOpacity : 0)); | 306 curve->add(WebFloatKeyframe(fadeDuration + extraDurationRequired, layoutTest
Mode() ? startOpacity : 0)); |
313 | 307 |
314 OwnPtr<WebCompositorAnimation> animation = adoptPtr(compositorSupport->creat
eAnimation(*curve, WebCompositorAnimation::TargetPropertyOpacity)); | 308 OwnPtr<WebCompositorAnimation> animation = adoptPtr(compositorSupport->creat
eAnimation(*curve, WebCompositorAnimation::TargetPropertyOpacity)); |
315 | 309 |
316 m_contentLayer->layer()->setDrawsContent(true); | 310 m_contentLayer->layer()->setDrawsContent(true); |
317 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) | 311 |
318 m_compositorPlayer->addAnimation(animation.leakPtr()); | 312 m_compositorPlayer->addAnimation(animation.leakPtr()); |
319 else | |
320 m_contentLayer->layer()->addAnimation(animation.leakPtr()); | |
321 | 313 |
322 invalidate(); | 314 invalidate(); |
323 m_owningWebViewImpl->scheduleAnimation(); | 315 m_owningWebViewImpl->scheduleAnimation(); |
324 } | 316 } |
325 | 317 |
326 void LinkHighlight::clearGraphicsLayerLinkHighlightPointer() | 318 void LinkHighlight::clearGraphicsLayerLinkHighlightPointer() |
327 { | 319 { |
328 if (m_currentGraphicsLayer) { | 320 if (m_currentGraphicsLayer) { |
329 m_currentGraphicsLayer->removeLinkHighlight(this); | 321 m_currentGraphicsLayer->removeLinkHighlight(this); |
330 m_currentGraphicsLayer = 0; | 322 m_currentGraphicsLayer = 0; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 { | 377 { |
386 return clipLayer(); | 378 return clipLayer(); |
387 } | 379 } |
388 | 380 |
389 WebCompositorAnimationPlayer* LinkHighlight::compositorPlayer() const | 381 WebCompositorAnimationPlayer* LinkHighlight::compositorPlayer() const |
390 { | 382 { |
391 return m_compositorPlayer.get(); | 383 return m_compositorPlayer.get(); |
392 } | 384 } |
393 | 385 |
394 } // namespace blink | 386 } // namespace blink |
OLD | NEW |