aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/views/win
diff options
context:
space:
mode:
authorGravatar hendrikw <hendrikw@chromium.org>2015-08-27 10:38:39 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-27 10:38:39 -0700
commit885bf0925514b9dfe3365bab227d36897d866b5d (patch)
tree4a80bbcffa086e8bbdede4903a30993dd4783800 /src/views/win
parent33c594c9611529ba72474ec52586be65f3e2d76f (diff)
skia: add ability to load command_buffer_gles2
Diffstat (limited to 'src/views/win')
-rw-r--r--src/views/win/SkOSWindow_win.cpp79
1 files changed, 78 insertions, 1 deletions
diff --git a/src/views/win/SkOSWindow_win.cpp b/src/views/win/SkOSWindow_win.cpp
index b0bb76ca19..e4609fb410 100644
--- a/src/views/win/SkOSWindow_win.cpp
+++ b/src/views/win/SkOSWindow_win.cpp
@@ -30,7 +30,17 @@
(IFACE)->fFunctions.f##X; \
} while (false)
-#endif
+#endif // SK_ANGLE
+
+#if SK_COMMAND_BUFFER
+#include "gl/command_buffer/SkCommandBufferGLContext.h"
+
+#define COMMAND_BUFFER_GL_CALL(IFACE, X) \
+ do { \
+ (IFACE)->fFunctions.f##X; \
+ } while (false)
+
+#endif // SK_COMMAND_BUFFER
#define WM_EVENT_CALLBACK (WM_USER+0)
@@ -53,6 +63,10 @@ SkOSWindow::SkOSWindow(const void* winInit) {
fContext = EGL_NO_CONTEXT;
fSurface = EGL_NO_SURFACE;
#endif
+#if SK_COMMAND_BUFFER
+ fCommandBuffer = nullptr;
+#endif // SK_COMMAND_BUFFER
+
fHGLRC = NULL;
#endif
fAttached = kNone_BackEndType;
@@ -80,6 +94,10 @@ SkOSWindow::~SkOSWindow() {
fDisplay = EGL_NO_DISPLAY;
}
#endif // SK_ANGLE
+#if SK_COMMAND_BUFFER
+ delete fCommandBuffer;
+#endif // SK_COMMAND_BUFFER
+
#endif // SK_SUPPORT_GPU
this->closeWindow();
}
@@ -530,6 +548,50 @@ void SkOSWindow::presentANGLE() {
eglSwapBuffers(fDisplay, fSurface);
}
#endif // SK_ANGLE
+
+#if SK_COMMAND_BUFFER
+
+bool SkOSWindow::attachCommandBuffer(int msaaSampleCount, AttachmentInfo* info) {
+ if (!fCommandBuffer) {
+ fCommandBuffer = SkCommandBufferGLContext::Create((HWND)fHWND, msaaSampleCount);
+ if (!fCommandBuffer)
+ return false;
+
+ SkAutoTUnref<const GrGLInterface> intf(GrGLCreateCommandBufferInterface());
+ if (intf) {
+ COMMAND_BUFFER_GL_CALL(intf, ClearStencil(0));
+ COMMAND_BUFFER_GL_CALL(intf, ClearColor(0, 0, 0, 0));
+ COMMAND_BUFFER_GL_CALL(intf, StencilMask(0xffffffff));
+ COMMAND_BUFFER_GL_CALL(intf, Clear(GL_STENCIL_BUFFER_BIT |GL_COLOR_BUFFER_BIT));
+ }
+ }
+
+ if (fCommandBuffer->makeCurrent()) {
+ info->fStencilBits = fCommandBuffer->getStencilBits();
+ info->fSampleCount = fCommandBuffer->getSampleCount();
+
+ SkAutoTUnref<const GrGLInterface> intf(GrGLCreateCommandBufferInterface());
+
+ if (intf ) {
+ COMMAND_BUFFER_GL_CALL(intf, Viewport(0, 0,
+ SkScalarRoundToInt(this->width()),
+ SkScalarRoundToInt(this->height())));
+ }
+ return true;
+ }
+ return false;
+}
+
+void SkOSWindow::detachCommandBuffer() {
+ delete fCommandBuffer;
+ fCommandBuffer = nullptr;
+}
+
+void SkOSWindow::presentCommandBuffer() {
+ fCommandBuffer->presentCommandBuffer();
+}
+#endif // SK_COMMAND_BUFFER
+
#endif // SK_SUPPORT_GPU
// return true on success
@@ -554,6 +616,11 @@ bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount, Attachme
result = attachANGLE(msaaSampleCount, info);
break;
#endif // SK_ANGLE
+#if SK_COMMAND_BUFFER
+ case kCommandBuffer_BackEndType:
+ result = attachCommandBuffer(msaaSampleCount, info);
+ break;
+#endif // SK_COMMAND_BUFFER
#endif // SK_SUPPORT_GPU
default:
SkASSERT(false);
@@ -582,6 +649,11 @@ void SkOSWindow::detach() {
detachANGLE();
break;
#endif // SK_ANGLE
+#if SK_COMMAND_BUFFER
+ case kCommandBuffer_BackEndType:
+ detachCommandBuffer();
+ break;
+#endif // SK_COMMAND_BUFFER
#endif // SK_SUPPORT_GPU
default:
SkASSERT(false);
@@ -604,6 +676,11 @@ void SkOSWindow::present() {
presentANGLE();
break;
#endif // SK_ANGLE
+#if SK_COMMAND_BUFFER
+ case kCommandBuffer_BackEndType:
+ presentCommandBuffer();
+ break;
+#endif // SK_COMMAND_BUFFER
#endif // SK_SUPPORT_GPU
default:
SkASSERT(false);