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

Unified Diff: cc/resource_update_controller.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: Back to a single OffscreenContext class 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/resource_update_controller.cc
diff --git a/cc/resource_update_controller.cc b/cc/resource_update_controller.cc
index d60b5bbed1ef361dd03c64fa06e53eb7be0f5a61..aaea39e789983f8184ab0823af46b0b17216e711 100644
--- a/cc/resource_update_controller.cc
+++ b/cc/resource_update_controller.cc
@@ -7,18 +7,17 @@
#include <limits>
#include "base/debug/trace_event.h"
+#include "cc/ganesh_resource_provider.h"
#include "cc/prioritized_resource.h"
#include "cc/resource_provider.h"
#include "cc/texture_copier.h"
#include "cc/thread.h"
#include "skia/ext/refptr.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebSharedGraphicsContext3D.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/skia/include/gpu/SkGpuDevice.h"
using WebKit::WebGraphicsContext3D;
-using WebKit::WebSharedGraphicsContext3D;
namespace {
@@ -67,9 +66,8 @@ size_t ResourceUpdateController::maxFullUpdatesPerTick(
return texturesPerTick ? texturesPerTick : 1;
}
-ResourceUpdateController::ResourceUpdateController(ResourceUpdateControllerClient* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourceProvider* resourceProvider, bool hasImplThread)
+ResourceUpdateController::ResourceUpdateController(ResourceUpdateControllerClient* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourceProvider* resourceProvider)
: m_client(client)
- , m_hasImplThread(hasImplThread)
, m_queue(queue.Pass())
, m_resourceProvider(resourceProvider)
, m_textureUpdatesPerTick(maxFullUpdatesPerTick(resourceProvider))
@@ -130,27 +128,25 @@ void ResourceUpdateController::updateTexture(ResourceUpdate update)
DCHECK(m_resourceProvider->resourceType(texture->resourceId()) ==
ResourceProvider::GLTexture);
- WebGraphicsContext3D* paintContext = m_hasImplThread ?
- WebSharedGraphicsContext3D::compositorThreadContext() :
- WebSharedGraphicsContext3D::mainThreadContext();
- GrContext* paintGrContext = m_hasImplThread ?
- WebSharedGraphicsContext3D::compositorThreadGrContext() :
- WebSharedGraphicsContext3D::mainThreadGrContext();
+ if (!m_resourceProvider->ganeshResourceProvider()->has_contexts())
+ return;
+
+ ResourceProvider::ScopedWriteLockGL lock(
+ m_resourceProvider, texture->resourceId());
// Flush the context in which the backing texture is created so that it
// is available in other shared contexts. It is important to do here
// because the backing texture is created in one context while it is
// being written to in another.
- ResourceProvider::ScopedWriteLockGL lock(
- m_resourceProvider, texture->resourceId());
- m_resourceProvider->flush();
+ GaneshResourceProvider::ScopedContextsFlushed offscreenContexts(
+ m_resourceProvider, m_resourceProvider->ganeshResourceProvider());
// Make sure ganesh uses the correct GL context.
- paintContext->makeContextCurrent();
+ offscreenContexts.context3d()->makeContextCurrent();
// Create an accelerated canvas to draw on.
skia::RefPtr<SkCanvas> canvas = createAcceleratedCanvas(
- paintGrContext, texture->size(), lock.textureId());
+ offscreenContexts.gr_context(), texture->size(), lock.textureId());
// The compositor expects the textures to be upside-down so it can flip
// the final composited image. Ganesh renders the image upright so we
@@ -168,14 +164,6 @@ void ResourceUpdateController::updateTexture(ResourceUpdate update)
pictureRect.x() - sourceRect.x() + destOffset.x(),
pictureRect.y() - sourceRect.y() + destOffset.y());
canvas->drawPicture(*update.picture);
-
- // Flush ganesh context so that all the rendered stuff appears on the
- // texture.
- paintGrContext->flush();
-
- // Flush the GL context so rendering results from this context are
- // visible in the compositor's context.
- paintContext->flush();
}
if (update.bitmap) {

Powered by Google App Engine
This is Rietveld 408576698