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

Unified Diff: webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.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: Fix typo 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: webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc
diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc b/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc
index bc19555b6a94e88083db3573c5c6c1247277cb8e..5dd58feeee7903744b080ae17009f12b2e43cd2e 100644
--- a/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc
+++ b/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc
@@ -6,6 +6,8 @@
#include "base/command_line.h"
#include "base/string_number_conversions.h"
+#include "base/synchronization/lock.h"
+#include "cc/context_provider.h"
#include "cc/fake_web_graphics_context_3d.h"
#include "cc/input_handler.h"
#include "cc/layer.h"
@@ -21,6 +23,7 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewClient.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebSharedGraphicsContext3D.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
#include "webkit/compositor_bindings/web_compositor_support_impl.h"
#include "webkit/compositor_bindings/web_compositor_support_software_output_device.h"
@@ -222,4 +225,77 @@ void WebLayerTreeViewImplForTesting::scheduleComposite() {
client_->scheduleComposite();
}
+class WebLayerTreeViewImplForTesting::MainThreadContextProvider
+ : public cc::ContextProvider {
+ public:
+ virtual bool InitializeOnMainThread() OVERRIDE { return true; }
+ virtual bool BindToCurrentThread() OVERRIDE { return true; }
+
+ virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE {
+ return WebSharedGraphicsContext3D::mainThreadContext();
+ }
+ virtual class GrContext* GrContext() OVERRIDE {
+ return WebSharedGraphicsContext3D::mainThreadGrContext();
+ }
+
+ virtual void VerifyContexts() OVERRIDE {}
+
+ protected:
+ virtual ~MainThreadContextProvider() {}
+};
+
+scoped_refptr<cc::ContextProvider>
+WebLayerTreeViewImplForTesting::OffscreenContextProviderForMainThread() {
+ if (!contexts_main_thread_)
+ contexts_main_thread_ = new MainThreadContextProvider;
+ return contexts_main_thread_;
+}
+
+class WebLayerTreeViewImplForTesting::CompositorThreadContextProvider
+ : public cc::ContextProvider {
+ public:
+ CompositorThreadContextProvider() : destroyed_(false) {}
+
+ virtual bool InitializeOnMainThread() OVERRIDE {
+ return WebSharedGraphicsContext3D::createCompositorThreadContext();
+ }
+ virtual bool BindToCurrentThread() OVERRIDE {
+ return Context3d()->makeContextCurrent();
+ }
+
+ virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE {
+ return WebSharedGraphicsContext3D::compositorThreadContext();
+ }
+ virtual class GrContext* GrContext() OVERRIDE {
+ return WebSharedGraphicsContext3D::compositorThreadGrContext();
+ }
+
+ virtual void VerifyContexts() OVERRIDE {
+ if (Context3d() && !Context3d()->isContextLost())
+ return;
+ base::AutoLock lock(destroyed_lock_);
+ destroyed_ = true;
+ }
+
+ bool DestroyedOnMainThread() {
+ base::AutoLock lock(destroyed_lock_);
+ return destroyed_;
+ }
+
+ protected:
+ virtual ~CompositorThreadContextProvider() {}
+
+ private:
+ base::Lock destroyed_lock_;
+ bool destroyed_;
+};
+
+scoped_refptr<cc::ContextProvider>
+WebLayerTreeViewImplForTesting::OffscreenContextProviderForCompositorThread() {
+ if (!contexts_compositor_thread_ ||
+ contexts_compositor_thread_->DestroyedOnMainThread())
+ contexts_compositor_thread_ = new CompositorThreadContextProvider;
+ return contexts_compositor_thread_;
+}
+
} // namespace WebKit

Powered by Google App Engine
This is Rietveld 408576698