Bug 932669 - Expose sensor rotation offset to JS. r=dhylands

This commit is contained in:
Mike Habicher 2013-12-06 09:47:29 -05:00
Родитель e409c16f7e
Коммит 6fc4849635
10 изменённых файлов: 54 добавлений и 0 удалений

Просмотреть файл

@ -79,6 +79,7 @@ enum {
CAMERA_PARAM_PICTURESIZE,
CAMERA_PARAM_THUMBNAILSIZE,
CAMERA_PARAM_THUMBNAILQUALITY,
CAMERA_PARAM_SENSORANGLE,
CAMERA_PARAM_SUPPORTED_PREVIEWSIZES,
CAMERA_PARAM_SUPPORTED_VIDEOSIZES,

Просмотреть файл

@ -268,6 +268,14 @@ CameraControlImpl::Get(uint32_t aKey, idl::CameraSize& aSize)
return NS_OK;
}
nsresult
CameraControlImpl::Get(uint32_t aKey, int32_t* aValue)
{
MOZ_ASSERT(aValue);
*aValue = GetParameterInt32(aKey);
return NS_OK;
}
already_AddRefed<RecorderProfileManager>
CameraControlImpl::GetRecorderProfileManager()
{

Просмотреть файл

@ -75,6 +75,7 @@ public:
nsresult Get(nsICameraPreviewStateChange** aOnPreviewStateChange);
nsresult Set(uint32_t aKey, const idl::CameraSize& aSize);
nsresult Get(uint32_t aKey, idl::CameraSize& aSize);
nsresult Get(uint32_t aKey, int32_t* aValue);
nsresult SetFocusAreas(JSContext* aCx, const JS::Value& aValue)
{
@ -92,6 +93,7 @@ public:
virtual const char* GetParameter(const char* aKey) = 0;
virtual const char* GetParameterConstChar(uint32_t aKey) = 0;
virtual double GetParameterDouble(uint32_t aKey) = 0;
virtual int32_t GetParameterInt32(uint32_t aKey) = 0;
virtual void GetParameter(uint32_t aKey, nsTArray<idl::CameraRegion>& aRegions) = 0;
virtual void GetParameter(uint32_t aKey, idl::CameraSize& aSize) = 0;
virtual void SetParameter(const char* aKey, const char* aValue) = 0;

Просмотреть файл

@ -285,6 +285,14 @@ nsDOMCameraControl::GetExposureCompensation(ErrorResult& aRv)
return compensation;
}
int32_t
nsDOMCameraControl::SensorAngle()
{
int32_t angle;
mCameraControl->Get(CAMERA_PARAM_SENSORANGLE, &angle);
return angle;
}
already_AddRefed<nsICameraShutterCallback>
nsDOMCameraControl::GetOnShutter(ErrorResult& aRv)
{

Просмотреть файл

@ -76,6 +76,7 @@ public:
double GetFocusDistanceFar(ErrorResult& aRv);
void SetExposureCompensation(const dom::Optional<double>& aCompensation, ErrorResult& aRv);
double GetExposureCompensation(ErrorResult& aRv);
int32_t SensorAngle();
already_AddRefed<nsICameraShutterCallback> GetOnShutter(ErrorResult& aRv);
void SetOnShutter(nsICameraShutterCallback* aCb, ErrorResult& aRv);
already_AddRefed<nsICameraClosedCallback> GetOnClosed(ErrorResult& aRv);

Просмотреть файл

@ -24,6 +24,7 @@ public:
const char* GetParameter(const char* aKey);
const char* GetParameterConstChar(uint32_t aKey);
double GetParameterDouble(uint32_t aKey);
int32_t GetParameterInt32(uint32_t aKey);
void GetParameter(uint32_t aKey, nsTArray<idl::CameraRegion>& aRegions);
void GetParameter(uint32_t aKey, idl::CameraSize& aSize);
void SetParameter(const char* aKey, const char* aValue);
@ -101,6 +102,12 @@ nsFallbackCameraControl::GetParameterDouble(uint32_t aKey)
return NAN;
}
int32_t
nsFallbackCameraControl::GetParameterInt32(uint32_t aKey)
{
return 0;
}
void
nsFallbackCameraControl::GetParameter(uint32_t aKey, nsTArray<idl::CameraRegion>& aRegions)
{

Просмотреть файл

@ -434,6 +434,25 @@ nsGonkCameraControl::GetParameterDouble(uint32_t aKey)
}
}
int32_t
nsGonkCameraControl::GetParameterInt32(uint32_t aKey)
{
if (aKey == CAMERA_PARAM_SENSORANGLE) {
if (!mCameraHw.get()) {
return 0;
}
return mCameraHw->GetSensorOrientation();
}
const char* key = getKeyText(aKey);
if (!key) {
return 0;
}
RwAutoLockRead lock(mRwLock);
return mParams.getInt(key);
}
void
nsGonkCameraControl::GetParameter(uint32_t aKey,
nsTArray<idl::CameraRegion>& aRegions)

Просмотреть файл

@ -53,6 +53,7 @@ public:
const char* GetParameter(const char* aKey);
const char* GetParameterConstChar(uint32_t aKey);
double GetParameterDouble(uint32_t aKey);
int32_t GetParameterInt32(uint32_t aKey);
void GetParameter(uint32_t aKey, nsTArray<idl::CameraRegion>& aRegions);
void GetParameter(uint32_t aKey, nsTArray<idl::CameraSize>& aSizes);
void GetParameter(uint32_t aKey, idl::CameraSize& aSize);

Просмотреть файл

@ -46,6 +46,7 @@ public:
virtual nsresult Get(nsICameraPreviewStateChange** aOnPreviewStateChange) = 0;
virtual nsresult Set(uint32_t aKey, const idl::CameraSize& aSize) = 0;
virtual nsresult Get(uint32_t aKey, idl::CameraSize& aSize) = 0;
virtual nsresult Get(uint32_t aKey, int32_t* aValue) = 0;
virtual nsresult SetFocusAreas(JSContext* aCx, const JS::Value& aValue) = 0;
virtual nsresult SetMeteringAreas(JSContext* aCx, const JS::Value& aValue) = 0;
virtual nsresult GetVideoSizes(nsTArray<idl::CameraSize>& aVideoSizes) = 0;

Просмотреть файл

@ -152,6 +152,12 @@ interface CameraControl {
[Throws]
attribute any thumbnailSize;
/* the angle, in degrees, that the image sensor is mounted relative
to the display; e.g. if 'sensorAngle' is 270 degrees (or -90 degrees),
then the preview stream needs to be rotated +90 degrees to have the
same orientation as the real world. */
readonly attribute long sensorAngle;
/* tell the camera to attempt to focus the image */
[Throws]
void autoFocus(CameraAutoFocusCallback onSuccess, optional CameraErrorCallback onError);