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

Side by Side Diff: ui/gfx/gl/gl_context_win.cc

Issue 6839008: Split EGLContext in GLContextEGL and GLSurfaceEGL. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/gl/gl_context_linux.cc ('k') | ui/gfx/gl/gl_surface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file implements the NativeViewGLContext and PbufferGLContext classes. 5 // This file implements the NativeViewGLContext and PbufferGLContext classes.
6 6
7 #include "ui/gfx/gl/gl_context.h" 7 #include "ui/gfx/gl/gl_context.h"
8 8
9 #include <GL/osmesa.h> 9 #include <GL/osmesa.h>
10 10
11 #include <algorithm> 11 #include <algorithm>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "ui/gfx/gl/gl_bindings.h" 15 #include "ui/gfx/gl/gl_bindings.h"
16 #include "ui/gfx/gl/gl_context_egl.h" 16 #include "ui/gfx/gl/gl_context_egl.h"
17 #include "ui/gfx/gl/gl_context_osmesa.h" 17 #include "ui/gfx/gl/gl_context_osmesa.h"
18 #include "ui/gfx/gl/gl_context_stub.h" 18 #include "ui/gfx/gl/gl_context_stub.h"
19 #include "ui/gfx/gl/gl_implementation.h" 19 #include "ui/gfx/gl/gl_implementation.h"
20 #include "ui/gfx/gl/gl_surface_egl.h"
20 21
21 namespace gfx { 22 namespace gfx {
22 23
23 typedef HGLRC GLContextHandle; 24 typedef HGLRC GLContextHandle;
24 typedef HPBUFFERARB PbufferHandle; 25 typedef HPBUFFERARB PbufferHandle;
25 26
26 class BaseWinGLContext : public GLContext { 27 class BaseWinGLContext : public GLContext {
27 public: 28 public:
28 virtual std::string GetExtensions(); 29 virtual std::string GetExtensions();
29 30
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 HDC device_context_; 126 HDC device_context_;
126 PbufferHandle pbuffer_; 127 PbufferHandle pbuffer_;
127 128
128 DISALLOW_COPY_AND_ASSIGN(PbufferGLContext); 129 DISALLOW_COPY_AND_ASSIGN(PbufferGLContext);
129 }; 130 };
130 131
131 static HWND g_window; 132 static HWND g_window;
132 static int g_regular_pixel_format = 0; 133 static int g_regular_pixel_format = 0;
133 static int g_multisampled_pixel_format = 0; 134 static int g_multisampled_pixel_format = 0;
134 135
135 // When using ANGLE we still need a window for D3D. This context creates the
136 // D3D device.
137 static BaseEGLContext* g_default_context;
138
139 const PIXELFORMATDESCRIPTOR kPixelFormatDescriptor = { 136 const PIXELFORMATDESCRIPTOR kPixelFormatDescriptor = {
140 sizeof(kPixelFormatDescriptor), // Size of structure. 137 sizeof(kPixelFormatDescriptor), // Size of structure.
141 1, // Default version. 138 1, // Default version.
142 PFD_DRAW_TO_WINDOW | // Window drawing support. 139 PFD_DRAW_TO_WINDOW | // Window drawing support.
143 PFD_SUPPORT_OPENGL | // OpenGL support. 140 PFD_SUPPORT_OPENGL | // OpenGL support.
144 PFD_DOUBLEBUFFER, // Double buffering support (not stereo). 141 PFD_DOUBLEBUFFER, // Double buffering support (not stereo).
145 PFD_TYPE_RGBA, // RGBA color mode (not indexed). 142 PFD_TYPE_RGBA, // RGBA color mode (not indexed).
146 24, // 24 bit color mode. 143 24, // 24 bit color mode.
147 0, 0, 0, 0, 0, 0, // Don't set RGB bits & shifts. 144 0, 0, 0, 0, 0, 0, // Don't set RGB bits & shifts.
148 8, 0, // 8 bit alpha 145 8, 0, // 8 bit alpha
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 303 }
307 304
308 wglMakeCurrent(intermediate_dc, NULL); 305 wglMakeCurrent(intermediate_dc, NULL);
309 wglDeleteContext(gl_context); 306 wglDeleteContext(gl_context);
310 ReleaseDC(g_window, intermediate_dc); 307 ReleaseDC(g_window, intermediate_dc);
311 UnregisterClass(reinterpret_cast<wchar_t*>(class_registration), 308 UnregisterClass(reinterpret_cast<wchar_t*>(class_registration),
312 module_handle); 309 module_handle);
313 break; 310 break;
314 } 311 }
315 case kGLImplementationEGLGLES2: 312 case kGLImplementationEGLGLES2:
316 if (!BaseEGLContext::InitializeOneOff()) { 313 if (!GLSurfaceEGL::InitializeOneOff()) {
317 LOG(ERROR) << "BaseEGLContext::InitializeOneOff failed."; 314 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
318 return false; 315 return false;
319 } 316 }
320 break; 317 break;
321 } 318 }
322 319
323 initialized = true; 320 initialized = true;
324 return true; 321 return true;
325 } 322 }
326 323
327 324
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 bool multisampled) { 541 bool multisampled) {
545 switch (GetGLImplementation()) { 542 switch (GetGLImplementation()) {
546 case kGLImplementationOSMesaGL: { 543 case kGLImplementationOSMesaGL: {
547 scoped_ptr<OSMesaViewGLContext> context(new OSMesaViewGLContext(window)); 544 scoped_ptr<OSMesaViewGLContext> context(new OSMesaViewGLContext(window));
548 if (!context->Initialize()) 545 if (!context->Initialize())
549 return NULL; 546 return NULL;
550 547
551 return context.release(); 548 return context.release();
552 } 549 }
553 case kGLImplementationEGLGLES2: { 550 case kGLImplementationEGLGLES2: {
554 scoped_ptr<NativeViewEGLContext> context( 551 scoped_ptr<NativeViewGLSurfaceEGL> surface(new NativeViewGLSurfaceEGL(
555 new NativeViewEGLContext(window)); 552 window));
556 if (!context->Initialize()) 553 if (!surface->Initialize())
554 return NULL;
555
556 scoped_ptr<GLContextEGL> context(
557 new GLContextEGL(surface.release()));
558 if (!context->Initialize(NULL))
557 return NULL; 559 return NULL;
558 560
559 return context.release(); 561 return context.release();
560 } 562 }
561 case kGLImplementationDesktopGL: { 563 case kGLImplementationDesktopGL: {
562 scoped_ptr<NativeViewGLContext> context(new NativeViewGLContext(window)); 564 scoped_ptr<NativeViewGLContext> context(new NativeViewGLContext(window));
563 if (!context->Initialize(multisampled)) 565 if (!context->Initialize(multisampled))
564 return NULL; 566 return NULL;
565 567
566 return context.release(); 568 return context.release();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 GLContext* GLContext::CreateOffscreenGLContext(GLContext* shared_context) { 701 GLContext* GLContext::CreateOffscreenGLContext(GLContext* shared_context) {
700 switch (GetGLImplementation()) { 702 switch (GetGLImplementation()) {
701 case kGLImplementationOSMesaGL: { 703 case kGLImplementationOSMesaGL: {
702 scoped_ptr<OSMesaGLContext> context(new OSMesaGLContext); 704 scoped_ptr<OSMesaGLContext> context(new OSMesaGLContext);
703 if (!context->Initialize(OSMESA_RGBA, shared_context)) 705 if (!context->Initialize(OSMESA_RGBA, shared_context))
704 return NULL; 706 return NULL;
705 707
706 return context.release(); 708 return context.release();
707 } 709 }
708 case kGLImplementationEGLGLES2: { 710 case kGLImplementationEGLGLES2: {
709 if (!shared_context) { 711 scoped_ptr<PbufferGLSurfaceEGL> surface(new PbufferGLSurfaceEGL(
710 if (!g_default_context) { 712 gfx::Size(1, 1)));
711 scoped_ptr<NativeViewEGLContext> default_context( 713 if (!surface->Initialize())
712 new NativeViewEGLContext(g_window)); 714 return NULL;
713 if (!default_context->Initialize())
714 return NULL;
715 715
716 g_default_context = default_context.release(); 716 scoped_ptr<GLContextEGL> context(new GLContextEGL(surface.release()));
717 }
718 shared_context = g_default_context;
719 }
720
721 scoped_ptr<SecondaryEGLContext> context(
722 new SecondaryEGLContext());
723 if (!context->Initialize(shared_context)) 717 if (!context->Initialize(shared_context))
724 return NULL; 718 return NULL;
725 719
726 return context.release(); 720 return context.release();
727 } 721 }
728 case kGLImplementationDesktopGL: { 722 case kGLImplementationDesktopGL: {
729 scoped_ptr<PbufferGLContext> context(new PbufferGLContext); 723 scoped_ptr<PbufferGLContext> context(new PbufferGLContext);
730 if (!context->Initialize(shared_context)) 724 if (!context->Initialize(shared_context))
731 return NULL; 725 return NULL;
732 726
733 return context.release(); 727 return context.release();
734 } 728 }
735 case kGLImplementationMockGL: 729 case kGLImplementationMockGL:
736 return new StubGLContext; 730 return new StubGLContext;
737 default: 731 default:
738 NOTREACHED(); 732 NOTREACHED();
739 return NULL; 733 return NULL;
740 } 734 }
741 } 735 }
742 736
743 } // namespace gfx 737 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/gl/gl_context_linux.cc ('k') | ui/gfx/gl/gl_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698