| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 , m_startTime(monotonicallyIncreasingTime()) | 76 , m_startTime(monotonicallyIncreasingTime()) |
| 77 { | 77 { |
| 78 ASSERT(m_node); | 78 ASSERT(m_node); |
| 79 ASSERT(owningWebViewImpl); | 79 ASSERT(owningWebViewImpl); |
| 80 WebCompositorSupport* compositorSupport = Platform::current()->compositorSup
port(); | 80 WebCompositorSupport* compositorSupport = Platform::current()->compositorSup
port(); |
| 81 ASSERT(compositorSupport); | 81 ASSERT(compositorSupport); |
| 82 m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this)); | 82 m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this)); |
| 83 m_clipLayer = adoptPtr(compositorSupport->createLayer()); | 83 m_clipLayer = adoptPtr(compositorSupport->createLayer()); |
| 84 m_clipLayer->setTransformOrigin(WebFloatPoint3D()); | 84 m_clipLayer->setTransformOrigin(WebFloatPoint3D()); |
| 85 m_clipLayer->addChild(m_contentLayer->layer()); | 85 m_clipLayer->addChild(m_contentLayer->layer()); |
| 86 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { | 86 |
| 87 m_compositorPlayer = adoptPtr(CompositorFactory::current().createAnimati
onPlayer()); | 87 m_compositorPlayer = adoptPtr(CompositorFactory::current().createAnimationPl
ayer()); |
| 88 ASSERT(m_compositorPlayer); | 88 ASSERT(m_compositorPlayer); |
| 89 m_compositorPlayer->setAnimationDelegate(this); | 89 m_compositorPlayer->setAnimationDelegate(this); |
| 90 if (m_owningWebViewImpl->linkHighlightsTimeline()) | 90 if (m_owningWebViewImpl->linkHighlightsTimeline()) |
| 91 m_owningWebViewImpl->linkHighlightsTimeline()->playerAttached(*this)
; | 91 m_owningWebViewImpl->linkHighlightsTimeline()->playerAttached(*this); |
| 92 m_compositorPlayer->attachLayer(m_contentLayer->layer()); | 92 m_compositorPlayer->attachLayer(m_contentLayer->layer()); |
| 93 } else { | 93 |
| 94 owningWebViewImpl->registerForAnimations(m_contentLayer->layer()); | |
| 95 m_contentLayer->layer()->setAnimationDelegate(this); | |
| 96 } | |
| 97 m_contentLayer->layer()->setDrawsContent(true); | 94 m_contentLayer->layer()->setDrawsContent(true); |
| 98 m_contentLayer->layer()->setOpacity(1); | 95 m_contentLayer->layer()->setOpacity(1); |
| 99 m_geometryNeedsUpdate = true; | 96 m_geometryNeedsUpdate = true; |
| 100 } | 97 } |
| 101 | 98 |
| 102 LinkHighlightImpl::~LinkHighlightImpl() | 99 LinkHighlightImpl::~LinkHighlightImpl() |
| 103 { | 100 { |
| 104 if (m_compositorPlayer) { | 101 if (m_compositorPlayer->isLayerAttached()) |
| 105 if (m_compositorPlayer->isLayerAttached()) | 102 m_compositorPlayer->detachLayer(); |
| 106 m_compositorPlayer->detachLayer(); | 103 if (m_owningWebViewImpl->linkHighlightsTimeline()) |
| 107 if (m_owningWebViewImpl->linkHighlightsTimeline()) | 104 m_owningWebViewImpl->linkHighlightsTimeline()->playerDestroyed(*this); |
| 108 m_owningWebViewImpl->linkHighlightsTimeline()->playerDestroyed(*this
); | 105 m_compositorPlayer->setAnimationDelegate(nullptr); |
| 109 m_compositorPlayer->setAnimationDelegate(nullptr); | |
| 110 } | |
| 111 m_compositorPlayer.clear(); | 106 m_compositorPlayer.clear(); |
| 112 | 107 |
| 113 clearGraphicsLayerLinkHighlightPointer(); | 108 clearGraphicsLayerLinkHighlightPointer(); |
| 114 releaseResources(); | 109 releaseResources(); |
| 115 } | 110 } |
| 116 | 111 |
| 117 WebContentLayer* LinkHighlightImpl::contentLayer() | 112 WebContentLayer* LinkHighlightImpl::contentLayer() |
| 118 { | 113 { |
| 119 return m_contentLayer.get(); | 114 return m_contentLayer.get(); |
| 120 } | 115 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 // Make sure we have displayed for at least minPreFadeDuration before starti
ng to fade out. | 296 // Make sure we have displayed for at least minPreFadeDuration before starti
ng to fade out. |
| 302 float extraDurationRequired = std::max(0.f, minPreFadeDuration - static_cast
<float>(monotonicallyIncreasingTime() - m_startTime)); | 297 float extraDurationRequired = std::max(0.f, minPreFadeDuration - static_cast
<float>(monotonicallyIncreasingTime() - m_startTime)); |
| 303 if (extraDurationRequired) | 298 if (extraDurationRequired) |
| 304 curve->add(CompositorFloatKeyframe(extraDurationRequired, startOpacity))
; | 299 curve->add(CompositorFloatKeyframe(extraDurationRequired, startOpacity))
; |
| 305 // For layout tests we don't fade out. | 300 // For layout tests we don't fade out. |
| 306 curve->add(CompositorFloatKeyframe(fadeDuration + extraDurationRequired, lay
outTestMode() ? startOpacity : 0)); | 301 curve->add(CompositorFloatKeyframe(fadeDuration + extraDurationRequired, lay
outTestMode() ? startOpacity : 0)); |
| 307 | 302 |
| 308 OwnPtr<CompositorAnimation> animation = adoptPtr(CompositorFactory::current(
).createAnimation(*curve, CompositorTargetProperty::OPACITY)); | 303 OwnPtr<CompositorAnimation> animation = adoptPtr(CompositorFactory::current(
).createAnimation(*curve, CompositorTargetProperty::OPACITY)); |
| 309 | 304 |
| 310 m_contentLayer->layer()->setDrawsContent(true); | 305 m_contentLayer->layer()->setDrawsContent(true); |
| 311 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) | 306 m_compositorPlayer->addAnimation(animation.leakPtr()); |
| 312 m_compositorPlayer->addAnimation(animation.leakPtr()); | |
| 313 else | |
| 314 m_contentLayer->layer()->addAnimation(animation->releaseCCAnimation()); | |
| 315 | 307 |
| 316 invalidate(); | 308 invalidate(); |
| 317 m_owningWebViewImpl->scheduleAnimation(); | 309 m_owningWebViewImpl->scheduleAnimation(); |
| 318 } | 310 } |
| 319 | 311 |
| 320 void LinkHighlightImpl::clearGraphicsLayerLinkHighlightPointer() | 312 void LinkHighlightImpl::clearGraphicsLayerLinkHighlightPointer() |
| 321 { | 313 { |
| 322 if (m_currentGraphicsLayer) { | 314 if (m_currentGraphicsLayer) { |
| 323 m_currentGraphicsLayer->removeLinkHighlight(this); | 315 m_currentGraphicsLayer->removeLinkHighlight(this); |
| 324 m_currentGraphicsLayer = 0; | 316 m_currentGraphicsLayer = 0; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 { | 372 { |
| 381 return clipLayer(); | 373 return clipLayer(); |
| 382 } | 374 } |
| 383 | 375 |
| 384 CompositorAnimationPlayer* LinkHighlightImpl::compositorPlayer() const | 376 CompositorAnimationPlayer* LinkHighlightImpl::compositorPlayer() const |
| 385 { | 377 { |
| 386 return m_compositorPlayer.get(); | 378 return m_compositorPlayer.get(); |
| 387 } | 379 } |
| 388 | 380 |
| 389 } // namespace blink | 381 } // namespace blink |
| OLD | NEW |