aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp
diff options
context:
space:
mode:
authorGravatar cdalton <cdalton@nvidia.com>2015-06-23 13:23:44 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-06-23 13:23:44 -0700
commitd416a5b10ff9e6d4f55a1f5b0419722132d68ff3 (patch)
treef9f39528fd8fd7c033882c137d711e12939c6fa2 /src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp
parentb607767703ff7898611cf88c1218d5d69535e984 (diff)
Implement SkGLContext swapBuffers with fence syncs
Improves the GPU measuring accuracy of nanobench by using fence syncs. Fence syncs are very widely supported and available on almost every platform. NO_MERGE_BUILDS BUG=skia: Review URL: https://codereview.chromium.org/1194783003
Diffstat (limited to 'src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp')
-rw-r--r--src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp b/src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp
index d387ef4922..8a4c5db5b3 100644
--- a/src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp
+++ b/src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp
@@ -21,12 +21,14 @@ class WinGLContext : public SkGLContext {
public:
WinGLContext(GrGLStandard forcedGpuAPI);
~WinGLContext() override;
- void makeCurrent() const override;
- void swapBuffers() const override;
private:
void destroyGLContext();
+ void onPlatformMakeCurrent() const override;
+ void onPlatformSwapBuffers() const override;
+ GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override;
+
HWND fWindow;
HDC fDeviceContext;
HGLRC fGlRenderContext;
@@ -113,25 +115,27 @@ WinGLContext::WinGLContext(GrGLStandard forcedGpuAPI)
return;
}
- fGL.reset(GrGLCreateNativeInterface());
- if (NULL == fGL.get()) {
+ SkAutoTUnref<const GrGLInterface> gl(GrGLCreateNativeInterface());
+ if (NULL == gl.get()) {
SkDebugf("Could not create GL interface.\n");
this->destroyGLContext();
return;
}
- if (!fGL->validate()) {
+ if (!gl->validate()) {
SkDebugf("Could not validate GL interface.\n");
this->destroyGLContext();
return;
}
+
+ this->init(gl.detach());
}
WinGLContext::~WinGLContext() {
+ this->teardown();
this->destroyGLContext();
}
void WinGLContext::destroyGLContext() {
- fGL.reset(NULL);
SkSafeSetNull(fPbufferContext);
if (fGlRenderContext) {
wglDeleteContext(fGlRenderContext);
@@ -147,7 +151,7 @@ void WinGLContext::destroyGLContext() {
}
}
-void WinGLContext::makeCurrent() const {
+void WinGLContext::onPlatformMakeCurrent() const {
HDC dc;
HGLRC glrc;
@@ -164,7 +168,7 @@ void WinGLContext::makeCurrent() const {
}
}
-void WinGLContext::swapBuffers() const {
+void WinGLContext::onPlatformSwapBuffers() const {
HDC dc;
if (NULL == fPbufferContext) {
@@ -177,6 +181,10 @@ void WinGLContext::swapBuffers() const {
}
}
+GrGLFuncPtr WinGLContext::onPlatformGetProcAddress(const char* name) const {
+ return reinterpret_cast<GrGLFuncPtr>(wglGetProcAddress(name));
+}
+
} // anonymous namespace
SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) {