Commit eeb1f537 by Cooper Partin Committed by Geoff Lang

Added SurfaceHost to enable additional hosts and abstract access for EGLNativeWindowType.

Change-Id: I590b52925c6b9127d08eaf0e5ba2a0bde30505c3 Reviewed-on: https://chromium-review.googlesource.com/219488Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 9e3f24f6
......@@ -376,6 +376,7 @@
<ClInclude Include="..\..\src\common\angleutils.h"/>
<ClInclude Include="..\..\src\common\platform.h"/>
<ClInclude Include="..\..\src\common\version.h"/>
<ClInclude Include="..\..\src\common\NativeWindow.h"/>
<ClInclude Include="..\..\src\third_party\systeminfo\SystemInfo.h"/>
<ClInclude Include="..\..\src\third_party\murmurhash\MurmurHash3.h"/>
<ClInclude Include="..\..\include\angle_gl.h"/>
......@@ -484,6 +485,7 @@
<ClCompile Include="..\..\src\common\debug.cpp"/>
<ClCompile Include="..\..\src\common\blocklayout.cpp"/>
<ClCompile Include="..\..\src\common\angleutils.cpp"/>
<ClCompile Include="..\..\src\common\win32\NativeWindow.cpp"/>
<ClCompile Include="..\..\src\third_party\systeminfo\SystemInfo.cpp"/>
<ClCompile Include="..\..\src\third_party\murmurhash\MurmurHash3.cpp"/>
</ItemGroup>
......
......@@ -34,6 +34,9 @@
<Filter Include="src\common">
<UniqueIdentifier>{2F5FD094-EF52-77F7-7AA8-4327A01BF747}</UniqueIdentifier>
</Filter>
<Filter Include="src\common\win32">
<UniqueIdentifier>{789FEF16-EFE7-512E-F91B-DF7E0D72FB79}</UniqueIdentifier>
</Filter>
<Filter Include="src\third_party">
<UniqueIdentifier>{D6C6CEA7-AAD0-03AD-2394-AC6FCBF8A498}</UniqueIdentifier>
</Filter>
......@@ -855,6 +858,12 @@
<ClCompile Include="..\..\src\common\angleutils.cpp">
<Filter>src\common</Filter>
</ClCompile>
<ClInclude Include="..\..\src\common\NativeWindow.h">
<Filter>src\common</Filter>
</ClInclude>
<ClCompile Include="..\..\src\common\win32\NativeWindow.cpp">
<Filter>src\common\win32</Filter>
</ClCompile>
<ClInclude Include="..\..\src\third_party\systeminfo\SystemInfo.h">
<Filter>src\third_party\systeminfo</Filter>
</ClInclude>
......
......@@ -223,6 +223,7 @@
<ClInclude Include="..\..\src\common\utilities.h"/>
<ClInclude Include="..\..\src\common\tls.h"/>
<ClInclude Include="..\..\src\common\angleutils.h"/>
<ClInclude Include="..\..\src\common\NativeWindow.h"/>
<ClInclude Include="..\..\include\angle_gl.h"/>
<ClInclude Include="..\..\include\KHR\khrplatform.h"/>
<ClInclude Include="..\..\include\GLSLANG\ShaderLang.h"/>
......@@ -250,6 +251,7 @@
<ClCompile Include="..\..\src\common\event_tracer.cpp"/>
<ClCompile Include="..\..\src\common\utilities.cpp"/>
<ClCompile Include="..\..\src\common\angleutils.cpp"/>
<ClCompile Include="..\..\src\common\win32\NativeWindow.cpp"/>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\src\libEGL\libEGL.rc"/>
......
......@@ -10,6 +10,9 @@
<Filter Include="src\common">
<UniqueIdentifier>{2F5FD094-EF52-77F7-7AA8-4327A01BF747}</UniqueIdentifier>
</Filter>
<Filter Include="src\common\win32">
<UniqueIdentifier>{789FEF16-EFE7-512E-F91B-DF7E0D72FB79}</UniqueIdentifier>
</Filter>
<Filter Include="include">
<UniqueIdentifier>{57CA55B8-BCC5-4000-CE3A-58972F82E9CB}</UniqueIdentifier>
</Filter>
......@@ -117,6 +120,12 @@
<ClCompile Include="..\..\src\common\angleutils.cpp">
<Filter>src\common</Filter>
</ClCompile>
<ClInclude Include="..\..\src\common\NativeWindow.h">
<Filter>src\common</Filter>
</ClInclude>
<ClCompile Include="..\..\src\common\win32\NativeWindow.cpp">
<Filter>src\common\win32</Filter>
</ClCompile>
<ClInclude Include="..\..\include\angle_gl.h">
<Filter>include</Filter>
</ClInclude>
......
//
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// NativeWindow.h: Defines NativeWindow, a class for managing and
// performing operations on an EGLNativeWindowType.
// It is used for HWND (Desktop Windows) and IInspectable objects
//(Windows Store Applications).
#ifndef COMMON_NATIVEWINDOW_H_
#define COMMON_NATIVEWINDOW_H_
#include <EGL/eglplatform.h>
#include "common/debug.h"
#include "common/platform.h"
// DXGISwapChain and DXGIFactory are typedef'd to specific required
// types. The HWND NativeWindow implementation requires IDXGISwapChain
// and IDXGIFactory and the Windows Store NativeWindow
// implementation requires IDXGISwapChain1 and IDXGIFactory2.
typedef IDXGISwapChain DXGISwapChain;
typedef IDXGIFactory DXGIFactory;
namespace rx
{
class NativeWindow
{
public:
explicit NativeWindow(EGLNativeWindowType window);
// The HWND NativeWindow implementation can benefit
// by having inline versions of these methods to
// reduce the calling overhead.
inline bool initialize() { return true; }
inline bool getClientRect(LPRECT rect) { return GetClientRect(mWindow, rect) == TRUE; }
inline bool isIconic() { return IsIconic(mWindow) == TRUE; }
HRESULT createSwapChain(ID3D11Device* device, DXGIFactory* factory,
DXGI_FORMAT format, UINT width, UINT height,
DXGISwapChain** swapChain);
inline EGLNativeWindowType getNativeWindow() const { return mWindow; }
private:
EGLNativeWindowType mWindow;
};
}
bool isValidEGLNativeWindowType(EGLNativeWindowType window);
#endif // COMMON_NATIVEWINDOW_H_
//
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// NativeWindow.cpp: Handler for managing HWND native window types.
#include "common/NativeWindow.h"
#include "common/debug.h"
bool isValidEGLNativeWindowType(EGLNativeWindowType window)
{
return (IsWindow(window) == TRUE);
}
namespace rx
{
NativeWindow::NativeWindow(EGLNativeWindowType window) : mWindow(window)
{
}
HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory,
DXGI_FORMAT format, unsigned int width, unsigned int height,
DXGISwapChain** swapChain)
{
if (device == NULL || factory == NULL || swapChain == NULL || width == 0 || height == 0)
{
return E_INVALIDARG;
}
DXGI_SWAP_CHAIN_DESC swapChainDesc = { 0 };
swapChainDesc.BufferCount = 1;
swapChainDesc.BufferDesc.Format = format;
swapChainDesc.BufferDesc.Width = width;
swapChainDesc.BufferDesc.Height = height;
swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_BACK_BUFFER;
swapChainDesc.Flags = 0;
swapChainDesc.OutputWindow = mWindow;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.Windowed = TRUE;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
return factory->CreateSwapChain(device, &swapChainDesc, swapChain);
}
};
\ No newline at end of file
......@@ -34,11 +34,13 @@
'common/mathutil.cpp',
'common/mathutil.h',
'common/platform.h',
'common/NativeWindow.h',
'common/tls.cpp',
'common/tls.h',
'common/utilities.cpp',
'common/utilities.h',
'common/version.h',
'common/win32/NativeWindow.cpp',
'libEGL/Config.cpp',
'libEGL/Config.h',
'libEGL/Display.cpp',
......
......@@ -192,7 +192,7 @@ bool Display::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value)
EGLSurface Display::createWindowSurface(HWND window, EGLConfig config, const EGLint *attribList)
EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig config, const EGLint *attribList)
{
const Config *configuration = mConfigSet.get(config);
EGLint postSubBufferSupported = EGL_FALSE;
......@@ -493,7 +493,7 @@ bool Display::isValidSurface(egl::Surface *surface)
return mSurfaceSet.find(surface) != mSurfaceSet.end();
}
bool Display::hasExistingWindowSurface(HWND window)
bool Display::hasExistingWindowSurface(EGLNativeWindowType window)
{
for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
{
......
......@@ -43,7 +43,7 @@ class Display
bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig);
bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value);
EGLSurface createWindowSurface(HWND window, EGLConfig config, const EGLint *attribList);
EGLSurface createWindowSurface(EGLNativeWindowType window, EGLConfig config, const EGLint *attribList);
EGLSurface createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList);
EGLContext createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets, bool robustAccess);
......@@ -54,7 +54,7 @@ class Display
bool isValidConfig(EGLConfig config);
bool isValidContext(gl::Context *context);
bool isValidSurface(egl::Surface *surface);
bool hasExistingWindowSurface(HWND window);
bool hasExistingWindowSurface(EGLNativeWindowType window);
rx::Renderer *getRenderer() { return mRenderer; };
......
......@@ -22,11 +22,13 @@
#include "libEGL/main.h"
#include "libEGL/Display.h"
#include "common/NativeWindow.h"
namespace egl
{
Surface::Surface(Display *display, const Config *config, HWND window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported)
: mDisplay(display), mConfig(config), mWindow(window), mPostSubBufferSupported(postSubBufferSupported)
Surface::Surface(Display *display, const Config *config, EGLNativeWindowType window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported)
: mDisplay(display), mConfig(config), mNativeWindow(window), mPostSubBufferSupported(postSubBufferSupported)
{
mRenderer = mDisplay->getRenderer();
mSwapChain = NULL;
......@@ -48,7 +50,7 @@ Surface::Surface(Display *display, const Config *config, HWND window, EGLint fix
}
Surface::Surface(Display *display, const Config *config, HANDLE shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureType)
: mDisplay(display), mWindow(NULL), mConfig(config), mShareHandle(shareHandle), mWidth(width), mHeight(height), mPostSubBufferSupported(EGL_FALSE)
: mDisplay(display), mNativeWindow(NULL), mConfig(config), mShareHandle(shareHandle), mWidth(width), mHeight(height), mPostSubBufferSupported(EGL_FALSE)
{
mRenderer = mDisplay->getRenderer();
mSwapChain = NULL;
......@@ -74,6 +76,14 @@ Surface::~Surface()
bool Surface::initialize()
{
if (mNativeWindow.getNativeWindow())
{
if (!mNativeWindow.initialize())
{
return false;
}
}
if (!resetSwapChain())
return false;
......@@ -102,7 +112,7 @@ bool Surface::resetSwapChain()
if (!mFixedSize)
{
RECT windowRect;
if (!GetClientRect(getWindowHandle(), &windowRect))
if (!mNativeWindow.getClientRect(&windowRect))
{
ASSERT(false);
......@@ -120,7 +130,7 @@ bool Surface::resetSwapChain()
height = mHeight;
}
mSwapChain = mRenderer->createSwapChain(mWindow, mShareHandle,
mSwapChain = mRenderer->createSwapChain(mNativeWindow, mShareHandle,
mConfig->mRenderTargetFormat,
mConfig->mDepthStencilFormat);
if (!mSwapChain)
......@@ -224,9 +234,9 @@ bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
return true;
}
HWND Surface::getWindowHandle()
EGLNativeWindowType Surface::getWindowHandle()
{
return mWindow;
return mNativeWindow.getNativeWindow();
}
......@@ -249,28 +259,29 @@ static LRESULT CALLBACK SurfaceWindowProc(HWND hwnd, UINT message, WPARAM wparam
void Surface::subclassWindow()
{
if (!mWindow)
HWND window = mNativeWindow.getNativeWindow();
if (!window)
{
return;
}
DWORD processId;
DWORD threadId = GetWindowThreadProcessId(mWindow, &processId);
DWORD threadId = GetWindowThreadProcessId(window, &processId);
if (processId != GetCurrentProcessId() || threadId != GetCurrentThreadId())
{
return;
}
SetLastError(0);
LONG_PTR oldWndProc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(SurfaceWindowProc));
LONG_PTR oldWndProc = SetWindowLongPtr(window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(SurfaceWindowProc));
if(oldWndProc == 0 && GetLastError() != ERROR_SUCCESS)
{
mWindowSubclassed = false;
return;
}
SetProp(mWindow, kSurfaceProperty, reinterpret_cast<HANDLE>(this));
SetProp(mWindow, kParentWndProc, reinterpret_cast<HANDLE>(oldWndProc));
SetProp(window, kSurfaceProperty, reinterpret_cast<HANDLE>(this));
SetProp(window, kParentWndProc, reinterpret_cast<HANDLE>(oldWndProc));
mWindowSubclassed = true;
}
......@@ -281,8 +292,14 @@ void Surface::unsubclassWindow()
return;
}
HWND window = mNativeWindow.getNativeWindow();
if (!window)
{
return;
}
// un-subclass
LONG_PTR parentWndFunc = reinterpret_cast<LONG_PTR>(GetProp(mWindow, kParentWndProc));
LONG_PTR parentWndFunc = reinterpret_cast<LONG_PTR>(GetProp(window, kParentWndProc));
// Check the windowproc is still SurfaceWindowProc.
// If this assert fails, then it is likely the application has subclassed the
......@@ -291,13 +308,13 @@ void Surface::unsubclassWindow()
// EGL context, or to unsubclass before destroying the EGL context.
if(parentWndFunc)
{
LONG_PTR prevWndFunc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, parentWndFunc);
LONG_PTR prevWndFunc = SetWindowLongPtr(window, GWLP_WNDPROC, parentWndFunc);
UNUSED_ASSERTION_VARIABLE(prevWndFunc);
ASSERT(prevWndFunc == reinterpret_cast<LONG_PTR>(SurfaceWindowProc));
}
RemoveProp(mWindow, kSurfaceProperty);
RemoveProp(mWindow, kParentWndProc);
RemoveProp(window, kSurfaceProperty);
RemoveProp(window, kParentWndProc);
mWindowSubclassed = false;
}
......@@ -307,11 +324,11 @@ bool Surface::checkForOutOfDateSwapChain()
int clientWidth = getWidth();
int clientHeight = getHeight();
bool sizeDirty = false;
if (!mFixedSize && !IsIconic(getWindowHandle()))
if (!mFixedSize && !mNativeWindow.isIconic())
{
// The window is automatically resized to 150x22 when it's minimized, but the swapchain shouldn't be resized
// because that's not a useful size to render to.
if (!GetClientRect(getWindowHandle(), &client))
if (!mNativeWindow.getClientRect(&client))
{
ASSERT(false);
return false;
......
......@@ -14,6 +14,7 @@
#include <EGL/egl.h>
#include "common/angleutils.h"
#include "common/NativeWindow.h"
namespace gl
{
......@@ -33,7 +34,7 @@ class Config;
class Surface
{
public:
Surface(Display *display, const egl::Config *config, HWND window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported);
Surface(Display *display, const egl::Config *config, EGLNativeWindowType window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported);
Surface(Display *display, const egl::Config *config, HANDLE shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget);
virtual ~Surface();
......@@ -42,7 +43,7 @@ class Surface
void release();
bool resetSwapChain();
HWND getWindowHandle();
EGLNativeWindowType getWindowHandle();
bool swap();
bool postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height);
......@@ -83,7 +84,7 @@ private:
bool resetSwapChain(int backbufferWidth, int backbufferHeight);
bool swapRect(EGLint x, EGLint y, EGLint width, EGLint height);
const HWND mWindow; // Window that the surface is created for.
rx::NativeWindow mNativeWindow; // Handler for the Window that the surface is created for.
bool mWindowSubclassed; // Indicates whether we successfully subclassed mWindow for WM_RESIZE hooking
const egl::Config *mConfig; // EGL config surface was created with
EGLint mHeight; // Height of surface
......
......@@ -19,6 +19,8 @@
#include "libEGL/Display.h"
#include "libEGL/Surface.h"
#include "common/NativeWindow.h"
bool validateDisplay(egl::Display *display)
{
if (display == EGL_NO_DISPLAY)
......@@ -324,14 +326,12 @@ EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EG
return EGL_NO_SURFACE;
}
HWND window = (HWND)win;
if (!IsWindow(window))
if (!isValidEGLNativeWindowType(win))
{
return egl::error(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
}
return display->createWindowSurface(window, config, attrib_list);
return display->createWindowSurface(win, config, attrib_list);
}
EGLSurface __stdcall eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
......
......@@ -36,11 +36,13 @@
'common/mathutil.cpp',
'common/mathutil.h',
'common/platform.h',
'common/NativeWindow.h',
'common/tls.cpp',
'common/tls.h',
'common/utilities.cpp',
'common/utilities.h',
'common/version.h',
'common/win32/NativeWindow.cpp',
'libGLESv2/BinaryStream.h',
'libGLESv2/Buffer.cpp',
'libGLESv2/Buffer.h',
......
......@@ -13,6 +13,7 @@
#include "libGLESv2/Uniform.h"
#include "libGLESv2/angletypes.h"
#include "libGLESv2/Caps.h"
#include "common/NativeWindow.h"
#include "libGLESv2/Error.h"
#include <cstdint>
......@@ -107,7 +108,7 @@ class Renderer
virtual void sync(bool block) = 0;
virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) = 0;
virtual SwapChain *createSwapChain(rx::NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) = 0;
virtual gl::Error generateSwizzle(gl::Texture *texture) = 0;
virtual gl::Error setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler) = 0;
......
......@@ -11,6 +11,7 @@
#define LIBGLESV2_RENDERER_SWAPCHAIN_H_
#include "common/angleutils.h"
#include "common/NativeWindow.h"
#include "common/platform.h"
#include <GLES2/gl2.h>
......@@ -26,8 +27,8 @@ namespace rx
class SwapChain
{
public:
SwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat)
: mWindow(window), mShareHandle(shareHandle), mBackBufferFormat(backBufferFormat), mDepthBufferFormat(depthBufferFormat)
SwapChain(rx::NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat)
: mNativeWindow(nativeWindow), mShareHandle(shareHandle), mBackBufferFormat(backBufferFormat), mDepthBufferFormat(depthBufferFormat)
{
}
......@@ -41,7 +42,7 @@ class SwapChain
virtual HANDLE getShareHandle() {return mShareHandle;};
protected:
const HWND mWindow; // Window that the surface is created for.
rx::NativeWindow mNativeWindow; // Handler for the Window that the surface is created for.
const GLenum mBackBufferFormat;
const GLenum mDepthBufferFormat;
......
......@@ -408,9 +408,9 @@ void Renderer11::sync(bool block)
}
}
SwapChain *Renderer11::createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat)
SwapChain *Renderer11::createSwapChain(rx::NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat)
{
return new rx::SwapChain11(this, window, shareHandle, backBufferFormat, depthBufferFormat);
return new rx::SwapChain11(this, nativeWindow, shareHandle, backBufferFormat, depthBufferFormat);
}
gl::Error Renderer11::generateSwizzle(gl::Texture *texture)
......
......@@ -57,7 +57,7 @@ class Renderer11 : public Renderer
virtual void sync(bool block);
virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat);
virtual SwapChain *createSwapChain(rx::NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat);
virtual gl::Error generateSwizzle(gl::Texture *texture);
virtual gl::Error setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler);
......
......@@ -15,12 +15,15 @@
#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough2d11vs.h"
#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2d11ps.h"
#include "common/NativeWindow.h"
namespace rx
{
SwapChain11::SwapChain11(Renderer11 *renderer, HWND window, HANDLE shareHandle,
SwapChain11::SwapChain11(Renderer11 *renderer, rx::NativeWindow nativeWindow, HANDLE shareHandle,
GLenum backBufferFormat, GLenum depthBufferFormat)
: mRenderer(renderer), SwapChain(window, shareHandle, backBufferFormat, depthBufferFormat)
: mRenderer(renderer),
SwapChain(nativeWindow, shareHandle, backBufferFormat, depthBufferFormat)
{
mSwapChain = NULL;
mBackBufferTexture = NULL;
......@@ -145,7 +148,7 @@ EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHei
}
else
{
const bool useSharedResource = !mWindow && mRenderer->getShareHandleSupport();
const bool useSharedResource = !mNativeWindow.getNativeWindow() && mRenderer->getShareHandleSupport();
D3D11_TEXTURE2D_DESC offscreenTextureDesc = {0};
offscreenTextureDesc.Width = backbufferWidth;
......@@ -393,30 +396,13 @@ EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swap
return EGL_SUCCESS;
}
if (mWindow)
if (mNativeWindow.getNativeWindow())
{
const d3d11::TextureFormat &backbufferFormatInfo = d3d11::GetTextureFormatInfo(mBackBufferFormat);
IDXGIFactory *factory = mRenderer->getDxgiFactory();
DXGI_SWAP_CHAIN_DESC swapChainDesc = {0};
swapChainDesc.BufferDesc.Width = backbufferWidth;
swapChainDesc.BufferDesc.Height = backbufferHeight;
swapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
swapChainDesc.BufferDesc.Format = backbufferFormatInfo.texFormat;
swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferCount = 1;
swapChainDesc.OutputWindow = mWindow;
swapChainDesc.Windowed = TRUE;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
swapChainDesc.Flags = 0;
HRESULT result = factory->CreateSwapChain(device, &swapChainDesc, &mSwapChain);
HRESULT result = mNativeWindow.createSwapChain(device, mRenderer->getDxgiFactory(),
backbufferFormatInfo.texFormat,
backbufferWidth, backbufferHeight, &mSwapChain);
if (FAILED(result))
{
......
......@@ -19,7 +19,7 @@ class Renderer11;
class SwapChain11 : public SwapChain
{
public:
SwapChain11(Renderer11 *renderer, HWND window, HANDLE shareHandle,
SwapChain11(Renderer11 *renderer, rx::NativeWindow nativeWindow, HANDLE shareHandle,
GLenum backBufferFormat, GLenum depthBufferFormat);
virtual ~SwapChain11();
......
......@@ -529,9 +529,9 @@ void Renderer9::sync(bool block)
}
}
SwapChain *Renderer9::createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat)
SwapChain *Renderer9::createSwapChain(rx::NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat)
{
return new rx::SwapChain9(this, window, shareHandle, backBufferFormat, depthBufferFormat);
return new rx::SwapChain9(this, nativeWindow, shareHandle, backBufferFormat, depthBufferFormat);
}
IDirect3DQuery9* Renderer9::allocateEventQuery()
......
......@@ -50,7 +50,7 @@ class Renderer9 : public Renderer
virtual void sync(bool block);
virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat);
virtual SwapChain *createSwapChain(rx::NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat);
IDirect3DQuery9* allocateEventQuery();
void freeEventQuery(IDirect3DQuery9* query);
......
......@@ -14,9 +14,10 @@
namespace rx
{
SwapChain9::SwapChain9(Renderer9 *renderer, HWND window, HANDLE shareHandle,
SwapChain9::SwapChain9(Renderer9 *renderer, rx::NativeWindow nativeWindow, HANDLE shareHandle,
GLenum backBufferFormat, GLenum depthBufferFormat)
: mRenderer(renderer), SwapChain(window, shareHandle, backBufferFormat, depthBufferFormat)
: mRenderer(renderer),
SwapChain(nativeWindow, shareHandle, backBufferFormat, depthBufferFormat)
{
mSwapChain = NULL;
mBackBuffer = NULL;
......@@ -41,7 +42,7 @@ void SwapChain9::release()
SafeRelease(mRenderTarget);
SafeRelease(mOffscreenTexture);
if (mWindow)
if (mNativeWindow.getNativeWindow())
{
mShareHandle = NULL;
}
......@@ -95,7 +96,7 @@ EGLint SwapChain9::reset(int backbufferWidth, int backbufferHeight, EGLint swapI
SafeRelease(mDepthStencil);
HANDLE *pShareHandle = NULL;
if (!mWindow && mRenderer->getShareHandleSupport())
if (!mNativeWindow.getNativeWindow() && mRenderer->getShareHandleSupport())
{
pShareHandle = &mShareHandle;
}
......@@ -152,7 +153,8 @@ EGLint SwapChain9::reset(int backbufferWidth, int backbufferHeight, EGLint swapI
const d3d9::TextureFormat &depthBufferd3dFormatInfo = d3d9::GetTextureFormatInfo(mDepthBufferFormat);
if (mWindow)
EGLNativeWindowType window = mNativeWindow.getNativeWindow();
if (window)
{
D3DPRESENT_PARAMETERS presentParameters = {0};
presentParameters.AutoDepthStencilFormat = depthBufferd3dFormatInfo.renderFormat;
......@@ -160,7 +162,7 @@ EGLint SwapChain9::reset(int backbufferWidth, int backbufferHeight, EGLint swapI
presentParameters.BackBufferFormat = backBufferd3dFormatInfo.renderFormat;
presentParameters.EnableAutoDepthStencil = FALSE;
presentParameters.Flags = 0;
presentParameters.hDeviceWindow = mWindow;
presentParameters.hDeviceWindow = window;
presentParameters.MultiSampleQuality = 0; // FIXME: Unimplemented
presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; // FIXME: Unimplemented
presentParameters.PresentationInterval = convertInterval(swapInterval);
......@@ -203,7 +205,7 @@ EGLint SwapChain9::reset(int backbufferWidth, int backbufferHeight, EGLint swapI
result = mSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &mBackBuffer);
ASSERT(SUCCEEDED(result));
InvalidateRect(mWindow, NULL, FALSE);
InvalidateRect(window, NULL, FALSE);
}
if (mDepthBufferFormat != GL_NONE)
......
......@@ -19,7 +19,7 @@ class Renderer9;
class SwapChain9 : public SwapChain
{
public:
SwapChain9(Renderer9 *renderer, HWND window, HANDLE shareHandle,
SwapChain9(Renderer9 *renderer, rx::NativeWindow nativeWindow, HANDLE shareHandle,
GLenum backBufferFormat, GLenum depthBufferFormat);
virtual ~SwapChain9();
......
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