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

Side by Side Diff: src/utils/win/SkWGL_win.cpp

Issue 351583002: Revert of Support using OpenGL ES context on desktop (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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/gl/win/SkNativeGLContext_win.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 2011 Google Inc. 3 * Copyright 2011 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 "SkWGL.h" 9 #include "SkWGL.h"
10 10
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 GET_PROC(CreateContextAttribs, ARB); 238 GET_PROC(CreateContextAttribs, ARB);
239 239
240 wglMakeCurrent(dummyDC, NULL); 240 wglMakeCurrent(dummyDC, NULL);
241 wglDeleteContext(dummyGLRC); 241 wglDeleteContext(dummyGLRC);
242 destroy_dummy_window(dummyWND); 242 destroy_dummy_window(dummyWND);
243 } 243 }
244 244
245 wglMakeCurrent(prevDC, prevGLRC); 245 wglMakeCurrent(prevDC, prevGLRC);
246 } 246 }
247 247
248 HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, SkWGLContextRequest contex tType) { 248 HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, bool preferCoreProfile) {
249 SkWGLExtensions extensions; 249 SkWGLExtensions extensions;
250 if (!extensions.hasExtension(dc, "WGL_ARB_pixel_format")) { 250 if (!extensions.hasExtension(dc, "WGL_ARB_pixel_format")) {
251 return NULL; 251 return NULL;
252 } 252 }
253 253
254 HDC prevDC = wglGetCurrentDC(); 254 HDC prevDC = wglGetCurrentDC();
255 HGLRC prevGLRC = wglGetCurrentContext(); 255 HGLRC prevGLRC = wglGetCurrentContext();
256 PIXELFORMATDESCRIPTOR pfd; 256 PIXELFORMATDESCRIPTOR pfd;
257 257
258 int format = 0; 258 int format = 0;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 if (0 == format) { 300 if (0 == format) {
301 // Either MSAA wasn't requested or creation failed 301 // Either MSAA wasn't requested or creation failed
302 unsigned int num; 302 unsigned int num;
303 extensions.choosePixelFormat(dc, iAttrs, fAttrs, 1, &format, &num); 303 extensions.choosePixelFormat(dc, iAttrs, fAttrs, 1, &format, &num);
304 DescribePixelFormat(dc, format, sizeof(pfd), &pfd); 304 DescribePixelFormat(dc, format, sizeof(pfd), &pfd);
305 SkDEBUGCODE(BOOL set =) SetPixelFormat(dc, format, &pfd); 305 SkDEBUGCODE(BOOL set =) SetPixelFormat(dc, format, &pfd);
306 SkASSERT(TRUE == set); 306 SkASSERT(TRUE == set);
307 } 307 }
308 308
309 HGLRC glrc = NULL; 309 HGLRC glrc = NULL;
310 if (kGLES_SkWGLContextRequest == contextType) { 310 if (preferCoreProfile && extensions.hasExtension(dc, "WGL_ARB_create_context ")) {
311 if (!extensions.hasExtension(dc, "WGL_EXT_create_context_es2_profile")) { 311 static const int kCoreGLVersions[] = {
312 return NULL; 312 4, 3,
313 } 313 4, 2,
314 static const int glesAttribs[] = { 314 4, 1,
315 SK_WGL_CONTEXT_MAJOR_VERSION, 3, 315 4, 0,
316 SK_WGL_CONTEXT_MINOR_VERSION, 0, 316 3, 3,
317 SK_WGL_CONTEXT_PROFILE_MASK, SK_WGL_CONTEXT_ES2_PROFILE_BIT, 317 3, 2,
318 };
319 int coreProfileAttribs[] = {
320 SK_WGL_CONTEXT_MAJOR_VERSION, -1,
321 SK_WGL_CONTEXT_MINOR_VERSION, -1,
322 SK_WGL_CONTEXT_PROFILE_MASK, SK_WGL_CONTEXT_CORE_PROFILE_BIT,
318 0, 323 0,
319 }; 324 };
320 glrc = extensions.createContextAttribs(dc, NULL, glesAttribs); 325 for (int v = 0; v < SK_ARRAY_COUNT(kCoreGLVersions) / 2; ++v) {
321 if (NULL == glrc) { 326 coreProfileAttribs[1] = kCoreGLVersions[2 * v];
322 return NULL; 327 coreProfileAttribs[3] = kCoreGLVersions[2 * v + 1];
323 } 328 glrc = extensions.createContextAttribs(dc, NULL, coreProfileAttribs) ;
324 } else { 329 if (NULL != glrc) {
325 if (kGLPreferCoreProfile_SkWGLContextRequest == contextType && 330 break;
326 extensions.hasExtension(dc, "WGL_ARB_create_context")) {
327 static const int kCoreGLVersions[] = {
328 4, 3,
329 4, 2,
330 4, 1,
331 4, 0,
332 3, 3,
333 3, 2,
334 };
335 int coreProfileAttribs[] = {
336 SK_WGL_CONTEXT_MAJOR_VERSION, -1,
337 SK_WGL_CONTEXT_MINOR_VERSION, -1,
338 SK_WGL_CONTEXT_PROFILE_MASK, SK_WGL_CONTEXT_CORE_PROFILE_BIT,
339 0,
340 };
341 for (int v = 0; v < SK_ARRAY_COUNT(kCoreGLVersions) / 2; ++v) {
342 coreProfileAttribs[1] = kCoreGLVersions[2 * v];
343 coreProfileAttribs[3] = kCoreGLVersions[2 * v + 1];
344 glrc = extensions.createContextAttribs(dc, NULL, coreProfileAttr ibs);
345 if (NULL != glrc) {
346 break;
347 }
348 } 331 }
349 } 332 }
350 } 333 }
351 334
352 if (NULL == glrc) { 335 if (NULL == glrc) {
353 glrc = wglCreateContext(dc); 336 glrc = wglCreateContext(dc);
354 } 337 }
355 SkASSERT(glrc); 338 SkASSERT(glrc);
356 339
357 wglMakeCurrent(prevDC, prevGLRC); 340 wglMakeCurrent(prevDC, prevGLRC);
358 return glrc; 341 return glrc;
359 } 342 }
OLDNEW
« no previous file with comments | « src/gpu/gl/win/SkNativeGLContext_win.cpp ('k') | src/views/win/SkOSWindow_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698