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

Unified Diff: src/views/win/SkOSWindow_win.cpp

Issue 1306823003: skia: add ability to load command_buffer_gles2 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: and NULL->nullptr, just because. Created 5 years, 4 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
« no previous file with comments | « src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698