implement [2396050] Add ETC1 texture support to AGL
This commit is contained in:
parent
b787383ba5
commit
18b915a102
|
@ -36,7 +36,12 @@ struct android_native_buffer_t;
|
|||
|
||||
namespace android {
|
||||
|
||||
const unsigned int OGLES_NUM_COMPRESSED_TEXTURE_FORMATS = 10;
|
||||
|
||||
const unsigned int OGLES_NUM_COMPRESSED_TEXTURE_FORMATS = 10
|
||||
#ifdef GL_OES_compressed_ETC1_RGB8_texture
|
||||
+ 1
|
||||
#endif
|
||||
;
|
||||
|
||||
class EGLTextureObject;
|
||||
class EGLSurfaceManager;
|
||||
|
|
|
@ -29,7 +29,7 @@ LOCAL_CFLAGS += -DLOG_TAG=\"libagl\"
|
|||
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
|
||||
LOCAL_CFLAGS += -fvisibility=hidden
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := libcutils libhardware libutils libpixelflinger
|
||||
LOCAL_SHARED_LIBRARIES := libcutils libhardware libutils libpixelflinger libETC1
|
||||
LOCAL_LDLIBS := -lpthread -ldl
|
||||
|
||||
ifeq ($(TARGET_ARCH),arm)
|
||||
|
|
|
@ -51,6 +51,9 @@ static char const * const gExtensionsString =
|
|||
// "GL_OES_point_size_array " // TODO
|
||||
// "GL_OES_point_sprite " // TODO
|
||||
"GL_OES_EGL_image " // OK
|
||||
#ifdef GL_OES_compressed_ETC1_RGB8_texture
|
||||
"GL_OES_compressed_ETC1_RGB8_texture " // OK
|
||||
#endif
|
||||
"GL_ARB_texture_compression " // OK
|
||||
"GL_ARB_texture_non_power_of_two " // OK
|
||||
"GL_ANDROID_user_clip_plane " // OK
|
||||
|
@ -386,6 +389,7 @@ const GLubyte* glGetString(GLenum string)
|
|||
|
||||
void glGetIntegerv(GLenum pname, GLint *params)
|
||||
{
|
||||
int i;
|
||||
ogles_context_t* c = ogles_context_t::get();
|
||||
switch (pname) {
|
||||
case GL_ALIASED_POINT_SIZE_RANGE:
|
||||
|
@ -431,6 +435,10 @@ void glGetIntegerv(GLenum pname, GLint *params)
|
|||
params[ 7] = GL_PALETTE8_R5_G6_B5_OES;
|
||||
params[ 8] = GL_PALETTE8_RGBA4_OES;
|
||||
params[ 9] = GL_PALETTE8_RGB5_A1_OES;
|
||||
i = 10;
|
||||
#ifdef GL_OES_compressed_ETC1_RGB8_texture
|
||||
params[i++] = GL_ETC1_RGB8_OES;
|
||||
#endif
|
||||
break;
|
||||
case GL_DEPTH_BITS:
|
||||
params[0] = c->rasterizer.state.buffers.depth.format ? 0 : 16;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "TextureObjectManager.h"
|
||||
|
||||
#include <private/ui/android_natives_priv.h>
|
||||
#include <ETC1/etc1.h>
|
||||
|
||||
#ifdef LIBAGL_USE_GRALLOC_COPYBITS
|
||||
#include "copybit.h"
|
||||
|
@ -1081,11 +1082,6 @@ void glCompressedTexImage2D(
|
|||
ogles_error(c, GL_INVALID_ENUM);
|
||||
return;
|
||||
}
|
||||
if ((internalformat < GL_PALETTE4_RGB8_OES ||
|
||||
internalformat > GL_PALETTE8_RGB5_A1_OES)) {
|
||||
ogles_error(c, GL_INVALID_ENUM);
|
||||
return;
|
||||
}
|
||||
if (width<0 || height<0 || border!=0) {
|
||||
ogles_error(c, GL_INVALID_VALUE);
|
||||
return;
|
||||
|
@ -1121,6 +1117,12 @@ void glCompressedTexImage2D(
|
|||
format = GL_RGBA;
|
||||
type = GL_UNSIGNED_SHORT_5_5_5_1;
|
||||
break;
|
||||
#ifdef GL_OES_compressed_ETC1_RGB8_texture
|
||||
case GL_ETC1_RGB8_OES:
|
||||
format = GL_RGB;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ogles_error(c, GL_INVALID_ENUM);
|
||||
return;
|
||||
|
@ -1133,6 +1135,30 @@ void glCompressedTexImage2D(
|
|||
|
||||
int32_t size;
|
||||
GGLSurface* surface;
|
||||
|
||||
#ifdef GL_OES_compressed_ETC1_RGB8_texture
|
||||
if (internalformat == GL_ETC1_RGB8_OES) {
|
||||
GLsizei compressedSize = etc1_get_encoded_data_size(width, height);
|
||||
if (compressedSize > imageSize) {
|
||||
ogles_error(c, GL_INVALID_VALUE);
|
||||
return;
|
||||
}
|
||||
int error = createTextureSurface(c, &surface, &size,
|
||||
level, format, type, width, height);
|
||||
if (error) {
|
||||
ogles_error(c, error);
|
||||
return;
|
||||
}
|
||||
if (etc1_decode_image(
|
||||
(const etc1_byte*)data,
|
||||
(etc1_byte*)surface->data,
|
||||
width, height, 3, surface->stride) != 0) {
|
||||
ogles_error(c, GL_INVALID_OPERATION);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// all mipmap levels are specified at once.
|
||||
const int numLevels = level<0 ? -level : 1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue