Update texture size information on egl[Bind|Release]TexImage.
BUG=450257
Change-Id: I7609131d78f255bf9f79b42f39b02303a5c14b60
Reviewed-on: https://chromium-review.googlesource.com/243915
Reviewed-by: Nicolas Capens <capn@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/Texture.cpp b/src/libANGLE/Texture.cpp
index 63af120..b268fd8 100644
--- a/src/libANGLE/Texture.cpp
+++ b/src/libANGLE/Texture.cpp
@@ -10,6 +10,7 @@
#include "libANGLE/Data.h"
#include "libANGLE/formatutils.h"
+#include "libANGLE/Config.h"
#include "libANGLE/Surface.h"
#include "common/mathutil.h"
@@ -390,6 +391,15 @@
mImageDescs[index] = desc;
}
+void Texture::clearImageDesc(const ImageIndex &index)
+{
+ ImageDescMap::iterator iter = mImageDescs.find(index);
+ if (iter != mImageDescs.end())
+ {
+ mImageDescs.erase(iter);
+ }
+}
+
void Texture::clearImageDescs()
{
mImageDescs.clear();
@@ -397,9 +407,17 @@
void Texture::bindTexImage(egl::Surface *surface)
{
+ ASSERT(surface);
+
releaseTexImage();
mTexture->bindTexImage(surface);
mBoundSurface = surface;
+
+ // Set the image info to the size and format of the surface
+ ASSERT(mTarget == GL_TEXTURE_2D);
+ Extents size(surface->getWidth(), surface->getHeight(), 1);
+ ImageDesc desc(size, surface->getConfig()->mRenderTargetFormat);
+ setImageDesc(ImageIndex::MakeGeneric(mTarget, 0), desc);
}
void Texture::releaseTexImage()
@@ -408,6 +426,10 @@
{
mBoundSurface = NULL;
mTexture->releaseTexImage();
+
+ // Erase the image info for level 0
+ ASSERT(mTarget == GL_TEXTURE_2D);
+ clearImageDesc(ImageIndex::MakeGeneric(mTarget, 0));
}
}