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

Unified Diff: src/gpu/gl/win/SkNativeGLContext_win.cpp

Issue 630843002: Make the Sk GL context class an abstract base class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix android link problem and ios compile problem Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp ('k') | tests/GLInterfaceValidationTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/win/SkNativeGLContext_win.cpp
diff --git a/src/gpu/gl/win/SkNativeGLContext_win.cpp b/src/gpu/gl/win/SkNativeGLContext_win.cpp
deleted file mode 100644
index ab66ba4d55ce3e61a715692e015d3453ca5e0909..0000000000000000000000000000000000000000
--- a/src/gpu/gl/win/SkNativeGLContext_win.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "gl/SkNativeGLContext.h"
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-SkNativeGLContext::AutoContextRestore::AutoContextRestore() {
- fOldHGLRC = wglGetCurrentContext();
- fOldHDC = wglGetCurrentDC();
-}
-
-SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
- wglMakeCurrent(fOldHDC, fOldHGLRC);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-ATOM SkNativeGLContext::gWC = 0;
-
-SkNativeGLContext::SkNativeGLContext()
- : fWindow(NULL)
- , fDeviceContext(NULL)
- , fGlRenderContext(0)
- , fPbufferContext(NULL) {
-}
-
-SkNativeGLContext::~SkNativeGLContext() {
- this->destroyGLContext();
-}
-
-void SkNativeGLContext::destroyGLContext() {
- SkSafeSetNull(fPbufferContext);
- if (fGlRenderContext) {
- wglDeleteContext(fGlRenderContext);
- fGlRenderContext = 0;
- }
- if (fWindow && fDeviceContext) {
- ReleaseDC(fWindow, fDeviceContext);
- fDeviceContext = 0;
- }
- if (fWindow) {
- DestroyWindow(fWindow);
- fWindow = 0;
- }
-}
-
-const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
- HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);
-
- if (!gWC) {
- WNDCLASS wc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hbrBackground = NULL;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hInstance = hInstance;
- wc.lpfnWndProc = (WNDPROC) DefWindowProc;
- wc.lpszClassName = TEXT("Griffin");
- wc.lpszMenuName = NULL;
- wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
-
- gWC = RegisterClass(&wc);
- if (!gWC) {
- SkDebugf("Could not register window class.\n");
- return NULL;
- }
- }
-
- if (!(fWindow = CreateWindow(TEXT("Griffin"),
- TEXT("The Invisible Man"),
- WS_OVERLAPPEDWINDOW,
- 0, 0, 1, 1,
- NULL, NULL,
- hInstance, NULL))) {
- SkDebugf("Could not create window.\n");
- return NULL;
- }
-
- if (!(fDeviceContext = GetDC(fWindow))) {
- SkDebugf("Could not get device context.\n");
- this->destroyGLContext();
- return NULL;
- }
- // Requesting a Core profile would bar us from using NVPR. So we request
- // compatibility profile or GL ES.
- SkWGLContextRequest contextType =
- kGLES_GrGLStandard == forcedGpuAPI ?
- kGLES_SkWGLContextRequest : kGLPreferCompatibilityProfile_SkWGLContextRequest;
-
- fPbufferContext = SkWGLPbufferContext::Create(fDeviceContext, 0, contextType);
-
- HDC dc;
- HGLRC glrc;
-
- if (NULL == fPbufferContext) {
- if (!(fGlRenderContext = SkCreateWGLContext(fDeviceContext, 0, contextType))) {
- SkDebugf("Could not create rendering context.\n");
- this->destroyGLContext();
- return NULL;
- }
- dc = fDeviceContext;
- glrc = fGlRenderContext;
- } else {
- ReleaseDC(fWindow, fDeviceContext);
- fDeviceContext = 0;
- DestroyWindow(fWindow);
- fWindow = 0;
-
- dc = fPbufferContext->getDC();
- glrc = fPbufferContext->getGLRC();
- }
-
- if (!(wglMakeCurrent(dc, glrc))) {
- SkDebugf("Could not set the context.\n");
- this->destroyGLContext();
- return NULL;
- }
-
- const GrGLInterface* interface = GrGLCreateNativeInterface();
- if (NULL == interface) {
- SkDebugf("Could not create GL interface.\n");
- this->destroyGLContext();
- return NULL;
- }
-
- return interface;
-}
-
-void SkNativeGLContext::makeCurrent() const {
- HDC dc;
- HGLRC glrc;
-
- if (NULL == fPbufferContext) {
- dc = fDeviceContext;
- glrc = fGlRenderContext;
- } else {
- dc = fPbufferContext->getDC();
- glrc = fPbufferContext->getGLRC();
- }
-
- if (!wglMakeCurrent(dc, glrc)) {
- SkDebugf("Could not create rendering context.\n");
- }
-}
-
-void SkNativeGLContext::swapBuffers() const {
- HDC dc;
-
- if (NULL == fPbufferContext) {
- dc = fDeviceContext;
- } else {
- dc = fPbufferContext->getDC();
- }
- if (!SwapBuffers(dc)) {
- SkDebugf("Could not complete SwapBuffers.\n");
- }
-}
« no previous file with comments | « src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp ('k') | tests/GLInterfaceValidationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698