Chromium Code Reviews| Index: third_party/WebKit/Source/web/WebViewImpl.cpp |
| diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp |
| index 107878abf2a9750ffbc8f1fbdcf4cac5e29e5b78..76e11230ecb33e86a1a9a93108cd30ff1aaa70cd 100644 |
| --- a/third_party/WebKit/Source/web/WebViewImpl.cpp |
| +++ b/third_party/WebKit/Source/web/WebViewImpl.cpp |
| @@ -33,6 +33,7 @@ |
| #include "core/CSSValueKeywords.h" |
| #include "core/HTMLNames.h" |
| #include "core/InputTypeNames.h" |
| +#include "core/animation/CustomCompositorAnimationManager.h" |
| #include "core/clipboard/DataObject.h" |
| #include "core/dom/Document.h" |
| #include "core/dom/Fullscreen.h" |
| @@ -106,12 +107,15 @@ |
| #include "platform/PlatformKeyboardEvent.h" |
| #include "platform/PlatformMouseEvent.h" |
| #include "platform/RuntimeEnabledFeatures.h" |
| +#include "platform/ThreadSafeFunctional.h" |
| #include "platform/TraceEvent.h" |
| #include "platform/UserGestureIndicator.h" |
| +#include "platform/WaitableEvent.h" |
| #include "platform/exported/WebActiveGestureAnimation.h" |
| #include "platform/fonts/FontCache.h" |
| #include "platform/graphics/Color.h" |
| #include "platform/graphics/CompositorFactory.h" |
| +#include "platform/graphics/CompositorMutatorClient.h" |
| #include "platform/graphics/FirstPaintInvalidationTracking.h" |
| #include "platform/graphics/GraphicsContext.h" |
| #include "platform/graphics/Image.h" |
| @@ -151,6 +155,8 @@ |
| #include "public/web/WebViewClient.h" |
| #include "public/web/WebWindowFeatures.h" |
| #include "web/CompositionUnderlineVectorBuilder.h" |
| +#include "web/CompositorMutatorImpl.h" |
| +#include "web/CompositorProxyClientImpl.h" |
| #include "web/ContextFeaturesClientImpl.h" |
| #include "web/ContextMenuAllowedScope.h" |
| #include "web/DatabaseClientImpl.h" |
| @@ -324,6 +330,14 @@ private: |
| WebColor m_color; |
| }; |
| +void createCompositorMutatorClient(std::unique_ptr<CompositorMutatorClient>* ptr, WaitableEvent* doneEvent) |
| +{ |
| + CompositorMutatorImpl* mutator = CompositorMutatorImpl::create(); |
| + (*ptr).reset(new CompositorMutatorClient(mutator, mutator->animationManager())); |
|
jbroman
2016/05/04 17:59:00
nit: the conventional way to write this would be p
flackr
2016/05/04 21:52:41
Done.
|
| + mutator->setClient((*ptr).get()); |
|
jbroman
2016/05/04 17:59:00
ditto, ptr->get() seems more natural?
flackr
2016/05/04 21:52:41
Done.
|
| + doneEvent->signal(); |
| +} |
| + |
| } // namespace |
| // WebView ---------------------------------------------------------------- |
| @@ -442,6 +456,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client) |
| , m_shouldDispatchFirstLayoutAfterFinishedLoading(false) |
| , m_displayMode(WebDisplayModeBrowser) |
| , m_elasticOverscroll(FloatSize()) |
| + , m_mutator(nullptr) |
| , m_scheduler(adoptPtr(Platform::current()->currentThread()->scheduler()->createWebViewScheduler(this).release())) |
| , m_lastFrameTimeMonotonic(0) |
| { |
| @@ -4473,6 +4488,26 @@ void WebViewImpl::forceNextDrawingBufferCreationToFail() |
| DrawingBuffer::forceNextDrawingBufferCreationToFail(); |
| } |
| +CompositorProxyClient* WebViewImpl::createCompositorProxyClient() |
| +{ |
| + if (!m_mutator) { |
| + std::unique_ptr<CompositorMutatorClient> mutatorClient; |
| + WaitableEvent doneEvent; |
| + if (WebThread* compositorThread = Platform::current()->compositorThread()) { |
| + compositorThread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&createCompositorMutatorClient, AllowCrossThreadAccess(&mutatorClient), AllowCrossThreadAccess(&doneEvent))); |
| + } else { |
| + createCompositorMutatorClient(&mutatorClient, &doneEvent); |
| + } |
| + // TODO(flackr): Instead of waiting for this event, we may be able to just set the |
| + // mutator on the CompositorProxyClient directly from the compositor thread before |
| + // it gets used there. We still need to make sure we only create one mutator though. |
| + doneEvent.wait(); |
| + m_mutator = static_cast<CompositorMutatorImpl*>(mutatorClient->mutator()); |
| + m_layerTreeView->setMutatorClient(std::move(mutatorClient)); |
| + } |
| + return new CompositorProxyClientImpl(m_mutator); |
| +} |
| + |
| void WebViewImpl::updatePageOverlays() |
| { |
| if (m_pageColorOverlay) |