summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjunjiez <junjiez@codeaurora.org>2016-11-28 14:09:34 +0800
committerArne Coucheron <arco68@gmail.com>2017-06-13 07:18:39 +0200
commit9d21c697f4bd8f62892c374e993ff41d6d98722b (patch)
tree6bb1e9c1ffe182fda3ac116aa81203e6eaa18f22
parentcc08b441ef6e94b95babc9f93420798bc6f52311 (diff)
downloadandroid_packages_apps_Snap-9d21c697f4bd8f62892c374e993ff41d6d98722b.tar.gz
android_packages_apps_Snap-9d21c697f4bd8f62892c374e993ff41d6d98722b.tar.bz2
android_packages_apps_Snap-9d21c697f4bd8f62892c374e993ff41d6d98722b.zip
SnapdragonCamera: Fix preview is flipped on 8996
Modidfy render script to implement flip another way not 90 according to the camera mounting position. Change-Id: Id6b305fd2b00bc4193f1ba73d4253794e04ee3a6 CRs-Fixed: 1087483
-rwxr-xr-x[-rw-r--r--]rs/rotator.rs20
-rw-r--r--src/com/android/camera/imageprocessor/FrameProcessor.java9
2 files changed, 23 insertions, 6 deletions
diff --git a/rs/rotator.rs b/rs/rotator.rs
index 5a27e00f7..2c57951d6 100644..100755
--- a/rs/rotator.rs
+++ b/rs/rotator.rs
@@ -35,32 +35,42 @@ rs_allocation gIn;
uint32_t width;
uint32_t height;
uint32_t pad;
-bool gFlip;
+uint32_t degree;
uchar __attribute__((kernel)) rotate90andMerge(uint32_t x, uint32_t y) {
uchar yValue = rsGetElementAt_uchar(gIn, x + y*width);
- if(gFlip) {
+ if(degree == 180) {
if(x >= width - pad)
return (uchar)0;
rsSetElementAt_uchar(gOut, yValue, (width-1-x-pad)*height + height - 1 - y);
- } else {
+ } else if (degree == 90) {
rsSetElementAt_uchar(gOut, yValue, x*height + height - 1 - y);
+ } else if (degree == 270) {
+ if(x >= width - pad)
+ return (uchar)0;
+ rsSetElementAt_uchar(gOut, yValue, (width-1-x-pad)*height + y);
}
+
if(x%2 == 0 && y%2 == 0) {
uint32_t ySize = width*height;
uint32_t index = ySize + x + ((y/2) * width);
uchar vValue = rsGetElementAt_uchar(gIn, index);
uchar uValue = rsGetElementAt_uchar(gIn, index + 1);
- if(gFlip) {
+ if(degree == 180) {
if(x >= width - pad)
return (uchar)0;
rsSetElementAt_uchar(gOut, uValue, ySize + (width-2-x-pad)/2*height + height - 1 - y);
rsSetElementAt_uchar(gOut, vValue, ySize + (width-2-x-pad)/2*height + height - 1 - y - 1);
- } else {
+ } else if (degree == 90) {
rsSetElementAt_uchar(gOut, uValue, ySize + x/2*height + height - 1 - y);
rsSetElementAt_uchar(gOut, vValue, ySize + x/2*height + height - 1 - y - 1);
+ } else if (degree == 270) {
+ if(x >= (width - pad))
+ return (uchar)0;
+ rsSetElementAt_uchar(gOut, uValue, ySize + (width-1-x-pad)/2*height + y -1);
+ rsSetElementAt_uchar(gOut, vValue, ySize + (width-1-x-pad)/2*height + y);
}
}
return (uchar)0;
diff --git a/src/com/android/camera/imageprocessor/FrameProcessor.java b/src/com/android/camera/imageprocessor/FrameProcessor.java
index 4bee19194..a85636bc1 100644
--- a/src/com/android/camera/imageprocessor/FrameProcessor.java
+++ b/src/com/android/camera/imageprocessor/FrameProcessor.java
@@ -31,6 +31,7 @@ package com.android.camera.imageprocessor;
import android.app.Activity;
import android.graphics.ImageFormat;
+import android.hardware.camera2.CameraCharacteristics;
import android.media.Image;
import android.media.ImageReader;
import android.os.Handler;
@@ -39,6 +40,7 @@ import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.Type;
+import android.util.Log;
import android.util.Size;
import android.view.Surface;
import android.widget.Toast;
@@ -152,7 +154,12 @@ public class FrameProcessor {
mRsRotator.set_width(width);
mRsRotator.set_height(height);
mRsRotator.set_pad(stridePad);
- mRsRotator.set_gFlip(!mModule.isBackCamera());
+ int degree = 90;
+ if(mModule.getMainCameraCharacteristics() != null) {
+ degree = mModule.getMainCameraCharacteristics().
+ get(CameraCharacteristics.SENSOR_ORIENTATION);
+ }
+ mRsRotator.set_degree(degree);
mRsYuvToRGB.set_gIn(mProcessAllocation);
mRsYuvToRGB.set_width(height);
mRsYuvToRGB.set_height(width);