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

Side by Side Diff: ui/gl/gl_surface_win.cc

Issue 196403008: gl: Move platform-specific EGL code into separate files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ui/gl/gl_surface.h" 5 #include "ui/gl/gl_surface.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/win/windows_version.h" 12 #include "base/win/windows_version.h"
13 #include "third_party/mesa/src/include/GL/osmesa.h" 13 #include "third_party/mesa/src/include/GL/osmesa.h"
14 #include "ui/gfx/frame_time.h" 14 #include "ui/gfx/frame_time.h"
15 #include "ui/gfx/native_widget_types.h" 15 #include "ui/gfx/native_widget_types.h"
16 #include "ui/gl/gl_bindings.h" 16 #include "ui/gl/gl_bindings.h"
17 #include "ui/gl/gl_implementation.h" 17 #include "ui/gl/gl_implementation.h"
18 #include "ui/gl/gl_surface_egl.h" 18 #include "ui/gl/gl_surface_egl.h"
19 #include "ui/gl/gl_surface_osmesa.h" 19 #include "ui/gl/gl_surface_osmesa.h"
20 #include "ui/gl/gl_surface_stub.h" 20 #include "ui/gl/gl_surface_stub.h"
21 #include "ui/gl/gl_surface_wgl.h" 21 #include "ui/gl/gl_surface_wgl.h"
22 22
23 // From ANGLE's egl/eglext.h.
24 #if !defined(EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE)
25 #define EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE \
26 reinterpret_cast<EGLNativeDisplayType>(-2)
27 #endif
28
23 namespace gfx { 29 namespace gfx {
24 30
31 namespace {
32
33 EGLNativeDisplayType GetEGLDisplay() {
34 EGLNativeDisplayType_native_display = EGL_DEFAULT_DISPLAY;
35 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableD3D11) &&
36 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableD3D11)) {
37 native_display = EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE;
38 }
39
40 return native_display;
41 }
42
25 // This OSMesa GL surface can use GDI to swap the contents of the buffer to a 43 // This OSMesa GL surface can use GDI to swap the contents of the buffer to a
26 // view. 44 // view.
27 class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa { 45 class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa {
28 public: 46 public:
29 explicit NativeViewGLSurfaceOSMesa(gfx::AcceleratedWidget window); 47 explicit NativeViewGLSurfaceOSMesa(gfx::AcceleratedWidget window);
30 virtual ~NativeViewGLSurfaceOSMesa(); 48 virtual ~NativeViewGLSurfaceOSMesa();
31 49
32 // Implement subset of GLSurface. 50 // Implement subset of GLSurface.
33 virtual bool Initialize() OVERRIDE; 51 virtual bool Initialize() OVERRIDE;
34 virtual void Destroy() OVERRIDE; 52 virtual void Destroy() OVERRIDE;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // pixel format. 105 // pixel format.
88 bool GLSurface::InitializeOneOffInternal() { 106 bool GLSurface::InitializeOneOffInternal() {
89 switch (GetGLImplementation()) { 107 switch (GetGLImplementation()) {
90 case kGLImplementationDesktopGL: 108 case kGLImplementationDesktopGL:
91 if (!GLSurfaceWGL::InitializeOneOff()) { 109 if (!GLSurfaceWGL::InitializeOneOff()) {
92 LOG(ERROR) << "GLSurfaceWGL::InitializeOneOff failed."; 110 LOG(ERROR) << "GLSurfaceWGL::InitializeOneOff failed.";
93 return false; 111 return false;
94 } 112 }
95 break; 113 break;
96 case kGLImplementationEGLGLES2: 114 case kGLImplementationEGLGLES2:
97 if (!GLSurfaceEGL::InitializeOneOff()) { 115 if (!GLSurfaceEGL::InitializeOneOff(GetEGLDisplay())) {
98 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; 116 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
99 return false; 117 return false;
100 } 118 }
101 break; 119 break;
102 } 120 }
103 return true; 121 return true;
104 } 122 }
105 123
106 NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa( 124 NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa(
107 gfx::AcceleratedWidget window) 125 gfx::AcceleratedWidget window)
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 302 }
285 case kGLImplementationMockGL: 303 case kGLImplementationMockGL:
286 return new GLSurfaceStub; 304 return new GLSurfaceStub;
287 default: 305 default:
288 NOTREACHED(); 306 NOTREACHED();
289 return NULL; 307 return NULL;
290 } 308 }
291 } 309 }
292 310
293 } // namespace gfx 311 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698