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