| OLD | NEW |
| 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 "gl/SkNativeGLContext.h" | 9 #include "gl/SkNativeGLContext.h" |
| 10 #include "SkWGL.h" | 10 #include "SkWGL.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 wglDeleteContext(fGlRenderContext); | 40 wglDeleteContext(fGlRenderContext); |
| 41 } | 41 } |
| 42 if (fWindow && fDeviceContext) { | 42 if (fWindow && fDeviceContext) { |
| 43 ReleaseDC(fWindow, fDeviceContext); | 43 ReleaseDC(fWindow, fDeviceContext); |
| 44 } | 44 } |
| 45 if (fWindow) { | 45 if (fWindow) { |
| 46 DestroyWindow(fWindow); | 46 DestroyWindow(fWindow); |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAP
I) { | 50 const GrGLInterface* SkNativeGLContext::createGLContext() { |
| 51 HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL); | 51 HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL); |
| 52 | 52 |
| 53 if (!gWC) { | 53 if (!gWC) { |
| 54 WNDCLASS wc; | 54 WNDCLASS wc; |
| 55 wc.cbClsExtra = 0; | 55 wc.cbClsExtra = 0; |
| 56 wc.cbWndExtra = 0; | 56 wc.cbWndExtra = 0; |
| 57 wc.hbrBackground = NULL; | 57 wc.hbrBackground = NULL; |
| 58 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | 58 wc.hCursor = LoadCursor(NULL, IDC_ARROW); |
| 59 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); | 59 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); |
| 60 wc.hInstance = hInstance; | 60 wc.hInstance = hInstance; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 78 hInstance, NULL))) { | 78 hInstance, NULL))) { |
| 79 SkDebugf("Could not create window.\n"); | 79 SkDebugf("Could not create window.\n"); |
| 80 return NULL; | 80 return NULL; |
| 81 } | 81 } |
| 82 | 82 |
| 83 if (!(fDeviceContext = GetDC(fWindow))) { | 83 if (!(fDeviceContext = GetDC(fWindow))) { |
| 84 SkDebugf("Could not get device context.\n"); | 84 SkDebugf("Could not get device context.\n"); |
| 85 this->destroyGLContext(); | 85 this->destroyGLContext(); |
| 86 return NULL; | 86 return NULL; |
| 87 } | 87 } |
| 88 // Requesting a Core profile would bar us from using NVPR. So we request | |
| 89 // compatibility profile or GL ES. | |
| 90 SkWGLContextRequest contextType = | |
| 91 kGLES_GrGLStandard == forcedGpuAPI ? | |
| 92 kGLES_SkWGLContextRequest : kGLPreferCompatibilityProfile_SkWGLContextRe
quest; | |
| 93 | 88 |
| 94 if (!(fGlRenderContext = SkCreateWGLContext(fDeviceContext, 0, contextType))
) { | 89 // Requesting a Core profile would bar us from using NVPR. So we pass false. |
| 90 if (!(fGlRenderContext = SkCreateWGLContext(fDeviceContext, 0, false))) { |
| 95 SkDebugf("Could not create rendering context.\n"); | 91 SkDebugf("Could not create rendering context.\n"); |
| 96 this->destroyGLContext(); | 92 this->destroyGLContext(); |
| 97 return NULL; | 93 return NULL; |
| 98 } | 94 } |
| 99 | 95 |
| 100 if (!(wglMakeCurrent(fDeviceContext, fGlRenderContext))) { | 96 if (!(wglMakeCurrent(fDeviceContext, fGlRenderContext))) { |
| 101 SkDebugf("Could not set the context.\n"); | 97 SkDebugf("Could not set the context.\n"); |
| 102 this->destroyGLContext(); | 98 this->destroyGLContext(); |
| 103 return NULL; | 99 return NULL; |
| 104 } | 100 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 116 if (!wglMakeCurrent(fDeviceContext, fGlRenderContext)) { | 112 if (!wglMakeCurrent(fDeviceContext, fGlRenderContext)) { |
| 117 SkDebugf("Could not create rendering context.\n"); | 113 SkDebugf("Could not create rendering context.\n"); |
| 118 } | 114 } |
| 119 } | 115 } |
| 120 | 116 |
| 121 void SkNativeGLContext::swapBuffers() const { | 117 void SkNativeGLContext::swapBuffers() const { |
| 122 if (!SwapBuffers(fDeviceContext)) { | 118 if (!SwapBuffers(fDeviceContext)) { |
| 123 SkDebugf("Could not complete SwapBuffers.\n"); | 119 SkDebugf("Could not complete SwapBuffers.\n"); |
| 124 } | 120 } |
| 125 } | 121 } |
| OLD | NEW |