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

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: no ifdefs 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
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/renderer_webkitplatformsupport_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5329e868965ce9da799d35f8904480e6800f17a9 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()
+ : shared_context_main_thread_(this),
piman 2013/02/11 19:15:30 nit: you'll need the ALLOW_THIS_IN_INITIALIZER_LIS
danakj 2013/02/11 20:53:36 Done.
+ 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,55 @@ 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");
+ scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
piman 2013/02/11 19:15:30 use WebGraphicsContext3DCommandBufferImpl::CreateO
danakj 2013/02/11 20:53:36 Oh, nice. Done.
+ new WebGraphicsContext3DCommandBufferImpl(
+ 0,
+ url,
+ this,
+ base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>()));
+ if (!context->Initialize(
+ attributes,
+ false,
+ CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE))
+ return NULL;
+ return context.release();
+}
+
WebKit::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter(
WebKit::WebMediaStreamCenterClient* client) {
#if defined(OS_ANDROID)
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/renderer_webkitplatformsupport_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698