Skip to content
Browse files

Add support for Panorama mode and fix colors

Add support for Panorama mode.
rapmv78/android_packages_apps_Camera@97666c3

Fix Panorama mode colors by doing YVU conversion in CPU.
rapmv78/android_packages_apps_Camera@652e2f0

Change-Id: I05995c03bd2a36da4fc42c83c8ad4d6b75426089
  • Loading branch information...
1 parent 773f6f9 commit 2595607df3cb7e4826fb7a5e1bd7438dd92e4ae6 @rapmv78 rapmv78 committed with cyanogen Oct 14, 2012
View
3 jni/Android.mk
@@ -10,6 +10,9 @@ LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/feature_mos/src/mosaic
LOCAL_CFLAGS := -O3 -DNDEBUG
+ifeq ($(BOARD_CPU_COLOR_CONVERT), true)
+LOCAL_CFLAGS += -DCPU_COLOR_CONVERT
+endif
LOCAL_SRC_FILES := \
feature_mos_jni.cpp \
View
2 jni/feature_mos/src/mosaic_renderer/SurfaceTextureRenderer.cpp
@@ -149,6 +149,7 @@ bool SurfaceTextureRenderer::DrawTexture(GLfloat *affine)
// And, finally, execute the GL draw command.
glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, g_iIndices2);
+ glFlush();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
succeeded = true;
} while (false);
@@ -174,7 +175,6 @@ const char* SurfaceTextureRenderer::VertexShaderSource() const
const char* SurfaceTextureRenderer::FragmentShaderSource() const
{
static const char gFragmentShader[] =
- "#extension GL_OES_EGL_image_external : require\n"
"precision mediump float;\n"
"varying vec2 vTextureNormCoord;\n"
"uniform samplerExternalOES sTexture;\n"
View
2 jni/feature_mos/src/mosaic_renderer/WarpRenderer.cpp
@@ -149,9 +149,11 @@ bool WarpRenderer::DrawTexture(GLfloat *affine)
checkGlError("glDrawElements");
+ glFlush();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
succeeded = true;
} while (false);
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
return succeeded;
}
View
12 jni/feature_mos/src/mosaic_renderer/YVURenderer.cpp
@@ -113,6 +113,7 @@ bool YVURenderer::DrawTexture()
checkGlError("glDrawElements");
+ glFlush();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
succeeded = true;
} while (false);
@@ -137,6 +138,7 @@ const char* YVURenderer::VertexShaderSource() const
const char* YVURenderer::FragmentShaderSource() const
{
+#ifndef CPU_COLOR_CONVERT
static const char gFragmentShader[] =
"precision mediump float;\n"
"uniform sampler2D s_texture;\n"
@@ -155,6 +157,14 @@ const char* YVURenderer::FragmentShaderSource() const
" p = texture2D(s_texture, v_texCoord);\n"
" gl_FragColor[3] = dot(p, coeff_y);\n"
"}\n";
-
+#else
+ static const char gFragmentShader[] =
+ "precision mediump float;\n"
+ "uniform sampler2D s_texture;\n"
+ "varying vec2 v_texCoord;\n"
+ "void main() {\n"
+ " gl_FragColor = texture2D(s_texture, v_texCoord);\n"
+ "}\n";
+#endif
return gFragmentShader;
}
View
22 jni/feature_mos_jni.cpp
@@ -354,10 +354,32 @@ void ConvertYVUAiToPlanarYVU(unsigned char *planar, unsigned char *in, int width
for (int i = 0; i < planeSize; i++)
{
+#ifndef CPU_COLOR_CONVERT
*Yptr++ = *in++;
*Vptr++ = *in++;
*Uptr++ = *in++;
in++; // Alpha
+#else // CPU_COLOR_CONVERT
+ int y, v, u;
+
+ y = ( 66 * in[0] + 152 * in[1] + 25 * in[2] + 16);
+ v = ( 112 * in[0] - 94 * in[1] - 18 * in[2] + 128);
+ u = (- 38 * in[0] - 75 * in[1] + 112 * in[2] + 128);
+
+ y >>= 8;
+ v >>= 8;
+ u >>= 8;
+
+ y += 16;
+ v += 128;
+ u += 128;
+
+ *Yptr++ = (unsigned char) (y);
+ *Vptr++ = (unsigned char) (v);
+ *Uptr++ = (unsigned char) (u);
+ in += 4; // Alpha
+
+#endif // CPU_COLOR_CONVERT
}
}
View
3 jni/mosaic_renderer_jni.cpp
@@ -634,6 +634,7 @@ JNIEXPORT void JNICALL Java_com_android_camera_panorama_MosaicRenderer_preproces
gSurfTexRenderer[LR].DrawTexture(g_dAffinetransIdentGL);
gSurfTexRenderer[HR].DrawTexture(g_dAffinetransIdentGL);
+ glFlush();
}
#ifndef now_ms
@@ -659,6 +660,7 @@ JNIEXPORT void JNICALL Java_com_android_camera_panorama_MosaicRenderer_transferG
gYVURenderer[LR].DrawTexture();
gYVURenderer[HR].DrawTexture();
+ glFlush();
sem_wait(&gPreviewImage_semaphore);
// Bind to the input LR FBO and read the Low-Res data from there...
glBindFramebuffer(GL_FRAMEBUFFER, gBufferInputYVU[LR].GetFrameBufferName());
@@ -686,6 +688,7 @@ JNIEXPORT void JNICALL Java_com_android_camera_panorama_MosaicRenderer_transferG
checkGlError("glReadPixels HR");
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
sem_post(&gPreviewImage_semaphore);
}
View
8 src/com/android/camera/PanoramaActivity.java
@@ -472,7 +472,7 @@ public void run() {
// means users exit and come back to panorama. Do not start the
// preview. Preview will be started after final mosaic is
// generated.
- if (!mPausing && !mThreadRunning) {
+ if (!mPausing) {
startCameraPreview();
}
}
@@ -940,7 +940,11 @@ private void reset() {
private void resetToPreview() {
reset();
- if (!mPausing) startCameraPreview();
+ if (!mPausing) {
+ mMosaicView.onPause();
+ mMosaicView.onResume();
+ startCameraPreview();
+ }
}
private void showFinalMosaic(Bitmap bitmap) {

0 comments on commit 2595607

Please sign in to comment.
Something went wrong with that request. Please try again.