~fboucault/qtubuntu-camera/resolution_fixes

« back to all changes in this revision

Viewing changes to src/aalcamerazoomcontrol.cpp

  • Committer: Florian Boucault
  • Date: 2015-11-25 17:05:44 UTC
  • mfrom: (151.3.4 staging)
  • Revision ID: florian.boucault@canonical.com-20151125170544-73hgdkbu1m3v5222
Merged with staging

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
    Q_EMIT currentDigitalZoomChanged(m_currentDigialZoom);
85
85
}
86
86
 
87
 
/*!
88
 
 * \brief AalCameraZoomControl::enablePhotoMode
89
 
 */
90
 
void AalCameraZoomControl::enablePhotoMode()
91
 
{
92
 
    Q_ASSERT(m_service->androidControl());
93
 
 
94
 
    if (!m_service->androidControl()) {
95
 
        return;
96
 
    }
97
 
 
98
 
    resetCurrentZoom();
99
 
 
100
 
    int maxZoom = 1;
101
 
    android_camera_get_max_zoom(m_service->androidControl(), &maxZoom);
102
 
    setMaxZoom(maxZoom);
103
 
}
104
 
 
105
 
/*!
106
 
 * \brief AalCameraZoomControl::enableVideoMode disabled zooming, as some HW has
107
 
 * issues zooming when focus mode is continuous focus
108
 
 * https://bugs.launchpad.net/camera-app/+bug/1191088
109
 
 */
110
 
void AalCameraZoomControl::enableVideoMode()
111
 
{
112
 
    resetCurrentZoom();
113
 
    setMaxZoom(1);
114
 
}
115
 
 
116
87
void AalCameraZoomControl::init(CameraControl *control, CameraControlListener *listener)
117
88
{
118
89
    Q_UNUSED(control);
119
90
    Q_UNUSED(listener);
120
91
 
121
 
    if (m_service->cameraControl()->captureMode() == QCamera::CaptureStillImage)
122
 
        enablePhotoMode();
123
 
    else
124
 
        enableVideoMode();
 
92
    resetZoom();
125
93
}
126
94
 
127
95
/*!
128
 
 * \brief AalCameraZoomControl::resetCurrentZoom sets the current zoom value to 1
 
96
 * \brief AalCameraZoomControl::reset sets the current zoom value to 1 and the
 
97
 * maximum zoom value to the maximum zoom level that the hardware reports as
 
98
 * supporting
129
99
 */
130
 
void AalCameraZoomControl::resetCurrentZoom()
 
100
void AalCameraZoomControl::resetZoom()
131
101
{
 
102
    if (!m_service->androidControl()) {
 
103
        return;
 
104
    }
 
105
 
132
106
    if (m_currentDigialZoom != 1) {
133
107
        m_currentDigialZoom = 1;
134
108
        Q_EMIT currentDigitalZoomChanged(m_currentDigialZoom);
135
109
    }
136
110
 
137
 
    if (m_service->androidControl())
138
 
        android_camera_set_zoom(m_service->androidControl(), m_currentDigialZoom);
139
 
}
 
111
    android_camera_set_zoom(m_service->androidControl(), m_currentDigialZoom);
140
112
 
141
 
/*!
142
 
 * \brief AalCameraZoomControl::setMaxZoom
143
 
 * \param maxValue
144
 
 */
145
 
void AalCameraZoomControl::setMaxZoom(int maxValue)
146
 
{
147
 
    if (maxValue < 1)
 
113
    int maxValue = 1;
 
114
    android_camera_get_max_zoom(m_service->androidControl(), &maxValue);
 
115
    if (maxValue < 1) {
148
116
        return;
 
117
    }
149
118
 
150
119
    if (maxValue != m_maximalDigitalZoom) {
151
120
        m_maximalDigitalZoom = maxValue;