Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e315b16e authored by David Li's avatar David Li Committed by Android (Google) Code Review
Browse files

Merge "GLES2Dbg: use libLZF for compressing images"

parents 2b010279 c6158166
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -13,7 +13,7 @@ LOCAL_SRC_FILES:= \
	EGL/hooks.cpp 	       \
	EGL/hooks.cpp 	       \
	EGL/Loader.cpp 	       \
	EGL/Loader.cpp 	       \
#
#
LOCAL_STATIC_LIBRARIES += libGLESv2_dbg libprotobuf-cpp-2.3.0-lite
LOCAL_STATIC_LIBRARIES += libGLESv2_dbg libprotobuf-cpp-2.3.0-lite liblzf
LOCAL_SHARED_LIBRARIES += libcutils libutils libstlport
LOCAL_SHARED_LIBRARIES += libcutils libutils libstlport
LOCAL_LDLIBS := -lpthread -ldl
LOCAL_LDLIBS := -lpthread -ldl
LOCAL_MODULE:= libEGL
LOCAL_MODULE:= libEGL
+1 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@ LOCAL_C_INCLUDES := \
    $(LOCAL_PATH)/../ \
    $(LOCAL_PATH)/../ \
    external/stlport/stlport \
    external/stlport/stlport \
    external/protobuf/src \
    external/protobuf/src \
    external \
    bionic
    bionic


#LOCAL_CFLAGS += -O0 -g -DDEBUG -UNDEBUG
#LOCAL_CFLAGS += -O0 -g -DDEBUG -UNDEBUG
+3 −1
Original line number Original line Diff line number Diff line
@@ -17,7 +17,9 @@
#define EXTEND_Debug_glCopyTexImage2D \
#define EXTEND_Debug_glCopyTexImage2D \
    void * pixels = malloc(width * height * 4); \
    void * pixels = malloc(width * height * 4); \
    getGLTraceThreadSpecific()->gl.glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); \
    getGLTraceThreadSpecific()->gl.glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); \
    msg.set_data(pixels, width * height * 4); \
    DbgContext * const dbg = getDbgContextThreadSpecific(); \
    const unsigned compressed = dbg->Compress(pixels, width * height * 4); \
    msg.set_data(dbg->lzf_buf, compressed); \
    free(pixels);
    free(pixels);
    
    
#define EXTEND_Debug_glCopyTexSubImage2D EXTEND_Debug_glCopyTexImage2D
#define EXTEND_Debug_glCopyTexSubImage2D EXTEND_Debug_glCopyTexImage2D
+23 −4
Original line number Original line Diff line number Diff line
@@ -16,12 +16,17 @@


#include "header.h"
#include "header.h"


extern "C" {
#include "liblzf/lzf.h"
}

namespace android
namespace android
{
{


DbgContext::DbgContext(const unsigned version, const gl_hooks_t * const hooks,
DbgContext::DbgContext(const unsigned version, const gl_hooks_t * const hooks,
                       const unsigned MAX_VERTEX_ATTRIBS)
                       const unsigned MAX_VERTEX_ATTRIBS)
        : version(version), hooks(hooks)
        : lzf_buf(NULL), lzf_bufSize(0)
        , version(version), hooks(hooks)
        , MAX_VERTEX_ATTRIBS(MAX_VERTEX_ATTRIBS)
        , MAX_VERTEX_ATTRIBS(MAX_VERTEX_ATTRIBS)
        , vertexAttribs(new VertexAttrib[MAX_VERTEX_ATTRIBS])
        , vertexAttribs(new VertexAttrib[MAX_VERTEX_ATTRIBS])
        , hasNonVBOAttribs(false), indexBuffers(NULL), indexBuffer(NULL)
        , hasNonVBOAttribs(false), indexBuffers(NULL), indexBuffer(NULL)
@@ -33,6 +38,7 @@ DbgContext::DbgContext(const unsigned version, const gl_hooks_t * const hooks,
DbgContext::~DbgContext()
DbgContext::~DbgContext()
{
{
    delete vertexAttribs;
    delete vertexAttribs;
    free(lzf_buf);
}
}


DbgContext * CreateDbgContext(const unsigned version, const gl_hooks_t * const hooks)
DbgContext * CreateDbgContext(const unsigned version, const gl_hooks_t * const hooks)
@@ -63,6 +69,19 @@ void DbgContext::Fetch(const unsigned index, std::string * const data) const
    }
    }
}
}


unsigned DbgContext::Compress(const void * in_data, unsigned in_len)
{
    if (lzf_bufSize < in_len + 256) {
        lzf_bufSize = in_len + 256;
        lzf_buf = (char *)realloc(lzf_buf, lzf_bufSize);
    }
    unsigned compressedSize = lzf_compress((const char *)in_data,
                              in_len, lzf_buf, lzf_bufSize);
    LOGD("DbgContext::lzf_compress in=%u out=%u", in_len, compressedSize);
    assert (0 < compressedSize);
    return compressedSize;
}

void DbgContext::glUseProgram(GLuint program)
void DbgContext::glUseProgram(GLuint program)
{
{
    while (GLenum error = hooks->gl.glGetError())
    while (GLenum error = hooks->gl.glGetError())
+8 −1
Original line number Original line Diff line number Diff line
@@ -57,6 +57,12 @@ namespace android
{
{


struct DbgContext {
struct DbgContext {
private:
    unsigned lzf_bufSize;
    
public:
    char * lzf_buf;
    
    const unsigned version; // 0 is GLES1, 1 is GLES2
    const unsigned version; // 0 is GLES1, 1 is GLES2
    const gl_hooks_t * const hooks;
    const gl_hooks_t * const hooks;
    const unsigned MAX_VERTEX_ATTRIBS;
    const unsigned MAX_VERTEX_ATTRIBS;
@@ -93,6 +99,7 @@ struct DbgContext {
    ~DbgContext();
    ~DbgContext();


    void Fetch(const unsigned index, std::string * const data) const;
    void Fetch(const unsigned index, std::string * const data) const;
    unsigned Compress(const void * in_data, unsigned in_len); // compressed to lzf_buf
    
    
    void glUseProgram(GLuint program);
    void glUseProgram(GLuint program);
    void glEnableVertexAttribArray(GLuint index);
    void glEnableVertexAttribArray(GLuint index);
Loading