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

Side by Side Diff: src/gpu/gl/glx/SkCreatePlatformGLContext_glx.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
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 "gl/SkGLContext.h" 8 #include "gl/SkGLContext.h"
9 9
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 void onPlatformSwapBuffers() const override; 56 void onPlatformSwapBuffers() const override;
57 GrGLFuncPtr onPlatformGetProcAddress(const char*) const override; 57 GrGLFuncPtr onPlatformGetProcAddress(const char*) const override;
58 58
59 GLXContext fContext; 59 GLXContext fContext;
60 Display* fDisplay; 60 Display* fDisplay;
61 Pixmap fPixmap; 61 Pixmap fPixmap;
62 GLXPixmap fGlxPixmap; 62 GLXPixmap fGlxPixmap;
63 }; 63 };
64 64
65 GLXGLContext::GLXGLContext(GrGLStandard forcedGpuAPI) 65 GLXGLContext::GLXGLContext(GrGLStandard forcedGpuAPI)
66 : fContext(NULL) 66 : fContext(nullptr)
67 , fDisplay(NULL) 67 , fDisplay(nullptr)
68 , fPixmap(0) 68 , fPixmap(0)
69 , fGlxPixmap(0) { 69 , fGlxPixmap(0) {
70 70
71 fDisplay = XOpenDisplay(0); 71 fDisplay = XOpenDisplay(0);
72 72
73 if (!fDisplay) { 73 if (!fDisplay) {
74 SkDebugf("Failed to open X display.\n"); 74 SkDebugf("Failed to open X display.\n");
75 this->destroyGLContext(); 75 this->destroyGLContext();
76 return; 76 return;
77 } 77 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 263 }
264 264
265 //SkDebugf("Making context current.\n"); 265 //SkDebugf("Making context current.\n");
266 if (!glXMakeCurrent(fDisplay, fGlxPixmap, fContext)) { 266 if (!glXMakeCurrent(fDisplay, fGlxPixmap, fContext)) {
267 SkDebugf("Could not set the context.\n"); 267 SkDebugf("Could not set the context.\n");
268 this->destroyGLContext(); 268 this->destroyGLContext();
269 return; 269 return;
270 } 270 }
271 271
272 SkAutoTUnref<const GrGLInterface> gl(GrGLCreateNativeInterface()); 272 SkAutoTUnref<const GrGLInterface> gl(GrGLCreateNativeInterface());
273 if (NULL == gl.get()) { 273 if (nullptr == gl.get()) {
274 SkDebugf("Failed to create gl interface"); 274 SkDebugf("Failed to create gl interface");
275 this->destroyGLContext(); 275 this->destroyGLContext();
276 return; 276 return;
277 } 277 }
278 278
279 if (!gl->validate()) { 279 if (!gl->validate()) {
280 SkDebugf("Failed to validate gl interface"); 280 SkDebugf("Failed to validate gl interface");
281 this->destroyGLContext(); 281 this->destroyGLContext();
282 return; 282 return;
283 } 283 }
284 284
285 this->init(gl.detach()); 285 this->init(gl.detach());
286 } 286 }
287 287
288 288
289 GLXGLContext::~GLXGLContext() { 289 GLXGLContext::~GLXGLContext() {
290 this->teardown(); 290 this->teardown();
291 this->destroyGLContext(); 291 this->destroyGLContext();
292 } 292 }
293 293
294 void GLXGLContext::destroyGLContext() { 294 void GLXGLContext::destroyGLContext() {
295 if (fDisplay) { 295 if (fDisplay) {
296 glXMakeCurrent(fDisplay, 0, 0); 296 glXMakeCurrent(fDisplay, 0, 0);
297 297
298 if (fContext) { 298 if (fContext) {
299 glXDestroyContext(fDisplay, fContext); 299 glXDestroyContext(fDisplay, fContext);
300 fContext = NULL; 300 fContext = nullptr;
301 } 301 }
302 302
303 if (fGlxPixmap) { 303 if (fGlxPixmap) {
304 glXDestroyGLXPixmap(fDisplay, fGlxPixmap); 304 glXDestroyGLXPixmap(fDisplay, fGlxPixmap);
305 fGlxPixmap = 0; 305 fGlxPixmap = 0;
306 } 306 }
307 307
308 if (fPixmap) { 308 if (fPixmap) {
309 XFreePixmap(fDisplay, fPixmap); 309 XFreePixmap(fDisplay, fPixmap);
310 fPixmap = 0; 310 fPixmap = 0;
311 } 311 }
312 312
313 XCloseDisplay(fDisplay); 313 XCloseDisplay(fDisplay);
314 fDisplay = NULL; 314 fDisplay = nullptr;
315 } 315 }
316 } 316 }
317 317
318 void GLXGLContext::onPlatformMakeCurrent() const { 318 void GLXGLContext::onPlatformMakeCurrent() const {
319 if (!glXMakeCurrent(fDisplay, fGlxPixmap, fContext)) { 319 if (!glXMakeCurrent(fDisplay, fGlxPixmap, fContext)) {
320 SkDebugf("Could not set the context.\n"); 320 SkDebugf("Could not set the context.\n");
321 } 321 }
322 } 322 }
323 323
324 void GLXGLContext::onPlatformSwapBuffers() const { 324 void GLXGLContext::onPlatformSwapBuffers() const {
325 glXSwapBuffers(fDisplay, fGlxPixmap); 325 glXSwapBuffers(fDisplay, fGlxPixmap);
326 } 326 }
327 327
328 GrGLFuncPtr GLXGLContext::onPlatformGetProcAddress(const char* procName) const { 328 GrGLFuncPtr GLXGLContext::onPlatformGetProcAddress(const char* procName) const {
329 return glXGetProcAddress(reinterpret_cast<const GLubyte*>(procName)); 329 return glXGetProcAddress(reinterpret_cast<const GLubyte*>(procName));
330 } 330 }
331 331
332 } // anonymous namespace 332 } // anonymous namespace
333 333
334 SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) { 334 SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) {
335 GLXGLContext *ctx = new GLXGLContext(forcedGpuAPI); 335 GLXGLContext *ctx = new GLXGLContext(forcedGpuAPI);
336 if (!ctx->isValid()) { 336 if (!ctx->isValid()) {
337 delete ctx; 337 delete ctx;
338 return NULL; 338 return nullptr;
339 } 339 }
340 return ctx; 340 return ctx;
341 } 341 }
OLDNEW
« no previous file with comments | « src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp ('k') | src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698