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

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 1328001: Added command buffer implementation of WebGL which runs in the sandbox.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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: gpu/command_buffer/service/gles2_cmd_decoder.cc
===================================================================
--- gpu/command_buffer/service/gles2_cmd_decoder.cc (revision 42776)
+++ gpu/command_buffer/service/gles2_cmd_decoder.cc (working copy)
@@ -879,6 +879,8 @@
HGLRC gl_context_;
HPBUFFERARB pbuffer_;
#elif defined(OS_MACOSX)
+ CGLContextObj gl_context_;
+ CGLPBufferObj pbuffer_;
AcceleratedSurface surface_;
#endif
@@ -1157,6 +1159,9 @@
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 @@
}
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;
@@ -1664,13 +1680,50 @@
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;
@@ -1753,6 +1806,16 @@
::wglDestroyPbufferARB(pbuffer_);
pbuffer_ = NULL;
}
+#elif defined(OS_MAC)
+ if (gl_context_) {
+ CGLDestroyContext(gl_context_);
+ gl_context_ = NULL;
+ }
+
+ if (pbuffer_) {
+ CGLDestroyPBuffer(pbuffer_);
+ pbuffer_ = NULL;
+ }
#endif
}

Powered by Google App Engine
This is Rietveld 408576698