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

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: 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 2d24429e118bbe0978c7fbdea8a9d9dc1d54324b..60b488a9b17131df002a4330bdf468ab4eee8ee6 100644
--- a/cc/thread_proxy.cc
+++ b/cc/thread_proxy.cc
@@ -17,9 +17,7 @@
#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;
+#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
namespace {
@@ -228,9 +226,18 @@ bool ThreadProxy::recreateOutputSurface()
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 (m_layerTreeHost->needsOffscreenContext()) {
+ offscreenContext3d = m_layerTreeHost->client()->createOrGetOffscreenContext3dForCompositorThread();
+ if (!offscreenContext3d ||
+ !offscreenContext3d->makeContextCurrent() ||
+ offscreenContext3d->getGraphicsResetStatusARB())
+ {
return false;
+ }
+ offscreenGrContext = m_layerTreeHost->client()->createOrGetOffscreenGrContextForCompositorThread();
+ }
// Make a blocking call to recreateOutputSurfaceOnImplThread. The results of that
// call are pushed into the recreateSucceeded and capabilities local
@@ -243,6 +250,8 @@ bool ThreadProxy::recreateOutputSurface()
m_implThreadWeakPtr,
&completion,
base::Passed(&outputSurface),
+ offscreenContext3d,
+ offscreenGrContext,
&recreateSucceeded,
&capabilities));
completion.wait();
@@ -589,9 +598,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
@@ -661,6 +667,13 @@ void ThreadProxy::beginFrame(scoped_ptr<BeginFrameAndCommitState> beginFrameStat
setNeedsAnimate();
}
+ WebKit::WebGraphicsContext3D* offscreenContext3d = NULL;
+ GrContext* offscreenGrContext = NULL;
+ if (m_layerTreeHost->needsOffscreenContext()) {
+ offscreenContext3d = m_layerTreeHost->client()->createOrGetOffscreenContext3dForCompositorThread();
+ offscreenGrContext = m_layerTreeHost->client()->createOrGetOffscreenGrContextForCompositorThread();
+ }
+
// 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,
@@ -672,7 +685,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();
@@ -684,7 +697,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);
@@ -700,6 +713,10 @@ 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
@@ -1045,7 +1062,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());
@@ -1054,6 +1071,9 @@ void ThreadProxy::recreateOutputSurfaceOnImplThread(CompletionEvent* completion,
if (*recreateSucceeded) {
*capabilities = m_layerTreeHostImpl->rendererCapabilities();
m_schedulerOnImplThread->didRecreateOutputSurface();
+ m_layerTreeHostImpl->resourceProvider()->setOffscreenContexts(
+ offscreenContext3d,
+ offscreenGrContext);
}
completion->signal();
}

Powered by Google App Engine
This is Rietveld 408576698