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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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 | « src/views/sdl/SkOSWindow_SDL.cpp ('k') | src/views/unix/skia_unix.cpp » ('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 15 matching lines...) Expand all
26 } 26 }
27 27
28 const int WIDTH = 500; 28 const int WIDTH = 500;
29 const int HEIGHT = 500; 29 const int HEIGHT = 500;
30 30
31 // Determine which events to listen for. 31 // Determine which events to listen for.
32 const long EVENT_MASK = StructureNotifyMask|ButtonPressMask|ButtonReleaseMask 32 const long EVENT_MASK = StructureNotifyMask|ButtonPressMask|ButtonReleaseMask
33 |ExposureMask|PointerMotionMask|KeyPressMask|KeyReleaseMask; 33 |ExposureMask|PointerMotionMask|KeyPressMask|KeyReleaseMask;
34 34
35 SkOSWindow::SkOSWindow(void*) 35 SkOSWindow::SkOSWindow(void*)
36 : fVi(NULL) 36 : fVi(nullptr)
37 , fMSAASampleCount(0) { 37 , fMSAASampleCount(0) {
38 fUnixWindow.fDisplay = NULL; 38 fUnixWindow.fDisplay = nullptr;
39 fUnixWindow.fGLContext = NULL; 39 fUnixWindow.fGLContext = nullptr;
40 this->initWindow(0, NULL); 40 this->initWindow(0, nullptr);
41 this->resize(WIDTH, HEIGHT); 41 this->resize(WIDTH, HEIGHT);
42 } 42 }
43 43
44 SkOSWindow::~SkOSWindow() { 44 SkOSWindow::~SkOSWindow() {
45 this->internalCloseWindow(); 45 this->internalCloseWindow();
46 } 46 }
47 47
48 void SkOSWindow::internalCloseWindow() { 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 = nullptr;
54 XDestroyWindow(fUnixWindow.fDisplay, fUnixWindow.fWin); 54 XDestroyWindow(fUnixWindow.fDisplay, fUnixWindow.fWin);
55 fVi = NULL; 55 fVi = nullptr;
56 XCloseDisplay(fUnixWindow.fDisplay); 56 XCloseDisplay(fUnixWindow.fDisplay);
57 fUnixWindow.fDisplay = NULL; 57 fUnixWindow.fDisplay = nullptr;
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->internalCloseWindow(); 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;
75 } 75 }
76 } 76 }
77 return; 77 return;
78 } 78 }
79 fUnixWindow.fDisplay = XOpenDisplay(NULL); 79 fUnixWindow.fDisplay = XOpenDisplay(nullptr);
80 Display* dsp = fUnixWindow.fDisplay; 80 Display* dsp = fUnixWindow.fDisplay;
81 if (NULL == dsp) { 81 if (nullptr == dsp) {
82 SkDebugf("Could not open an X Display"); 82 SkDebugf("Could not open an X Display");
83 return; 83 return;
84 } 84 }
85 // Attempt to create a window that supports GL 85 // Attempt to create a window that supports GL
86 GLint att[] = { 86 GLint att[] = {
87 GLX_RGBA, 87 GLX_RGBA,
88 GLX_DEPTH_SIZE, 24, 88 GLX_DEPTH_SIZE, 24,
89 GLX_DOUBLEBUFFER, 89 GLX_DOUBLEBUFFER,
90 GLX_STENCIL_SIZE, 8, 90 GLX_STENCIL_SIZE, 8,
91 None 91 None
92 }; 92 };
93 SkASSERT(NULL == fVi); 93 SkASSERT(nullptr == fVi);
94 if (requestedMSAASampleCount > 0) { 94 if (requestedMSAASampleCount > 0) {
95 static const GLint kAttCount = SK_ARRAY_COUNT(att); 95 static const GLint kAttCount = SK_ARRAY_COUNT(att);
96 GLint msaaAtt[kAttCount + 4]; 96 GLint msaaAtt[kAttCount + 4];
97 memcpy(msaaAtt, att, sizeof(att)); 97 memcpy(msaaAtt, att, sizeof(att));
98 SkASSERT(None == msaaAtt[kAttCount - 1]); 98 SkASSERT(None == msaaAtt[kAttCount - 1]);
99 msaaAtt[kAttCount - 1] = GLX_SAMPLE_BUFFERS_ARB; 99 msaaAtt[kAttCount - 1] = GLX_SAMPLE_BUFFERS_ARB;
100 msaaAtt[kAttCount + 0] = 1; 100 msaaAtt[kAttCount + 0] = 1;
101 msaaAtt[kAttCount + 1] = GLX_SAMPLES_ARB; 101 msaaAtt[kAttCount + 1] = GLX_SAMPLES_ARB;
102 msaaAtt[kAttCount + 2] = requestedMSAASampleCount; 102 msaaAtt[kAttCount + 2] = requestedMSAASampleCount;
103 msaaAtt[kAttCount + 3] = None; 103 msaaAtt[kAttCount + 3] = None;
104 fVi = glXChooseVisual(dsp, DefaultScreen(dsp), msaaAtt); 104 fVi = glXChooseVisual(dsp, DefaultScreen(dsp), msaaAtt);
105 fMSAASampleCount = requestedMSAASampleCount; 105 fMSAASampleCount = requestedMSAASampleCount;
106 } 106 }
107 if (NULL == fVi) { 107 if (nullptr == fVi) {
108 fVi = glXChooseVisual(dsp, DefaultScreen(dsp), att); 108 fVi = glXChooseVisual(dsp, DefaultScreen(dsp), att);
109 fMSAASampleCount = 0; 109 fMSAASampleCount = 0;
110 } 110 }
111 111
112 if (fVi) { 112 if (fVi) {
113 if (info) { 113 if (info) {
114 glXGetConfig(dsp, fVi, GLX_SAMPLES_ARB, &info->fSampleCount); 114 glXGetConfig(dsp, fVi, GLX_SAMPLES_ARB, &info->fSampleCount);
115 glXGetConfig(dsp, fVi, GLX_STENCIL_SIZE, &info->fStencilBits); 115 glXGetConfig(dsp, fVi, GLX_STENCIL_SIZE, &info->fStencilBits);
116 } 116 }
117 Colormap colorMap = XCreateColormap(dsp, 117 Colormap colorMap = XCreateColormap(dsp,
(...skipping 21 matching lines...) Expand all
139 // Create a simple window instead. We will not be able to show GL 139 // Create a simple window instead. We will not be able to show GL
140 fUnixWindow.fWin = XCreateSimpleWindow(dsp, 140 fUnixWindow.fWin = XCreateSimpleWindow(dsp,
141 DefaultRootWindow(dsp), 141 DefaultRootWindow(dsp),
142 0, 0, // x, y 142 0, 0, // x, y
143 WIDTH, HEIGHT, 143 WIDTH, HEIGHT,
144 0, // border width 144 0, // border width
145 0, // border value 145 0, // border value
146 0); // background value 146 0); // background value
147 } 147 }
148 this->mapWindowAndWait(); 148 this->mapWindowAndWait();
149 fUnixWindow.fGc = XCreateGC(dsp, fUnixWindow.fWin, 0, NULL); 149 fUnixWindow.fGc = XCreateGC(dsp, fUnixWindow.fWin, 0, nullptr);
150 } 150 }
151 151
152 static unsigned getModi(const XEvent& evt) { 152 static unsigned getModi(const XEvent& evt) {
153 static const struct { 153 static const struct {
154 unsigned fXMask; 154 unsigned fXMask;
155 unsigned fSkMask; 155 unsigned fSkMask;
156 } gModi[] = { 156 } gModi[] = {
157 // X values found by experiment. Is there a better way? 157 // X values found by experiment. Is there a better way?
158 { 1, kShift_SkModifierKey }, 158 { 1, kShift_SkModifierKey },
159 { 4, kControl_SkModifierKey }, 159 { 4, kControl_SkModifierKey },
(...skipping 23 matching lines...) Expand all
183 if (ms > 0) { 183 if (ms > 0) {
184 int x11_fd = ConnectionNumber(dsp); 184 int x11_fd = ConnectionNumber(dsp);
185 fd_set input_fds; 185 fd_set input_fds;
186 FD_ZERO(&input_fds); 186 FD_ZERO(&input_fds);
187 FD_SET(x11_fd, &input_fds); 187 FD_SET(x11_fd, &input_fds);
188 188
189 timeval tv; 189 timeval tv;
190 tv.tv_sec = ms / 1000; // seconds 190 tv.tv_sec = ms / 1000; // seconds
191 tv.tv_usec = (ms % 1000) * 1000; // microseconds 191 tv.tv_usec = (ms % 1000) * 1000; // microseconds
192 192
193 if (!select(x11_fd + 1, &input_fds, NULL, NULL, &tv)) { 193 if (!select(x11_fd + 1, &input_fds, nullptr, nullptr, &tv)) {
194 if (!XPending(dsp)) { 194 if (!XPending(dsp)) {
195 return false; 195 return false;
196 } 196 }
197 } 197 }
198 } 198 }
199 XNextEvent(dsp, evt); 199 XNextEvent(dsp, evt);
200 return true; 200 return true;
201 } 201 }
202 202
203 static Atom wm_delete_window_message; 203 static Atom wm_delete_window_message;
(...skipping 11 matching lines...) Expand all
215 if (0 == evt.xexpose.count) { 215 if (0 == evt.xexpose.count) {
216 return kPaintRequest_NextXEventResult; 216 return kPaintRequest_NextXEventResult;
217 } 217 }
218 break; 218 break;
219 case ConfigureNotify: 219 case ConfigureNotify:
220 this->resize(evt.xconfigure.width, evt.xconfigure.height); 220 this->resize(evt.xconfigure.width, evt.xconfigure.height);
221 break; 221 break;
222 case ButtonPress: 222 case ButtonPress:
223 if (evt.xbutton.button == Button1) 223 if (evt.xbutton.button == Button1)
224 this->handleClick(evt.xbutton.x, evt.xbutton.y, 224 this->handleClick(evt.xbutton.x, evt.xbutton.y,
225 SkView::Click::kDown_State, NULL, getModi(evt)); 225 SkView::Click::kDown_State, nullptr, getModi(evt));
226 break; 226 break;
227 case ButtonRelease: 227 case ButtonRelease:
228 if (evt.xbutton.button == Button1) 228 if (evt.xbutton.button == Button1)
229 this->handleClick(evt.xbutton.x, evt.xbutton.y, 229 this->handleClick(evt.xbutton.x, evt.xbutton.y,
230 SkView::Click::kUp_State, NULL, getModi(evt)); 230 SkView::Click::kUp_State, nullptr, getModi(evt));
231 break; 231 break;
232 case MotionNotify: 232 case MotionNotify:
233 this->handleClick(evt.xmotion.x, evt.xmotion.y, 233 this->handleClick(evt.xmotion.x, evt.xmotion.y,
234 SkView::Click::kMoved_State, NULL, getModi(evt)); 234 SkView::Click::kMoved_State, nullptr, getModi(evt));
235 break; 235 break;
236 case KeyPress: { 236 case KeyPress: {
237 int shiftLevel = (evt.xkey.state & ShiftMask) ? 1 : 0; 237 int shiftLevel = (evt.xkey.state & ShiftMask) ? 1 : 0;
238 KeySym keysym = XkbKeycodeToKeysym(dsp, evt.xkey.keycode, 238 KeySym keysym = XkbKeycodeToKeysym(dsp, evt.xkey.keycode,
239 0, shiftLevel); 239 0, shiftLevel);
240 if (keysym == XK_Escape) { 240 if (keysym == XK_Escape) {
241 return kQuitRequest_NextXEventResult; 241 return kQuitRequest_NextXEventResult;
242 } 242 }
243 this->handleKey(XKeyToSkKey(keysym)); 243 this->handleKey(XKeyToSkKey(keysym));
244 long uni = keysym2ucs(keysym); 244 long uni = keysym2ucs(keysym);
(...skipping 12 matching lines...) Expand all
257 // fallthrough 257 // fallthrough
258 default: 258 default:
259 // Do nothing for other events 259 // Do nothing for other events
260 break; 260 break;
261 } 261 }
262 return kContinue_NextXEventResult; 262 return kContinue_NextXEventResult;
263 } 263 }
264 264
265 void SkOSWindow::loop() { 265 void SkOSWindow::loop() {
266 Display* dsp = fUnixWindow.fDisplay; 266 Display* dsp = fUnixWindow.fDisplay;
267 if (NULL == dsp) { 267 if (nullptr == dsp) {
268 return; 268 return;
269 } 269 }
270 Window win = fUnixWindow.fWin; 270 Window win = fUnixWindow.fWin;
271 271
272 wm_delete_window_message = XInternAtom(dsp, "WM_DELETE_WINDOW", False); 272 wm_delete_window_message = XInternAtom(dsp, "WM_DELETE_WINDOW", False);
273 XSetWMProtocols(dsp, win, &wm_delete_window_message, 1); 273 XSetWMProtocols(dsp, win, &wm_delete_window_message, 1);
274 274
275 XSelectInput(dsp, win, EVENT_MASK); 275 XSelectInput(dsp, win, EVENT_MASK);
276 276
277 bool sentExposeEvent = false; 277 bool sentExposeEvent = false;
(...skipping 13 matching lines...) Expand all
291 XSendEvent(dsp, win, false, ExposureMask, &evt); 291 XSendEvent(dsp, win, false, ExposureMask, &evt);
292 } 292 }
293 293
294 if (XPending(dsp) || !moreToDo) { 294 if (XPending(dsp) || !moreToDo) {
295 switch (this->nextXEvent()) { 295 switch (this->nextXEvent()) {
296 case kContinue_NextXEventResult: 296 case kContinue_NextXEventResult:
297 break; 297 break;
298 case kPaintRequest_NextXEventResult: 298 case kPaintRequest_NextXEventResult:
299 sentExposeEvent = false; 299 sentExposeEvent = false;
300 if (this->isDirty()) { 300 if (this->isDirty()) {
301 this->update(NULL); 301 this->update(nullptr);
302 } 302 }
303 this->doPaint(); 303 this->doPaint();
304 break; 304 break;
305 case kQuitRequest_NextXEventResult: 305 case kQuitRequest_NextXEventResult:
306 return; 306 return;
307 } 307 }
308 } 308 }
309 } 309 }
310 } 310 }
311 311
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 EXT_WRANGLE(glXSwapIntervalEXT, PFNGLXSWAPINTERVALEXTPROC, dsp, drawable, in terval); 345 EXT_WRANGLE(glXSwapIntervalEXT, PFNGLXSWAPINTERVALEXTPROC, dsp, drawable, in terval);
346 EXT_WRANGLE(glXSwapIntervalMESA, PFNGLXSWAPINTERVALMESAPROC, interval); 346 EXT_WRANGLE(glXSwapIntervalMESA, PFNGLXSWAPINTERVALMESAPROC, interval);
347 EXT_WRANGLE(glXSwapIntervalSGI, PFNGLXSWAPINTERVALSGIPROC, interval); 347 EXT_WRANGLE(glXSwapIntervalSGI, PFNGLXSWAPINTERVALSGIPROC, interval);
348 } 348 }
349 349
350 ///////////////////////////////////////////////////////////////////////// 350 /////////////////////////////////////////////////////////////////////////
351 351
352 bool SkOSWindow::attach(SkBackEndTypes, int msaaSampleCount, AttachmentInfo* inf o) { 352 bool SkOSWindow::attach(SkBackEndTypes, int msaaSampleCount, AttachmentInfo* inf o) {
353 this->initWindow(msaaSampleCount, info); 353 this->initWindow(msaaSampleCount, info);
354 354
355 if (NULL == fUnixWindow.fDisplay) { 355 if (nullptr == fUnixWindow.fDisplay) {
356 return false; 356 return false;
357 } 357 }
358 if (NULL == fUnixWindow.fGLContext) { 358 if (nullptr == fUnixWindow.fGLContext) {
359 SkASSERT(fVi); 359 SkASSERT(fVi);
360 360
361 fUnixWindow.fGLContext = glXCreateContext(fUnixWindow.fDisplay, 361 fUnixWindow.fGLContext = glXCreateContext(fUnixWindow.fDisplay,
362 fVi, 362 fVi,
363 NULL, 363 nullptr,
364 GL_TRUE); 364 GL_TRUE);
365 if (NULL == fUnixWindow.fGLContext) { 365 if (nullptr == fUnixWindow.fGLContext) {
366 return false; 366 return false;
367 } 367 }
368 } 368 }
369 glXMakeCurrent(fUnixWindow.fDisplay, 369 glXMakeCurrent(fUnixWindow.fDisplay,
370 fUnixWindow.fWin, 370 fUnixWindow.fWin,
371 fUnixWindow.fGLContext); 371 fUnixWindow.fGLContext);
372 glViewport(0, 0, 372 glViewport(0, 0,
373 SkScalarRoundToInt(this->width()), 373 SkScalarRoundToInt(this->width()),
374 SkScalarRoundToInt(this->height())); 374 SkScalarRoundToInt(this->height()));
375 glClearColor(0, 0, 0, 0); 375 glClearColor(0, 0, 0, 0);
376 glClearStencil(0); 376 glClearStencil(0);
377 glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 377 glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
378 return true; 378 return true;
379 } 379 }
380 380
381 void SkOSWindow::detach() { 381 void SkOSWindow::detach() {
382 if (NULL == fUnixWindow.fDisplay || NULL == fUnixWindow.fGLContext) { 382 if (nullptr == fUnixWindow.fDisplay || nullptr == fUnixWindow.fGLContext) {
383 return; 383 return;
384 } 384 }
385 glXMakeCurrent(fUnixWindow.fDisplay, None, NULL); 385 glXMakeCurrent(fUnixWindow.fDisplay, None, nullptr);
386 glXDestroyContext(fUnixWindow.fDisplay, fUnixWindow.fGLContext); 386 glXDestroyContext(fUnixWindow.fDisplay, fUnixWindow.fGLContext);
387 fUnixWindow.fGLContext = NULL; 387 fUnixWindow.fGLContext = nullptr;
388 } 388 }
389 389
390 void SkOSWindow::present() { 390 void SkOSWindow::present() {
391 if (fUnixWindow.fDisplay && fUnixWindow.fGLContext) { 391 if (fUnixWindow.fDisplay && fUnixWindow.fGLContext) {
392 glXSwapBuffers(fUnixWindow.fDisplay, fUnixWindow.fWin); 392 glXSwapBuffers(fUnixWindow.fDisplay, fUnixWindow.fWin);
393 } 393 }
394 } 394 }
395 395
396 void SkOSWindow::onSetTitle(const char title[]) { 396 void SkOSWindow::onSetTitle(const char title[]) {
397 if (NULL == fUnixWindow.fDisplay) { 397 if (nullptr == fUnixWindow.fDisplay) {
398 return; 398 return;
399 } 399 }
400 XTextProperty textProp; 400 XTextProperty textProp;
401 textProp.value = (unsigned char*)title; 401 textProp.value = (unsigned char*)title;
402 textProp.format = 8; 402 textProp.format = 8;
403 textProp.nitems = strlen((char*)textProp.value); 403 textProp.nitems = strlen((char*)textProp.value);
404 textProp.encoding = XA_STRING; 404 textProp.encoding = XA_STRING;
405 XSetWMName(fUnixWindow.fDisplay, fUnixWindow.fWin, &textProp); 405 XSetWMName(fUnixWindow.fDisplay, fUnixWindow.fWin, &textProp);
406 } 406 }
407 407
408 static bool convertBitmapToXImage(XImage& image, const SkBitmap& bitmap) { 408 static bool convertBitmapToXImage(XImage& image, const SkBitmap& bitmap) {
409 sk_bzero(&image, sizeof(image)); 409 sk_bzero(&image, sizeof(image));
410 410
411 int bitsPerPixel = bitmap.bytesPerPixel() * 8; 411 int bitsPerPixel = bitmap.bytesPerPixel() * 8;
412 image.width = bitmap.width(); 412 image.width = bitmap.width();
413 image.height = bitmap.height(); 413 image.height = bitmap.height();
414 image.format = ZPixmap; 414 image.format = ZPixmap;
415 image.data = (char*) bitmap.getPixels(); 415 image.data = (char*) bitmap.getPixels();
416 image.byte_order = LSBFirst; 416 image.byte_order = LSBFirst;
417 image.bitmap_unit = bitsPerPixel; 417 image.bitmap_unit = bitsPerPixel;
418 image.bitmap_bit_order = LSBFirst; 418 image.bitmap_bit_order = LSBFirst;
419 image.bitmap_pad = bitsPerPixel; 419 image.bitmap_pad = bitsPerPixel;
420 image.depth = 24; 420 image.depth = 24;
421 image.bytes_per_line = bitmap.rowBytes() - bitmap.width() * 4; 421 image.bytes_per_line = bitmap.rowBytes() - bitmap.width() * 4;
422 image.bits_per_pixel = bitsPerPixel; 422 image.bits_per_pixel = bitsPerPixel;
423 return XInitImage(&image); 423 return XInitImage(&image);
424 } 424 }
425 425
426 void SkOSWindow::doPaint() { 426 void SkOSWindow::doPaint() {
427 if (NULL == fUnixWindow.fDisplay) { 427 if (nullptr == fUnixWindow.fDisplay) {
428 return; 428 return;
429 } 429 }
430 // If we are drawing with GL, we don't need XPutImage. 430 // If we are drawing with GL, we don't need XPutImage.
431 if (fUnixWindow.fGLContext) { 431 if (fUnixWindow.fGLContext) {
432 return; 432 return;
433 } 433 }
434 // Draw the bitmap to the screen. 434 // Draw the bitmap to the screen.
435 const SkBitmap& bitmap = getBitmap(); 435 const SkBitmap& bitmap = getBitmap();
436 int width = bitmap.width(); 436 int width = bitmap.width();
437 int height = bitmap.height(); 437 int height = bitmap.height();
(...skipping 13 matching lines...) Expand all
451 } 451 }
452 452
453 enum { 453 enum {
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 bool SkOSWindow::makeFullscreen() { 459 bool SkOSWindow::makeFullscreen() {
460 Display* dsp = fUnixWindow.fDisplay; 460 Display* dsp = fUnixWindow.fDisplay;
461 if (NULL == dsp) { 461 if (nullptr == dsp) {
462 return false; 462 return false;
463 } 463 }
464 464
465 // Full screen 465 // Full screen
466 Atom wm_state = XInternAtom(dsp, "_NET_WM_STATE", False); 466 Atom wm_state = XInternAtom(dsp, "_NET_WM_STATE", False);
467 Atom fullscreen = XInternAtom(dsp, "_NET_WM_STATE_FULLSCREEN", False); 467 Atom fullscreen = XInternAtom(dsp, "_NET_WM_STATE_FULLSCREEN", False);
468 468
469 XEvent evt; 469 XEvent evt;
470 sk_bzero(&evt, sizeof(evt)); 470 sk_bzero(&evt, sizeof(evt));
471 evt.type = ClientMessage; 471 evt.type = ClientMessage;
(...skipping 11 matching lines...) Expand all
483 483
484 void SkOSWindow::setVsync(bool vsync) { 484 void SkOSWindow::setVsync(bool vsync) {
485 if (fUnixWindow.fDisplay && fUnixWindow.fGLContext && fUnixWindow.fWin) { 485 if (fUnixWindow.fDisplay && fUnixWindow.fGLContext && fUnixWindow.fWin) {
486 int swapInterval = vsync ? 1 : 0; 486 int swapInterval = vsync ? 1 : 0;
487 glXSwapInterval(fUnixWindow.fDisplay, fUnixWindow.fWin, swapInterval); 487 glXSwapInterval(fUnixWindow.fDisplay, fUnixWindow.fWin, swapInterval);
488 } 488 }
489 } 489 }
490 490
491 void SkOSWindow::closeWindow() { 491 void SkOSWindow::closeWindow() {
492 Display* dsp = fUnixWindow.fDisplay; 492 Display* dsp = fUnixWindow.fDisplay;
493 if (NULL == dsp) { 493 if (nullptr == dsp) {
494 return; 494 return;
495 } 495 }
496 496
497 XEvent evt; 497 XEvent evt;
498 sk_bzero(&evt, sizeof(evt)); 498 sk_bzero(&evt, sizeof(evt));
499 evt.type = ClientMessage; 499 evt.type = ClientMessage;
500 evt.xclient.message_type = XInternAtom(dsp, "WM_PROTOCOLS", true); 500 evt.xclient.message_type = XInternAtom(dsp, "WM_PROTOCOLS", true);
501 evt.xclient.window = fUnixWindow.fWin; 501 evt.xclient.window = fUnixWindow.fWin;
502 evt.xclient.format = 32; 502 evt.xclient.format = 32;
503 evt.xclient.data.l[0] = XInternAtom(dsp, "WM_DELETE_WINDOW", false); 503 evt.xclient.data.l[0] = XInternAtom(dsp, "WM_DELETE_WINDOW", false);
504 evt.xclient.data.l[1] = CurrentTime; 504 evt.xclient.data.l[1] = CurrentTime;
505 505
506 XSendEvent(dsp, fUnixWindow.fWin, false, NoEventMask, &evt); 506 XSendEvent(dsp, fUnixWindow.fWin, false, NoEventMask, &evt);
507 } 507 }
508 508
509 /////////////////////////////////////////////////////////////////////////////// 509 ///////////////////////////////////////////////////////////////////////////////
510 510
511 void SkEvent::SignalNonEmptyQueue() { 511 void SkEvent::SignalNonEmptyQueue() {
512 // nothing to do, since we spin on our event-queue, polling for XPending 512 // nothing to do, since we spin on our event-queue, polling for XPending
513 } 513 }
514 514
515 void SkEvent::SignalQueueTimer(SkMSec delay) { 515 void SkEvent::SignalQueueTimer(SkMSec delay) {
516 // just need to record the delay time. We handle waking up for it in 516 // just need to record the delay time. We handle waking up for it in
517 // MyXNextEventWithDelay() 517 // MyXNextEventWithDelay()
518 gTimerDelay = delay; 518 gTimerDelay = delay;
519 } 519 }
OLDNEW
« no previous file with comments | « src/views/sdl/SkOSWindow_SDL.cpp ('k') | src/views/unix/skia_unix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698