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

Side by Side Diff: ui/gfx/gl/gl_context_linux.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_egl.cc ('k') | ui/gfx/gl/gl_context_win.cc » ('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 ViewGLContext and PbufferGLContext classes. 5 // This file implements the ViewGLContext and PbufferGLContext classes.
6 6
7 #include "ui/gfx/gl/gl_context.h" 7 #include "ui/gfx/gl/gl_context.h"
8 8
9 extern "C" { 9 extern "C" {
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
11 } 11 }
12 12
13 #include <GL/osmesa.h> 13 #include <GL/osmesa.h>
14 14
15 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "ui/base/x/x11_util.h" 18 #include "ui/base/x/x11_util.h"
19 #include "ui/gfx/gl/gl_bindings.h" 19 #include "ui/gfx/gl/gl_bindings.h"
20 #include "ui/gfx/gl/gl_context_egl.h" 20 #include "ui/gfx/gl/gl_context_egl.h"
21 #include "ui/gfx/gl/gl_context_osmesa.h" 21 #include "ui/gfx/gl/gl_context_osmesa.h"
22 #include "ui/gfx/gl/gl_context_stub.h" 22 #include "ui/gfx/gl/gl_context_stub.h"
23 #include "ui/gfx/gl/gl_implementation.h" 23 #include "ui/gfx/gl/gl_implementation.h"
24 #include "ui/gfx/gl/gl_surface_egl.h"
24 25
25 namespace { 26 namespace {
26 27
27 Display* GetXDisplayHelper() { 28 Display* GetXDisplayHelper() {
28 static Display* display = NULL; 29 static Display* display = NULL;
29 30
30 if (!display) { 31 if (!display) {
31 display = XOpenDisplay(NULL); 32 display = XOpenDisplay(NULL);
32 CHECK(display); 33 CHECK(display);
33 } 34 }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 return false; 211 return false;
211 } 212 }
212 213
213 if (major == 1 && minor < 3) { 214 if (major == 1 && minor < 3) {
214 LOG(WARNING) << "GLX 1.3 or later is recommended."; 215 LOG(WARNING) << "GLX 1.3 or later is recommended.";
215 } 216 }
216 217
217 break; 218 break;
218 } 219 }
219 case kGLImplementationEGLGLES2: 220 case kGLImplementationEGLGLES2:
220 if (!BaseEGLContext::InitializeOneOff()) { 221 if (!GLSurfaceEGL::InitializeOneOff()) {
221 LOG(ERROR) << "BaseEGLContext::InitializeOneOff failed."; 222 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
222 return false; 223 return false;
223 } 224 }
224 break; 225 break;
225 default: 226 default:
226 break; 227 break;
227 } 228 }
228 229
229 initialized = true; 230 initialized = true;
230 return true; 231 return true;
231 } 232 }
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 switch (GetGLImplementation()) { 509 switch (GetGLImplementation()) {
509 case kGLImplementationDesktopGL: { 510 case kGLImplementationDesktopGL: {
510 scoped_ptr<ViewGLContext> context(new ViewGLContext(window)); 511 scoped_ptr<ViewGLContext> context(new ViewGLContext(window));
511 512
512 if (!context->Initialize(multisampled)) 513 if (!context->Initialize(multisampled))
513 return NULL; 514 return NULL;
514 515
515 return context.release(); 516 return context.release();
516 } 517 }
517 case kGLImplementationEGLGLES2: { 518 case kGLImplementationEGLGLES2: {
518 scoped_ptr<NativeViewEGLContext> context( 519 scoped_ptr<NativeViewGLSurfaceEGL> surface(new NativeViewGLSurfaceEGL(
519 new NativeViewEGLContext(reinterpret_cast<void *>(window))); 520 reinterpret_cast<void*>(window)));
520 if (!context->Initialize()) 521 if (!surface->Initialize())
522 return NULL;
523
524 scoped_ptr<GLContextEGL> context(
525 new GLContextEGL(surface.release()));
526 if (!context->Initialize(NULL))
521 return NULL; 527 return NULL;
522 528
523 return context.release(); 529 return context.release();
524 } 530 }
525 case kGLImplementationOSMesaGL: { 531 case kGLImplementationOSMesaGL: {
526 scoped_ptr<OSMesaViewGLContext> context(new OSMesaViewGLContext(window)); 532 scoped_ptr<OSMesaViewGLContext> context(new OSMesaViewGLContext(window));
527 533
528 if (!context->Initialize()) 534 if (!context->Initialize())
529 return NULL; 535 return NULL;
530 536
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 if (context->Initialize(shared_context)) 804 if (context->Initialize(shared_context))
799 return context.release(); 805 return context.release();
800 806
801 scoped_ptr<PixmapGLContext> context_pixmap(new PixmapGLContext); 807 scoped_ptr<PixmapGLContext> context_pixmap(new PixmapGLContext);
802 if (context_pixmap->Initialize(shared_context)) 808 if (context_pixmap->Initialize(shared_context))
803 return context_pixmap.release(); 809 return context_pixmap.release();
804 810
805 return NULL; 811 return NULL;
806 } 812 }
807 case kGLImplementationEGLGLES2: { 813 case kGLImplementationEGLGLES2: {
808 scoped_ptr<SecondaryEGLContext> context( 814 scoped_ptr<PbufferGLSurfaceEGL> surface(new PbufferGLSurfaceEGL(
809 new SecondaryEGLContext()); 815 gfx::Size(1, 1)));
816 if (!surface->Initialize())
817 return NULL;
818
819 scoped_ptr<GLContextEGL> context(new GLContextEGL(surface.release()));
810 if (!context->Initialize(shared_context)) 820 if (!context->Initialize(shared_context))
811 return NULL; 821 return NULL;
812 822
813 return context.release(); 823 return context.release();
814 } 824 }
815 case kGLImplementationOSMesaGL: { 825 case kGLImplementationOSMesaGL: {
816 scoped_ptr<OSMesaGLContext> context(new OSMesaGLContext); 826 scoped_ptr<OSMesaGLContext> context(new OSMesaGLContext);
817 if (!context->Initialize(OSMESA_RGBA, shared_context)) 827 if (!context->Initialize(OSMESA_RGBA, shared_context))
818 return NULL; 828 return NULL;
819 829
820 return context.release(); 830 return context.release();
821 } 831 }
822 case kGLImplementationMockGL: 832 case kGLImplementationMockGL:
823 return new StubGLContext; 833 return new StubGLContext;
824 default: 834 default:
825 NOTREACHED(); 835 NOTREACHED();
826 return NULL; 836 return NULL;
827 } 837 }
828 } 838 }
829 839
830 } // namespace gfx 840 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/gl/gl_context_egl.cc ('k') | ui/gfx/gl/gl_context_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698