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

Side by Side Diff: src/views/win/SkOSWindow_win.cpp

Issue 1815823002: Move SkGLContext and some GrGLInterface implementations to skgputest module (Closed) Base URL: https://chromium.googlesource.com/skia.git@debugobject
Patch Set: Address comments Created 4 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
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 #include "SkTypes.h" 8 #include "SkTypes.h"
9 9
10 #if defined(SK_BUILD_FOR_WIN) 10 #if defined(SK_BUILD_FOR_WIN)
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 389 }
390 390
391 void SkOSWindow::presentGL() { 391 void SkOSWindow::presentGL() {
392 HDC dc = GetDC((HWND)fHWND); 392 HDC dc = GetDC((HWND)fHWND);
393 SwapBuffers(dc); 393 SwapBuffers(dc);
394 ReleaseDC((HWND)fHWND, dc); 394 ReleaseDC((HWND)fHWND, dc);
395 } 395 }
396 396
397 #if SK_ANGLE 397 #if SK_ANGLE
398 398
399 void* get_angle_egl_display(void* nativeDisplay) {
400 PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT;
401 eglGetPlatformDisplayEXT =
402 (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDispla yEXT");
403
404 // We expect ANGLE to support this extension
405 if (!eglGetPlatformDisplayEXT) {
406 return EGL_NO_DISPLAY;
407 }
408
409 EGLDisplay display = EGL_NO_DISPLAY;
410 // Try for an ANGLE D3D11 context, fall back to D3D9, and finally GL.
411 EGLint attribs[3][3] = {
412 {
413 EGL_PLATFORM_ANGLE_TYPE_ANGLE,
414 EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
415 EGL_NONE
416 },
417 {
418 EGL_PLATFORM_ANGLE_TYPE_ANGLE,
419 EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE,
420 EGL_NONE
421 },
422 };
423 for (int i = 0; i < 3 && display == EGL_NO_DISPLAY; ++i) {
424 display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,nativeDispla y, attribs[i]);
425 }
426 return display;
427 }
428
399 bool create_ANGLE(EGLNativeWindowType hWnd, 429 bool create_ANGLE(EGLNativeWindowType hWnd,
400 int msaaSampleCount, 430 int msaaSampleCount,
401 EGLDisplay* eglDisplay, 431 EGLDisplay* eglDisplay,
402 EGLContext* eglContext, 432 EGLContext* eglContext,
403 EGLSurface* eglSurface, 433 EGLSurface* eglSurface,
404 EGLConfig* eglConfig) { 434 EGLConfig* eglConfig) {
405 static const EGLint contextAttribs[] = { 435 static const EGLint contextAttribs[] = {
406 EGL_CONTEXT_CLIENT_VERSION, 2, 436 EGL_CONTEXT_CLIENT_VERSION, 2,
407 EGL_NONE, EGL_NONE 437 EGL_NONE, EGL_NONE
408 }; 438 };
409 static const EGLint configAttribList[] = { 439 static const EGLint configAttribList[] = {
410 EGL_RED_SIZE, 8, 440 EGL_RED_SIZE, 8,
411 EGL_GREEN_SIZE, 8, 441 EGL_GREEN_SIZE, 8,
412 EGL_BLUE_SIZE, 8, 442 EGL_BLUE_SIZE, 8,
413 EGL_ALPHA_SIZE, 8, 443 EGL_ALPHA_SIZE, 8,
414 EGL_DEPTH_SIZE, 8, 444 EGL_DEPTH_SIZE, 8,
415 EGL_STENCIL_SIZE, 8, 445 EGL_STENCIL_SIZE, 8,
416 EGL_NONE 446 EGL_NONE
417 }; 447 };
418 static const EGLint surfaceAttribList[] = { 448 static const EGLint surfaceAttribList[] = {
419 EGL_NONE, EGL_NONE 449 EGL_NONE, EGL_NONE
420 }; 450 };
421 451
422 EGLDisplay display = SkANGLEGLContext::GetD3DEGLDisplay(GetDC(hWnd), false); 452 EGLDisplay display = get_angle_egl_display(GetDC(hWnd), false);
423 453
424 if (EGL_NO_DISPLAY == display) { 454 if (EGL_NO_DISPLAY == display) {
425 SkDebugf("Could not create ANGLE egl display!\n"); 455 SkDebugf("Could not create ANGLE egl display!\n");
426 return false; 456 return false;
427 } 457 }
428 458
429 // Initialize EGL 459 // Initialize EGL
430 EGLint majorVersion, minorVersion; 460 EGLint majorVersion, minorVersion;
431 if (!eglInitialize(display, &majorVersion, &minorVersion)) { 461 if (!eglInitialize(display, &majorVersion, &minorVersion)) {
432 return false; 462 return false;
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 } 801 }
772 802
773 void SkOSWindow::closeWindow() { 803 void SkOSWindow::closeWindow() {
774 DestroyWindow((HWND)fHWND); 804 DestroyWindow((HWND)fHWND);
775 if (fFullscreen) { 805 if (fFullscreen) {
776 DestroyWindow((HWND)fSavedWindowState.fHWND); 806 DestroyWindow((HWND)fSavedWindowState.fHWND);
777 } 807 }
778 gHwndToOSWindowMap.remove(fHWND); 808 gHwndToOSWindowMap.remove(fHWND);
779 } 809 }
780 #endif 810 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698