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

Side by Side Diff: src/gpu/gl/angle/SkANGLEGLContext.cpp

Issue 1338003002: skia: Add ANGLE with GL backend to nanobench/DM (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove PictureRenderer changes Created 5 years, 3 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
« no previous file with comments | « src/gpu/GrContextFactory.cpp ('k') | src/views/win/SkOSWindow_win.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "gl/angle/SkANGLEGLContext.h" 9 #include "gl/angle/SkANGLEGLContext.h"
10 10
11 #include <EGL/egl.h> 11 #include <EGL/egl.h>
12 #include <EGL/eglext.h> 12 #include <EGL/eglext.h>
13 13
14 #define EGL_PLATFORM_ANGLE_ANGLE 0x3202 14 #define EGL_PLATFORM_ANGLE_ANGLE 0x3202
15 #define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 15 #define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
16 #define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207 16 #define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207
17 #define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208 17 #define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
18 #define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D
18 19
19 void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay) { 20 void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend) {
20 PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT; 21 PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT;
21 eglGetPlatformDisplayEXT = 22 eglGetPlatformDisplayEXT =
22 (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDispla yEXT"); 23 (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDispla yEXT");
23 24
24 if (!eglGetPlatformDisplayEXT) { 25 if (!eglGetPlatformDisplayEXT) {
25 return eglGetDisplay(static_cast<EGLNativeDisplayType>(nativeDisplay)); 26 return eglGetDisplay(static_cast<EGLNativeDisplayType>(nativeDisplay));
26 } 27 }
27 28
28 // Try for an ANGLE D3D11 context, fall back to D3D9. 29 EGLDisplay display = EGL_NO_DISPLAY;
29 EGLint attribs[2][3] = { 30 if (useGLBackend) {
30 { 31 // Try for an ANGLE D3D11 context, fall back to D3D9.
31 EGL_PLATFORM_ANGLE_TYPE_ANGLE, 32 EGLint attribs[3] = {
32 EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, 33 EGL_PLATFORM_ANGLE_TYPE_ANGLE,
33 EGL_NONE 34 EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE,
34 }, 35 EGL_NONE
35 { 36 };
36 EGL_PLATFORM_ANGLE_TYPE_ANGLE, 37 display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
37 EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, 38 nativeDisplay, attribs);
38 EGL_NONE 39 } else {
40 // Try for an ANGLE D3D11 context, fall back to D3D9, and finally GL.
41 EGLint attribs[3][3] = {
42 {
43 EGL_PLATFORM_ANGLE_TYPE_ANGLE,
44 EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
45 EGL_NONE
46 },
47 {
48 EGL_PLATFORM_ANGLE_TYPE_ANGLE,
49 EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE,
50 EGL_NONE
51 },
52 {
53 EGL_PLATFORM_ANGLE_TYPE_ANGLE,
54 EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE,
55 EGL_NONE
56 }
57 };
58 for (int i = 0; i < 3 && display == EGL_NO_DISPLAY; ++i) {
59 display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
60 nativeDisplay, attribs[i]);
39 } 61 }
40 };
41
42 EGLDisplay display = EGL_NO_DISPLAY;
43 for (int i = 0; i < 2 && display == EGL_NO_DISPLAY; ++i) {
44 display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
45 nativeDisplay, attribs[i]);
46 } 62 }
47 return display; 63 return display;
48 } 64 }
49 65
50 SkANGLEGLContext::SkANGLEGLContext() 66 SkANGLEGLContext::SkANGLEGLContext(bool useGLBackend)
51 : fContext(EGL_NO_CONTEXT) 67 : fContext(EGL_NO_CONTEXT)
52 , fDisplay(EGL_NO_DISPLAY) 68 , fDisplay(EGL_NO_DISPLAY)
53 , fSurface(EGL_NO_SURFACE) { 69 , fSurface(EGL_NO_SURFACE) {
54 70
55 EGLint numConfigs; 71 EGLint numConfigs;
56 static const EGLint configAttribs[] = { 72 static const EGLint configAttribs[] = {
57 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, 73 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
58 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 74 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
59 EGL_RED_SIZE, 8, 75 EGL_RED_SIZE, 8,
60 EGL_GREEN_SIZE, 8, 76 EGL_GREEN_SIZE, 8,
61 EGL_BLUE_SIZE, 8, 77 EGL_BLUE_SIZE, 8,
62 EGL_ALPHA_SIZE, 8, 78 EGL_ALPHA_SIZE, 8,
63 EGL_NONE 79 EGL_NONE
64 }; 80 };
65 81
66 fDisplay = GetD3DEGLDisplay(EGL_DEFAULT_DISPLAY); 82 fDisplay = GetD3DEGLDisplay(EGL_DEFAULT_DISPLAY, useGLBackend);
67 if (EGL_NO_DISPLAY == fDisplay) { 83 if (EGL_NO_DISPLAY == fDisplay) {
68 SkDebugf("Could not create EGL display!"); 84 SkDebugf("Could not create EGL display!");
69 return; 85 return;
70 } 86 }
71 87
72 EGLint majorVersion; 88 EGLint majorVersion;
73 EGLint minorVersion; 89 EGLint minorVersion;
74 eglInitialize(fDisplay, &majorVersion, &minorVersion); 90 eglInitialize(fDisplay, &majorVersion, &minorVersion);
75 91
76 EGLConfig surfaceConfig; 92 EGLConfig surfaceConfig;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 156
141 void SkANGLEGLContext::onPlatformSwapBuffers() const { 157 void SkANGLEGLContext::onPlatformSwapBuffers() const {
142 if (!eglSwapBuffers(fDisplay, fSurface)) { 158 if (!eglSwapBuffers(fDisplay, fSurface)) {
143 SkDebugf("Could not complete eglSwapBuffers.\n"); 159 SkDebugf("Could not complete eglSwapBuffers.\n");
144 } 160 }
145 } 161 }
146 162
147 GrGLFuncPtr SkANGLEGLContext::onPlatformGetProcAddress(const char* name) const { 163 GrGLFuncPtr SkANGLEGLContext::onPlatformGetProcAddress(const char* name) const {
148 return eglGetProcAddress(name); 164 return eglGetProcAddress(name);
149 } 165 }
OLDNEW
« no previous file with comments | « src/gpu/GrContextFactory.cpp ('k') | src/views/win/SkOSWindow_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698