Closed Bug 825826 Opened 13 years ago Closed 11 years ago

Camera preview may have wrong orientation

Categories

(Firefox OS Graveyard :: Gaia::Camera, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 947956

People

(Reporter: alan.yenlin.huang, Unassigned)

Details

In otoro and unagi, camera orientation is 270-deg clockwise, so camera.js applied a 90-deg transform to make preview orientation as user's expectation. But not all partners put camera in 270-deg clockwise. We are porting B2G on new device, amgoo. Amgoo's camera orientation is 90-deg clockwise. I think in camera.js, we couldn't just rotate as below: var transform = 'rotate(90deg)'; Camera App should use an API to get camera orientation, and then decide the rotation transform. (BTW, gonk could report this via GonkCameraHardware::GetSensorOrientation already.)
The preview of camera view of Flatfish is upside-down. The root cause seems to be from the orientation issue just like the one in Alan's post. We did some modifications shown below: 1. in camera.css, we changed the viewfinder's configurations: #viewfinder { position: absolute; transform-origin: 0 0; transform: rotate(270deg); left: 0px; top: 1280px; z-index: 25; } 2. We commented off the style.transform in camera.js: transform = 'translate(' + dx + 'px,' + dy + 'px) ' + transform; //style.transform = transform; style.width = width + 'px'; style.height = height + 'px'; Those changes can solve the upside-down preview issue quickly on Flatfish. But I think this is not a good solution. Do you have any other suggestions?
(In reply to JustinLee from comment #1) > The preview of camera view of Flatfish is upside-down. The root cause seems > to be from the orientation issue just like the one in Alan's post. We did > some modifications shown below: > 1. in camera.css, we changed the viewfinder's configurations: > #viewfinder { > > position: absolute; > transform-origin: 0 0; > transform: rotate(270deg); > left: 0px; > top: 1280px; > z-index: 25; > } > 2. We commented off the style.transform in camera.js: > transform = 'translate(' + dx + 'px,' + dy + 'px) ' + transform; > //style.transform = transform; > style.width = width + 'px'; > style.height = height + 'px'; > > Those changes can solve the upside-down preview issue quickly on Flatfish. > But I think this is not a good solution. > Do you have any other suggestions? Those changes are hardly to land into gaia master because I am afraid the changes only for flatfish. The thing is Camera service should set native_window_set_buffers_transform(..., mOrientation) with correct mOrientation. This action will also set to SurfaceTextureClient::perform() for a given window. I tried to hard code to change the mOrientation but it didn't have any angle change from preview view. Currently Flatfish doesn't enable HwComposer so it goes with GPU compositing. I will observe layer structure to get orientation info to figure out further.
(In reply to Vincent Liu[:vliu] from comment #2) > Those changes are hardly to land into gaia master because I am afraid the > changes only for flatfish. The thing is Camera service should set > native_window_set_buffers_transform(..., mOrientation) with correct native_window_set_buffers_transform() do not work. It is not connected. http://mxr.mozilla.org/mozilla-central/source/widget/gonk/nativewindow/GonkNativeWindowICS.cpp#568 It comes from architectural difference between android and b2g. I never heard about a request about it now. If we want to use it, architectural investigation becomes necessary.
Blocks: 930961
No longer blocks: 930961
(In reply to Sotaro Ikeda [:sotaro] from comment #3) > (In reply to Vincent Liu[:vliu] from comment #2) > > Those changes are hardly to land into gaia master because I am afraid the > > changes only for flatfish. The thing is Camera service should set > > native_window_set_buffers_transform(..., mOrientation) with correct > > native_window_set_buffers_transform() do not work. It is not connected. > http://mxr.mozilla.org/mozilla-central/source/widget/gonk/nativewindow/ > GonkNativeWindowICS.cpp#568 > > It comes from architectural difference between android and b2g. I never > heard about a request about it now. If we want to use it, architectural > investigation becomes necessary. The platform of flatfish is based on Android (JB 4.2). The flow I saw by adding print message is 1. http://mxr.mozilla.org/mozilla-central/source/dom/camera/GonkCameraHwMgr.cpp#187 setPreviewTexture called to CameraClient::setPreviewTexture(...) in camera service. It then new SurfaceTextureClient(surfaceTexture). 2. http://mxr.mozilla.org/mozilla-central/source/dom/camera/GonkCameraHwMgr.cpp#310 startCameraMode(CAMERA_PREVIEW_MODE) called to CameraClient::startPreviewMode() in camera service. It then called to native_window_set_buffers_transform(mPreviewWindow.get(), mOrientation); 3. Once native_window_set_buffers_transform was called, SurfaceTextureClient::perform(...) received this request and then called dispatchSetBuffersTransform(...). I got some questions. 1. From the above observation, native_window_set_buffers_transform() should be called on Camera preview case. I can't figure out what you said in Comment 3. Can you please explain more? 2. I tried to hard code the value of mOrientation but the preview screen always get up-side down. Does it you mean that native_window_set_buffers_transform() do not work? 3. In Gecko, we have GonkNativeWindowClient. Why we still use SurfaceTextureClient for camera usage? 4. Currently the way we can solve it is modifying the transform value from setPreviewSize() or css in camera app. But this way will become device dependent and hardly to land into gaia master. Do you have a better way to solve this problem? Thanks.
Is this still an issue? Sounds like it would have been fixed with the `sensorAngle` work that was done in bug 947956.
Flags: needinfo?(ahuang)
Yup I think bug 947956 fixed this :)
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: needinfo?(ahuang)
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.