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

Unified Diff: src/views/unix/SkOSWindow_Unix.cpp

Issue 1151333004: CL to add setFullscreen and setVsync to SkWindow (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 7 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 | « include/views/SkWindow.h ('k') | tools/VisualBench.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/views/unix/SkOSWindow_Unix.cpp
diff --git a/src/views/unix/SkOSWindow_Unix.cpp b/src/views/unix/SkOSWindow_Unix.cpp
index e22377a2643a04d05b51f8e2b1c9ac6f33ad2c83..ea2d60b0f3323809ade3fbc43d175b38d49aefe7 100644
--- a/src/views/unix/SkOSWindow_Unix.cpp
+++ b/src/views/unix/SkOSWindow_Unix.cpp
@@ -326,6 +326,29 @@ void SkOSWindow::mapWindowAndWait() {
}
+////////////////////////////////////////////////
+
+// Some helper code to load the correct version of glXSwapInterval
+#define GLX_GET_PROC_ADDR(name) glXGetProcAddress(reinterpret_cast<const GLubyte*>((name)))
+#define EXT_WRANGLE(name, type, ...) \
+ if (GLX_GET_PROC_ADDR(#name)) { \
+ static type k##name; \
+ if (!k##name) { \
+ k##name = (type) GLX_GET_PROC_ADDR(#name); \
+ } \
+ k##name(__VA_ARGS__); \
+ SkDebugf("using %s\n", #name); \
+ return; \
+ }
+
+static void glXSwapInterval(Display* dsp, GLXDrawable drawable, int interval) {
+ EXT_WRANGLE(glXSwapIntervalEXT, PFNGLXSWAPINTERVALEXTPROC, dsp, drawable, interval);
+ EXT_WRANGLE(glXSwapIntervalMESA, PFNGLXSWAPINTERVALMESAPROC, interval);
+ EXT_WRANGLE(glXSwapIntervalSGI, PFNGLXSWAPINTERVALSGIPROC, interval);
+}
+
+/////////////////////////////////////////////////////////////////////////
+
bool SkOSWindow::attach(SkBackEndTypes, int msaaSampleCount, AttachmentInfo* info) {
this->initWindow(msaaSampleCount, info);
@@ -427,6 +450,44 @@ void SkOSWindow::doPaint() {
width, height);
}
+enum {
+ _NET_WM_STATE_REMOVE =0,
+ _NET_WM_STATE_ADD = 1,
+ _NET_WM_STATE_TOGGLE =2
+};
+
+void SkOSWindow::setFullscreen(bool setFullscreen) {
+ Display* dsp = fUnixWindow.fDisplay;
+ if (NULL == dsp) {
+ return;
+ }
+ Window win = fUnixWindow.fWin;
+
+ // Full screen
+ Atom wm_state = XInternAtom(dsp, "_NET_WM_STATE", False);
+ Atom fullscreen = XInternAtom(dsp, "_NET_WM_STATE_FULLSCREEN", False);
+
+ XEvent evt;
+ sk_bzero(&evt, sizeof(evt));
+ evt.type = ClientMessage;
+ evt.xclient.window = win;
+ evt.xclient.message_type = wm_state;
+ evt.xclient.format = 32;
+ evt.xclient.data.l[0] = setFullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
+ evt.xclient.data.l[1] = fullscreen;
+ evt.xclient.data.l[2] = 0;
+
+ XSendEvent(dsp, DefaultRootWindow(dsp), False,
+ SubstructureRedirectMask | SubstructureNotifyMask, &evt);
+}
+
+void SkOSWindow::setVsync(bool vsync) {
+ if (fUnixWindow.fDisplay && fUnixWindow.fGLContext && fUnixWindow.fWin) {
+ int swapInterval = vsync ? 1 : 0;
+ glXSwapInterval(fUnixWindow.fDisplay, fUnixWindow.fWin, swapInterval);
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
void SkEvent::SignalNonEmptyQueue() {
« no previous file with comments | « include/views/SkWindow.h ('k') | tools/VisualBench.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698