diff options
Diffstat (limited to 'jni/feature_mos')
-rw-r--r--[-rwxr-xr-x] | jni/feature_mos/src/mosaic_renderer/Renderer.cpp | 10 | ||||
-rw-r--r--[-rwxr-xr-x] | jni/feature_mos/src/mosaic_renderer/Renderer.h | 4 | ||||
-rw-r--r--[-rwxr-xr-x] | jni/feature_mos/src/mosaic_renderer/SurfaceTextureRenderer.cpp | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | jni/feature_mos/src/mosaic_renderer/WarpRenderer.cpp | 52 | ||||
-rwxr-xr-x | jni/feature_mos/src/mosaic_renderer/WarpRenderer.h | 4 | ||||
-rw-r--r--[-rwxr-xr-x] | jni/feature_mos/src/mosaic_renderer/YVURenderer.cpp | 2 |
6 files changed, 64 insertions, 10 deletions
diff --git a/jni/feature_mos/src/mosaic_renderer/Renderer.cpp b/jni/feature_mos/src/mosaic_renderer/Renderer.cpp index b9938eb6b..8d0632402 100755..100644 --- a/jni/feature_mos/src/mosaic_renderer/Renderer.cpp +++ b/jni/feature_mos/src/mosaic_renderer/Renderer.cpp @@ -111,8 +111,8 @@ GLuint Renderer::createProgram(const char* pVertexSource, const char* pFragmentS } // Set this renderer to use the default frame-buffer (screen) and -// set the viewport size to be the given width and height (pixels). -bool Renderer::SetupGraphics(int width, int height) +// set the viewport size to be the given x, y, width and height (pixels). +bool Renderer::SetupGraphics(int x, int y, int width, int height) { bool succeeded = false; do { @@ -131,8 +131,10 @@ bool Renderer::SetupGraphics(int width, int height) mFrameBuffer = NULL; mSurfaceWidth = width; mSurfaceHeight = height; + mSurfaceXOffset = x; + mSurfaceYOffset = y; - glViewport(0, 0, mSurfaceWidth, mSurfaceHeight); + glViewport(mSurfaceXOffset, mSurfaceYOffset, mSurfaceWidth, mSurfaceHeight); if (!checkGlError("glViewport")) break; succeeded = true; } while (false); @@ -176,7 +178,7 @@ bool Renderer::Clear(float r, float g, float b, float a) bool succeeded = false; do { bool rt = (mFrameBuffer == NULL)? - SetupGraphics(mSurfaceWidth, mSurfaceHeight) : + SetupGraphics(mSurfaceXOffset, mSurfaceYOffset, mSurfaceWidth, mSurfaceHeight) : SetupGraphics(mFrameBuffer); if(!rt) diff --git a/jni/feature_mos/src/mosaic_renderer/Renderer.h b/jni/feature_mos/src/mosaic_renderer/Renderer.h index a43e8028e..ffb9cbd25 100755..100644 --- a/jni/feature_mos/src/mosaic_renderer/Renderer.h +++ b/jni/feature_mos/src/mosaic_renderer/Renderer.h @@ -18,7 +18,7 @@ class Renderer { virtual bool InitializeGLProgram() = 0; bool SetupGraphics(FrameBuffer* buffer); - bool SetupGraphics(int width, int height); + bool SetupGraphics(int x, int y, int width, int height); bool Clear(float r, float g, float b, float a); @@ -59,6 +59,8 @@ class Renderer { int mSurfaceWidth; // Width of target surface. int mSurfaceHeight; // Height of target surface. + int mSurfaceXOffset; // X Offset target surface. + int mSurfaceYOffset; // Y Offset of target surface. FrameBuffer *mFrameBuffer; }; diff --git a/jni/feature_mos/src/mosaic_renderer/SurfaceTextureRenderer.cpp b/jni/feature_mos/src/mosaic_renderer/SurfaceTextureRenderer.cpp index 88aac3626..4725463f2 100755..100644 --- a/jni/feature_mos/src/mosaic_renderer/SurfaceTextureRenderer.cpp +++ b/jni/feature_mos/src/mosaic_renderer/SurfaceTextureRenderer.cpp @@ -119,7 +119,7 @@ bool SurfaceTextureRenderer::DrawTexture(GLfloat *affine) bool succeeded = false; do { bool rt = (mFrameBuffer == NULL)? - SetupGraphics(mSurfaceWidth, mSurfaceHeight) : + SetupGraphics(mSurfaceXOffset, mSurfaceYOffset, mSurfaceWidth, mSurfaceHeight) : SetupGraphics(mFrameBuffer); if(!rt) diff --git a/jni/feature_mos/src/mosaic_renderer/WarpRenderer.cpp b/jni/feature_mos/src/mosaic_renderer/WarpRenderer.cpp index af6779a3f..e4755b1ed 100755..100644 --- a/jni/feature_mos/src/mosaic_renderer/WarpRenderer.cpp +++ b/jni/feature_mos/src/mosaic_renderer/WarpRenderer.cpp @@ -68,6 +68,51 @@ void WarpRenderer::SetScalingMatrix(float xscale, float yscale) mScalingMatrix[15] = 1.0f; } +void WarpRenderer::SetRotation(int degree) +{ + for(int i=0; i<16; i++) + { + mRotationMatrix[i] = 0.0f; + } + + switch(degree) + { + case 0: + mRotationMatrix[0] = 1.0f; + mRotationMatrix[1] = 0.0f; + mRotationMatrix[4] = 0.0f; + mRotationMatrix[5] = 1.0f; + break; + case 90: + mRotationMatrix[0] = 0.0f; + mRotationMatrix[1] = 1.0f; + mRotationMatrix[4] = -1.0f; + mRotationMatrix[5] = 0.0f; + break; + case 180: + mRotationMatrix[0] = -1.0f; + mRotationMatrix[1] = 0.0f; + mRotationMatrix[4] = 0.0f; + mRotationMatrix[5] = -1.0f; + break; + case 270: + mRotationMatrix[0] = 0.0f; + mRotationMatrix[1] = -1.0f; + mRotationMatrix[4] = 1.0f; + mRotationMatrix[5] = 0.0f; + break; + default: + mRotationMatrix[0] = 1.0f; + mRotationMatrix[1] = 0.0f; + mRotationMatrix[4] = 0.0f; + mRotationMatrix[5] = 1.0f; + break; + } + + mRotationMatrix[10] = 1.0f; + mRotationMatrix[15] = 1.0f; +} + bool WarpRenderer::InitializeGLProgram() { bool succeeded = false; @@ -87,6 +132,7 @@ bool WarpRenderer::InitializeGLProgram() mAffinetransLoc = glGetUniformLocation(glProgram, "u_affinetrans"); mViewporttransLoc = glGetUniformLocation(glProgram, "u_viewporttrans"); mScalingtransLoc = glGetUniformLocation(glProgram, "u_scalingtrans"); + mRotationtransLoc = glGetUniformLocation(glProgram, "u_rotationtrans"); mTexCoordLoc = glGetAttribLocation(glProgram, "a_texCoord"); // Get sampler location @@ -110,7 +156,7 @@ bool WarpRenderer::DrawTexture(GLfloat *affine) bool succeeded = false; do { bool rt = (mFrameBuffer == NULL)? - SetupGraphics(mSurfaceWidth, mSurfaceHeight) : + SetupGraphics(mSurfaceXOffset, mSurfaceYOffset, mSurfaceWidth, mSurfaceHeight) : SetupGraphics(mFrameBuffer); if(!rt) @@ -143,6 +189,7 @@ bool WarpRenderer::DrawTexture(GLfloat *affine) glUniformMatrix4fv(mAffinetransLoc, 1, GL_FALSE, affine); glUniformMatrix4fv(mViewporttransLoc, 1, GL_FALSE, mViewportMatrix); glUniformMatrix4fv(mScalingtransLoc, 1, GL_FALSE, mScalingMatrix); + glUniformMatrix4fv(mRotationtransLoc, 1, GL_FALSE, mRotationMatrix); // And, finally, execute the GL draw command. glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, g_iIndices); @@ -161,12 +208,13 @@ const char* WarpRenderer::VertexShaderSource() const "uniform mat4 u_affinetrans; \n" "uniform mat4 u_viewporttrans; \n" "uniform mat4 u_scalingtrans; \n" + "uniform mat4 u_rotationtrans; \n" "attribute vec4 a_position; \n" "attribute vec2 a_texCoord; \n" "varying vec2 v_texCoord; \n" "void main() \n" "{ \n" - " gl_Position = u_scalingtrans * u_viewporttrans * u_affinetrans * a_position; \n" + " gl_Position = u_scalingtrans * u_viewporttrans * u_affinetrans * u_rotationtrans * a_position; \n" " v_texCoord = a_texCoord; \n" "} \n"; diff --git a/jni/feature_mos/src/mosaic_renderer/WarpRenderer.h b/jni/feature_mos/src/mosaic_renderer/WarpRenderer.h index 8e9a694ec..2f50c6f34 100755 --- a/jni/feature_mos/src/mosaic_renderer/WarpRenderer.h +++ b/jni/feature_mos/src/mosaic_renderer/WarpRenderer.h @@ -20,7 +20,7 @@ class WarpRenderer: public Renderer { void SetViewportMatrix(int w, int h, int W, int H); void SetScalingMatrix(float xscale, float yscale); - + void SetRotation(int degree); bool DrawTexture(GLfloat *affine); private: @@ -38,9 +38,11 @@ class WarpRenderer: public Renderer { GLint mViewporttransLoc; GLint mScalingtransLoc; GLint mTexCoordLoc; + GLint mRotationtransLoc; GLfloat mViewportMatrix[16]; GLfloat mScalingMatrix[16]; + GLfloat mRotationMatrix[16]; // Sampler location GLint mSamplerLoc; diff --git a/jni/feature_mos/src/mosaic_renderer/YVURenderer.cpp b/jni/feature_mos/src/mosaic_renderer/YVURenderer.cpp index f7dcf6f61..b30e6f7b6 100755..100644 --- a/jni/feature_mos/src/mosaic_renderer/YVURenderer.cpp +++ b/jni/feature_mos/src/mosaic_renderer/YVURenderer.cpp @@ -79,7 +79,7 @@ bool YVURenderer::DrawTexture() bool succeeded = false; do { bool rt = (mFrameBuffer == NULL)? - SetupGraphics(mSurfaceWidth, mSurfaceHeight) : + SetupGraphics(mSurfaceXOffset, mSurfaceYOffset, mSurfaceWidth, mSurfaceHeight) : SetupGraphics(mFrameBuffer); if(!rt) |