Commit 0bc81b6c by Geoff Lang Committed by Commit Bot

Store egl::Image size/format information at initialization time.

This avoids potential null-dereferences on the source if it is orphaned. BUG=angleproject:2668 Change-Id: I5d591a941d114bb231044572a31a8c43cf3a9c4f Reviewed-on: https://chromium-review.googlesource.com/1155104 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent a11819de
......@@ -118,7 +118,13 @@ void ImageSibling::setSourceEGLImageInitState(gl::InitState initState) const
}
ImageState::ImageState(EGLenum target, ImageSibling *buffer, const AttributeMap &attribs)
: label(nullptr), imageIndex(GetImageIndex(target, attribs)), source(buffer), targets()
: label(nullptr),
imageIndex(GetImageIndex(target, attribs)),
source(buffer),
targets(),
format(buffer->getAttachmentFormat(GL_NONE, imageIndex)),
size(buffer->getAttachmentSize(imageIndex)),
samples(buffer->getAttachmentSamples(imageIndex))
{
}
......@@ -198,24 +204,24 @@ gl::Error Image::orphanSibling(const gl::Context *context, ImageSibling *sibling
return gl::NoError();
}
gl::Format Image::getFormat() const
const gl::Format &Image::getFormat() const
{
return mState.source->getAttachmentFormat(GL_NONE, mState.imageIndex);
return mState.format;
}
size_t Image::getWidth() const
{
return mState.source->getAttachmentSize(mState.imageIndex).width;
return mState.size.width;
}
size_t Image::getHeight() const
{
return mState.source->getAttachmentSize(mState.imageIndex).height;
return mState.size.height;
}
size_t Image::getSamples() const
{
return mState.source->getAttachmentSamples(mState.imageIndex);
return mState.samples;
}
rx::ImageImpl *Image::getImplementation() const
......
......@@ -72,6 +72,10 @@ struct ImageState : private angle::NonCopyable
gl::ImageIndex imageIndex;
gl::BindingPointer<ImageSibling> source;
std::set<ImageSibling *> targets;
gl::Format format;
gl::Extents size;
size_t samples;
};
class Image final : public gl::RefCountObject, public LabeledObject
......@@ -89,7 +93,7 @@ class Image final : public gl::RefCountObject, public LabeledObject
void setLabel(EGLLabelKHR label) override;
EGLLabelKHR getLabel() const override;
gl::Format getFormat() const;
const gl::Format &getFormat() const;
size_t getWidth() const;
size_t getHeight() const;
size_t getSamples() const;
......
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