Commit cd7cd2a8 by Geoff Lang Committed by Commit Bot

Pass Context to EGLImage creation and Display to EGLImage initialization.

BUG=angleproject:2507 Change-Id: I6c195434131709203f892be6037e974002c174c2 Reviewed-on: https://chromium-review.googlesource.com/1143453Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 0df813c3
......@@ -730,8 +730,8 @@ Error Display::createImage(const gl::Context *context,
ASSERT(sibling != nullptr);
angle::UniqueObjectPointer<Image, gl::Context> imagePtr(
new Image(mImplementation, target, sibling, attribs), context);
ANGLE_TRY(imagePtr->initialize());
new Image(mImplementation, context, target, sibling, attribs), context);
ANGLE_TRY(imagePtr->initialize(this));
Image *image = imagePtr.release();
......
......@@ -127,12 +127,13 @@ ImageState::~ImageState()
}
Image::Image(rx::EGLImplFactory *factory,
const gl::Context *context,
EGLenum target,
ImageSibling *buffer,
const AttributeMap &attribs)
: RefCountObject(0),
mState(target, buffer, attribs),
mImplementation(factory->createImage(mState, target, attribs)),
mImplementation(factory->createImage(mState, context, target, attribs)),
mOrphanedAndNeedsInit(false)
{
ASSERT(mImplementation != nullptr);
......@@ -222,9 +223,9 @@ rx::ImageImpl *Image::getImplementation() const
return mImplementation;
}
Error Image::initialize()
Error Image::initialize(const Display *display)
{
return mImplementation->initialize();
return mImplementation->initialize(display);
}
bool Image::orphaned() const
......
......@@ -28,6 +28,7 @@ class ImageImpl;
namespace egl
{
class Image;
class Display;
// Only currently Renderbuffers and Textures can be bound with images. This makes the relationship
// explicit, and also ensures that an image sibling can determine if it's been initialized or not,
......@@ -77,6 +78,7 @@ class Image final : public gl::RefCountObject, public LabeledObject
{
public:
Image(rx::EGLImplFactory *factory,
const gl::Context *context,
EGLenum target,
ImageSibling *buffer,
const AttributeMap &attribs);
......@@ -92,7 +94,7 @@ class Image final : public gl::RefCountObject, public LabeledObject
size_t getHeight() const;
size_t getSamples() const;
Error initialize();
Error initialize(const Display *display);
rx::ImageImpl *getImplementation() const;
......
......@@ -24,7 +24,7 @@ namespace angle
{
ACTION(CreateMockImageImpl)
{
return new rx::MockImageImpl(arg0, arg1, arg2);
return new rx::MockImageImpl(arg0);
}
// Verify ref counts are maintained between images and their siblings when objects are deleted
......@@ -39,12 +39,12 @@ TEST(ImageTest, RefCounting)
gl::Texture *texture = new gl::Texture(&mockGLFactory, 1, gl::TextureType::_2D);
texture->addRef();
EXPECT_CALL(mockEGLFactory, createImage(_, _, _))
EXPECT_CALL(mockEGLFactory, createImage(_, _, _, _))
.WillOnce(CreateMockImageImpl())
.RetiresOnSaturation();
egl::Image *image =
new egl::Image(&mockEGLFactory, EGL_GL_TEXTURE_2D, texture, egl::AttributeMap());
new egl::Image(&mockEGLFactory, nullptr, EGL_GL_TEXTURE_2D, texture, egl::AttributeMap());
image->addRef();
// Verify that the image added a ref to the texture and the texture has not added a ref to the
......@@ -116,12 +116,12 @@ TEST(ImageTest, RespecificationReleasesReferences)
gl::Extents(1, 1, 1), GL_RGBA, GL_UNSIGNED_BYTE, nullptr)
.isError());
EXPECT_CALL(mockEGLFactory, createImage(_, _, _))
EXPECT_CALL(mockEGLFactory, createImage(_, _, _, _))
.WillOnce(CreateMockImageImpl())
.RetiresOnSaturation();
egl::Image *image =
new egl::Image(&mockEGLFactory, EGL_GL_TEXTURE_2D, texture, egl::AttributeMap());
new egl::Image(&mockEGLFactory, nullptr, EGL_GL_TEXTURE_2D, texture, egl::AttributeMap());
image->addRef();
// Verify that the image added a ref to the texture and the texture has not added a ref to the
......
......@@ -53,6 +53,7 @@ class EGLImplFactory : angle::NonCopyable
const egl::AttributeMap &attribs) = 0;
virtual ImageImpl *createImage(const egl::ImageState &state,
const gl::Context *context,
EGLenum target,
const egl::AttributeMap &attribs) = 0;
......
......@@ -19,6 +19,7 @@ class Context;
namespace egl
{
class Display;
class ImageSibling;
struct ImageState;
} // namespace egl
......@@ -30,7 +31,7 @@ class ImageImpl : angle::NonCopyable
public:
ImageImpl(const egl::ImageState &state) : mState(state) {}
virtual ~ImageImpl() {}
virtual egl::Error initialize() = 0;
virtual egl::Error initialize(const egl::Display *display) = 0;
virtual gl::Error orphan(const gl::Context *context, egl::ImageSibling *sibling) = 0;
......
......@@ -18,14 +18,9 @@ namespace rx
class MockImageImpl : public ImageImpl
{
public:
MockImageImpl(const egl::ImageState &state,
EGLenum /*target*/,
const egl::AttributeMap & /*attribs*/)
: ImageImpl(state)
{
}
MockImageImpl(const egl::ImageState &state) : ImageImpl(state) {}
virtual ~MockImageImpl() { destructor(); }
MOCK_METHOD0(initialize, egl::Error(void));
MOCK_METHOD1(initialize, egl::Error(const egl::Display *));
MOCK_METHOD2(orphan, gl::Error(const gl::Context *, egl::ImageSibling *));
MOCK_METHOD0(destructor, void());
};
......
......@@ -189,6 +189,7 @@ SurfaceImpl *DisplayD3D::createPixmapSurface(const egl::SurfaceState &state,
}
ImageImpl *DisplayD3D::createImage(const egl::ImageState &state,
const gl::Context *context,
EGLenum target,
const egl::AttributeMap &attribs)
{
......
......@@ -39,6 +39,7 @@ class DisplayD3D : public DisplayImpl
const egl::AttributeMap &attribs) override;
ImageImpl *createImage(const egl::ImageState &state,
const gl::Context *context,
EGLenum target,
const egl::AttributeMap &attribs) override;
......
......@@ -37,7 +37,7 @@ EGLImageD3D::~EGLImageD3D()
SafeDelete(mRenderTarget);
}
egl::Error EGLImageD3D::initialize()
egl::Error EGLImageD3D::initialize(const egl::Display *display)
{
return egl::NoError();
}
......
......@@ -38,7 +38,7 @@ class EGLImageD3D final : public ImageImpl
RendererD3D *renderer);
~EGLImageD3D() override;
egl::Error initialize() override;
egl::Error initialize(const egl::Display *display) override;
gl::Error orphan(const gl::Context *context, egl::ImageSibling *sibling) override;
......
......@@ -41,6 +41,7 @@ void DisplayGL::terminate()
}
ImageImpl *DisplayGL::createImage(const egl::ImageState &state,
const gl::Context *context,
EGLenum target,
const egl::AttributeMap &attribs)
{
......
......@@ -32,6 +32,7 @@ class DisplayGL : public DisplayImpl
void terminate() override;
ImageImpl *createImage(const egl::ImageState &state,
const gl::Context *context,
EGLenum target,
const egl::AttributeMap &attribs) override;
......
......@@ -242,14 +242,6 @@ SurfaceImpl *DisplayAndroid::createPixmapSurface(const egl::SurfaceState &state,
return nullptr;
}
ImageImpl *DisplayAndroid::createImage(const egl::ImageState &state,
EGLenum target,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return DisplayGL::createImage(state, target, attribs);
}
ContextImpl *DisplayAndroid::createContext(const gl::ContextState &state,
const egl::Config *configuration,
const gl::Context *shareContext,
......
......@@ -43,10 +43,6 @@ class DisplayAndroid : public DisplayEGL
NativePixmapType nativePixmap,
const egl::AttributeMap &attribs) override;
ImageImpl *createImage(const egl::ImageState &state,
EGLenum target,
const egl::AttributeMap &attribs) override;
ContextImpl *createContext(const gl::ContextState &state,
const egl::Config *configuration,
const gl::Context *shareContext,
......
......@@ -159,6 +159,7 @@ SurfaceImpl *DisplayNULL::createPixmapSurface(const egl::SurfaceState &state,
}
ImageImpl *DisplayNULL::createImage(const egl::ImageState &state,
const gl::Context *context,
EGLenum target,
const egl::AttributeMap &attribs)
{
......
......@@ -59,6 +59,7 @@ class DisplayNULL : public DisplayImpl
const egl::AttributeMap &attribs) override;
ImageImpl *createImage(const egl::ImageState &state,
const gl::Context *context,
EGLenum target,
const egl::AttributeMap &attribs) override;
......
......@@ -22,7 +22,7 @@ ImageNULL::~ImageNULL()
{
}
egl::Error ImageNULL::initialize()
egl::Error ImageNULL::initialize(const egl::Display *display)
{
return egl::NoError();
}
......
......@@ -20,7 +20,7 @@ class ImageNULL : public ImageImpl
public:
ImageNULL(const egl::ImageState &state);
~ImageNULL() override;
egl::Error initialize() override;
egl::Error initialize(const egl::Display *display) override;
gl::Error orphan(const gl::Context *context, egl::ImageSibling *sibling) override;
};
......
......@@ -133,6 +133,7 @@ SurfaceImpl *DisplayVk::createPixmapSurface(const egl::SurfaceState &state,
}
ImageImpl *DisplayVk::createImage(const egl::ImageState &state,
const gl::Context *context,
EGLenum target,
const egl::AttributeMap &attribs)
{
......
......@@ -54,6 +54,7 @@ class DisplayVk : public DisplayImpl, public vk::Context
const egl::AttributeMap &attribs) override;
ImageImpl *createImage(const egl::ImageState &state,
const gl::Context *context,
EGLenum target,
const egl::AttributeMap &attribs) override;
......
......@@ -22,7 +22,7 @@ ImageVk::~ImageVk()
{
}
egl::Error ImageVk::initialize()
egl::Error ImageVk::initialize(const egl::Display *display)
{
UNIMPLEMENTED();
return egl::EglBadAccess();
......
......@@ -20,7 +20,7 @@ class ImageVk : public ImageImpl
public:
ImageVk(const egl::ImageState &state);
~ImageVk() override;
egl::Error initialize() override;
egl::Error initialize(const egl::Display *display) override;
gl::Error orphan(const gl::Context *context, egl::ImageSibling *sibling) override;
};
......
......@@ -119,8 +119,11 @@ class MockEGLFactory : public EGLImplFactory
SurfaceImpl *(const egl::SurfaceState &,
NativePixmapType,
const egl::AttributeMap &));
MOCK_METHOD3(createImage,
ImageImpl *(const egl::ImageState &, EGLenum, const egl::AttributeMap &));
MOCK_METHOD4(createImage,
ImageImpl *(const egl::ImageState &,
const gl::Context *,
EGLenum,
const egl::AttributeMap &));
MOCK_METHOD4(createContext,
ContextImpl *(const gl::ContextState &,
const egl::Config *,
......
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