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

Side by Side Diff: src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp

Issue 1684413003: Implement support for using GL ES 3.0 with command buffer (Closed) Base URL: https://skia.googlesource.com/skia.git@no-texture-rectangle-gles
Patch Set: Created 4 years, 10 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 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 #include "SkOnce.h" 8 #include "SkOnce.h"
9 #include "gl/GrGLInterface.h" 9 #include "gl/GrGLInterface.h"
10 #include "gl/GrGLAssembleInterface.h" 10 #include "gl/GrGLAssembleInterface.h"
(...skipping 15 matching lines...) Expand all
26 typedef void (*__eglMustCastToProperFunctionPointerType)(void); 26 typedef void (*__eglMustCastToProperFunctionPointerType)(void);
27 #define EGL_FALSE 0 27 #define EGL_FALSE 0
28 #define EGL_OPENGL_ES2_BIT 0x0004 28 #define EGL_OPENGL_ES2_BIT 0x0004
29 #define EGL_CONTEXT_CLIENT_VERSION 0x3098 29 #define EGL_CONTEXT_CLIENT_VERSION 0x3098
30 #define EGL_NO_SURFACE ((EGLSurface)0) 30 #define EGL_NO_SURFACE ((EGLSurface)0)
31 #define EGL_NO_DISPLAY ((EGLDisplay)0) 31 #define EGL_NO_DISPLAY ((EGLDisplay)0)
32 #define EGL_NO_CONTEXT ((EGLContext)0) 32 #define EGL_NO_CONTEXT ((EGLContext)0)
33 #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) 33 #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
34 #define EGL_SURFACE_TYPE 0x3033 34 #define EGL_SURFACE_TYPE 0x3033
35 #define EGL_PBUFFER_BIT 0x0001 35 #define EGL_PBUFFER_BIT 0x0001
36 #define EGL_WINDOW_BIT 0x0004
36 #define EGL_RENDERABLE_TYPE 0x3040 37 #define EGL_RENDERABLE_TYPE 0x3040
37 #define EGL_RED_SIZE 0x3024 38 #define EGL_RED_SIZE 0x3024
38 #define EGL_GREEN_SIZE 0x3023 39 #define EGL_GREEN_SIZE 0x3023
39 #define EGL_BLUE_SIZE 0x3022 40 #define EGL_BLUE_SIZE 0x3022
40 #define EGL_ALPHA_SIZE 0x3021 41 #define EGL_ALPHA_SIZE 0x3021
41 #define EGL_DEPTH_SIZE 0x3025 42 #define EGL_DEPTH_SIZE 0x3025
42 #define EGL_STENCIL_SIZE 0x3025 43 #define EGL_STENCIL_SIZE 0x3025
43 #define EGL_SAMPLES 0x3031 44 #define EGL_SAMPLES 0x3031
44 #define EGL_SAMPLE_BUFFERS 0x3032 45 #define EGL_SAMPLE_BUFFERS 0x3032
45 #define EGL_NONE 0x3038 46 #define EGL_NONE 0x3038
46 #define EGL_WIDTH 0x3057 47 #define EGL_WIDTH 0x3057
47 #define EGL_HEIGHT 0x3056 48 #define EGL_HEIGHT 0x3056
48 49
49 #else 50 #else
50 51
51 #include <EGL/egl.h> 52 #include <EGL/egl.h>
52 53
53 #endif 54 #endif
54 55
56 #ifndef EGL_OPENGL_ES3_BIT
57 // Part of EGL 1.5, typical headers are 1.4.
58 #define EGL_OPENGL_ES3_BIT 0x0040
59 #endif
60
55 typedef EGLDisplay (*GetDisplayProc)(EGLNativeDisplayType display_id); 61 typedef EGLDisplay (*GetDisplayProc)(EGLNativeDisplayType display_id);
56 typedef EGLBoolean (*InitializeProc)(EGLDisplay dpy, EGLint *major, EGLint *mino r); 62 typedef EGLBoolean (*InitializeProc)(EGLDisplay dpy, EGLint *major, EGLint *mino r);
57 typedef EGLBoolean (*TerminateProc)(EGLDisplay dpy); 63 typedef EGLBoolean (*TerminateProc)(EGLDisplay dpy);
58 typedef EGLBoolean (*ChooseConfigProc)(EGLDisplay dpy, const EGLint* attrib_list , EGLConfig* configs, EGLint config_size, EGLint* num_config); 64 typedef EGLBoolean (*ChooseConfigProc)(EGLDisplay dpy, const EGLint* attrib_list , EGLConfig* configs, EGLint config_size, EGLint* num_config);
59 typedef EGLBoolean (*GetConfigAttrib)(EGLDisplay dpy, EGLConfig config, EGLint a ttribute, EGLint* value); 65 typedef EGLBoolean (*GetConfigAttrib)(EGLDisplay dpy, EGLConfig config, EGLint a ttribute, EGLint* value);
60 typedef EGLSurface (*CreateWindowSurfaceProc)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list); 66 typedef EGLSurface (*CreateWindowSurfaceProc)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list);
61 typedef EGLSurface (*CreatePbufferSurfaceProc)(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list); 67 typedef EGLSurface (*CreatePbufferSurfaceProc)(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list);
62 typedef EGLBoolean (*DestroySurfaceProc)(EGLDisplay dpy, EGLSurface surface); 68 typedef EGLBoolean (*DestroySurfaceProc)(EGLDisplay dpy, EGLSurface surface);
63 typedef EGLContext (*CreateContextProc)(EGLDisplay dpy, EGLConfig config, EGLCon text share_context, const EGLint* attrib_list); 69 typedef EGLContext (*CreateContextProc)(EGLDisplay dpy, EGLConfig config, EGLCon text share_context, const EGLint* attrib_list);
64 typedef EGLBoolean (*DestroyContextProc)(EGLDisplay dpy, EGLContext ctx); 70 typedef EGLBoolean (*DestroyContextProc)(EGLDisplay dpy, EGLContext ctx);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 136 }
131 137
132 const GrGLInterface* GrGLCreateCommandBufferInterface() { 138 const GrGLInterface* GrGLCreateCommandBufferInterface() {
133 LoadCommandBufferOnce(); 139 LoadCommandBufferOnce();
134 if (!gfFunctionsLoadedSuccessfully) { 140 if (!gfFunctionsLoadedSuccessfully) {
135 return nullptr; 141 return nullptr;
136 } 142 }
137 return GrGLAssembleGLESInterface(gLibrary, command_buffer_get_gl_proc); 143 return GrGLAssembleGLESInterface(gLibrary, command_buffer_get_gl_proc);
138 } 144 }
139 145
140 SkCommandBufferGLContext::SkCommandBufferGLContext() 146 SkCommandBufferGLContext::SkCommandBufferGLContext(ContextVersion minContextVers ion)
141 : fContext(EGL_NO_CONTEXT) 147 : fContext(EGL_NO_CONTEXT)
142 , fDisplay(EGL_NO_DISPLAY) 148 , fDisplay(EGL_NO_DISPLAY)
143 , fSurface(EGL_NO_SURFACE) { 149 , fSurface(EGL_NO_SURFACE) {
144 150
145 static const EGLint configAttribs[] = { 151 static const EGLint configAttribs[] = {
146 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, 152 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
147 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 153 EGL_RENDERABLE_TYPE, minContextVersion == kGLES3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT,
148 EGL_RED_SIZE, 8, 154 EGL_RED_SIZE, 8,
149 EGL_GREEN_SIZE, 8, 155 EGL_GREEN_SIZE, 8,
150 EGL_BLUE_SIZE, 8, 156 EGL_BLUE_SIZE, 8,
151 EGL_ALPHA_SIZE, 8, 157 EGL_ALPHA_SIZE, 8,
152 EGL_NONE 158 EGL_NONE
153 }; 159 };
154 160
155 static const EGLint surfaceAttribs[] = { 161 static const EGLint surfaceAttribs[] = {
156 EGL_WIDTH, 1, 162 EGL_WIDTH, 1,
157 EGL_HEIGHT, 1, 163 EGL_HEIGHT, 1,
158 EGL_NONE 164 EGL_NONE
159 }; 165 };
160 166
161 initializeGLContext(nullptr, configAttribs, surfaceAttribs); 167 initializeGLContext(minContextVersion, nullptr, configAttribs, surfaceAttrib s);
162 } 168 }
163 169
164 SkCommandBufferGLContext::SkCommandBufferGLContext(void* nativeWindow, int msaaS ampleCount) { 170 SkCommandBufferGLContext::SkCommandBufferGLContext(void* nativeWindow, int msaaS ampleCount) {
165 static const EGLint surfaceAttribs[] = { EGL_NONE }; 171 static const EGLint surfaceAttribs[] = { EGL_NONE };
166 172
167 EGLint configAttribs[] = { 173 EGLint configAttribs[] = {
174 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
175 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
168 EGL_RED_SIZE, 8, 176 EGL_RED_SIZE, 8,
169 EGL_GREEN_SIZE, 8, 177 EGL_GREEN_SIZE, 8,
170 EGL_BLUE_SIZE, 8, 178 EGL_BLUE_SIZE, 8,
171 EGL_ALPHA_SIZE, 8, 179 EGL_ALPHA_SIZE, 8,
172 EGL_DEPTH_SIZE, 8, 180 EGL_DEPTH_SIZE, 8,
173 EGL_STENCIL_SIZE, 8, 181 EGL_STENCIL_SIZE, 8,
174 EGL_SAMPLE_BUFFERS, 1, 182 EGL_SAMPLE_BUFFERS, 1,
175 EGL_SAMPLES, msaaSampleCount, 183 EGL_SAMPLES, msaaSampleCount,
176 EGL_NONE 184 EGL_NONE
177 }; 185 };
178 if (msaaSampleCount == 0) { 186 if (msaaSampleCount == 0) {
179 configAttribs[12] = EGL_NONE; 187 configAttribs[12] = EGL_NONE;
180 } 188 }
181 189
182 initializeGLContext(nativeWindow, configAttribs, surfaceAttribs); 190 initializeGLContext(kGLES2, nativeWindow, configAttribs, surfaceAttribs);
183 } 191 }
184 192
185 void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int * configAttribs, 193 void SkCommandBufferGLContext::initializeGLContext(ContextVersion minContextVers ion,
194 void* nativeWindow, const int * configAttribs,
186 const int* surfaceAttribs) { 195 const int* surfaceAttribs) {
187 LoadCommandBufferOnce(); 196 LoadCommandBufferOnce();
188 if (!gfFunctionsLoadedSuccessfully) { 197 if (!gfFunctionsLoadedSuccessfully) {
189 SkDebugf("Command Buffer: Could not load EGL functions.\n"); 198 SkDebugf("Command Buffer: Could not load EGL functions.\n");
190 return; 199 return;
191 } 200 }
192 201
193 // Make sure CHROMIUM_path_rendering is enabled for NVPR support. 202 // Make sure CHROMIUM_path_rendering is enabled for NVPR support.
194 sk_setenv("CHROME_COMMAND_BUFFER_GLES2_ARGS", "--enable-gl-path-rendering"); 203 sk_setenv("CHROME_COMMAND_BUFFER_GLES2_ARGS", "--enable-gl-path-rendering");
195 fDisplay = gfGetDisplay(EGL_DEFAULT_DISPLAY); 204 fDisplay = gfGetDisplay(EGL_DEFAULT_DISPLAY);
(...skipping 28 matching lines...) Expand all
224 static_cast<EGLConfig>(fConfig), 233 static_cast<EGLConfig>(fConfig),
225 surfaceAttribs); 234 surfaceAttribs);
226 } 235 }
227 if (EGL_NO_SURFACE == fSurface) { 236 if (EGL_NO_SURFACE == fSurface) {
228 SkDebugf("Command Buffer: Could not create EGL surface.\n"); 237 SkDebugf("Command Buffer: Could not create EGL surface.\n");
229 this->destroyGLContext(); 238 this->destroyGLContext();
230 return; 239 return;
231 } 240 }
232 241
233 static const EGLint contextAttribs[] = { 242 static const EGLint contextAttribs[] = {
234 EGL_CONTEXT_CLIENT_VERSION, 2, 243 EGL_CONTEXT_CLIENT_VERSION, minContextVersion == kGLES3 ? 3 : 2,
235 EGL_NONE 244 EGL_NONE
236 }; 245 };
237 fContext = gfCreateContext(fDisplay, static_cast<EGLConfig>(fConfig), nullpt r, contextAttribs); 246 fContext = gfCreateContext(fDisplay, static_cast<EGLConfig>(fConfig), nullpt r, contextAttribs);
238 if (EGL_NO_CONTEXT == fContext) { 247 if (EGL_NO_CONTEXT == fContext) {
239 SkDebugf("Command Buffer: Could not create EGL context.\n"); 248 SkDebugf("Command Buffer: Could not create EGL context.\n");
240 this->destroyGLContext(); 249 this->destroyGLContext();
241 return; 250 return;
242 } 251 }
243 252
244 if (!gfMakeCurrent(fDisplay, fSurface, fSurface, fContext)) { 253 if (!gfMakeCurrent(fDisplay, fSurface, fSurface, fContext)) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 EGLint result = 0; 339 EGLint result = 0;
331 gfGetConfigAttrib(fDisplay, static_cast<EGLConfig>(fConfig), EGL_STENCIL_SIZ E, &result); 340 gfGetConfigAttrib(fDisplay, static_cast<EGLConfig>(fConfig), EGL_STENCIL_SIZ E, &result);
332 return result; 341 return result;
333 } 342 }
334 343
335 int SkCommandBufferGLContext::getSampleCount() { 344 int SkCommandBufferGLContext::getSampleCount() {
336 EGLint result = 0; 345 EGLint result = 0;
337 gfGetConfigAttrib(fDisplay, static_cast<EGLConfig>(fConfig), EGL_SAMPLES, &r esult); 346 gfGetConfigAttrib(fDisplay, static_cast<EGLConfig>(fConfig), EGL_SAMPLES, &r esult);
338 return result; 347 return result;
339 } 348 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698