Index: src/views/win/SkOSWindow_win.cpp |
diff --git a/src/views/win/SkOSWindow_win.cpp b/src/views/win/SkOSWindow_win.cpp |
index b0bb76ca19cc05071a108a6902cce64b5e4fee2e..e4609fb4103c6030d31b6e9683933beaa1942aed 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); |