fix [2793164] Spam 2x/second with TOT master in SurfaceFlinger
Make sure to not use GL_TEXTURE_EXTERNAL when it's not supported
by the GL. The error was harmless, but annoying.
Change-Id: I571a9a9b05d35da51420950a6a6e95629067efd0
diff --git a/libs/surfaceflinger/TextureManager.cpp b/libs/surfaceflinger/TextureManager.cpp
index d9bdc6a..e4dd42f 100644
--- a/libs/surfaceflinger/TextureManager.cpp
+++ b/libs/surfaceflinger/TextureManager.cpp
@@ -30,14 +30,15 @@
#include "clz.h"
#include "DisplayHardware/DisplayHardware.h"
+#include "GLExtensions.h"
#include "TextureManager.h"
namespace android {
// ---------------------------------------------------------------------------
-TextureManager::TextureManager(uint32_t flags)
- : mFlags(flags)
+TextureManager::TextureManager()
+ : mGLExtensions(GLExtensions::getInstance())
{
}
@@ -85,9 +86,11 @@
GLenum target = GL_TEXTURE_2D;
#if defined(GL_OES_texture_external)
- if (format && isSupportedYuvFormat(format)) {
- target = GL_TEXTURE_EXTERNAL_OES;
- pImage->target = Texture::TEXTURE_EXTERNAL;
+ if (GLExtensions::getInstance().haveTextureExternal()) {
+ if (format && isSupportedYuvFormat(format)) {
+ target = GL_TEXTURE_EXTERNAL_OES;
+ pImage->target = Texture::TEXTURE_EXTERNAL;
+ }
}
#endif
@@ -208,7 +211,7 @@
/*
* round to POT if needed
*/
- if (!(mFlags & DisplayHardware::NPOT_EXTENSION)) {
+ if (!mGLExtensions.haveNpot()) {
texture->NPOTAdjust = true;
}
@@ -294,14 +297,19 @@
void TextureManager::activateTexture(const Texture& texture, bool filter)
{
const GLenum target = getTextureTarget(&texture);
-
- glBindTexture(target, texture.name);
- glEnable(target);
-
+ if (target == Texture::TEXTURE_2D) {
+ glBindTexture(GL_TEXTURE_2D, texture.name);
+ glEnable(GL_TEXTURE_2D);
#if defined(GL_OES_texture_external)
- if (texture.target == Texture::TEXTURE_2D) {
- glDisable(GL_TEXTURE_EXTERNAL_OES);
- } else {
+ if (GLExtensions::getInstance().haveTextureExternal()) {
+ glDisable(GL_TEXTURE_EXTERNAL_OES);
+ }
+#endif
+ }
+#if defined(GL_OES_texture_external)
+ else {
+ glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture.name);
+ glEnable(GL_TEXTURE_EXTERNAL_OES);
glDisable(GL_TEXTURE_2D);
}
#endif
@@ -319,7 +327,9 @@
{
glDisable(GL_TEXTURE_2D);
#if defined(GL_OES_texture_external)
- glDisable(GL_TEXTURE_EXTERNAL_OES);
+ if (GLExtensions::getInstance().haveTextureExternal()) {
+ glDisable(GL_TEXTURE_EXTERNAL_OES);
+ }
#endif
}