From 905a1a9fb1913bc9fecf18eb285e680ebb2347ce Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Wed, 9 Nov 2016 09:42:57 +0100 Subject: [PATCH] Do not support translation/rotation for textures we render --- .../host/libs/libOpenglRender/ColorBuffer.cpp | 4 ++-- .../host/libs/libOpenglRender/TextureDraw.cpp | 24 ++++--------------- .../host/libs/libOpenglRender/TextureDraw.h | 7 ++---- 3 files changed, 8 insertions(+), 27 deletions(-) diff --git a/external/android-emugl/host/libs/libOpenglRender/ColorBuffer.cpp b/external/android-emugl/host/libs/libOpenglRender/ColorBuffer.cpp index 95de4dd..6ca08d0 100644 --- a/external/android-emugl/host/libs/libOpenglRender/ColorBuffer.cpp +++ b/external/android-emugl/host/libs/libOpenglRender/ColorBuffer.cpp @@ -335,7 +335,7 @@ bool ColorBuffer::blitFromCurrentReadBuffer() s_gles2.glViewport(0, 0, m_width, m_height); // render m_blitTex - m_helper->getTextureDraw()->draw(m_blitTex, 0., 0, 0); + m_helper->getTextureDraw()->draw(m_blitTex); // Restore previous viewport. s_gles2.glViewport(vport[0], vport[1], vport[2], vport[3]); @@ -380,7 +380,7 @@ bool ColorBuffer::bindToRenderbuffer() { bool ColorBuffer::post(float rotation, float dx, float dy) { // NOTE: Do not call m_helper->setupContext() here! - return m_helper->getTextureDraw()->draw(m_resizer->update(m_tex), rotation, dx, dy); + return m_helper->getTextureDraw()->draw(m_resizer->update(m_tex)); } void ColorBuffer::readback(unsigned char* img) { diff --git a/external/android-emugl/host/libs/libOpenglRender/TextureDraw.cpp b/external/android-emugl/host/libs/libOpenglRender/TextureDraw.cpp index 9e2a16a..f725ac6 100644 --- a/external/android-emugl/host/libs/libOpenglRender/TextureDraw.cpp +++ b/external/android-emugl/host/libs/libOpenglRender/TextureDraw.cpp @@ -57,20 +57,14 @@ GLuint createShader(GLint shaderType, const char* shaderText) { } // No scaling / projection since we want to fill the whole viewport with -// the texture, hence a trivial vertex shader that only supports clockwise -// rotation. +// the texture, hence a trivial vertex shader. const char kVertexShaderSource[] = "attribute vec4 position;\n" "attribute vec2 inCoord;\n" "varying lowp vec2 outCoord;\n" - "uniform float rotation;\n" - "uniform vec2 translation;\n" - "void main(void) {\n" - " float cs = cos(rotation);\n" - " float sn = sin(rotation);\n" - " gl_Position.x = position.x * cs + position.y * sn - translation.x;\n" - " gl_Position.y = position.y * cs - position.x * sn - translation.y;\n" + " gl_Position.x = position.x;\n" + " gl_Position.y = position.y;\n" " gl_Position.zw = position.zw;\n" " outCoord = inCoord;\n" "}\n"; @@ -142,15 +136,8 @@ TextureDraw::TextureDraw(EGLDisplay display) : mInCoordSlot = s_gles2.glGetAttribLocation(mProgram, "inCoord"); s_gles2.glEnableVertexAttribArray(mInCoordSlot); - mRotationSlot = s_gles2.glGetUniformLocation(mProgram, "rotation"); - mTranslationSlot = s_gles2.glGetUniformLocation(mProgram, "translation"); mTextureSlot = s_gles2.glGetUniformLocation(mProgram, "texture"); -#if 0 - printf("SLOTS position=%d inCoord=%d texture=%d rotation=%d\n", - mPositionSlot, mInCoordSlot, mTextureSlot, mRotationSlot); -#endif - // Create vertex and index buffers. s_gles2.glGenBuffers(1, &mVertexBuffer); s_gles2.glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer); @@ -165,7 +152,7 @@ TextureDraw::TextureDraw(EGLDisplay display) : GL_STATIC_DRAW); } -bool TextureDraw::draw(GLuint texture, float rotation, float dx, float dy) { +bool TextureDraw::draw(GLuint texture) { if (!mProgram) { ERR("%s: no program\n", __FUNCTION__); return false; @@ -220,9 +207,6 @@ bool TextureDraw::draw(GLuint texture, float rotation, float dx, float dy) { s_gles2.glBindTexture(GL_TEXTURE_2D, texture); s_gles2.glUniform1i(mTextureSlot, 0); - // setup the |rotation| uniform value. - s_gles2.glUniform1f(mRotationSlot, rotation * M_PI / 180.); - s_gles2.glUniform2f(mTranslationSlot, dx, dy); #if 1 // Validate program, just to be sure. diff --git a/external/android-emugl/host/libs/libOpenglRender/TextureDraw.h b/external/android-emugl/host/libs/libOpenglRender/TextureDraw.h index ee9371f..b8cc7c3 100644 --- a/external/android-emugl/host/libs/libOpenglRender/TextureDraw.h +++ b/external/android-emugl/host/libs/libOpenglRender/TextureDraw.h @@ -38,11 +38,8 @@ public: ~TextureDraw(); // Fill the current framebuffer with the content of |texture|, which must - // be the name of a GLES 2.x texture object. |rotationDegrees| is a - // clockwise rotation angle in degrees (clockwise in the GL Y-upwards - // coordinate space). |dx,dy| is the translation of the image towards the - // origin. - bool draw(GLuint texture, float rotationDegrees, float dx, float dy); + // be the name of a GLES 2.x texture object. + bool draw(GLuint texture); private: EGLDisplay mDisplay;