Commit 7aea7e05 by Jamie Madill

Add EGLImplFactory.

Also rename ImplFactory to GLImplFactory. This will allow us to use the same factory design pattern for EGL objects, and to use State helper classes to share data with Impls. BUG=angleproject:1363 BUG=angleproject:1369 Change-Id: I07a8fe40838d5d4ca32b04910c306edeab4d25a7 Reviewed-on: https://chromium-review.googlesource.com/342051Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 43d0e609
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "common/debug.h" #include "common/debug.h"
#include "libANGLE/ContextState.h" #include "libANGLE/ContextState.h"
#include "libANGLE/renderer/CompilerImpl.h" #include "libANGLE/renderer/CompilerImpl.h"
#include "libANGLE/renderer/ImplFactory.h" #include "libANGLE/renderer/GLImplFactory.h"
namespace gl namespace gl
{ {
...@@ -25,7 +25,7 @@ size_t activeCompilerHandles = 0; ...@@ -25,7 +25,7 @@ size_t activeCompilerHandles = 0;
} // anonymous namespace } // anonymous namespace
Compiler::Compiler(rx::ImplFactory *implFactory, const ContextState &data) Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &data)
: mImplementation(implFactory->createCompiler()), : mImplementation(implFactory->createCompiler()),
mSpec(data.clientVersion > 2 ? SH_GLES3_SPEC : SH_GLES2_SPEC), mSpec(data.clientVersion > 2 ? SH_GLES3_SPEC : SH_GLES2_SPEC),
mOutputType(mImplementation->getTranslatorOutputType()), mOutputType(mImplementation->getTranslatorOutputType()),
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
namespace rx namespace rx
{ {
class CompilerImpl; class CompilerImpl;
class ImplFactory; class GLImplFactory;
} }
namespace gl namespace gl
...@@ -26,7 +26,7 @@ struct ContextState; ...@@ -26,7 +26,7 @@ struct ContextState;
class Compiler final : angle::NonCopyable class Compiler final : angle::NonCopyable
{ {
public: public:
Compiler(rx::ImplFactory *implFactory, const ContextState &data); Compiler(rx::GLImplFactory *implFactory, const ContextState &data);
~Compiler(); ~Compiler();
Error release(); Error release();
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/renderer/ContextImpl.h" #include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/FramebufferImpl.h" #include "libANGLE/renderer/FramebufferImpl.h"
#include "libANGLE/renderer/ImplFactory.h" #include "libANGLE/renderer/GLImplFactory.h"
#include "libANGLE/renderer/RenderbufferImpl.h" #include "libANGLE/renderer/RenderbufferImpl.h"
#include "libANGLE/renderer/SurfaceImpl.h" #include "libANGLE/renderer/SurfaceImpl.h"
...@@ -170,7 +170,7 @@ bool FramebufferState::attachmentsHaveSameDimensions() const ...@@ -170,7 +170,7 @@ bool FramebufferState::attachmentsHaveSameDimensions() const
return !hasMismatchedSize(mStencilAttachment); return !hasMismatchedSize(mStencilAttachment);
} }
Framebuffer::Framebuffer(const Caps &caps, rx::ImplFactory *factory, GLuint id) Framebuffer::Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id)
: mState(caps), mImpl(factory->createFramebuffer(mState)), mId(id) : mState(caps), mImpl(factory->createFramebuffer(mState)), mId(id)
{ {
ASSERT(mId != 0); ASSERT(mId != 0);
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
namespace rx namespace rx
{ {
class ContextImpl; class ContextImpl;
class ImplFactory; class GLImplFactory;
class FramebufferImpl; class FramebufferImpl;
class RenderbufferImpl; class RenderbufferImpl;
class SurfaceImpl; class SurfaceImpl;
...@@ -89,7 +89,7 @@ class FramebufferState final : angle::NonCopyable ...@@ -89,7 +89,7 @@ class FramebufferState final : angle::NonCopyable
class Framebuffer final : public LabeledObject class Framebuffer final : public LabeledObject
{ {
public: public:
Framebuffer(const Caps &caps, rx::ImplFactory *factory, GLuint id); Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id);
Framebuffer(rx::SurfaceImpl *surface); Framebuffer(rx::SurfaceImpl *surface);
virtual ~Framebuffer(); virtual ~Framebuffer();
......
...@@ -25,7 +25,7 @@ namespace angle ...@@ -25,7 +25,7 @@ namespace angle
// Verify ref counts are maintained between images and their siblings when objects are deleted // Verify ref counts are maintained between images and their siblings when objects are deleted
TEST(ImageTest, RefCounting) TEST(ImageTest, RefCounting)
{ {
NiceMock<rx::MockFactory> mockFactory; NiceMock<rx::MockGLFactory> mockFactory;
// Create a texture and an EGL image that uses the texture as its source // Create a texture and an EGL image that uses the texture as its source
rx::MockTextureImpl *textureImpl = new rx::MockTextureImpl(); rx::MockTextureImpl *textureImpl = new rx::MockTextureImpl();
EXPECT_CALL(mockFactory, createTexture(_)).WillOnce(Return(textureImpl)); EXPECT_CALL(mockFactory, createTexture(_)).WillOnce(Return(textureImpl));
...@@ -86,7 +86,7 @@ TEST(ImageTest, RefCounting) ...@@ -86,7 +86,7 @@ TEST(ImageTest, RefCounting)
// Verify that respecifiying textures releases references to the Image. // Verify that respecifiying textures releases references to the Image.
TEST(ImageTest, RespecificationReleasesReferences) TEST(ImageTest, RespecificationReleasesReferences)
{ {
NiceMock<rx::MockFactory> mockFactory; NiceMock<rx::MockGLFactory> mockFactory;
// Create a texture and an EGL image that uses the texture as its source // Create a texture and an EGL image that uses the texture as its source
rx::MockTextureImpl *textureImpl = new rx::MockTextureImpl(); rx::MockTextureImpl *textureImpl = new rx::MockTextureImpl();
EXPECT_CALL(mockFactory, createTexture(_)).WillOnce(Return(textureImpl)); EXPECT_CALL(mockFactory, createTexture(_)).WillOnce(Return(textureImpl));
......
...@@ -336,7 +336,7 @@ GLuint ProgramState::getUniformIndex(const std::string &name) const ...@@ -336,7 +336,7 @@ GLuint ProgramState::getUniformIndex(const std::string &name) const
return GL_INVALID_INDEX; return GL_INVALID_INDEX;
} }
Program::Program(rx::ImplFactory *factory, ResourceManager *manager, GLuint handle) Program::Program(rx::GLImplFactory *factory, ResourceManager *manager, GLuint handle)
: mProgram(factory->createProgram(mState)), : mProgram(factory->createProgram(mState)),
mValidated(false), mValidated(false),
mLinked(false), mLinked(false),
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
namespace rx namespace rx
{ {
class ImplFactory; class GLImplFactory;
class ProgramImpl; class ProgramImpl;
struct TranslatedAttribute; struct TranslatedAttribute;
} }
...@@ -211,7 +211,7 @@ class ProgramState final : angle::NonCopyable ...@@ -211,7 +211,7 @@ class ProgramState final : angle::NonCopyable
class Program final : angle::NonCopyable, public LabeledObject class Program final : angle::NonCopyable, public LabeledObject
{ {
public: public:
Program(rx::ImplFactory *factory, ResourceManager *manager, GLuint handle); Program(rx::GLImplFactory *factory, ResourceManager *manager, GLuint handle);
~Program(); ~Program();
GLuint id() const { return mHandle; } GLuint id() const { return mHandle; }
......
...@@ -20,9 +20,7 @@ ...@@ -20,9 +20,7 @@
namespace gl namespace gl
{ {
ResourceManager::ResourceManager(rx::ImplFactory *factory) ResourceManager::ResourceManager(rx::GLImplFactory *factory) : mFactory(factory), mRefCount(1)
: mFactory(factory),
mRefCount(1)
{ {
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
namespace rx namespace rx
{ {
class ImplFactory; class GLImplFactory;
} }
namespace gl namespace gl
...@@ -34,7 +34,7 @@ class Texture; ...@@ -34,7 +34,7 @@ class Texture;
class ResourceManager : angle::NonCopyable class ResourceManager : angle::NonCopyable
{ {
public: public:
explicit ResourceManager(rx::ImplFactory *factory); explicit ResourceManager(rx::GLImplFactory *factory);
~ResourceManager(); ~ResourceManager();
void addRef(); void addRef();
...@@ -76,7 +76,7 @@ class ResourceManager : angle::NonCopyable ...@@ -76,7 +76,7 @@ class ResourceManager : angle::NonCopyable
private: private:
void createTextureInternal(GLuint handle); void createTextureInternal(GLuint handle);
rx::ImplFactory *mFactory; rx::GLImplFactory *mFactory;
std::size_t mRefCount; std::size_t mRefCount;
ResourceMap<Buffer> mBufferMap; ResourceMap<Buffer> mBufferMap;
......
...@@ -31,7 +31,7 @@ class ResourceManagerTest : public testing::Test ...@@ -31,7 +31,7 @@ class ResourceManagerTest : public testing::Test
SafeDelete(mResourceManager); SafeDelete(mResourceManager);
} }
MockFactory mMockFactory; MockGLFactory mMockFactory;
ResourceManager *mResourceManager; ResourceManager *mResourceManager;
}; };
......
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
#include "libANGLE/Sampler.h" #include "libANGLE/Sampler.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/renderer/ImplFactory.h" #include "libANGLE/renderer/GLImplFactory.h"
#include "libANGLE/renderer/SamplerImpl.h" #include "libANGLE/renderer/SamplerImpl.h"
namespace gl namespace gl
{ {
Sampler::Sampler(rx::ImplFactory *factory, GLuint id) Sampler::Sampler(rx::GLImplFactory *factory, GLuint id)
: RefCountObject(id), mImpl(factory->createSampler()), mLabel(), mSamplerState() : RefCountObject(id), mImpl(factory->createSampler()), mLabel(), mSamplerState()
{ {
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
namespace rx namespace rx
{ {
class ImplFactory; class GLImplFactory;
class SamplerImpl; class SamplerImpl;
} }
...@@ -26,7 +26,7 @@ namespace gl ...@@ -26,7 +26,7 @@ namespace gl
class Sampler final : public RefCountObject, public LabeledObject class Sampler final : public RefCountObject, public LabeledObject
{ {
public: public:
Sampler(rx::ImplFactory *factory, GLuint id); Sampler(rx::GLImplFactory *factory, GLuint id);
~Sampler() override; ~Sampler() override;
void setLabel(const std::string &label) override; void setLabel(const std::string &label) override;
......
...@@ -81,7 +81,7 @@ ShaderState::~ShaderState() ...@@ -81,7 +81,7 @@ ShaderState::~ShaderState()
} }
Shader::Shader(ResourceManager *manager, Shader::Shader(ResourceManager *manager,
rx::ImplFactory *implFactory, rx::GLImplFactory *implFactory,
const gl::Limitations &rendererLimitations, const gl::Limitations &rendererLimitations,
GLenum type, GLenum type,
GLuint handle) GLuint handle)
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
namespace rx namespace rx
{ {
class ImplFactory; class GLImplFactory;
class ShaderImpl; class ShaderImpl;
class ShaderSh; class ShaderSh;
} }
...@@ -81,7 +81,7 @@ class Shader final : angle::NonCopyable, public LabeledObject ...@@ -81,7 +81,7 @@ class Shader final : angle::NonCopyable, public LabeledObject
{ {
public: public:
Shader(ResourceManager *manager, Shader(ResourceManager *manager,
rx::ImplFactory *implFactory, rx::GLImplFactory *implFactory,
const gl::Limitations &rendererLimitations, const gl::Limitations &rendererLimitations,
GLenum type, GLenum type,
GLuint handle); GLuint handle);
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "libANGLE/Image.h" #include "libANGLE/Image.h"
#include "libANGLE/Surface.h" #include "libANGLE/Surface.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/renderer/ImplFactory.h" #include "libANGLE/renderer/GLImplFactory.h"
#include "libANGLE/renderer/TextureImpl.h" #include "libANGLE/renderer/TextureImpl.h"
namespace gl namespace gl
...@@ -49,7 +49,7 @@ static size_t GetImageDescIndex(GLenum target, size_t level) ...@@ -49,7 +49,7 @@ static size_t GetImageDescIndex(GLenum target, size_t level)
return IsCubeMapTextureTarget(target) ? ((level * 6) + CubeMapTextureTargetToLayerIndex(target)) : level; return IsCubeMapTextureTarget(target) ? ((level * 6) + CubeMapTextureTargetToLayerIndex(target)) : level;
} }
Texture::Texture(rx::ImplFactory *factory, GLuint id, GLenum target) Texture::Texture(rx::GLImplFactory *factory, GLuint id, GLenum target)
: egl::ImageSibling(id), : egl::ImageSibling(id),
mTexture(factory->createTexture(target)), mTexture(factory->createTexture(target)),
mLabel(), mLabel(),
......
...@@ -31,7 +31,7 @@ class Stream; ...@@ -31,7 +31,7 @@ class Stream;
namespace rx namespace rx
{ {
class ImplFactory; class GLImplFactory;
class TextureImpl; class TextureImpl;
} }
...@@ -47,7 +47,7 @@ class Texture final : public egl::ImageSibling, ...@@ -47,7 +47,7 @@ class Texture final : public egl::ImageSibling,
public LabeledObject public LabeledObject
{ {
public: public:
Texture(rx::ImplFactory *factory, GLuint id, GLenum target); Texture(rx::GLImplFactory *factory, GLuint id, GLenum target);
~Texture() override; ~Texture() override;
void setLabel(const std::string &label) override; void setLabel(const std::string &label) override;
......
...@@ -10,13 +10,13 @@ ...@@ -10,13 +10,13 @@
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/ContextState.h" #include "libANGLE/ContextState.h"
#include "libANGLE/Program.h" #include "libANGLE/Program.h"
#include "libANGLE/renderer/ImplFactory.h" #include "libANGLE/renderer/GLImplFactory.h"
#include "libANGLE/renderer/TransformFeedbackImpl.h" #include "libANGLE/renderer/TransformFeedbackImpl.h"
namespace gl namespace gl
{ {
TransformFeedback::TransformFeedback(rx::ImplFactory *implFactory, GLuint id, const Caps &caps) TransformFeedback::TransformFeedback(rx::GLImplFactory *implFactory, GLuint id, const Caps &caps)
: RefCountObject(id), : RefCountObject(id),
mImplementation(implFactory->createTransformFeedback()), mImplementation(implFactory->createTransformFeedback()),
mLabel(), mLabel(),
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
namespace rx namespace rx
{ {
class ImplFactory; class GLImplFactory;
class TransformFeedbackImpl; class TransformFeedbackImpl;
} }
...@@ -29,7 +29,7 @@ class Program; ...@@ -29,7 +29,7 @@ class Program;
class TransformFeedback final : public RefCountObject, public LabeledObject class TransformFeedback final : public RefCountObject, public LabeledObject
{ {
public: public:
TransformFeedback(rx::ImplFactory *implFactory, GLuint id, const Caps &caps); TransformFeedback(rx::GLImplFactory *implFactory, GLuint id, const Caps &caps);
virtual ~TransformFeedback(); virtual ~TransformFeedback();
void setLabel(const std::string &label) override; void setLabel(const std::string &label) override;
......
...@@ -53,7 +53,7 @@ class TransformFeedbackTest : public testing::Test ...@@ -53,7 +53,7 @@ class TransformFeedbackTest : public testing::Test
testing::Mock::VerifyAndClear(mImpl); testing::Mock::VerifyAndClear(mImpl);
} }
rx::MockFactory mMockFactory; rx::MockGLFactory mMockFactory;
rx::MockTransformFeedbackImpl* mImpl; rx::MockTransformFeedbackImpl* mImpl;
gl::TransformFeedback* mFeedback; gl::TransformFeedback* mFeedback;
gl::Caps mCaps; gl::Caps mCaps;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "libANGLE/VertexArray.h" #include "libANGLE/VertexArray.h"
#include "libANGLE/Buffer.h" #include "libANGLE/Buffer.h"
#include "libANGLE/renderer/ImplFactory.h" #include "libANGLE/renderer/GLImplFactory.h"
#include "libANGLE/renderer/VertexArrayImpl.h" #include "libANGLE/renderer/VertexArrayImpl.h"
namespace gl namespace gl
...@@ -28,7 +28,7 @@ VertexArrayState::~VertexArrayState() ...@@ -28,7 +28,7 @@ VertexArrayState::~VertexArrayState()
mElementArrayBuffer.set(nullptr); mElementArrayBuffer.set(nullptr);
} }
VertexArray::VertexArray(rx::ImplFactory *factory, GLuint id, size_t maxAttribs) VertexArray::VertexArray(rx::GLImplFactory *factory, GLuint id, size_t maxAttribs)
: mId(id), mState(maxAttribs), mVertexArray(factory->createVertexArray(mState)) : mId(id), mState(maxAttribs), mVertexArray(factory->createVertexArray(mState))
{ {
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
namespace rx namespace rx
{ {
class ImplFactory; class GLImplFactory;
class VertexArrayImpl; class VertexArrayImpl;
} }
...@@ -59,7 +59,7 @@ class VertexArrayState final : public angle::NonCopyable ...@@ -59,7 +59,7 @@ class VertexArrayState final : public angle::NonCopyable
class VertexArray final : public LabeledObject class VertexArray final : public LabeledObject
{ {
public: public:
VertexArray(rx::ImplFactory *factory, GLuint id, size_t maxAttribs); VertexArray(rx::GLImplFactory *factory, GLuint id, size_t maxAttribs);
~VertexArray(); ~VertexArray();
GLuint id() const; GLuint id() const;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/Config.h" #include "libANGLE/Config.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/renderer/EGLImplFactory.h"
#include "libANGLE/renderer/Renderer.h" #include "libANGLE/renderer/Renderer.h"
#include "libANGLE/Stream.h" #include "libANGLE/Stream.h"
...@@ -41,7 +42,7 @@ struct ConfigDesc; ...@@ -41,7 +42,7 @@ struct ConfigDesc;
class DeviceImpl; class DeviceImpl;
class StreamProducerImpl; class StreamProducerImpl;
class DisplayImpl : angle::NonCopyable class DisplayImpl : public EGLImplFactory
{ {
public: public:
DisplayImpl(); DisplayImpl();
...@@ -50,30 +51,6 @@ class DisplayImpl : angle::NonCopyable ...@@ -50,30 +51,6 @@ class DisplayImpl : angle::NonCopyable
virtual egl::Error initialize(egl::Display *display) = 0; virtual egl::Error initialize(egl::Display *display) = 0;
virtual void terminate() = 0; virtual void terminate() = 0;
virtual SurfaceImpl *createWindowSurface(const egl::Config *configuration,
EGLNativeWindowType window,
const egl::AttributeMap &attribs) = 0;
virtual SurfaceImpl *createPbufferSurface(const egl::Config *configuration,
const egl::AttributeMap &attribs) = 0;
virtual SurfaceImpl *createPbufferFromClientBuffer(const egl::Config *configuration,
EGLClientBuffer shareHandle,
const egl::AttributeMap &attribs) = 0;
virtual SurfaceImpl *createPixmapSurface(const egl::Config *configuration,
NativePixmapType nativePixmap,
const egl::AttributeMap &attribs) = 0;
virtual ImageImpl *createImage(EGLenum target,
egl::ImageSibling *buffer,
const egl::AttributeMap &attribs) = 0;
virtual gl::Context *createContext(const egl::Config *config,
const gl::Context *shareContext,
const egl::AttributeMap &attribs) = 0;
virtual StreamProducerImpl *createStreamProducerD3DTextureNV12(
egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) = 0;
virtual egl::Error makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) = 0; virtual egl::Error makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) = 0;
virtual egl::ConfigSet generateConfigs() const = 0; virtual egl::ConfigSet generateConfigs() const = 0;
......
//
// Copyright 2016 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.
//
// EGLImplFactory.h:
// Factory interface for EGL Impl objects.
//
#ifndef LIBANGLE_RENDERER_EGLIMPLFACTORY_H_
#define LIBANGLE_RENDERER_EGLIMPLFACTORY_H_
#include "libANGLE/Stream.h"
namespace egl
{
class AttributeMap;
struct Config;
class ImageSibling;
}
namespace gl
{
class Context;
}
namespace rx
{
class ImageImpl;
class SurfaceImpl;
class EGLImplFactory : angle::NonCopyable
{
public:
EGLImplFactory() {}
virtual ~EGLImplFactory() {}
virtual SurfaceImpl *createWindowSurface(const egl::Config *configuration,
EGLNativeWindowType window,
const egl::AttributeMap &attribs) = 0;
virtual SurfaceImpl *createPbufferSurface(const egl::Config *configuration,
const egl::AttributeMap &attribs) = 0;
virtual SurfaceImpl *createPbufferFromClientBuffer(const egl::Config *configuration,
EGLClientBuffer shareHandle,
const egl::AttributeMap &attribs) = 0;
virtual SurfaceImpl *createPixmapSurface(const egl::Config *configuration,
NativePixmapType nativePixmap,
const egl::AttributeMap &attribs) = 0;
virtual ImageImpl *createImage(EGLenum target,
egl::ImageSibling *buffer,
const egl::AttributeMap &attribs) = 0;
virtual gl::Context *createContext(const egl::Config *config,
const gl::Context *shareContext,
const egl::AttributeMap &attribs) = 0;
virtual StreamProducerImpl *createStreamProducerD3DTextureNV12(
egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) = 0;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_EGLIMPLFACTORY_H_
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// ImplFactory.h: // GLImplFactory.h:
// Factory interface for Impl objects. // Factory interface for OpenGL ES Impl objects.
// //
#ifndef LIBANGLE_RENDERER_IMPLFACTORY_H_ #ifndef LIBANGLE_RENDERER_GLIMPLFACTORY_H_
#define LIBANGLE_RENDERER_IMPLFACTORY_H_ #define LIBANGLE_RENDERER_GLIMPLFACTORY_H_
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/Program.h" #include "libANGLE/Program.h"
...@@ -37,11 +37,11 @@ class TextureImpl; ...@@ -37,11 +37,11 @@ class TextureImpl;
class TransformFeedbackImpl; class TransformFeedbackImpl;
class VertexArrayImpl; class VertexArrayImpl;
class ImplFactory : angle::NonCopyable class GLImplFactory : angle::NonCopyable
{ {
public: public:
ImplFactory() {} GLImplFactory() {}
virtual ~ImplFactory() {} virtual ~GLImplFactory() {}
// Context creation // Context creation
virtual ContextImpl *createContext(const gl::ContextState &state) = 0; virtual ContextImpl *createContext(const gl::ContextState &state) = 0;
...@@ -78,6 +78,6 @@ class ImplFactory : angle::NonCopyable ...@@ -78,6 +78,6 @@ class ImplFactory : angle::NonCopyable
virtual SamplerImpl *createSampler() = 0; virtual SamplerImpl *createSampler() = 0;
}; };
} } // namespace rx
#endif // LIBANGLE_RENDERER_IMPLFACTORY_H_ #endif // LIBANGLE_RENDERER_GLIMPLFACTORY_H_
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "libANGLE/State.h" #include "libANGLE/State.h"
#include "libANGLE/Uniform.h" #include "libANGLE/Uniform.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/renderer/ImplFactory.h" #include "libANGLE/renderer/GLImplFactory.h"
#include "common/mathutil.h" #include "common/mathutil.h"
#include <stdint.h> #include <stdint.h>
...@@ -37,7 +37,7 @@ struct SourceIndexData; ...@@ -37,7 +37,7 @@ struct SourceIndexData;
struct WorkaroundsD3D; struct WorkaroundsD3D;
class DisplayImpl; class DisplayImpl;
class Renderer : public ImplFactory class Renderer : public GLImplFactory
{ {
public: public:
Renderer(); Renderer();
......
...@@ -69,7 +69,7 @@ TEST(ValidationESTest, DrawElementsWithMaxIndexGivesError) ...@@ -69,7 +69,7 @@ TEST(ValidationESTest, DrawElementsWithMaxIndexGivesError)
auto programImpl = MakeProgramMock(); auto programImpl = MakeProgramMock();
// TODO(jmadill): Generalize some of this code so we can re-use it for other tests. // TODO(jmadill): Generalize some of this code so we can re-use it for other tests.
NiceMock<MockFactory> mockFactory; NiceMock<MockGLFactory> mockFactory;
EXPECT_CALL(mockFactory, createFramebuffer(_)).WillOnce(Return(framebufferImpl)); EXPECT_CALL(mockFactory, createFramebuffer(_)).WillOnce(Return(framebufferImpl));
EXPECT_CALL(mockFactory, createProgram(_)).WillOnce(Return(programImpl)); EXPECT_CALL(mockFactory, createProgram(_)).WillOnce(Return(programImpl));
EXPECT_CALL(mockFactory, createVertexArray(_)).WillOnce(Return(nullptr)); EXPECT_CALL(mockFactory, createVertexArray(_)).WillOnce(Return(nullptr));
......
...@@ -142,11 +142,12 @@ ...@@ -142,11 +142,12 @@
'libANGLE/renderer/DeviceImpl.h', 'libANGLE/renderer/DeviceImpl.h',
'libANGLE/renderer/DisplayImpl.cpp', 'libANGLE/renderer/DisplayImpl.cpp',
'libANGLE/renderer/DisplayImpl.h', 'libANGLE/renderer/DisplayImpl.h',
'libANGLE/renderer/EGLImplFactory.h',
'libANGLE/renderer/FenceNVImpl.h', 'libANGLE/renderer/FenceNVImpl.h',
'libANGLE/renderer/FenceSyncImpl.h', 'libANGLE/renderer/FenceSyncImpl.h',
'libANGLE/renderer/FramebufferImpl.h', 'libANGLE/renderer/FramebufferImpl.h',
'libANGLE/renderer/GLImplFactory.h',
'libANGLE/renderer/ImageImpl.h', 'libANGLE/renderer/ImageImpl.h',
'libANGLE/renderer/ImplFactory.h',
'libANGLE/renderer/ProgramImpl.h', 'libANGLE/renderer/ProgramImpl.h',
'libANGLE/renderer/QueryImpl.h', 'libANGLE/renderer/QueryImpl.h',
'libANGLE/renderer/RenderbufferImpl.h', 'libANGLE/renderer/RenderbufferImpl.h',
......
...@@ -10,13 +10,14 @@ ...@@ -10,13 +10,14 @@
#define TESTS_ANGLE_UNITTESTS_UTILS_H_ #define TESTS_ANGLE_UNITTESTS_UTILS_H_
#include "libANGLE/renderer/ContextImpl.h" #include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/ImplFactory.h" #include "libANGLE/renderer/EGLImplFactory.h"
#include "libANGLE/renderer/GLImplFactory.h"
namespace rx namespace rx
{ {
// Useful when mocking a part of the ImplFactory class // Useful when mocking a part of the GLImplFactory class
class NullFactory : public ImplFactory class NullFactory : public GLImplFactory
{ {
public: public:
NullFactory() {} NullFactory() {}
...@@ -60,7 +61,7 @@ class NullFactory : public ImplFactory ...@@ -60,7 +61,7 @@ class NullFactory : public ImplFactory
}; };
// A class with all the factory methods mocked. // A class with all the factory methods mocked.
class MockFactory : public ImplFactory class MockGLFactory : public GLImplFactory
{ {
public: public:
MOCK_METHOD1(createContext, ContextImpl *(const gl::ContextState &)); MOCK_METHOD1(createContext, ContextImpl *(const gl::ContextState &));
...@@ -78,6 +79,29 @@ class MockFactory : public ImplFactory ...@@ -78,6 +79,29 @@ class MockFactory : public ImplFactory
MOCK_METHOD0(createTransformFeedback, TransformFeedbackImpl *()); MOCK_METHOD0(createTransformFeedback, TransformFeedbackImpl *());
MOCK_METHOD0(createSampler, SamplerImpl *()); MOCK_METHOD0(createSampler, SamplerImpl *());
}; };
}
class MockEGLFactory : public EGLImplFactory
{
public:
MOCK_METHOD3(createWindowSurface,
SurfaceImpl *(const egl::Config *,
EGLNativeWindowType,
const egl::AttributeMap &));
MOCK_METHOD2(createPbufferSurface,
SurfaceImpl *(const egl::Config *, const egl::AttributeMap &));
MOCK_METHOD3(createPbufferFromClientBuffer,
SurfaceImpl *(const egl::Config *, EGLClientBuffer, const egl::AttributeMap &));
MOCK_METHOD3(createPixmapSurface,
SurfaceImpl *(const egl::Config *, NativePixmapType, const egl::AttributeMap &));
MOCK_METHOD3(createImage, ImageImpl *(EGLenum, egl::ImageSibling *, const egl::AttributeMap &));
MOCK_METHOD3(createContext,
gl::Context *(const egl::Config *,
const gl::Context *,
const egl::AttributeMap &));
MOCK_METHOD2(createStreamProducerD3DTextureNV12,
StreamProducerImpl *(egl::Stream::ConsumerType, const egl::AttributeMap &));
};
} // namespace rx
#endif // TESTS_ANGLE_UNITTESTS_UTILS_H_ #endif // TESTS_ANGLE_UNITTESTS_UTILS_H_
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