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

Unified Diff: content/renderer/render_thread_impl.cc

Issue 12212100: Provide shared context to Platform API in renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CreateOffscreenContext() 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: content/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 975e13ec35cacd44864906732b0242d882a1e803..def32598ab7c67ac764c96982393041406a6139b 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -14,6 +14,7 @@
#include "base/debug/trace_event.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
+#include "base/memory/weak_ptr.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/metrics/stats_table.h"
@@ -98,6 +99,7 @@
#include "ui/base/ui_base_switches.h"
#include "v8/include/v8.h"
#include "webkit/glue/webkit_glue.h"
+#include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
#if defined(OS_WIN)
#include <windows.h>
@@ -281,12 +283,16 @@ RenderThreadImpl* RenderThreadImpl::current() {
// When we run plugins in process, we actually run them on the render thread,
// which means that we need to make the render thread pump UI events.
-RenderThreadImpl::RenderThreadImpl() {
+RenderThreadImpl::RenderThreadImpl()
+ : ALLOW_THIS_IN_INITIALIZER_LIST(shared_context_main_thread_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(shared_context_compositor_thread_(this)) {
Init();
}
RenderThreadImpl::RenderThreadImpl(const std::string& channel_name)
- : ChildThread(channel_name) {
+ : ChildThread(channel_name),
+ shared_context_main_thread_(this),
+ shared_context_compositor_thread_(this) {
Init();
}
@@ -1124,6 +1130,45 @@ GpuChannelHost* RenderThreadImpl::EstablishGpuChannelSync(
return GetGpuChannel();
}
+WebKit::WebGraphicsContext3D* RenderThreadImpl::
+ OffscreenContext3dForMainThread() {
+ DCHECK(IsMainThread());
+ return shared_context_main_thread_.Context3d();
+}
+WebKit::WebGraphicsContext3D* RenderThreadImpl::
+ OffscreenContext3dForCompositorThread() {
+ DCHECK(IsMainThread());
+ return shared_context_compositor_thread_.Context3d();
+}
+
+GrContext* RenderThreadImpl::OffscreenGrContextForMainThread() {
+ DCHECK(IsMainThread());
+ return shared_context_main_thread_.GrContext();
+}
+
+GrContext* RenderThreadImpl::OffscreenGrContextForCompositorThread() {
+ DCHECK(IsMainThread());
+ return shared_context_compositor_thread_.GrContext();
+}
+
+WebKit::WebGraphicsContext3D* RenderThreadImpl::CreateOffscreenContext() {
+ WebKit::WebGraphicsContext3D::Attributes attributes;
+ attributes.shareResources = true;
+ attributes.depth = false;
+ attributes.stencil = false;
+ attributes.antialias = false;
+ attributes.noAutomaticFlushes = true;
+
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) {
+ return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView(
+ attributes, false);
+ }
+
+ GURL url("chrome://gpu/RenderThreadImpl::CreateOffscreenContext");
+ return WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
+ this, attributes, url);
+}
+
WebKit::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter(
WebKit::WebMediaStreamCenterClient* client) {
#if defined(OS_ANDROID)

Powered by Google App Engine
This is Rietveld 408576698