| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2016 Google Inc. | 3 * Copyright 2016 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 | 8 |
| 9 #include "GLWindowContext_unix.h" | 9 #include "GLWindowContext_mac.h" |
| 10 | 10 |
| 11 #include <GL/gl.h> | 11 //#include <GL/gl.h> |
| 12 | 12 |
| 13 #include "Window_unix.h" | 13 #include "Window_mac.h" |
| 14 | 14 |
| 15 namespace sk_app { | 15 namespace sk_app { |
| 16 | 16 |
| 17 // platform-dependent create | 17 // platform-dependent create |
| 18 GLWindowContext* GLWindowContext::Create(void* platformData, const DisplayParams
& params) { | 18 GLWindowContext* GLWindowContext::Create(void* platformData, const DisplayParams
& params) { |
| 19 GLWindowContext_unix* ctx = new GLWindowContext_unix(platformData, params); | 19 GLWindowContext_mac* ctx = new GLWindowContext_mac(platformData, params); |
| 20 if (!ctx->isValid()) { | 20 if (!ctx->isValid()) { |
| 21 delete ctx; | 21 delete ctx; |
| 22 return nullptr; | 22 return nullptr; |
| 23 } | 23 } |
| 24 return ctx; | 24 return ctx; |
| 25 } | 25 } |
| 26 | 26 |
| 27 GLWindowContext_unix::GLWindowContext_unix(void* platformData, const DisplayPara
ms& params) | 27 GLWindowContext_mac::GLWindowContext_mac(void* platformData, const DisplayParams
& params) |
| 28 : GLWindowContext(platformData, params) | 28 : GLWindowContext(platformData, params) |
| 29 #if 0 |
| 30 // TODO: init Mac-specific OpenGL objects |
| 29 , fDisplay(nullptr) | 31 , fDisplay(nullptr) |
| 30 , fWindow(0) | 32 , fWindow(0) |
| 31 , fGLContext(0) { | 33 , fGLContext(0) |
| 34 #endif |
| 35 { |
| 32 | 36 |
| 33 // any config code here (particularly for msaa)? | 37 // any config code here (particularly for msaa)? |
| 34 | 38 |
| 35 this->initializeContext(platformData, params); | 39 this->initializeContext(platformData, params); |
| 36 } | 40 } |
| 37 | 41 |
| 38 GLWindowContext_unix::~GLWindowContext_unix() { | 42 GLWindowContext_mac::~GLWindowContext_mac() { |
| 39 this->destroyContext(); | 43 this->destroyContext(); |
| 40 } | 44 } |
| 41 | 45 |
| 42 void GLWindowContext_unix::onInitializeContext(void* platformData, const Display
Params& params) { | 46 void GLWindowContext_mac::onInitializeContext(void* platformData, const DisplayP
arams& params) { |
| 43 ContextPlatformData_unix* unixPlatformData = | 47 #if 0 |
| 44 reinterpret_cast<ContextPlatformData_unix*>(platformData); | 48 // TODO: Init for Mac |
| 49 ContextPlatformData_mac* unixPlatformData = |
| 50 reinterpret_cast<ContextPlatformData_mac*>(platformData); |
| 45 | 51 |
| 46 if (unixPlatformData) { | 52 if (unixPlatformData) { |
| 47 fDisplay = unixPlatformData->fDisplay; | 53 fDisplay = unixPlatformData->fDisplay; |
| 48 fWindow = unixPlatformData->fWindow; | 54 fWindow = unixPlatformData->fWindow; |
| 49 fVisualInfo = unixPlatformData->fVisualInfo; | 55 fVisualInfo = unixPlatformData->fVisualInfo; |
| 50 } | 56 } |
| 51 SkASSERT(fDisplay); | 57 SkASSERT(fDisplay); |
| 52 | 58 |
| 53 fGLContext = glXCreateContext(fDisplay, fVisualInfo, nullptr, GL_TRUE); | 59 fGLContext = glXCreateContext(fDisplay, fVisualInfo, nullptr, GL_TRUE); |
| 54 if (!fGLContext) { | 60 if (!fGLContext) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 69 glXGetConfig(fDisplay, fVisualInfo, GLX_STENCIL_SIZE, &fStencilBits); | 75 glXGetConfig(fDisplay, fVisualInfo, GLX_STENCIL_SIZE, &fStencilBits); |
| 70 glXGetConfig(fDisplay, fVisualInfo, GLX_SAMPLES_ARB, &fSampleCount); | 76 glXGetConfig(fDisplay, fVisualInfo, GLX_SAMPLES_ARB, &fSampleCount); |
| 71 | 77 |
| 72 XWindow root; | 78 XWindow root; |
| 73 int x, y; | 79 int x, y; |
| 74 unsigned int border_width, depth; | 80 unsigned int border_width, depth; |
| 75 XGetGeometry(fDisplay, fWindow, &root, &x, &y, | 81 XGetGeometry(fDisplay, fWindow, &root, &x, &y, |
| 76 (unsigned int*)&fWidth, (unsigned int*)&fHeight, &border_wi
dth, &depth); | 82 (unsigned int*)&fWidth, (unsigned int*)&fHeight, &border_wi
dth, &depth); |
| 77 glViewport(0, 0, fWidth, fHeight); | 83 glViewport(0, 0, fWidth, fHeight); |
| 78 } | 84 } |
| 85 #endif |
| 79 } | 86 } |
| 80 | 87 |
| 81 void GLWindowContext_unix::onDestroyContext() { | 88 void GLWindowContext_mac::onDestroyContext() { |
| 89 #if 0 |
| 90 // TODO: teardown for Mac |
| 82 if (!fDisplay || !fGLContext) { | 91 if (!fDisplay || !fGLContext) { |
| 83 return; | 92 return; |
| 84 } | 93 } |
| 85 glXMakeCurrent(fDisplay, None, nullptr); | 94 glXMakeCurrent(fDisplay, None, nullptr); |
| 86 glXDestroyContext(fDisplay, fGLContext); | 95 glXDestroyContext(fDisplay, fGLContext); |
| 87 fGLContext = nullptr; | 96 fGLContext = nullptr; |
| 97 #endif |
| 88 } | 98 } |
| 89 | 99 |
| 90 | 100 |
| 91 void GLWindowContext_unix::onSwapBuffers() { | 101 void GLWindowContext_mac::onSwapBuffers() { |
| 102 #if 0 |
| 103 // TODO: swap for Mac |
| 92 if (fDisplay && fGLContext) { | 104 if (fDisplay && fGLContext) { |
| 93 glXSwapBuffers(fDisplay, fWindow); | 105 glXSwapBuffers(fDisplay, fWindow); |
| 94 } | 106 } |
| 107 #endif |
| 95 } | 108 } |
| 96 | 109 |
| 97 | 110 |
| 98 } //namespace sk_app | 111 } //namespace sk_app |
| OLD | NEW |