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

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

Issue 336863009: When performing offscreen rendering on windows, attempt to use a pbuffer context. (Closed) Base URL: https://skia.googlesource.com/skia.git@klein
Patch Set: Address initial comments 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 side-by-side diff with in-line comments
Download patch
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
index f085fdc6eedef859328fb983a756c8821ec5d851..ab66ba4d55ce3e61a715692e015d3453ca5e0909 100644
--- a/src/gpu/gl/win/SkNativeGLContext_win.cpp
+++ b/src/gpu/gl/win/SkNativeGLContext_win.cpp
@@ -7,7 +7,6 @@
*/
#include "gl/SkNativeGLContext.h"
-#include "SkWGL.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -28,7 +27,8 @@ ATOM SkNativeGLContext::gWC = 0;
SkNativeGLContext::SkNativeGLContext()
: fWindow(NULL)
, fDeviceContext(NULL)
- , fGlRenderContext(0) {
+ , fGlRenderContext(0)
+ , fPbufferContext(NULL) {
}
SkNativeGLContext::~SkNativeGLContext() {
@@ -36,14 +36,18 @@ SkNativeGLContext::~SkNativeGLContext() {
}
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;
}
}
@@ -91,17 +95,35 @@ const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAP
kGLES_GrGLStandard == forcedGpuAPI ?
kGLES_SkWGLContextRequest : kGLPreferCompatibilityProfile_SkWGLContextRequest;
- if (!(fGlRenderContext = SkCreateWGLContext(fDeviceContext, 0, contextType))) {
- SkDebugf("Could not create rendering context.\n");
- this->destroyGLContext();
- return NULL;
+ 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(fDeviceContext, fGlRenderContext))) {
+ 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");
@@ -113,13 +135,31 @@ const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAP
}
void SkNativeGLContext::makeCurrent() const {
- if (!wglMakeCurrent(fDeviceContext, fGlRenderContext)) {
+ 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 {
- if (!SwapBuffers(fDeviceContext)) {
+ 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 | « include/utils/SkWGL.h ('k') | src/utils/win/SkWGL_win.cpp » ('j') | src/utils/win/SkWGL_win.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698