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

Side by Side Diff: src/views/unix/SkOSWindow_Unix.cpp

Issue 1159213002: Expand VisualBench to a real benching tool (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « include/views/SkWindow.h ('k') | tools/VisualBench.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 #include <X11/Xatom.h> 9 #include <X11/Xatom.h>
10 #include <X11/XKBlib.h> 10 #include <X11/XKBlib.h>
(...skipping 24 matching lines...) Expand all
35 SkOSWindow::SkOSWindow(void*) 35 SkOSWindow::SkOSWindow(void*)
36 : fVi(NULL) 36 : fVi(NULL)
37 , fMSAASampleCount(0) { 37 , fMSAASampleCount(0) {
38 fUnixWindow.fDisplay = NULL; 38 fUnixWindow.fDisplay = NULL;
39 fUnixWindow.fGLContext = NULL; 39 fUnixWindow.fGLContext = NULL;
40 this->initWindow(0, NULL); 40 this->initWindow(0, NULL);
41 this->resize(WIDTH, HEIGHT); 41 this->resize(WIDTH, HEIGHT);
42 } 42 }
43 43
44 SkOSWindow::~SkOSWindow() { 44 SkOSWindow::~SkOSWindow() {
45 this->closeWindow(); 45 this->internalCloseWindow();
46 } 46 }
47 47
48 void SkOSWindow::closeWindow() { 48 void SkOSWindow::internalCloseWindow() {
49 if (fUnixWindow.fDisplay) { 49 if (fUnixWindow.fDisplay) {
50 this->detach(); 50 this->detach();
51 SkASSERT(fUnixWindow.fGc); 51 SkASSERT(fUnixWindow.fGc);
52 XFreeGC(fUnixWindow.fDisplay, fUnixWindow.fGc); 52 XFreeGC(fUnixWindow.fDisplay, fUnixWindow.fGc);
53 fUnixWindow.fGc = NULL; 53 fUnixWindow.fGc = NULL;
54 XDestroyWindow(fUnixWindow.fDisplay, fUnixWindow.fWin); 54 XDestroyWindow(fUnixWindow.fDisplay, fUnixWindow.fWin);
55 fVi = NULL; 55 fVi = NULL;
56 XCloseDisplay(fUnixWindow.fDisplay); 56 XCloseDisplay(fUnixWindow.fDisplay);
57 fUnixWindow.fDisplay = NULL; 57 fUnixWindow.fDisplay = NULL;
58 fMSAASampleCount = 0; 58 fMSAASampleCount = 0;
59 } 59 }
60 } 60 }
61 61
62 void SkOSWindow::initWindow(int requestedMSAASampleCount, AttachmentInfo* info) { 62 void SkOSWindow::initWindow(int requestedMSAASampleCount, AttachmentInfo* info) {
63 if (fMSAASampleCount != requestedMSAASampleCount) { 63 if (fMSAASampleCount != requestedMSAASampleCount) {
64 this->closeWindow(); 64 this->internalCloseWindow();
65 } 65 }
66 // presence of fDisplay means we already have a window 66 // presence of fDisplay means we already have a window
67 if (fUnixWindow.fDisplay) { 67 if (fUnixWindow.fDisplay) {
68 if (info) { 68 if (info) {
69 if (fVi) { 69 if (fVi) {
70 glXGetConfig(fUnixWindow.fDisplay, fVi, GLX_SAMPLES_ARB, &info-> fSampleCount); 70 glXGetConfig(fUnixWindow.fDisplay, fVi, GLX_SAMPLES_ARB, &info-> fSampleCount);
71 glXGetConfig(fUnixWindow.fDisplay, fVi, GLX_STENCIL_SIZE, &info- >fStencilBits); 71 glXGetConfig(fUnixWindow.fDisplay, fVi, GLX_STENCIL_SIZE, &info- >fStencilBits);
72 } else { 72 } else {
73 info->fSampleCount = 0; 73 info->fSampleCount = 0;
74 info->fStencilBits = 0; 74 info->fStencilBits = 0;
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 _NET_WM_STATE_REMOVE =0, 454 _NET_WM_STATE_REMOVE =0,
455 _NET_WM_STATE_ADD = 1, 455 _NET_WM_STATE_ADD = 1,
456 _NET_WM_STATE_TOGGLE =2 456 _NET_WM_STATE_TOGGLE =2
457 }; 457 };
458 458
459 void SkOSWindow::setFullscreen(bool setFullscreen) { 459 void SkOSWindow::setFullscreen(bool setFullscreen) {
460 Display* dsp = fUnixWindow.fDisplay; 460 Display* dsp = fUnixWindow.fDisplay;
461 if (NULL == dsp) { 461 if (NULL == dsp) {
462 return; 462 return;
463 } 463 }
464 Window win = fUnixWindow.fWin;
465 464
466 // Full screen 465 // Full screen
467 Atom wm_state = XInternAtom(dsp, "_NET_WM_STATE", False); 466 Atom wm_state = XInternAtom(dsp, "_NET_WM_STATE", False);
468 Atom fullscreen = XInternAtom(dsp, "_NET_WM_STATE_FULLSCREEN", False); 467 Atom fullscreen = XInternAtom(dsp, "_NET_WM_STATE_FULLSCREEN", False);
469 468
470 XEvent evt; 469 XEvent evt;
471 sk_bzero(&evt, sizeof(evt)); 470 sk_bzero(&evt, sizeof(evt));
472 evt.type = ClientMessage; 471 evt.type = ClientMessage;
473 evt.xclient.window = win; 472 evt.xclient.window = fUnixWindow.fWin;
474 evt.xclient.message_type = wm_state; 473 evt.xclient.message_type = wm_state;
475 evt.xclient.format = 32; 474 evt.xclient.format = 32;
476 evt.xclient.data.l[0] = setFullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_RE MOVE; 475 evt.xclient.data.l[0] = setFullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_RE MOVE;
477 evt.xclient.data.l[1] = fullscreen; 476 evt.xclient.data.l[1] = fullscreen;
478 evt.xclient.data.l[2] = 0; 477 evt.xclient.data.l[2] = 0;
479 478
480 XSendEvent(dsp, DefaultRootWindow(dsp), False, 479 XSendEvent(dsp, DefaultRootWindow(dsp), False,
481 SubstructureRedirectMask | SubstructureNotifyMask, &evt); 480 SubstructureRedirectMask | SubstructureNotifyMask, &evt);
482 } 481 }
483 482
484 void SkOSWindow::setVsync(bool vsync) { 483 void SkOSWindow::setVsync(bool vsync) {
485 if (fUnixWindow.fDisplay && fUnixWindow.fGLContext && fUnixWindow.fWin) { 484 if (fUnixWindow.fDisplay && fUnixWindow.fGLContext && fUnixWindow.fWin) {
486 int swapInterval = vsync ? 1 : 0; 485 int swapInterval = vsync ? 1 : 0;
487 glXSwapInterval(fUnixWindow.fDisplay, fUnixWindow.fWin, swapInterval); 486 glXSwapInterval(fUnixWindow.fDisplay, fUnixWindow.fWin, swapInterval);
488 } 487 }
489 } 488 }
490 489
490 void SkOSWindow::closeWindow() {
491 Display* dsp = fUnixWindow.fDisplay;
492 if (NULL == dsp) {
493 return;
494 }
495
496 XEvent evt;
497 sk_bzero(&evt, sizeof(evt));
498 evt.type = ClientMessage;
499 evt.xclient.message_type = XInternAtom(dsp, "WM_PROTOCOLS", true);
500 evt.xclient.window = fUnixWindow.fWin;
501 evt.xclient.format = 32;
502 evt.xclient.data.l[0] = XInternAtom(dsp, "WM_DELETE_WINDOW", false);
503 evt.xclient.data.l[1] = CurrentTime;
504
505 XSendEvent(dsp, fUnixWindow.fWin, false, NoEventMask, &evt);
506 }
507
491 /////////////////////////////////////////////////////////////////////////////// 508 ///////////////////////////////////////////////////////////////////////////////
492 509
493 void SkEvent::SignalNonEmptyQueue() { 510 void SkEvent::SignalNonEmptyQueue() {
494 // nothing to do, since we spin on our event-queue, polling for XPending 511 // nothing to do, since we spin on our event-queue, polling for XPending
495 } 512 }
496 513
497 void SkEvent::SignalQueueTimer(SkMSec delay) { 514 void SkEvent::SignalQueueTimer(SkMSec delay) {
498 // just need to record the delay time. We handle waking up for it in 515 // just need to record the delay time. We handle waking up for it in
499 // MyXNextEventWithDelay() 516 // MyXNextEventWithDelay()
500 gTimerDelay = delay; 517 gTimerDelay = delay;
501 } 518 }
OLDNEW
« 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