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/Surface.cpp b/src/libANGLE/Surface.cpp
index e0a64f8..2a7e6f4 100644
--- a/src/libANGLE/Surface.cpp
+++ b/src/libANGLE/Surface.cpp
@@ -83,6 +83,11 @@
return mImplementation->getConfig()->mConfigID;
}
+const Config *Surface::getConfig() const
+{
+ return mImplementation->getConfig();
+}
+
EGLint Surface::getPixelAspectRatio() const
{
return mPixelAspectRatio;
diff --git a/src/libANGLE/Surface.h b/src/libANGLE/Surface.h
index a49343b..ce2292c 100644
--- a/src/libANGLE/Surface.h
+++ b/src/libANGLE/Surface.h
@@ -53,6 +53,7 @@
void setSwapInterval(EGLint interval);
EGLint getConfigID() const;
+ const Config *getConfig() const;
// width and height can change with client window resizing
EGLint getWidth() const;
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));
}
}
diff --git a/src/libANGLE/Texture.h b/src/libANGLE/Texture.h
index 4ad1f26..8ed441d 100644
--- a/src/libANGLE/Texture.h
+++ b/src/libANGLE/Texture.h
@@ -127,6 +127,7 @@
const ImageDesc &getImageDesc(const ImageIndex &index) const;
void setImageDesc(const ImageIndex &index, const ImageDesc &desc);
void setImageDescChain(size_t levels, Extents baseSize, GLenum sizedInternalFormat);
+ void clearImageDesc(const ImageIndex &index);
void clearImageDescs();
typedef std::map<ImageIndex, ImageDesc> ImageDescMap;