summaryrefslogtreecommitdiffstats
path: root/jni/mosaic_renderer_jni.cpp
diff options
context:
space:
mode:
authorWei-Ta Chen <weita@google.com>2011-09-11 10:13:04 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-11 10:13:04 -0700
commit452b0dae881f1ed6db431dae2936b4a8115af289 (patch)
tree1b2a1e381595c5db7cd452cf46219615d3f98173 /jni/mosaic_renderer_jni.cpp
parent6bffa99880bb5e26c38d9c577463ad415de86bd5 (diff)
parent85dedb803016feea39a78efc4bfc07b4f436cc6c (diff)
downloadLegacyCamera-452b0dae881f1ed6db431dae2936b4a8115af289.zip
LegacyCamera-452b0dae881f1ed6db431dae2936b4a8115af289.tar.gz
LegacyCamera-452b0dae881f1ed6db431dae2936b4a8115af289.tar.bz2
Merge "Make the preview mosaic leave a margin."
Diffstat (limited to 'jni/mosaic_renderer_jni.cpp')
-rw-r--r--jni/mosaic_renderer_jni.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/jni/mosaic_renderer_jni.cpp b/jni/mosaic_renderer_jni.cpp
index e741bef..b0d6b44 100644
--- a/jni/mosaic_renderer_jni.cpp
+++ b/jni/mosaic_renderer_jni.cpp
@@ -445,11 +445,17 @@ JNIEXPORT jint JNICALL Java_com_android_camera_panorama_MosaicRenderer_init(
JNIEXPORT void JNICALL Java_com_android_camera_panorama_MosaicRenderer_reset(
JNIEnv * env, jobject obj, jint width, jint height)
{
- gUILayoutScalingX = (PREVIEW_FBO_WIDTH_SCALE / PREVIEW_FBO_HEIGHT_SCALE) *
- (gPreviewImageWidth[LR] / gPreviewImageHeight[LR]) / (width / height) *
- PREVIEW_FBO_HEIGHT_SCALE;
+ // Scale the current frame's height to the height of view and
+ // maintain the aspect ratio of the current frame on the screen.
gUILayoutScalingY = PREVIEW_FBO_HEIGHT_SCALE;
+ // Note that OpenGL scales a texture to view's width and height automatically.
+ // The "width / height" inverts the scaling, so as to maintain the aspect ratio
+ // of the current frame.
+ gUILayoutScalingX = ((float) (PREVIEW_FBO_WIDTH_SCALE * gPreviewImageWidth[LR])
+ / (PREVIEW_FBO_HEIGHT_SCALE * gPreviewImageHeight[LR]) * PREVIEW_FBO_HEIGHT_SCALE)
+ / ((float) width / height);
+
gBuffer[0].Init(gPreviewFBOWidth, gPreviewFBOHeight, GL_RGBA);
gBuffer[1].Init(gPreviewFBOWidth, gPreviewFBOHeight, GL_RGBA);