daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 1 | // |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 2 | // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // Surface.cpp: Implements the egl::Surface class, representing a drawing surface |
| 8 | // such as the client area of a window, including any back buffers. |
| 9 | // Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3. |
| 10 | |
| 11 | #include <tchar.h> |
| 12 | |
Scott Graham | 86f601c | 2013-09-17 13:28:00 -0700 | [diff] [blame] | 13 | #include <algorithm> |
| 14 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 15 | #include "libEGL/Surface.h" |
| 16 | |
| 17 | #include "common/debug.h" |
| 18 | #include "libGLESv2/Texture.h" |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 19 | #include "libGLESv2/renderer/SwapChain.h" |
daniel@transgaming.com | cfa8efd | 2012-11-28 19:30:55 +0000 | [diff] [blame] | 20 | #include "libGLESv2/main.h" |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 21 | |
| 22 | #include "libEGL/main.h" |
| 23 | #include "libEGL/Display.h" |
| 24 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 25 | namespace egl |
| 26 | { |
| 27 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 28 | Surface::Surface(Display *display, const Config *config, HWND window, EGLint postSubBufferSupported) |
| 29 | : mDisplay(display), mConfig(config), mWindow(window), mPostSubBufferSupported(postSubBufferSupported) |
| 30 | { |
daniel@transgaming.com | b9bb279 | 2012-11-28 19:36:49 +0000 | [diff] [blame] | 31 | mRenderer = mDisplay->getRenderer(); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 32 | mSwapChain = NULL; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 33 | mShareHandle = NULL; |
| 34 | mTexture = NULL; |
| 35 | mTextureFormat = EGL_NO_TEXTURE; |
| 36 | mTextureTarget = EGL_NO_TEXTURE; |
| 37 | |
| 38 | mPixelAspectRatio = (EGLint)(1.0 * EGL_DISPLAY_SCALING); // FIXME: Determine actual pixel aspect ratio |
| 39 | mRenderBuffer = EGL_BACK_BUFFER; |
| 40 | mSwapBehavior = EGL_BUFFER_PRESERVED; |
| 41 | mSwapInterval = -1; |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 42 | mWidth = -1; |
| 43 | mHeight = -1; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 44 | setSwapInterval(1); |
| 45 | |
| 46 | subclassWindow(); |
| 47 | } |
| 48 | |
| 49 | Surface::Surface(Display *display, const Config *config, HANDLE shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureType) |
| 50 | : mDisplay(display), mWindow(NULL), mConfig(config), mShareHandle(shareHandle), mWidth(width), mHeight(height), mPostSubBufferSupported(EGL_FALSE) |
| 51 | { |
daniel@transgaming.com | 28e3692 | 2012-11-28 21:02:47 +0000 | [diff] [blame] | 52 | mRenderer = mDisplay->getRenderer(); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 53 | mSwapChain = NULL; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 54 | mWindowSubclassed = false; |
| 55 | mTexture = NULL; |
| 56 | mTextureFormat = textureFormat; |
| 57 | mTextureTarget = textureType; |
| 58 | |
| 59 | mPixelAspectRatio = (EGLint)(1.0 * EGL_DISPLAY_SCALING); // FIXME: Determine actual pixel aspect ratio |
| 60 | mRenderBuffer = EGL_BACK_BUFFER; |
| 61 | mSwapBehavior = EGL_BUFFER_PRESERVED; |
| 62 | mSwapInterval = -1; |
| 63 | setSwapInterval(1); |
| 64 | } |
| 65 | |
| 66 | Surface::~Surface() |
| 67 | { |
| 68 | unsubclassWindow(); |
| 69 | release(); |
| 70 | } |
| 71 | |
| 72 | bool Surface::initialize() |
| 73 | { |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 74 | if (!resetSwapChain()) |
| 75 | return false; |
| 76 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 77 | return true; |
| 78 | } |
| 79 | |
| 80 | void Surface::release() |
| 81 | { |
daniel@transgaming.com | b9bb279 | 2012-11-28 19:36:49 +0000 | [diff] [blame] | 82 | delete mSwapChain; |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 83 | mSwapChain = NULL; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 84 | |
| 85 | if (mTexture) |
| 86 | { |
| 87 | mTexture->releaseTexImage(); |
| 88 | mTexture = NULL; |
| 89 | } |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | bool Surface::resetSwapChain() |
| 93 | { |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 94 | ASSERT(!mSwapChain); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 95 | |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 96 | int width; |
| 97 | int height; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 98 | |
| 99 | if (mWindow) |
| 100 | { |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 101 | RECT windowRect; |
| 102 | if (!GetClientRect(getWindowHandle(), &windowRect)) |
apatrick@chromium.org | 85e4419 | 2012-08-17 20:58:01 +0000 | [diff] [blame] | 103 | { |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 104 | ASSERT(false); |
| 105 | |
| 106 | ERR("Could not retrieve the window dimensions"); |
| 107 | return error(EGL_BAD_SURFACE, false); |
apatrick@chromium.org | 85e4419 | 2012-08-17 20:58:01 +0000 | [diff] [blame] | 108 | } |
apatrick@chromium.org | 0c71fd4 | 2012-08-10 18:08:47 +0000 | [diff] [blame] | 109 | |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 110 | width = windowRect.right - windowRect.left; |
| 111 | height = windowRect.bottom - windowRect.top; |
| 112 | } |
| 113 | else |
| 114 | { |
| 115 | // non-window surface - size is determined at creation |
| 116 | width = mWidth; |
| 117 | height = mHeight; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 118 | } |
| 119 | |
daniel@transgaming.com | b9bb279 | 2012-11-28 19:36:49 +0000 | [diff] [blame] | 120 | mSwapChain = mRenderer->createSwapChain(mWindow, mShareHandle, |
| 121 | mConfig->mRenderTargetFormat, |
| 122 | mConfig->mDepthStencilFormat); |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 123 | if (!mSwapChain) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 124 | { |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 125 | return error(EGL_BAD_ALLOC, false); |
| 126 | } |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 127 | |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 128 | if (!resetSwapChain(width, height)) |
| 129 | { |
daniel@transgaming.com | b9bb279 | 2012-11-28 19:36:49 +0000 | [diff] [blame] | 130 | delete mSwapChain; |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 131 | mSwapChain = NULL; |
daniel@transgaming.com | 2a99bfa | 2012-10-31 19:55:50 +0000 | [diff] [blame] | 132 | return false; |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 133 | } |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 134 | |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 135 | return true; |
| 136 | } |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 137 | |
shannon.woods@transgaming.com | c71ca75 | 2013-02-28 23:06:50 +0000 | [diff] [blame] | 138 | bool Surface::resizeSwapChain(int backbufferWidth, int backbufferHeight) |
| 139 | { |
| 140 | ASSERT(backbufferWidth >= 0 && backbufferHeight >= 0); |
| 141 | ASSERT(mSwapChain); |
| 142 | |
| 143 | EGLint status = mSwapChain->resize(backbufferWidth, backbufferHeight); |
| 144 | |
| 145 | if (status == EGL_CONTEXT_LOST) |
| 146 | { |
| 147 | mDisplay->notifyDeviceLost(); |
| 148 | return false; |
| 149 | } |
| 150 | else if (status != EGL_SUCCESS) |
| 151 | { |
| 152 | return error(status, false); |
| 153 | } |
| 154 | |
| 155 | mWidth = backbufferWidth; |
| 156 | mHeight = backbufferHeight; |
| 157 | |
| 158 | return true; |
| 159 | } |
| 160 | |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 161 | bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) |
| 162 | { |
| 163 | ASSERT(backbufferWidth >= 0 && backbufferHeight >= 0); |
| 164 | ASSERT(mSwapChain); |
| 165 | |
| 166 | EGLint status = mSwapChain->reset(backbufferWidth, backbufferHeight, mSwapInterval); |
| 167 | |
| 168 | if (status == EGL_CONTEXT_LOST) |
| 169 | { |
shannon.woods@transgaming.com | eb049e2 | 2013-02-28 23:04:49 +0000 | [diff] [blame] | 170 | mRenderer->notifyDeviceLost(); |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 171 | return false; |
| 172 | } |
| 173 | else if (status != EGL_SUCCESS) |
| 174 | { |
| 175 | return error(status, false); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 176 | } |
| 177 | |
apatrick@chromium.org | 0c71fd4 | 2012-08-10 18:08:47 +0000 | [diff] [blame] | 178 | mWidth = backbufferWidth; |
| 179 | mHeight = backbufferHeight; |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 180 | mSwapIntervalDirty = false; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 181 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 182 | return true; |
| 183 | } |
| 184 | |
| 185 | bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height) |
| 186 | { |
| 187 | if (!mSwapChain) |
| 188 | { |
| 189 | return true; |
| 190 | } |
| 191 | |
| 192 | if (x + width > mWidth) |
| 193 | { |
| 194 | width = mWidth - x; |
| 195 | } |
| 196 | |
| 197 | if (y + height > mHeight) |
| 198 | { |
| 199 | height = mHeight - y; |
| 200 | } |
| 201 | |
| 202 | if (width == 0 || height == 0) |
| 203 | { |
| 204 | return true; |
| 205 | } |
| 206 | |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 207 | EGLint status = mSwapChain->swapRect(x, y, width, height); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 208 | |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 209 | if (status == EGL_CONTEXT_LOST) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 210 | { |
shannon.woods@transgaming.com | eb049e2 | 2013-02-28 23:04:49 +0000 | [diff] [blame] | 211 | mRenderer->notifyDeviceLost(); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 212 | return false; |
| 213 | } |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 214 | else if (status != EGL_SUCCESS) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 215 | { |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 216 | return error(status, false); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 217 | } |
| 218 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 219 | checkForOutOfDateSwapChain(); |
| 220 | |
| 221 | return true; |
| 222 | } |
| 223 | |
| 224 | HWND Surface::getWindowHandle() |
| 225 | { |
| 226 | return mWindow; |
| 227 | } |
| 228 | |
| 229 | |
| 230 | #define kSurfaceProperty _TEXT("Egl::SurfaceOwner") |
| 231 | #define kParentWndProc _TEXT("Egl::SurfaceParentWndProc") |
| 232 | |
| 233 | static LRESULT CALLBACK SurfaceWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) |
| 234 | { |
| 235 | if (message == WM_SIZE) |
| 236 | { |
| 237 | Surface* surf = reinterpret_cast<Surface*>(GetProp(hwnd, kSurfaceProperty)); |
| 238 | if(surf) |
| 239 | { |
| 240 | surf->checkForOutOfDateSwapChain(); |
| 241 | } |
| 242 | } |
| 243 | WNDPROC prevWndFunc = reinterpret_cast<WNDPROC >(GetProp(hwnd, kParentWndProc)); |
| 244 | return CallWindowProc(prevWndFunc, hwnd, message, wparam, lparam); |
| 245 | } |
| 246 | |
| 247 | void Surface::subclassWindow() |
| 248 | { |
| 249 | if (!mWindow) |
| 250 | { |
| 251 | return; |
| 252 | } |
| 253 | |
| 254 | DWORD processId; |
| 255 | DWORD threadId = GetWindowThreadProcessId(mWindow, &processId); |
| 256 | if (processId != GetCurrentProcessId() || threadId != GetCurrentThreadId()) |
| 257 | { |
| 258 | return; |
| 259 | } |
| 260 | |
| 261 | SetLastError(0); |
| 262 | LONG_PTR oldWndProc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(SurfaceWindowProc)); |
| 263 | if(oldWndProc == 0 && GetLastError() != ERROR_SUCCESS) |
| 264 | { |
| 265 | mWindowSubclassed = false; |
| 266 | return; |
| 267 | } |
| 268 | |
| 269 | SetProp(mWindow, kSurfaceProperty, reinterpret_cast<HANDLE>(this)); |
| 270 | SetProp(mWindow, kParentWndProc, reinterpret_cast<HANDLE>(oldWndProc)); |
| 271 | mWindowSubclassed = true; |
| 272 | } |
| 273 | |
| 274 | void Surface::unsubclassWindow() |
| 275 | { |
| 276 | if(!mWindowSubclassed) |
| 277 | { |
| 278 | return; |
| 279 | } |
| 280 | |
| 281 | // un-subclass |
| 282 | LONG_PTR parentWndFunc = reinterpret_cast<LONG_PTR>(GetProp(mWindow, kParentWndProc)); |
| 283 | |
| 284 | // Check the windowproc is still SurfaceWindowProc. |
| 285 | // If this assert fails, then it is likely the application has subclassed the |
| 286 | // hwnd as well and did not unsubclass before destroying its EGL context. The |
| 287 | // application should be modified to either subclass before initializing the |
| 288 | // EGL context, or to unsubclass before destroying the EGL context. |
| 289 | if(parentWndFunc) |
| 290 | { |
| 291 | LONG_PTR prevWndFunc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, parentWndFunc); |
| 292 | ASSERT(prevWndFunc == reinterpret_cast<LONG_PTR>(SurfaceWindowProc)); |
| 293 | } |
| 294 | |
| 295 | RemoveProp(mWindow, kSurfaceProperty); |
| 296 | RemoveProp(mWindow, kParentWndProc); |
| 297 | mWindowSubclassed = false; |
| 298 | } |
| 299 | |
| 300 | bool Surface::checkForOutOfDateSwapChain() |
| 301 | { |
| 302 | RECT client; |
| 303 | if (!GetClientRect(getWindowHandle(), &client)) |
| 304 | { |
| 305 | ASSERT(false); |
| 306 | return false; |
| 307 | } |
| 308 | |
| 309 | // Grow the buffer now, if the window has grown. We need to grow now to avoid losing information. |
| 310 | int clientWidth = client.right - client.left; |
| 311 | int clientHeight = client.bottom - client.top; |
| 312 | bool sizeDirty = clientWidth != getWidth() || clientHeight != getHeight(); |
| 313 | |
John Bauman | 827a471 | 2013-10-29 16:03:11 -0700 | [diff] [blame^] | 314 | if (IsIconic(getWindowHandle())) |
| 315 | { |
| 316 | // The window is automatically resized to 150x22 when it's minimized, but the swapchain shouldn't be resized |
| 317 | // because that's not a useful size to render to. |
| 318 | sizeDirty = false; |
| 319 | } |
| 320 | |
Jamie Madill | 58e6032 | 2013-12-02 11:09:36 -0500 | [diff] [blame] | 321 | bool wasDirty = (mSwapIntervalDirty || sizeDirty); |
| 322 | |
shannon.woods@transgaming.com | c71ca75 | 2013-02-28 23:06:50 +0000 | [diff] [blame] | 323 | if (mSwapIntervalDirty) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 324 | { |
| 325 | resetSwapChain(clientWidth, clientHeight); |
shannon.woods@transgaming.com | c71ca75 | 2013-02-28 23:06:50 +0000 | [diff] [blame] | 326 | } |
| 327 | else if (sizeDirty) |
| 328 | { |
| 329 | resizeSwapChain(clientWidth, clientHeight); |
| 330 | } |
| 331 | |
Jamie Madill | 58e6032 | 2013-12-02 11:09:36 -0500 | [diff] [blame] | 332 | if (wasDirty) |
shannon.woods@transgaming.com | c71ca75 | 2013-02-28 23:06:50 +0000 | [diff] [blame] | 333 | { |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 334 | if (static_cast<egl::Surface*>(getCurrentDrawSurface()) == this) |
| 335 | { |
| 336 | glMakeCurrent(glGetCurrentContext(), static_cast<egl::Display*>(getCurrentDisplay()), this); |
| 337 | } |
| 338 | |
| 339 | return true; |
| 340 | } |
shannon.woods@transgaming.com | c71ca75 | 2013-02-28 23:06:50 +0000 | [diff] [blame] | 341 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 342 | return false; |
| 343 | } |
| 344 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 345 | bool Surface::swap() |
| 346 | { |
| 347 | return swapRect(0, 0, mWidth, mHeight); |
| 348 | } |
| 349 | |
| 350 | bool Surface::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) |
| 351 | { |
| 352 | if (!mPostSubBufferSupported) |
| 353 | { |
| 354 | // Spec is not clear about how this should be handled. |
| 355 | return true; |
| 356 | } |
| 357 | |
| 358 | return swapRect(x, y, width, height); |
| 359 | } |
| 360 | |
| 361 | EGLint Surface::getWidth() const |
| 362 | { |
| 363 | return mWidth; |
| 364 | } |
| 365 | |
| 366 | EGLint Surface::getHeight() const |
| 367 | { |
| 368 | return mHeight; |
| 369 | } |
| 370 | |
| 371 | EGLint Surface::isPostSubBufferSupported() const |
| 372 | { |
| 373 | return mPostSubBufferSupported; |
| 374 | } |
| 375 | |
daniel@transgaming.com | 76d3e6e | 2012-10-31 19:55:33 +0000 | [diff] [blame] | 376 | rx::SwapChain *Surface::getSwapChain() const |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 377 | { |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 378 | return mSwapChain; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | void Surface::setSwapInterval(EGLint interval) |
| 382 | { |
| 383 | if (mSwapInterval == interval) |
| 384 | { |
| 385 | return; |
| 386 | } |
| 387 | |
| 388 | mSwapInterval = interval; |
daniel@transgaming.com | 114bd46 | 2012-10-31 18:42:47 +0000 | [diff] [blame] | 389 | mSwapInterval = std::max(mSwapInterval, mRenderer->getMinSwapInterval()); |
| 390 | mSwapInterval = std::min(mSwapInterval, mRenderer->getMaxSwapInterval()); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 391 | |
daniel@transgaming.com | 3c72078 | 2012-10-31 18:42:34 +0000 | [diff] [blame] | 392 | mSwapIntervalDirty = true; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | EGLenum Surface::getTextureFormat() const |
| 396 | { |
| 397 | return mTextureFormat; |
| 398 | } |
| 399 | |
| 400 | EGLenum Surface::getTextureTarget() const |
| 401 | { |
| 402 | return mTextureTarget; |
| 403 | } |
| 404 | |
| 405 | void Surface::setBoundTexture(gl::Texture2D *texture) |
| 406 | { |
| 407 | mTexture = texture; |
| 408 | } |
| 409 | |
| 410 | gl::Texture2D *Surface::getBoundTexture() const |
| 411 | { |
| 412 | return mTexture; |
| 413 | } |
| 414 | |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 415 | EGLenum Surface::getFormat() const |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 416 | { |
| 417 | return mConfig->mRenderTargetFormat; |
| 418 | } |
| 419 | } |