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

Unified Diff: cc/thread_proxy.cc

Issue 12212007: cc: Route offscreen context creation for compositor to the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove the GrContextProvider::ScopedContexts guard classes Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: cc/thread_proxy.cc
diff --git a/cc/thread_proxy.cc b/cc/thread_proxy.cc
index fe92817ea58a659061e98380f4953a1c5dd5043c..c06fc74a95da96ba893fc99d4682169c760cf768 100644
--- a/cc/thread_proxy.cc
+++ b/cc/thread_proxy.cc
@@ -17,9 +17,6 @@
#include "cc/prioritized_resource_manager.h"
#include "cc/scheduler.h"
#include "cc/thread.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebSharedGraphicsContext3D.h"
-
-using WebKit::WebSharedGraphicsContext3D;
namespace {
@@ -224,13 +221,22 @@ bool ThreadProxy::recreateOutputSurface()
TRACE_EVENT0("cc", "ThreadProxy::recreateOutputSurface");
DCHECK(isMainThread());
+ bool needsOffscreenContext = m_RendererCapabilitiesMainThreadCopy.usingOffscreenContext3d && m_layerTreeHost->needsOffscreenContext();
+ if (needsOffscreenContext)
+ m_layerTreeHost->client()->DestroyOffscreenContext3dForCompositorThread();
+
// Try to create the surface.
scoped_ptr<OutputSurface> outputSurface = m_layerTreeHost->createOutputSurface();
if (!outputSurface.get())
return false;
- if (m_layerTreeHost->needsSharedContext())
- if (!WebSharedGraphicsContext3D::createCompositorThreadContext())
+ WebKit::WebGraphicsContext3D* offscreenContext3d = NULL;
+ GrContext* offscreenGrContext = NULL;
+ if (needsOffscreenContext) {
+ offscreenContext3d = m_layerTreeHost->client()->OffscreenContext3dForCompositorThread();
+ if (!offscreenContext3d)
return false;
+ offscreenGrContext = m_layerTreeHost->client()->OffscreenGrContextForCompositorThread();
+ }
// Make a blocking call to recreateOutputSurfaceOnImplThread. The results of that
// call are pushed into the recreateSucceeded and capabilities local
@@ -243,6 +249,8 @@ bool ThreadProxy::recreateOutputSurface()
m_implThreadWeakPtr,
&completion,
base::Passed(&outputSurface),
+ offscreenContext3d,
+ offscreenGrContext,
&recreateSucceeded,
&capabilities));
completion.wait();
@@ -599,9 +607,6 @@ void ThreadProxy::beginFrame(scoped_ptr<BeginFrameAndCommitState> beginFrameStat
return;
}
- if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::haveCompositorThreadContext())
- WebSharedGraphicsContext3D::createCompositorThreadContext();
-
// Do not notify the impl thread of commit requests that occur during
// the apply/animate/layout part of the beginFrameAndCommit process since
// those commit requests will get painted immediately. Once we have done
@@ -671,6 +676,13 @@ void ThreadProxy::beginFrame(scoped_ptr<BeginFrameAndCommitState> beginFrameStat
setNeedsAnimate();
}
+ WebKit::WebGraphicsContext3D* offscreenContext3d = NULL;
+ GrContext* offscreenGrContext = NULL;
+ if (m_RendererCapabilitiesMainThreadCopy.usingOffscreenContext3d && m_layerTreeHost->needsOffscreenContext()) {
+ offscreenContext3d = m_layerTreeHost->client()->OffscreenContext3dForCompositorThread();
+ offscreenGrContext = m_layerTreeHost->client()->OffscreenGrContextForCompositorThread();
+ }
+
// Notify the impl thread that the beginFrame has completed. This will
// begin the commit process, which is blocking from the main thread's
// point of view, but asynchronously performed on the impl thread,
@@ -682,7 +694,7 @@ void ThreadProxy::beginFrame(scoped_ptr<BeginFrameAndCommitState> beginFrameStat
base::TimeTicks startTime = base::TimeTicks::HighResNow();
CompletionEvent completion;
- Proxy::implThread()->postTask(base::Bind(&ThreadProxy::beginFrameCompleteOnImplThread, m_implThreadWeakPtr, &completion, queue.release()));
+ Proxy::implThread()->postTask(base::Bind(&ThreadProxy::beginFrameCompleteOnImplThread, m_implThreadWeakPtr, &completion, queue.release(), offscreenContext3d, offscreenGrContext));
completion.wait();
base::TimeTicks endTime = base::TimeTicks::HighResNow();
@@ -694,7 +706,7 @@ void ThreadProxy::beginFrame(scoped_ptr<BeginFrameAndCommitState> beginFrameStat
m_layerTreeHost->didBeginFrame();
}
-void ThreadProxy::beginFrameCompleteOnImplThread(CompletionEvent* completion, ResourceUpdateQueue* rawQueue)
+void ThreadProxy::beginFrameCompleteOnImplThread(CompletionEvent* completion, ResourceUpdateQueue* rawQueue, WebKit::WebGraphicsContext3D* offscreenContext3d, GrContext* offscreenGrContext)
{
scoped_ptr<ResourceUpdateQueue> queue(rawQueue);
@@ -710,6 +722,8 @@ void ThreadProxy::beginFrameCompleteOnImplThread(CompletionEvent* completion, Re
return;
}
+ m_layerTreeHostImpl->resourceProvider()->setOffscreenContexts(offscreenContext3d, offscreenGrContext);
+
if (m_layerTreeHost->contentsTextureManager()->linkedEvictedBackingsExist()) {
// Clear any uploads we were making to textures linked to evicted
// resources
@@ -721,7 +735,7 @@ void ThreadProxy::beginFrameCompleteOnImplThread(CompletionEvent* completion, Re
m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings();
- m_currentResourceUpdateControllerOnImplThread = ResourceUpdateController::create(this, Proxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourceProvider(), hasImplThread());
+ m_currentResourceUpdateControllerOnImplThread = ResourceUpdateController::create(this, Proxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourceProvider());
m_currentResourceUpdateControllerOnImplThread->performMoreUpdates(
m_schedulerOnImplThread->anticipatedDrawTime());
@@ -1059,7 +1073,7 @@ size_t ThreadProxy::maxPartialTextureUpdates() const
return ResourceUpdateController::maxPartialTextureUpdates();
}
-void ThreadProxy::recreateOutputSurfaceOnImplThread(CompletionEvent* completion, scoped_ptr<OutputSurface> outputSurface, bool* recreateSucceeded, RendererCapabilities* capabilities)
+void ThreadProxy::recreateOutputSurfaceOnImplThread(CompletionEvent* completion, scoped_ptr<OutputSurface> outputSurface, WebKit::WebGraphicsContext3D* offscreenContext3d, GrContext* offscreenGrContext, bool* recreateSucceeded, RendererCapabilities* capabilities)
{
TRACE_EVENT0("cc", "ThreadProxy::recreateOutputSurfaceOnImplThread");
DCHECK(isImplThread());
@@ -1067,6 +1081,7 @@ void ThreadProxy::recreateOutputSurfaceOnImplThread(CompletionEvent* completion,
*recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(outputSurface.Pass());
if (*recreateSucceeded) {
*capabilities = m_layerTreeHostImpl->rendererCapabilities();
+ m_layerTreeHostImpl->resourceProvider()->setOffscreenContexts(offscreenContext3d, offscreenGrContext);
m_schedulerOnImplThread->didRecreateOutputSurface();
}
completion->signal();

Powered by Google App Engine
This is Rietveld 408576698