summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer
diff options
context:
space:
mode:
authorkbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-27 00:23:34 +0000
committerkbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-27 00:23:34 +0000
commit3bf4d53ecb0a07e8639b4403997cddb6869ebc61 (patch)
tree5283f1b9733ecab92f0b2875110a4194c1ee41e0 /gpu/command_buffer
parent6f4926b7834dfaf506957b02dd80e6004489824e (diff)
downloadchromium_src-3bf4d53ecb0a07e8639b4403997cddb6869ebc61.zip
chromium_src-3bf4d53ecb0a07e8639b4403997cddb6869ebc61.tar.gz
chromium_src-3bf4d53ecb0a07e8639b4403997cddb6869ebc61.tar.bz2
Added command buffer implementation of WebGL which runs in the sandbox.
Added synchronous initialization of the channel to the GPU process, needed to obey WebGL startup semantics. There are problems with this on the Windows platform which will be addressed via refactoring in the GpuProcessHost in a subsequent CL. Implemented offscreen rendering code path in GGL / GLES2CmdDecoder for Mac OS X. This new code path is not yet complete for all platforms and is still being stress tested. The previous in-process WebGL implementation is currently used when the sandbox is disabled; it will be removed in a subsequent CL. A one-line code change in WebKit is needed after this CL lands to enable the new code path. BUG=29120 TEST=ran WebGL demos on command buffer implementation on Mac Review URL: http://codereview.chromium.org/1328001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42879 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc73
1 files changed, 68 insertions, 5 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 92b1312..3bfc42b 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -879,6 +879,8 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
HGLRC gl_context_;
HPBUFFERARB pbuffer_;
#elif defined(OS_MACOSX)
+ CGLContextObj gl_context_;
+ CGLPBufferObj pbuffer_;
AcceleratedSurface surface_;
#endif
@@ -1157,6 +1159,9 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
gl_device_context_(NULL),
gl_context_(NULL),
pbuffer_(NULL),
+#elif defined(OS_MAC)
+ gl_context_(NULL),
+ pbuffer_(NULL),
#endif
anti_aliased_(false) {
}
@@ -1537,9 +1542,20 @@ bool GLES2DecoderImpl::MakeCurrent() {
}
return true;
#elif defined(OS_LINUX)
+ // TODO(apatrick): offscreen rendering not yet supported on this platform.
return window()->MakeCurrent();
#elif defined(OS_MACOSX)
- return surface_.MakeCurrent();
+ if (gl_context_) {
+ if (CGLGetCurrentContext() != gl_context_) {
+ if (CGLSetCurrentContext(gl_context_) != kCGLNoError) {
+ DLOG(ERROR) << "Unable to make gl context current.";
+ return false;
+ }
+ }
+ return true;
+ } else {
+ return surface_.MakeCurrent();
+ }
#else
NOTREACHED();
return false;
@@ -1666,13 +1682,50 @@ bool GLES2DecoderImpl::InitPlatformSpecific() {
if (!window()->Initialize())
return false;
#elif defined(OS_MACOSX)
- // TODO(apatrick): offscreen rendering not yet supported on this platform.
- DCHECK(!offscreen);
-
// TODO(apatrick): parent contexts not yet supported on this platform.
DCHECK(!parent_);
- return surface_.Initialize();
+ if (offscreen) {
+ // Create a 1x1 pbuffer and associated context to bootstrap things
+ static const CGLPixelFormatAttribute attribs[] = {
+ (CGLPixelFormatAttribute) kCGLPFAPBuffer,
+ (CGLPixelFormatAttribute) 0
+ };
+ CGLPixelFormatObj pixel_format;
+ GLint num_pixel_formats;
+ if (CGLChoosePixelFormat(attribs,
+ &pixel_format,
+ &num_pixel_formats) != kCGLNoError) {
+ DLOG(ERROR) << "Error choosing pixel format.";
+ DestroyPlatformSpecific();
+ return false;
+ }
+ if (!pixel_format) {
+ return false;
+ }
+ CGLError res = CGLCreateContext(pixel_format, 0, &gl_context_);
+ CGLDestroyPixelFormat(pixel_format);
+ if (res != kCGLNoError) {
+ DLOG(ERROR) << "Error creating context.";
+ DestroyPlatformSpecific();
+ return false;
+ }
+ if (CGLCreatePBuffer(1, 1,
+ GL_TEXTURE_2D, GL_RGBA,
+ 0, &pbuffer_) != kCGLNoError) {
+ DLOG(ERROR) << "Error creating pbuffer.";
+ DestroyPlatformSpecific();
+ return false;
+ }
+ if (CGLSetPBuffer(gl_context_, pbuffer_, 0, 0, 0) != kCGLNoError) {
+ DLOG(ERROR) << "Error attaching pbuffer to context.";
+ DestroyPlatformSpecific();
+ return false;
+ }
+ return true;
+ } else {
+ return surface_.Initialize();
+ }
#endif
return true;
@@ -1755,6 +1808,16 @@ void GLES2DecoderImpl::DestroyPlatformSpecific() {
::wglDestroyPbufferARB(pbuffer_);
pbuffer_ = NULL;
}
+#elif defined(OS_MAC)
+ if (gl_context_) {
+ CGLDestroyContext(gl_context_);
+ gl_context_ = NULL;
+ }
+
+ if (pbuffer_) {
+ CGLDestroyPBuffer(pbuffer_);
+ pbuffer_ = NULL;
+ }
#endif
}