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: Yuly Novikov <ynovikov@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Image.cpp b/src/libANGLE/Image.cpp
index 24866b9..dc2467b 100644
--- a/src/libANGLE/Image.cpp
+++ b/src/libANGLE/Image.cpp
@@ -118,7 +118,13 @@
}
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 @@
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