Commit fb0580a6 by Jamie Madill

MANGLE egl::Surface.

This class has its fingers in a lot of other classes. In particular, we will likely need to revisit the context lost handling methods when we implement the robustness extensions on top of desktop GL. For now, we can leave them tied pretty tightly to the D3D implementation. BUG=angle:795 Change-Id: I9b3ac90dfd393f52c5b49bc2bd6b97fb5536ed91 Reviewed-on: https://chromium-review.googlesource.com/228916Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 533f0a1d
......@@ -19,10 +19,11 @@
#include "common/debug.h"
#include "common/mathutil.h"
#include "libANGLE/Context.h"
#include "libANGLE/renderer/SwapChain.h"
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/Renderer.h"
//TODO(jmadill): remove these
#include "libANGLE/renderer/SwapChain.h"
#include "libANGLE/renderer/d3d/SurfaceD3D.h"
#include <EGL/eglext.h>
......@@ -372,7 +373,11 @@ Error Display::createWindowSurface(EGLNativeWindowType window, EGLConfig config,
}
}
Surface *surface = new Surface(this, configuration, window, fixedSize, width, height, postSubBufferSupported);
//TODO(jmadill): MANGLE refactor
rx::SurfaceD3D *surfaceD3D = rx::SurfaceD3D::createFromWindow(this, configuration, window, fixedSize,
width, height, postSubBufferSupported);
Surface *surface = new Surface(surfaceD3D);
Error error = surface->initialize();
if (error.isError())
{
......@@ -386,7 +391,8 @@ Error Display::createWindowSurface(EGLNativeWindowType window, EGLConfig config,
return Error(EGL_SUCCESS);
}
Error Display::createOffscreenSurface(EGLConfig config, EGLClientBuffer shareHandle, const EGLint *attribList, EGLSurface *outSurface)
Error Display::createOffscreenSurface(EGLConfig config, EGLClientBuffer shareHandle,
const EGLint *attribList, EGLSurface *outSurface)
{
EGLint width = 0, height = 0;
EGLenum textureFormat = EGL_NO_TEXTURE;
......@@ -489,7 +495,11 @@ Error Display::createOffscreenSurface(EGLConfig config, EGLClientBuffer shareHan
}
}
Surface *surface = new Surface(this, configuration, shareHandle, width, height, textureFormat, textureTarget);
//TODO(jmadill): MANGLE refactor
rx::SurfaceD3D *surfaceD3D = rx::SurfaceD3D::createOffscreen(this, configuration, shareHandle,
width, height, textureFormat, textureTarget);
Surface *surface = new Surface(surfaceD3D);
Error error = surface->initialize();
if (error.isError())
{
......@@ -546,9 +556,16 @@ Error Display::restoreLostDevice()
}
// Release surface resources to make the Reset() succeed
for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
for (const auto &surface : mSurfaceSet)
{
(*surface)->release();
//TODO(jmadill): MANGLE refactor
rx::SurfaceD3D *surfaceD3D = rx::SurfaceD3D::makeSurfaceD3D(surface);
if (surface->getBoundTexture())
{
surface->releaseTexImage(EGL_BACK_BUFFER);
}
surfaceD3D->releaseSwapChain();
}
if (!mRenderer->resetDevice())
......@@ -557,9 +574,12 @@ Error Display::restoreLostDevice()
}
// Restore any surfaces that may have been lost
for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
for (const auto &surface : mSurfaceSet)
{
Error error = (*surface)->resetSwapChain();
//TODO(jmadill): MANGLE refactor
rx::SurfaceD3D *surfaceD3D = rx::SurfaceD3D::makeSurfaceD3D(surface);
Error error = surfaceD3D->resetSwapChain();
if (error.isError())
{
return error;
......@@ -592,9 +612,11 @@ void Display::notifyDeviceLost()
void Display::recreateSwapChains()
{
for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
for (const auto &surface : mSurfaceSet)
{
(*surface)->getSwapChain()->recreate();
//TODO(jmadill): MANGLE refactor
rx::SurfaceD3D *surfaceD3D = rx::SurfaceD3D::makeSurfaceD3D(surface);
surfaceD3D->getSwapChain()->recreate();
}
}
......
......@@ -11,23 +11,19 @@
#ifndef LIBANGLE_SURFACE_H_
#define LIBANGLE_SURFACE_H_
#include "common/angleutils.h"
#include "libANGLE/Error.h"
// TODO: don't expose this to egl::Surface
#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h"
#include <EGL/egl.h>
#include "common/angleutils.h"
namespace gl
{
class Texture2D;
}
namespace rx
{
class SwapChain;
class RendererD3D; //TODO(jmadill): remove this
class SurfaceImpl;
}
namespace egl
......@@ -35,85 +31,55 @@ namespace egl
class Display;
class Config;
class Surface
class Surface final
{
public:
Surface(Display *display, const egl::Config *config, EGLNativeWindowType window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported);
Surface(Display *display, const egl::Config *config, EGLClientBuffer shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget);
Surface(rx::SurfaceImpl *impl);
~Surface();
virtual ~Surface();
rx::SurfaceImpl *getImplementation() const { return mImplementation; }
Error initialize();
void release();
Error resetSwapChain();
EGLNativeWindowType getWindowHandle();
Error swap();
Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height);
Error querySurfacePointerANGLE(EGLint attribute, void **value);
Error bindTexImage(gl::Texture2D *texture, EGLint buffer);
Error releaseTexImage(EGLint buffer);
virtual EGLint isPostSubBufferSupported() const;
EGLNativeWindowType getWindowHandle() const;
virtual rx::SwapChain *getSwapChain() const;
EGLint isPostSubBufferSupported() const;
void setSwapInterval(EGLint interval);
bool checkForOutOfDateSwapChain(); // Returns true if swapchain changed due to resize or interval update
virtual EGLint getConfigID() const;
virtual EGLint getWidth() const;
virtual EGLint getHeight() const;
virtual EGLint getPixelAspectRatio() const;
virtual EGLenum getRenderBuffer() const;
virtual EGLenum getSwapBehavior() const;
virtual EGLenum getTextureFormat() const;
virtual EGLenum getTextureTarget() const;
virtual EGLenum getFormat() const;
EGLint getConfigID() const;
// width and height can change with client window resizing
EGLint getWidth() const;
EGLint getHeight() const;
EGLint getPixelAspectRatio() const;
EGLenum getRenderBuffer() const;
EGLenum getSwapBehavior() const;
EGLenum getTextureFormat() const;
EGLenum getTextureTarget() const;
EGLenum getFormat() const;
virtual void setBoundTexture(gl::Texture2D *texture);
virtual gl::Texture2D *getBoundTexture() const;
gl::Texture2D *getBoundTexture() const { return mTexture; }
EGLint isFixedSize() const;
private:
DISALLOW_COPY_AND_ASSIGN(Surface);
Display *const mDisplay;
rx::RendererD3D *mRenderer;
EGLClientBuffer mShareHandle;
rx::SwapChain *mSwapChain;
void subclassWindow();
void unsubclassWindow();
Error resizeSwapChain(int backbufferWidth, int backbufferHeight);
Error resetSwapChain(int backbufferWidth, int backbufferHeight);
Error swapRect(EGLint x, EGLint y, EGLint width, EGLint height);
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
EGLint mWidth; // Width of surface
// EGLint horizontalResolution; // Horizontal dot pitch
// EGLint verticalResolution; // Vertical dot pitch
// EGLBoolean largestPBuffer; // If true, create largest pbuffer possible
// EGLBoolean mipmapTexture; // True if texture has mipmaps
// EGLint mipmapLevel; // Mipmap level to render to
// EGLenum multisampleResolve; // Multisample resolve behavior
rx::SurfaceImpl *mImplementation;
EGLint mPixelAspectRatio; // Display aspect ratio
EGLenum mRenderBuffer; // Render buffer
EGLenum mSwapBehavior; // Buffer swap behavior
EGLenum mTextureFormat; // Format of texture: RGB, RGBA, or no texture
EGLenum mTextureTarget; // Type of texture: 2D or no texture
// EGLenum vgAlphaFormat; // Alpha format for OpenVG
// EGLenum vgColorSpace; // Color space for OpenVG
EGLint mSwapInterval;
EGLint mPostSubBufferSupported;
EGLint mFixedSize;
bool mSwapIntervalDirty;
gl::Texture2D *mTexture;
};
}
#endif // LIBANGLE_SURFACE_H_
......@@ -181,7 +181,7 @@ Texture2D::~Texture2D()
{
if (mSurface)
{
mSurface->setBoundTexture(NULL);
mSurface->releaseTexImage(EGL_BACK_BUFFER);
mSurface = NULL;
}
}
......@@ -228,20 +228,15 @@ Error Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum int
void Texture2D::bindTexImage(egl::Surface *surface)
{
releaseTexImage();
mTexture->bindTexImage(surface);
mSurface = surface;
mSurface->setBoundTexture(this);
}
void Texture2D::releaseTexImage()
{
if (mSurface)
{
mSurface->setBoundTexture(NULL);
mSurface = NULL;
mTexture->releaseTexImage();
}
}
......
//
// 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.
//
// SurfaceImpl.cpp: Implementation of Surface stub method class
#include "libANGLE/renderer/SurfaceImpl.h"
#include "libANGLE/Config.h"
namespace rx
{
SurfaceImpl::SurfaceImpl(egl::Display *display, const egl::Config *config, EGLint width, EGLint height,
EGLint fixedSize, EGLint postSubBufferSupported, EGLenum textureFormat,
EGLenum textureType, EGLClientBuffer shareHandle)
: mDisplay(display),
mConfig(config),
mWidth(width),
mHeight(height),
mFixedSize(fixedSize),
mSwapInterval(-1),
mPostSubBufferSupported(postSubBufferSupported),
mTextureFormat(textureFormat),
mTextureTarget(textureType),
mShareHandle(shareHandle)
{
}
SurfaceImpl::~SurfaceImpl()
{
}
EGLenum SurfaceImpl::getFormat() const
{
return mConfig->mRenderTargetFormat;
}
}
//
// Copyright (c) 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.
//
// SurfaceImpl.h: Implementation methods of egl::Surface
#ifndef LIBANGLE_RENDERER_SURFACEIMPL_H_
#define LIBANGLE_RENDERER_SURFACEIMPL_H_
#include "common/angleutils.h"
#include "libANGLE/Error.h"
namespace egl
{
class Display;
class Config;
}
namespace gl
{
class Texture2D;
}
namespace rx
{
class SurfaceImpl
{
public:
SurfaceImpl(egl::Display *display, const egl::Config *config, EGLint width, EGLint height,
EGLint fixedSize, EGLint postSubBufferSupported, EGLenum textureFormat,
EGLenum textureType, EGLClientBuffer shareHandle);
virtual ~SurfaceImpl();
virtual egl::Error initialize() = 0;
virtual egl::Error swap() = 0;
virtual egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) = 0;
virtual egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) = 0;
virtual egl::Error bindTexImage(EGLint buffer) = 0;
virtual egl::Error releaseTexImage(EGLint buffer) = 0;
virtual void setSwapInterval(EGLint interval) = 0;
// width and height can change with client window resizing
EGLint getWidth() const { return mWidth; }
EGLint getHeight() const { return mHeight; }
//TODO(jmadill): Possibly should be redesigned
virtual EGLNativeWindowType getWindowHandle() const = 0;
const egl::Config *getConfig() const { return mConfig; }
EGLint isFixedSize() const { return mFixedSize; }
EGLenum getFormat() const;
EGLint isPostSubBufferSupported() const { return mPostSubBufferSupported; }
EGLenum getTextureFormat() const { return mTextureFormat; }
EGLenum getTextureTarget() const { return mTextureTarget; }
protected:
// Useful for mocking
SurfaceImpl()
: mDisplay(nullptr),
mConfig(nullptr),
mWidth(0),
mHeight(0),
mFixedSize(0),
mPostSubBufferSupported(0),
mTextureFormat(EGL_NONE),
mTextureTarget(EGL_NONE),
mShareHandle(static_cast<EGLClientBuffer>(0))
{}
egl::Display *const mDisplay;
const egl::Config *mConfig; // EGL config surface was created with
EGLint mWidth;
EGLint mHeight;
EGLint mFixedSize;
EGLint mSwapInterval;
EGLint mPostSubBufferSupported;
// EGLint horizontalResolution; // Horizontal dot pitch
// EGLint verticalResolution; // Vertical dot pitch
// EGLBoolean largestPBuffer; // If true, create largest pbuffer possible
// EGLBoolean mipmapTexture; // True if texture has mipmaps
// EGLint mipmapLevel; // Mipmap level to render to
// EGLenum multisampleResolve; // Multisample resolve behavior
EGLenum mTextureFormat; // Format of texture: RGB, RGBA, or no texture
EGLenum mTextureTarget; // Type of texture: 2D or no texture
// EGLenum vgAlphaFormat; // Alpha format for OpenVG
// EGLenum vgColorSpace; // Color space for OpenVG
EGLClientBuffer mShareHandle;
private:
DISALLOW_COPY_AND_ASSIGN(SurfaceImpl);
};
}
#endif // LIBANGLE_RENDERER_SURFACEIMPL_H_
//
// Copyright (c) 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.
//
// SurfaceD3D.h: D3D implementation of an EGL surface
#ifndef LIBANGLE_RENDERER_D3D_SURFACED3D_H_
#define LIBANGLE_RENDERER_D3D_SURFACED3D_H_
#include "libANGLE/renderer/SurfaceImpl.h"
#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h"
namespace egl
{
class Surface;
}
namespace rx
{
class SwapChain;
class RendererD3D;
class SurfaceD3D : public SurfaceImpl
{
public:
static SurfaceD3D *createFromWindow(egl::Display *display, const egl::Config *config,
EGLNativeWindowType window, EGLint fixedSize,
EGLint width, EGLint height, EGLint postSubBufferSupported);
static SurfaceD3D *createOffscreen(egl::Display *display, const egl::Config *config,
EGLClientBuffer shareHandle, EGLint width, EGLint height,
EGLenum textureFormat, EGLenum textureTarget);
~SurfaceD3D() override;
void releaseSwapChain();
static SurfaceD3D *makeSurfaceD3D(SurfaceImpl *impl);
static SurfaceD3D *makeSurfaceD3D(egl::Surface *surface);
egl::Error initialize() override;
egl::Error swap() override;
egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) override;
egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override;
egl::Error bindTexImage(EGLint buffer) override;
egl::Error releaseTexImage(EGLint buffer) override;
void setSwapInterval(EGLint interval) override;
// D3D implementations (some virtual to hack across DLL boundaries)
virtual SwapChain *getSwapChain() const;
egl::Error resetSwapChain();
// Returns true if swapchain changed due to resize or interval update
bool checkForOutOfDateSwapChain();
EGLNativeWindowType getWindowHandle() const override;
private:
DISALLOW_COPY_AND_ASSIGN(SurfaceD3D);
SurfaceD3D(egl::Display *display, const egl::Config *config, EGLint width, EGLint height,
EGLint fixedSize, EGLint postSubBufferSupported, EGLenum textureFormat,
EGLenum textureType, EGLClientBuffer shareHandle, EGLNativeWindowType window);
egl::Error swapRect(EGLint x, EGLint y, EGLint width, EGLint height);
egl::Error resetSwapChain(int backbufferWidth, int backbufferHeight);
egl::Error resizeSwapChain(int backbufferWidth, int backbufferHeight);
void subclassWindow();
void unsubclassWindow();
RendererD3D *mRenderer;
SwapChain *mSwapChain;
bool mSwapIntervalDirty;
bool mWindowSubclassed; // Indicates whether we successfully subclassed mWindow for WM_RESIZE hooking
NativeWindow mNativeWindow; // Handler for the Window that the surface is created for.
};
}
#endif // LIBANGLE_RENDERER_D3D_SURFACED3D_H_
......@@ -6,22 +6,22 @@
// TextureD3D.cpp: Implementations of the Texture interfaces shared betweeen the D3D backends.
#include "libANGLE/renderer/d3d/TextureD3D.h"
#include "common/mathutil.h"
#include "common/utilities.h"
#include "libANGLE/Buffer.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/Surface.h"
#include "libANGLE/Texture.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/BufferImpl.h"
#include "libANGLE/renderer/RenderTarget.h"
#include "libANGLE/renderer/d3d/BufferD3D.h"
#include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/renderer/d3d/TextureStorage.h"
#include "libANGLE/renderer/d3d/ImageD3D.h"
#include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/Surface.h"
#include "common/mathutil.h"
#include "common/utilities.h"
#include "libANGLE/renderer/d3d/SurfaceD3D.h"
#include "libANGLE/renderer/d3d/TextureStorage.h"
namespace rx
{
......@@ -847,7 +847,10 @@ void TextureD3D_2D::bindTexImage(egl::Surface *surface)
SafeDelete(mTexStorage);
}
mTexStorage = mRenderer->createTextureStorage2D(surface->getSwapChain());
SurfaceD3D *surfaceD3D = SurfaceD3D::makeSurfaceD3D(surface);
ASSERT(surfaceD3D);
mTexStorage = mRenderer->createTextureStorage2D(surfaceD3D->getSwapChain());
mDirtyImages = true;
}
......
......@@ -6,48 +6,46 @@
// Renderer11.cpp: Implements a back-end specific class for the D3D11 renderer.
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "common/utilities.h"
#include "common/tls.h"
#include "libANGLE/Buffer.h"
#include "libANGLE/Display.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/ProgramBinary.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/State.h"
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "libANGLE/renderer/d3d/IndexDataManager.h"
#include "libANGLE/renderer/d3d/ProgramD3D.h"
#include "libANGLE/renderer/d3d/RenderbufferD3D.h"
#include "libANGLE/renderer/d3d/ShaderD3D.h"
#include "libANGLE/renderer/d3d/SurfaceD3D.h"
#include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/renderer/d3d/TransformFeedbackD3D.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/VertexDataManager.h"
#include "libANGLE/renderer/d3d/d3d11/Blit11.h"
#include "libANGLE/renderer/d3d/d3d11/Buffer11.h"
#include "libANGLE/renderer/d3d/d3d11/Clear11.h"
#include "libANGLE/renderer/d3d/d3d11/Fence11.h"
#include "libANGLE/renderer/d3d/d3d11/Image11.h"
#include "libANGLE/renderer/d3d/d3d11/IndexBuffer11.h"
#include "libANGLE/renderer/d3d/d3d11/PixelTransfer11.h"
#include "libANGLE/renderer/d3d/d3d11/Query11.h"
#include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/renderer/d3d/d3d11/ShaderExecutable11.h"
#include "libANGLE/renderer/d3d/d3d11/SwapChain11.h"
#include "libANGLE/renderer/d3d/d3d11/Image11.h"
#include "libANGLE/renderer/d3d/d3d11/VertexBuffer11.h"
#include "libANGLE/renderer/d3d/d3d11/IndexBuffer11.h"
#include "libANGLE/renderer/d3d/d3d11/Buffer11.h"
#include "libANGLE/renderer/d3d/VertexDataManager.h"
#include "libANGLE/renderer/d3d/IndexDataManager.h"
#include "libANGLE/renderer/d3d/d3d11/TextureStorage11.h"
#include "libANGLE/renderer/d3d/d3d11/Query11.h"
#include "libANGLE/renderer/d3d/d3d11/Fence11.h"
#include "libANGLE/renderer/d3d/d3d11/Blit11.h"
#include "libANGLE/renderer/d3d/d3d11/Clear11.h"
#include "libANGLE/renderer/d3d/d3d11/Trim11.h"
#include "libANGLE/renderer/d3d/d3d11/PixelTransfer11.h"
#include "libANGLE/renderer/d3d/d3d11/VertexArray11.h"
#include "libANGLE/renderer/d3d/d3d11/Buffer11.h"
#include "libANGLE/renderer/d3d/RenderbufferD3D.h"
#include "libANGLE/Display.h"
#include "libANGLE/Surface.h"
#include "common/utilities.h"
#include "common/tls.h"
#include <EGL/eglext.h>
#include "libANGLE/renderer/d3d/d3d11/VertexBuffer11.h"
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
#include <sstream>
#include <EGL/eglext.h>
// Enable ANGLE_SKIP_DXGI_1_2_CHECK if there is not a possibility of using cross-process
// HWNDs or the Windows 7 Platform Update (KB2670838) is expected to be installed.
......@@ -2392,7 +2390,9 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
DefaultAttachmentImpl *Renderer11::createDefaultAttachment(GLenum type, egl::Surface *surface)
{
SwapChain11 *swapChain = SwapChain11::makeSwapChain11(surface->getSwapChain());
SurfaceD3D *surfaceD3D = SurfaceD3D::makeSurfaceD3D(surface);
SwapChain11 *swapChain = SwapChain11::makeSwapChain11(surfaceD3D->getSwapChain());
switch (type)
{
case GL_BACK:
......
......@@ -7,40 +7,41 @@
// Renderer9.cpp: Implements a back-end specific class for the D3D9 renderer.
#include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
#include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h"
#include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
#include "libANGLE/renderer/d3d/d3d9/ShaderExecutable9.h"
#include "libANGLE/renderer/d3d/d3d9/SwapChain9.h"
#include "libANGLE/renderer/d3d/d3d9/TextureStorage9.h"
#include "libANGLE/renderer/d3d/d3d9/Image9.h"
#include "libANGLE/renderer/d3d/d3d9/Blit9.h"
#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
#include "libANGLE/renderer/d3d/d3d9/VertexBuffer9.h"
#include "libANGLE/renderer/d3d/d3d9/IndexBuffer9.h"
#include "libANGLE/renderer/d3d/d3d9/Buffer9.h"
#include "libANGLE/renderer/d3d/d3d9/Query9.h"
#include "libANGLE/renderer/d3d/d3d9/Fence9.h"
#include "libANGLE/renderer/d3d/d3d9/VertexArray9.h"
#include "libANGLE/renderer/d3d/IndexDataManager.h"
#include "libANGLE/renderer/d3d/ProgramD3D.h"
#include "libANGLE/renderer/d3d/ShaderD3D.h"
#include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/renderer/d3d/TransformFeedbackD3D.h"
#include "libANGLE/renderer/d3d/RenderbufferD3D.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "common/utilities.h"
#include "libANGLE/Buffer.h"
#include "libANGLE/Texture.h"
#include "libANGLE/Display.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Renderbuffer.h"
#include "libANGLE/ProgramBinary.h"
#include "libANGLE/Renderbuffer.h"
#include "libANGLE/State.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/Display.h"
#include "libANGLE/Surface.h"
#include "libANGLE/Texture.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/features.h"
#include "common/utilities.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "libANGLE/renderer/d3d/IndexDataManager.h"
#include "libANGLE/renderer/d3d/ProgramD3D.h"
#include "libANGLE/renderer/d3d/RenderbufferD3D.h"
#include "libANGLE/renderer/d3d/ShaderD3D.h"
#include "libANGLE/renderer/d3d/SurfaceD3D.h"
#include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/renderer/d3d/TransformFeedbackD3D.h"
#include "libANGLE/renderer/d3d/d3d9/Blit9.h"
#include "libANGLE/renderer/d3d/d3d9/Buffer9.h"
#include "libANGLE/renderer/d3d/d3d9/Fence9.h"
#include "libANGLE/renderer/d3d/d3d9/Image9.h"
#include "libANGLE/renderer/d3d/d3d9/IndexBuffer9.h"
#include "libANGLE/renderer/d3d/d3d9/Query9.h"
#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
#include "libANGLE/renderer/d3d/d3d9/ShaderExecutable9.h"
#include "libANGLE/renderer/d3d/d3d9/SwapChain9.h"
#include "libANGLE/renderer/d3d/d3d9/TextureStorage9.h"
#include "libANGLE/renderer/d3d/d3d9/VertexArray9.h"
#include "libANGLE/renderer/d3d/d3d9/VertexBuffer9.h"
#include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h"
#include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
#include "third_party/trace_event/trace_event.h"
......@@ -2849,7 +2850,9 @@ gl::Error Renderer9::createRenderTarget(int width, int height, GLenum format, GL
DefaultAttachmentImpl *Renderer9::createDefaultAttachment(GLenum type, egl::Surface *surface)
{
SwapChain9 *swapChain = SwapChain9::makeSwapChain9(surface->getSwapChain());
SurfaceD3D *surfaceD3D = SurfaceD3D::makeSurfaceD3D(surface);
SwapChain9 *swapChain = SwapChain9::makeSwapChain9(surfaceD3D->getSwapChain());
switch (type)
{
case GL_BACK:
......
......@@ -18,9 +18,6 @@
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/SwapChain.h"
// TODO: don't reference this from here, use a method on DisplayImpl to validate windows
#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h"
#include "common/debug.h"
#include "common/version.h"
......@@ -763,7 +760,7 @@ EGLBoolean __stdcall eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint
return EGL_FALSE;
}
textureObject->bindTexImage(eglSurface);
eglSurface->bindTexImage(textureObject, buffer);
}
recordError(egl::Error(EGL_SUCCESS));
......@@ -804,7 +801,7 @@ EGLBoolean __stdcall eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLi
if (texture)
{
texture->releaseTexImage();
eglSurface->releaseTexImage(buffer);
}
recordError(egl::Error(EGL_SUCCESS));
......
......@@ -127,6 +127,8 @@
'libANGLE/renderer/RenderTarget.cpp',
'libANGLE/renderer/ShaderExecutable.h',
'libANGLE/renderer/ShaderImpl.h',
'libANGLE/renderer/SurfaceImpl.cpp',
'libANGLE/renderer/SurfaceImpl.h',
'libANGLE/renderer/SwapChain.h',
'libANGLE/renderer/TextureImpl.h',
'libANGLE/renderer/TransformFeedbackImpl.h',
......@@ -182,6 +184,8 @@
'libANGLE/renderer/d3d/RendererD3D.h',
'libANGLE/renderer/d3d/ShaderD3D.cpp',
'libANGLE/renderer/d3d/ShaderD3D.h',
'libANGLE/renderer/d3d/SurfaceD3D.cpp',
'libANGLE/renderer/d3d/SurfaceD3D.h',
'libANGLE/renderer/d3d/TextureD3D.cpp',
'libANGLE/renderer/d3d/TextureD3D.h',
'libANGLE/renderer/d3d/TextureStorage.cpp',
......
//
// Copyright (c) 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.
//
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/SurfaceImpl.h"
namespace
{
class MockSurfaceImpl : public rx::SurfaceImpl
{
public:
virtual ~MockSurfaceImpl() { destroy(); }
MOCK_METHOD0(initialize, egl::Error());
MOCK_METHOD0(swap, egl::Error());
MOCK_METHOD4(postSubBuffer, egl::Error(EGLint, EGLint, EGLint, EGLint));
MOCK_METHOD2(querySurfacePointerANGLE, egl::Error(EGLint, void**));
MOCK_METHOD1(bindTexImage, egl::Error(EGLint));
MOCK_METHOD1(releaseTexImage, egl::Error(EGLint));
MOCK_METHOD1(setSwapInterval, void(EGLint));
MOCK_CONST_METHOD0(getWindowHandle, EGLNativeWindowType());
MOCK_METHOD0(destroy, void());
};
class SurfaceTest : public testing::Test
{
protected:
virtual void SetUp()
{
mImpl = new MockSurfaceImpl;
EXPECT_CALL(*mImpl, setSwapInterval(1));
EXPECT_CALL(*mImpl, destroy());
mSurface = new egl::Surface(mImpl);
}
virtual void TearDown()
{
delete mSurface;
}
MockSurfaceImpl *mImpl;
egl::Surface *mSurface;
};
TEST_F(SurfaceTest, DestructionDeletesImpl)
{
MockSurfaceImpl *impl = new MockSurfaceImpl;
EXPECT_CALL(*impl, setSwapInterval(1)).Times(1).RetiresOnSaturation();
EXPECT_CALL(*impl, destroy()).Times(1).RetiresOnSaturation();
egl::Surface *surface = new egl::Surface(impl);
delete surface;
// Only needed because the mock is leaked if bugs are present,
// which logs an error, but does not cause the test to fail.
// Ordinarily mocks are verified when destroyed.
testing::Mock::VerifyAndClear(impl);
}
} // namespace
......@@ -7,6 +7,7 @@
[
'Fence_unittest.cpp',
'ImageIndexIterator_unittest.cpp',
'Surface_unittest.cpp',
'TransformFeedback_unittest.cpp'
],
}
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