aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/utils/SkWGL.h
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-07-01 07:20:11 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-01 07:20:11 -0700
commit9245b7ee764b61222ffba409a7d2d7e62fde01a6 (patch)
treeb9c3550a2211a480fb25f65c92d69251e4fc58ba /include/utils/SkWGL.h
parent2fd0d14b9be34a7a945942733c3516d97d07f516 (diff)
When performing offscreen rendering on windows, attempt to use a pbuffer context.
A pbuffer context is less likely to have a blocking SwapBuffers (due to vsync). R=robertphillips@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/336863009
Diffstat (limited to 'include/utils/SkWGL.h')
-rw-r--r--include/utils/SkWGL.h53
1 files changed, 48 insertions, 5 deletions
diff --git a/include/utils/SkWGL.h b/include/utils/SkWGL.h
index 5272f17c87..d502eb0aa7 100644
--- a/include/utils/SkWGL.h
+++ b/include/utils/SkWGL.h
@@ -56,6 +56,8 @@
#define SK_ERROR_INVALID_VERSION 0x2095
#define SK_ERROR_INVALID_PROFILE 0x2096
+DECLARE_HANDLE(HPBUFFER);
+
class SkWGLExtensions {
public:
SkWGLExtensions();
@@ -73,6 +75,13 @@ public:
BOOL getPixelFormatAttribfv(HDC hdc, int, int, UINT, const int*, FLOAT*) const;
HGLRC createContextAttribs(HDC, HGLRC, const int *) const;
+ BOOL swapInterval(int interval) const;
+
+ HPBUFFER createPbuffer(HDC, int , int, int, const int*) const;
+ HDC getPbufferDC(HPBUFFER) const;
+ int releasePbufferDC(HPBUFFER, HDC) const;
+ BOOL destroyPbuffer(HPBUFFER) const;
+
/**
* WGL doesn't have precise rules for the ordering of formats returned
* by wglChoosePixelFormat. This function helps choose among the set of
@@ -89,19 +98,29 @@ public:
int selectFormat(const int formats[],
int formatCount,
HDC dc,
- int desiredSampleCount);
+ int desiredSampleCount) const;
private:
- typedef const char* (WINAPI *GetExtensionsStringProc)(HDC hdc);
- typedef BOOL (WINAPI *ChoosePixelFormatProc)(HDC hdc, const int *, const FLOAT *, UINT, int *, UINT *);
+ typedef const char* (WINAPI *GetExtensionsStringProc)(HDC);
+ typedef BOOL (WINAPI *ChoosePixelFormatProc)(HDC, const int *, const FLOAT *, UINT, int *, UINT *);
typedef BOOL (WINAPI *GetPixelFormatAttribivProc)(HDC, int, int, UINT, const int*, int*);
- typedef BOOL (WINAPI *GetPixelFormatAttribfvProc)(HDC hdc, int, int, UINT, const int*, FLOAT*);
- typedef HGLRC (WINAPI *CreateContextAttribsProc)(HDC hDC, HGLRC, const int *);
+ typedef BOOL (WINAPI *GetPixelFormatAttribfvProc)(HDC, int, int, UINT, const int*, FLOAT*);
+ typedef HGLRC (WINAPI *CreateContextAttribsProc)(HDC, HGLRC, const int *);
+ typedef BOOL (WINAPI* SwapIntervalProc)(int);
+ typedef HPBUFFER (WINAPI* CreatePbufferProc)(HDC, int , int, int, const int*);
+ typedef HDC (WINAPI* GetPbufferDCProc)(HPBUFFER);
+ typedef int (WINAPI* ReleasePbufferDCProc)(HPBUFFER, HDC);
+ typedef BOOL (WINAPI* DestroyPbufferProc)(HPBUFFER);
GetExtensionsStringProc fGetExtensionsString;
ChoosePixelFormatProc fChoosePixelFormat;
GetPixelFormatAttribfvProc fGetPixelFormatAttribfv;
GetPixelFormatAttribivProc fGetPixelFormatAttribiv;
CreateContextAttribsProc fCreateContextAttribs;
+ SwapIntervalProc fSwapInterval;
+ CreatePbufferProc fCreatePbuffer;
+ GetPbufferDCProc fGetPbufferDC;
+ ReleasePbufferDCProc fReleasePbufferDC;
+ DestroyPbufferProc fDestroyPbuffer;
};
enum SkWGLContextRequest {
@@ -122,4 +141,28 @@ enum SkWGLContextRequest {
*/
HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, SkWGLContextRequest context);
+/**
+ * Helper class for creating a pbuffer context and deleting all the handles when finished. This
+ * requires that a device context has been created. However, the pbuffer gets its own device
+ * context. The original device context can be released once the pbuffer context is created.
+ */
+class SkWGLPbufferContext : public SkRefCnt {
+public:
+ static SkWGLPbufferContext* Create(HDC parentDC, int msaaSampleCount,
+ SkWGLContextRequest contextType);
+
+ virtual ~SkWGLPbufferContext();
+
+ HDC getDC() const { return fDC; }
+ HGLRC getGLRC() const { return fGLRC; }
+
+private:
+ SkWGLPbufferContext(HPBUFFER pbuffer, HDC dc, HGLRC glrc);
+
+ HPBUFFER fPbuffer;
+ HDC fDC;
+ HGLRC fGLRC;
+ SkWGLExtensions fExtensions;
+};
+
#endif