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

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
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..3f5cfa676534bd7cc123b497fa89a8787fe5750f 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,43 @@ void SkOSWindow::doPaint() {
width, height);
}
+void SkOSWindow::setFullscreen(bool) {
+ Display* dsp = fUnixWindow.fDisplay;
+ if (NULL == dsp) {
+ return;
+ }
+ Window win = fUnixWindow.fWin;
+
+ // Full screen, this is a one way trip so callers should be careful
+ Atom wm_state = XInternAtom(dsp, "_NET_WM_STATE", False);
+ Atom fullscreen = XInternAtom(dsp, "_NET_WM_STATE_FULLSCREEN", False);
+
+ XEvent xev;
+ sk_bzero(&xev, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.xclient.window = win;
+ xev.xclient.message_type = wm_state;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = 1;
+ xev.xclient.data.l[1] = fullscreen;
+ xev.xclient.data.l[2] = 0;
+
+ XSendEvent(dsp, DefaultRootWindow(dsp), False,
+ SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+}
+
+void SkOSWindow::setVsync(bool vsync) {
+ if (fUnixWindow.fDisplay && fUnixWindow.fGLContext && fUnixWindow.fWin) {
robertphillips 2015/05/26 21:07:27 int swapInterval = vsync ? 1 : 0; ?
joshualitt 2015/05/27 14:09:34 Acknowledged.
+ int swapInterval;
+ if (vsync) {
+ swapInterval = 1;
+ } else {
+ swapInterval = 0;
+ }
+ glXSwapInterval(fUnixWindow.fDisplay, fUnixWindow.fWin, swapInterval);
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
void SkEvent::SignalNonEmptyQueue() {

Powered by Google App Engine
This is Rietveld 408576698