| 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() { | 50 const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAP
I) { |
| 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; |
| 88 | 93 |
| 89 // Requesting a Core profile would bar us from using NVPR. So we pass false. | 94 if (!(fGlRenderContext = SkCreateWGLContext(fDeviceContext, 0, contextType))
) { |
| 90 if (!(fGlRenderContext = SkCreateWGLContext(fDeviceContext, 0, false))) { | |
| 91 SkDebugf("Could not create rendering context.\n"); | 95 SkDebugf("Could not create rendering context.\n"); |
| 92 this->destroyGLContext(); | 96 this->destroyGLContext(); |
| 93 return NULL; | 97 return NULL; |
| 94 } | 98 } |
| 95 | 99 |
| 96 if (!(wglMakeCurrent(fDeviceContext, fGlRenderContext))) { | 100 if (!(wglMakeCurrent(fDeviceContext, fGlRenderContext))) { |
| 97 SkDebugf("Could not set the context.\n"); | 101 SkDebugf("Could not set the context.\n"); |
| 98 this->destroyGLContext(); | 102 this->destroyGLContext(); |
| 99 return NULL; | 103 return NULL; |
| 100 } | 104 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 112 if (!wglMakeCurrent(fDeviceContext, fGlRenderContext)) { | 116 if (!wglMakeCurrent(fDeviceContext, fGlRenderContext)) { |
| 113 SkDebugf("Could not create rendering context.\n"); | 117 SkDebugf("Could not create rendering context.\n"); |
| 114 } | 118 } |
| 115 } | 119 } |
| 116 | 120 |
| 117 void SkNativeGLContext::swapBuffers() const { | 121 void SkNativeGLContext::swapBuffers() const { |
| 118 if (!SwapBuffers(fDeviceContext)) { | 122 if (!SwapBuffers(fDeviceContext)) { |
| 119 SkDebugf("Could not complete SwapBuffers.\n"); | 123 SkDebugf("Could not complete SwapBuffers.\n"); |
| 120 } | 124 } |
| 121 } | 125 } |
| OLD | NEW |