Implemented eglSwapInterval

TRAC #12137 Signed-off-by: Andrew Lewycky Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@235 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent fc23fe28
...@@ -26,6 +26,7 @@ Display::Display(HDC deviceContext) : mDc(deviceContext) ...@@ -26,6 +26,7 @@ Display::Display(HDC deviceContext) : mDc(deviceContext)
mAdapter = D3DADAPTER_DEFAULT; mAdapter = D3DADAPTER_DEFAULT;
mDeviceType = D3DDEVTYPE_HAL; mDeviceType = D3DDEVTYPE_HAL;
mSwapInterval = 1;
} }
Display::~Display() Display::~Display()
...@@ -224,7 +225,7 @@ bool Display::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value) ...@@ -224,7 +225,7 @@ bool Display::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value)
case EGL_ALPHA_MASK_SIZE: *value = configuration->mAlphaMaskSize; break; case EGL_ALPHA_MASK_SIZE: *value = configuration->mAlphaMaskSize; break;
case EGL_COLOR_BUFFER_TYPE: *value = configuration->mColorBufferType; break; case EGL_COLOR_BUFFER_TYPE: *value = configuration->mColorBufferType; break;
case EGL_RENDERABLE_TYPE: *value = configuration->mRenderableType; break; case EGL_RENDERABLE_TYPE: *value = configuration->mRenderableType; break;
case EGL_MATCH_NATIVE_PIXMAP: *value = false; UNIMPLEMENTED(); break; case EGL_MATCH_NATIVE_PIXMAP: *value = false; UNIMPLEMENTED(); break;
case EGL_CONFORMANT: *value = configuration->mConformant; break; case EGL_CONFORMANT: *value = configuration->mConformant; break;
default: default:
return false; return false;
...@@ -233,9 +234,9 @@ bool Display::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value) ...@@ -233,9 +234,9 @@ bool Display::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value)
return true; return true;
} }
egl::Surface *Display::createWindowSurface(HWND window, EGLConfig config) Surface *Display::createWindowSurface(HWND window, EGLConfig config)
{ {
const egl::Config *configuration = mConfigSet.get(config); const Config *configuration = mConfigSet.get(config);
D3DPRESENT_PARAMETERS presentParameters = {0}; D3DPRESENT_PARAMETERS presentParameters = {0};
...@@ -249,7 +250,7 @@ egl::Surface *Display::createWindowSurface(HWND window, EGLConfig config) ...@@ -249,7 +250,7 @@ egl::Surface *Display::createWindowSurface(HWND window, EGLConfig config)
presentParameters.hDeviceWindow = window; presentParameters.hDeviceWindow = window;
presentParameters.MultiSampleQuality = 0; // FIXME: Unimplemented presentParameters.MultiSampleQuality = 0; // FIXME: Unimplemented
presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; // FIXME: Unimplemented presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; // FIXME: Unimplemented
presentParameters.PresentationInterval = configuration->mMinSwapInterval; presentParameters.PresentationInterval = getPresentInterval(configuration, true);
presentParameters.SwapEffect = D3DSWAPEFFECT_COPY; presentParameters.SwapEffect = D3DSWAPEFFECT_COPY;
presentParameters.Windowed = TRUE; // FIXME presentParameters.Windowed = TRUE; // FIXME
...@@ -345,7 +346,7 @@ egl::Surface *Display::createWindowSurface(HWND window, EGLConfig config) ...@@ -345,7 +346,7 @@ egl::Surface *Display::createWindowSurface(HWND window, EGLConfig config)
if (swapChain) if (swapChain)
{ {
surface = new Surface(this, swapChain, depthStencilSurface, configuration->mConfigID); surface = new Surface(this, swapChain, depthStencilSurface, configuration);
mSurfaceSet.insert(surface); mSurfaceSet.insert(surface);
swapChain->Release(); swapChain->Release();
...@@ -409,6 +410,30 @@ bool Display::hasExistingWindowSurface(HWND window) ...@@ -409,6 +410,30 @@ bool Display::hasExistingWindowSurface(HWND window)
return false; return false;
} }
void Display::setSwapInterval(GLint interval)
{
mSwapInterval = interval;
}
DWORD Display::getPresentInterval(const egl::Config *config, bool maximumRate)
{
GLint interval = maximumRate ? 0 : mSwapInterval;
interval = interval < config->mMinSwapInterval ? config->mMinSwapInterval : interval;
interval = interval > config->mMaxSwapInterval ? config->mMaxSwapInterval : interval;
switch(interval)
{
case 0: return D3DPRESENT_INTERVAL_IMMEDIATE;
case 1: return D3DPRESENT_INTERVAL_ONE;
case 2: return D3DPRESENT_INTERVAL_TWO;
case 3: return D3DPRESENT_INTERVAL_THREE;
case 4: return D3DPRESENT_INTERVAL_FOUR;
default: UNREACHABLE();
}
return D3DPRESENT_INTERVAL_DEFAULT;
}
IDirect3DDevice9 *Display::getDevice() IDirect3DDevice9 *Display::getDevice()
{ {
return mDevice; return mDevice;
......
...@@ -54,6 +54,9 @@ class Display ...@@ -54,6 +54,9 @@ class Display
bool isValidSurface(egl::Surface *surface); bool isValidSurface(egl::Surface *surface);
bool hasExistingWindowSurface(HWND window); bool hasExistingWindowSurface(HWND window);
void setSwapInterval(GLint interval);
DWORD getPresentInterval(const egl::Config *config, bool maximumRate);
virtual IDirect3DDevice9 *getDevice(); virtual IDirect3DDevice9 *getDevice();
private: private:
...@@ -66,6 +69,7 @@ class Display ...@@ -66,6 +69,7 @@ class Display
IDirect3DDevice9 *mDevice; IDirect3DDevice9 *mDevice;
bool mSceneStarted; bool mSceneStarted;
GLint mSwapInterval;
typedef std::set<Surface*> SurfaceSet; typedef std::set<Surface*> SurfaceSet;
SurfaceSet mSurfaceSet; SurfaceSet mSurfaceSet;
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
namespace egl namespace egl
{ {
Surface::Surface(Display *display, IDirect3DSwapChain9 *swapChain, IDirect3DSurface9 *depthStencil, EGLint configID) Surface::Surface(Display *display, IDirect3DSwapChain9 *swapChain, IDirect3DSurface9 *depthStencil, const Config *config)
: mDisplay(display), mSwapChain(swapChain), mConfigID(configID), mDepthStencil(depthStencil) : mDisplay(display), mSwapChain(swapChain), mDepthStencil(depthStencil), mConfig(config)
{ {
mBackBuffer = NULL; mBackBuffer = NULL;
mRenderTarget = NULL; mRenderTarget = NULL;
...@@ -150,7 +150,7 @@ void Surface::swap() ...@@ -150,7 +150,7 @@ void Surface::swap()
texture->Release(); texture->Release();
mDisplay->endScene(); mDisplay->endScene();
result = mSwapChain->Present(NULL, NULL, NULL, NULL, D3DPRESENT_INTERVAL_IMMEDIATE | D3DPRESENT_DONOTWAIT); // FIXME: Get the swap interval from the associated Display result = mSwapChain->Present(NULL, NULL, NULL, NULL, mDisplay->getPresentInterval(mConfig, false));
if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_DRIVERINTERNALERROR) if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_DRIVERINTERNALERROR)
{ {
......
...@@ -20,11 +20,12 @@ ...@@ -20,11 +20,12 @@
namespace egl namespace egl
{ {
class Display; class Display;
class Config;
class Surface class Surface
{ {
public: public:
Surface(Display *display, IDirect3DSwapChain9 *swapChain, IDirect3DSurface9* depthStencil, EGLint configID); Surface(Display *display, IDirect3DSwapChain9 *swapChain, IDirect3DSurface9* depthStencil, const egl::Config *config);
~Surface(); ~Surface();
...@@ -45,7 +46,7 @@ class Surface ...@@ -45,7 +46,7 @@ class Surface
IDirect3DSurface9 *mRenderTarget; IDirect3DSurface9 *mRenderTarget;
IDirect3DSurface9 *mDepthStencil; IDirect3DSurface9 *mDepthStencil;
const EGLint mConfigID; // ID of EGLConfig surface was created with const egl::Config *mConfig; // EGL config surface was created with
EGLint mHeight; // Height of surface EGLint mHeight; // Height of surface
EGLint mWidth; // Width of surface EGLint mWidth; // Width of surface
// EGLint horizontalResolution; // Horizontal dot pitch // EGLint horizontalResolution; // Horizontal dot pitch
......
...@@ -746,7 +746,7 @@ EGLBoolean __stdcall eglSwapInterval(EGLDisplay dpy, EGLint interval) ...@@ -746,7 +746,7 @@ EGLBoolean __stdcall eglSwapInterval(EGLDisplay dpy, EGLint interval)
return EGL_FALSE; return EGL_FALSE;
} }
// UNIMPLEMENTED(); // FIXME display->setSwapInterval(interval);
return success(EGL_TRUE); return success(EGL_TRUE);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment