blob: 94cf8dfae635f54db73d5f2553bdec8b56be40ef [file] [log] [blame]
daniel@transgaming.com95a758f2012-07-12 15:17:06 +00001//
Nicolas Capens3501c162014-05-21 13:27:15 -04002// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com95a758f2012-07-12 15:17:06 +00003// 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 Graham86f601c2013-09-17 13:28:00 -070013#include <algorithm>
14
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000015#include "libEGL/Surface.h"
16
17#include "common/debug.h"
18#include "libGLESv2/Texture.h"
daniel@transgaming.com3c720782012-10-31 18:42:34 +000019#include "libGLESv2/renderer/SwapChain.h"
daniel@transgaming.comcfa8efd2012-11-28 19:30:55 +000020#include "libGLESv2/main.h"
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000021
22#include "libEGL/main.h"
23#include "libEGL/Display.h"
24
Cooper Partineeb1f532014-09-23 10:25:02 -070025#include "common/NativeWindow.h"
26
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000027namespace egl
28{
29
Cooper Partineeb1f532014-09-23 10:25:02 -070030Surface::Surface(Display *display, const Config *config, EGLNativeWindowType window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported)
31 : mDisplay(display), mConfig(config), mNativeWindow(window), mPostSubBufferSupported(postSubBufferSupported)
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000032{
daniel@transgaming.comb9bb2792012-11-28 19:36:49 +000033 mRenderer = mDisplay->getRenderer();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000034 mSwapChain = NULL;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000035 mShareHandle = NULL;
36 mTexture = NULL;
37 mTextureFormat = EGL_NO_TEXTURE;
38 mTextureTarget = EGL_NO_TEXTURE;
39
40 mPixelAspectRatio = (EGLint)(1.0 * EGL_DISPLAY_SCALING); // FIXME: Determine actual pixel aspect ratio
41 mRenderBuffer = EGL_BACK_BUFFER;
42 mSwapBehavior = EGL_BUFFER_PRESERVED;
43 mSwapInterval = -1;
John Bauman3dc300a2014-01-28 15:30:35 -080044 mWidth = width;
45 mHeight = height;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000046 setSwapInterval(1);
John Bauman3dc300a2014-01-28 15:30:35 -080047 mFixedSize = fixedSize;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000048
49 subclassWindow();
50}
51
52Surface::Surface(Display *display, const Config *config, HANDLE shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureType)
Cooper Partineeb1f532014-09-23 10:25:02 -070053 : mDisplay(display), mNativeWindow(NULL), mConfig(config), mShareHandle(shareHandle), mWidth(width), mHeight(height), mPostSubBufferSupported(EGL_FALSE)
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000054{
daniel@transgaming.com28e36922012-11-28 21:02:47 +000055 mRenderer = mDisplay->getRenderer();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000056 mSwapChain = NULL;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000057 mWindowSubclassed = false;
58 mTexture = NULL;
59 mTextureFormat = textureFormat;
60 mTextureTarget = textureType;
61
62 mPixelAspectRatio = (EGLint)(1.0 * EGL_DISPLAY_SCALING); // FIXME: Determine actual pixel aspect ratio
63 mRenderBuffer = EGL_BACK_BUFFER;
64 mSwapBehavior = EGL_BUFFER_PRESERVED;
65 mSwapInterval = -1;
66 setSwapInterval(1);
John Bauman3dc300a2014-01-28 15:30:35 -080067 // This constructor is for offscreen surfaces, which are always fixed-size.
68 mFixedSize = EGL_TRUE;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000069}
70
71Surface::~Surface()
72{
73 unsubclassWindow();
74 release();
75}
76
Geoff Lang6b0cf992014-10-06 10:28:07 -040077Error Surface::initialize()
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000078{
Cooper Partineeb1f532014-09-23 10:25:02 -070079 if (mNativeWindow.getNativeWindow())
80 {
81 if (!mNativeWindow.initialize())
82 {
Geoff Lang6b0cf992014-10-06 10:28:07 -040083 return Error(EGL_BAD_SURFACE);
Cooper Partineeb1f532014-09-23 10:25:02 -070084 }
85 }
86
Geoff Lang6b0cf992014-10-06 10:28:07 -040087 Error error = resetSwapChain();
88 if (error.isError())
89 {
90 return error;
91 }
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000092
Geoff Lang6b0cf992014-10-06 10:28:07 -040093 return Error(EGL_SUCCESS);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000094}
95
96void Surface::release()
97{
daniel@transgaming.comb9bb2792012-11-28 19:36:49 +000098 delete mSwapChain;
daniel@transgaming.com3c720782012-10-31 18:42:34 +000099 mSwapChain = NULL;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000100
101 if (mTexture)
102 {
103 mTexture->releaseTexImage();
104 mTexture = NULL;
105 }
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000106}
107
Geoff Lang6b0cf992014-10-06 10:28:07 -0400108Error Surface::resetSwapChain()
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000109{
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000110 ASSERT(!mSwapChain);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000111
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000112 int width;
113 int height;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000114
John Bauman3dc300a2014-01-28 15:30:35 -0800115 if (!mFixedSize)
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000116 {
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000117 RECT windowRect;
Cooper Partineeb1f532014-09-23 10:25:02 -0700118 if (!mNativeWindow.getClientRect(&windowRect))
apatrick@chromium.org85e44192012-08-17 20:58:01 +0000119 {
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000120 ASSERT(false);
121
Geoff Lang6b0cf992014-10-06 10:28:07 -0400122 return Error(EGL_BAD_SURFACE, "Could not retrieve the window dimensions");
apatrick@chromium.org85e44192012-08-17 20:58:01 +0000123 }
apatrick@chromium.org0c71fd42012-08-10 18:08:47 +0000124
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000125 width = windowRect.right - windowRect.left;
126 height = windowRect.bottom - windowRect.top;
127 }
128 else
129 {
130 // non-window surface - size is determined at creation
131 width = mWidth;
132 height = mHeight;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000133 }
134
Cooper Partineeb1f532014-09-23 10:25:02 -0700135 mSwapChain = mRenderer->createSwapChain(mNativeWindow, mShareHandle,
daniel@transgaming.comb9bb2792012-11-28 19:36:49 +0000136 mConfig->mRenderTargetFormat,
137 mConfig->mDepthStencilFormat);
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000138 if (!mSwapChain)
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000139 {
Geoff Lang6b0cf992014-10-06 10:28:07 -0400140 return Error(EGL_BAD_ALLOC);
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000141 }
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000142
Geoff Lang6b0cf992014-10-06 10:28:07 -0400143 Error error = resetSwapChain(width, height);
144 if (error.isError())
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000145 {
Geoff Lang6b0cf992014-10-06 10:28:07 -0400146 SafeDelete(mSwapChain);
147 return error;
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000148 }
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000149
Geoff Lang6b0cf992014-10-06 10:28:07 -0400150 return Error(EGL_SUCCESS);
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000151}
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000152
Geoff Lang6b0cf992014-10-06 10:28:07 -0400153Error Surface::resizeSwapChain(int backbufferWidth, int backbufferHeight)
shannon.woods@transgaming.comc71ca752013-02-28 23:06:50 +0000154{
155 ASSERT(backbufferWidth >= 0 && backbufferHeight >= 0);
156 ASSERT(mSwapChain);
157
John Bauman3dc300a2014-01-28 15:30:35 -0800158 EGLint status = mSwapChain->resize(std::max(1, backbufferWidth), std::max(1, backbufferHeight));
shannon.woods@transgaming.comc71ca752013-02-28 23:06:50 +0000159
160 if (status == EGL_CONTEXT_LOST)
161 {
162 mDisplay->notifyDeviceLost();
Geoff Lang6b0cf992014-10-06 10:28:07 -0400163 return Error(status);
shannon.woods@transgaming.comc71ca752013-02-28 23:06:50 +0000164 }
165 else if (status != EGL_SUCCESS)
166 {
Geoff Lang6b0cf992014-10-06 10:28:07 -0400167 return Error(status);
shannon.woods@transgaming.comc71ca752013-02-28 23:06:50 +0000168 }
169
170 mWidth = backbufferWidth;
171 mHeight = backbufferHeight;
172
Geoff Lang6b0cf992014-10-06 10:28:07 -0400173 return Error(EGL_SUCCESS);
shannon.woods@transgaming.comc71ca752013-02-28 23:06:50 +0000174}
175
Geoff Lang6b0cf992014-10-06 10:28:07 -0400176Error Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000177{
178 ASSERT(backbufferWidth >= 0 && backbufferHeight >= 0);
179 ASSERT(mSwapChain);
180
John Bauman3dc300a2014-01-28 15:30:35 -0800181 EGLint status = mSwapChain->reset(std::max(1, backbufferWidth), std::max(1, backbufferHeight), mSwapInterval);
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000182
183 if (status == EGL_CONTEXT_LOST)
184 {
shannon.woods@transgaming.comeb049e22013-02-28 23:04:49 +0000185 mRenderer->notifyDeviceLost();
Geoff Lang6b0cf992014-10-06 10:28:07 -0400186 return Error(status);
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000187 }
188 else if (status != EGL_SUCCESS)
189 {
Geoff Lang6b0cf992014-10-06 10:28:07 -0400190 return Error(status);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000191 }
192
apatrick@chromium.org0c71fd42012-08-10 18:08:47 +0000193 mWidth = backbufferWidth;
194 mHeight = backbufferHeight;
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000195 mSwapIntervalDirty = false;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000196
Geoff Lang6b0cf992014-10-06 10:28:07 -0400197 return Error(EGL_SUCCESS);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000198}
199
Geoff Lang6b0cf992014-10-06 10:28:07 -0400200Error Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000201{
202 if (!mSwapChain)
203 {
Geoff Lang6b0cf992014-10-06 10:28:07 -0400204 return Error(EGL_SUCCESS);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000205 }
206
207 if (x + width > mWidth)
208 {
209 width = mWidth - x;
210 }
211
212 if (y + height > mHeight)
213 {
214 height = mHeight - y;
215 }
216
217 if (width == 0 || height == 0)
218 {
Geoff Lang6b0cf992014-10-06 10:28:07 -0400219 return Error(EGL_SUCCESS);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000220 }
221
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000222 EGLint status = mSwapChain->swapRect(x, y, width, height);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000223
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000224 if (status == EGL_CONTEXT_LOST)
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000225 {
shannon.woods@transgaming.comeb049e22013-02-28 23:04:49 +0000226 mRenderer->notifyDeviceLost();
Geoff Lang6b0cf992014-10-06 10:28:07 -0400227 return Error(status);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000228 }
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000229 else if (status != EGL_SUCCESS)
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000230 {
Geoff Lang6b0cf992014-10-06 10:28:07 -0400231 return Error(status);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000232 }
233
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000234 checkForOutOfDateSwapChain();
235
Geoff Lang6b0cf992014-10-06 10:28:07 -0400236 return Error(EGL_SUCCESS);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000237}
238
Cooper Partineeb1f532014-09-23 10:25:02 -0700239EGLNativeWindowType Surface::getWindowHandle()
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000240{
Cooper Partineeb1f532014-09-23 10:25:02 -0700241 return mNativeWindow.getNativeWindow();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000242}
243
Cooper Partin88d3b8c2014-10-08 10:41:56 -0700244#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000245#define kSurfaceProperty _TEXT("Egl::SurfaceOwner")
246#define kParentWndProc _TEXT("Egl::SurfaceParentWndProc")
247
248static LRESULT CALLBACK SurfaceWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
249{
250 if (message == WM_SIZE)
251 {
252 Surface* surf = reinterpret_cast<Surface*>(GetProp(hwnd, kSurfaceProperty));
253 if(surf)
254 {
255 surf->checkForOutOfDateSwapChain();
256 }
257 }
258 WNDPROC prevWndFunc = reinterpret_cast<WNDPROC >(GetProp(hwnd, kParentWndProc));
259 return CallWindowProc(prevWndFunc, hwnd, message, wparam, lparam);
260}
Cooper Partin88d3b8c2014-10-08 10:41:56 -0700261#endif
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000262
263void Surface::subclassWindow()
264{
Cooper Partin88d3b8c2014-10-08 10:41:56 -0700265#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
Cooper Partineeb1f532014-09-23 10:25:02 -0700266 HWND window = mNativeWindow.getNativeWindow();
267 if (!window)
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000268 {
269 return;
270 }
271
272 DWORD processId;
Cooper Partineeb1f532014-09-23 10:25:02 -0700273 DWORD threadId = GetWindowThreadProcessId(window, &processId);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000274 if (processId != GetCurrentProcessId() || threadId != GetCurrentThreadId())
275 {
276 return;
277 }
278
279 SetLastError(0);
Cooper Partineeb1f532014-09-23 10:25:02 -0700280 LONG_PTR oldWndProc = SetWindowLongPtr(window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(SurfaceWindowProc));
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000281 if(oldWndProc == 0 && GetLastError() != ERROR_SUCCESS)
282 {
283 mWindowSubclassed = false;
284 return;
285 }
286
Cooper Partineeb1f532014-09-23 10:25:02 -0700287 SetProp(window, kSurfaceProperty, reinterpret_cast<HANDLE>(this));
288 SetProp(window, kParentWndProc, reinterpret_cast<HANDLE>(oldWndProc));
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000289 mWindowSubclassed = true;
Cooper Partin88d3b8c2014-10-08 10:41:56 -0700290#endif
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000291}
292
293void Surface::unsubclassWindow()
294{
295 if(!mWindowSubclassed)
296 {
297 return;
298 }
299
Cooper Partin88d3b8c2014-10-08 10:41:56 -0700300#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
Cooper Partineeb1f532014-09-23 10:25:02 -0700301 HWND window = mNativeWindow.getNativeWindow();
302 if (!window)
303 {
304 return;
305 }
306
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000307 // un-subclass
Cooper Partineeb1f532014-09-23 10:25:02 -0700308 LONG_PTR parentWndFunc = reinterpret_cast<LONG_PTR>(GetProp(window, kParentWndProc));
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000309
310 // Check the windowproc is still SurfaceWindowProc.
311 // If this assert fails, then it is likely the application has subclassed the
312 // hwnd as well and did not unsubclass before destroying its EGL context. The
313 // application should be modified to either subclass before initializing the
314 // EGL context, or to unsubclass before destroying the EGL context.
315 if(parentWndFunc)
316 {
Cooper Partineeb1f532014-09-23 10:25:02 -0700317 LONG_PTR prevWndFunc = SetWindowLongPtr(window, GWLP_WNDPROC, parentWndFunc);
Geoff Lang9cd19152014-05-28 15:54:34 -0400318 UNUSED_ASSERTION_VARIABLE(prevWndFunc);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000319 ASSERT(prevWndFunc == reinterpret_cast<LONG_PTR>(SurfaceWindowProc));
320 }
321
Cooper Partineeb1f532014-09-23 10:25:02 -0700322 RemoveProp(window, kSurfaceProperty);
323 RemoveProp(window, kParentWndProc);
Cooper Partin88d3b8c2014-10-08 10:41:56 -0700324#endif
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000325 mWindowSubclassed = false;
326}
327
328bool Surface::checkForOutOfDateSwapChain()
329{
330 RECT client;
John Bauman3dc300a2014-01-28 15:30:35 -0800331 int clientWidth = getWidth();
332 int clientHeight = getHeight();
333 bool sizeDirty = false;
Cooper Partineeb1f532014-09-23 10:25:02 -0700334 if (!mFixedSize && !mNativeWindow.isIconic())
John Bauman827a4712013-10-29 16:03:11 -0700335 {
336 // The window is automatically resized to 150x22 when it's minimized, but the swapchain shouldn't be resized
337 // because that's not a useful size to render to.
Cooper Partineeb1f532014-09-23 10:25:02 -0700338 if (!mNativeWindow.getClientRect(&client))
John Bauman3dc300a2014-01-28 15:30:35 -0800339 {
340 ASSERT(false);
341 return false;
342 }
343
344 // Grow the buffer now, if the window has grown. We need to grow now to avoid losing information.
345 clientWidth = client.right - client.left;
346 clientHeight = client.bottom - client.top;
347 sizeDirty = clientWidth != getWidth() || clientHeight != getHeight();
John Bauman827a4712013-10-29 16:03:11 -0700348 }
349
Jamie Madill58e60322013-12-02 11:09:36 -0500350 bool wasDirty = (mSwapIntervalDirty || sizeDirty);
351
shannon.woods@transgaming.comc71ca752013-02-28 23:06:50 +0000352 if (mSwapIntervalDirty)
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000353 {
354 resetSwapChain(clientWidth, clientHeight);
shannon.woods@transgaming.comc71ca752013-02-28 23:06:50 +0000355 }
356 else if (sizeDirty)
357 {
358 resizeSwapChain(clientWidth, clientHeight);
359 }
360
Jamie Madill58e60322013-12-02 11:09:36 -0500361 if (wasDirty)
shannon.woods@transgaming.comc71ca752013-02-28 23:06:50 +0000362 {
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000363 if (static_cast<egl::Surface*>(getCurrentDrawSurface()) == this)
364 {
365 glMakeCurrent(glGetCurrentContext(), static_cast<egl::Display*>(getCurrentDisplay()), this);
366 }
367
368 return true;
369 }
shannon.woods@transgaming.comc71ca752013-02-28 23:06:50 +0000370
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000371 return false;
372}
373
Geoff Lang6b0cf992014-10-06 10:28:07 -0400374Error Surface::swap()
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000375{
376 return swapRect(0, 0, mWidth, mHeight);
377}
378
Geoff Lang6b0cf992014-10-06 10:28:07 -0400379Error Surface::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height)
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000380{
381 if (!mPostSubBufferSupported)
382 {
383 // Spec is not clear about how this should be handled.
Geoff Lang6b0cf992014-10-06 10:28:07 -0400384 return Error(EGL_SUCCESS);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000385 }
Nicolas Capens3501c162014-05-21 13:27:15 -0400386
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000387 return swapRect(x, y, width, height);
388}
389
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000390EGLint Surface::isPostSubBufferSupported() const
391{
392 return mPostSubBufferSupported;
393}
394
daniel@transgaming.com76d3e6e2012-10-31 19:55:33 +0000395rx::SwapChain *Surface::getSwapChain() const
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000396{
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000397 return mSwapChain;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000398}
399
400void Surface::setSwapInterval(EGLint interval)
401{
402 if (mSwapInterval == interval)
403 {
404 return;
405 }
Nicolas Capens3501c162014-05-21 13:27:15 -0400406
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000407 mSwapInterval = interval;
daniel@transgaming.com114bd462012-10-31 18:42:47 +0000408 mSwapInterval = std::max(mSwapInterval, mRenderer->getMinSwapInterval());
409 mSwapInterval = std::min(mSwapInterval, mRenderer->getMaxSwapInterval());
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000410
daniel@transgaming.com3c720782012-10-31 18:42:34 +0000411 mSwapIntervalDirty = true;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000412}
413
Nicolas Capens3501c162014-05-21 13:27:15 -0400414EGLint Surface::getConfigID() const
415{
416 return mConfig->mConfigID;
417}
418
419EGLint Surface::getWidth() const
420{
421 return mWidth;
422}
423
424EGLint Surface::getHeight() const
425{
426 return mHeight;
427}
428
429EGLint Surface::getPixelAspectRatio() const
430{
431 return mPixelAspectRatio;
432}
433
434EGLenum Surface::getRenderBuffer() const
435{
436 return mRenderBuffer;
437}
438
439EGLenum Surface::getSwapBehavior() const
440{
441 return mSwapBehavior;
442}
443
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000444EGLenum Surface::getTextureFormat() const
445{
446 return mTextureFormat;
447}
448
449EGLenum Surface::getTextureTarget() const
450{
451 return mTextureTarget;
452}
453
454void Surface::setBoundTexture(gl::Texture2D *texture)
455{
456 mTexture = texture;
457}
458
459gl::Texture2D *Surface::getBoundTexture() const
460{
461 return mTexture;
462}
463
John Bauman3dc300a2014-01-28 15:30:35 -0800464EGLint Surface::isFixedSize() const
465{
466 return mFixedSize;
467}
468
daniel@transgaming.com106e1f72012-10-31 18:38:36 +0000469EGLenum Surface::getFormat() const
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000470{
471 return mConfig->mRenderTargetFormat;
472}
473}