1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.camera.one.v2.autofocus;
18 
19 import android.graphics.PointF;
20 
21 import com.android.camera.async.Updatable;
22 import com.android.camera.one.Settings3A;
23 
24 /**
25  * A ManualAutoFocus implementation which updates metering parameters and runs
26  * an AF Scan.
27  */
28 class ManualAutoFocusImpl implements ManualAutoFocus {
29     private final Updatable<MeteringParameters> mMeteringParameters;
30     private final Runnable mAFScanRunnable;
31     private final int mSensorOrientation;
32     private final Settings3A mSettings3A;
33 
ManualAutoFocusImpl(Updatable<MeteringParameters> meteringParameters, Runnable afScanRunnable, int sensorOrientation, Settings3A settings3A)34     public ManualAutoFocusImpl(Updatable<MeteringParameters> meteringParameters,
35             Runnable afScanRunnable,
36             int sensorOrientation,
37             Settings3A settings3A) {
38         mMeteringParameters = meteringParameters;
39         mAFScanRunnable = afScanRunnable;
40         mSensorOrientation = sensorOrientation;
41         mSettings3A = settings3A;
42     }
43 
44     @Override
triggerFocusAndMeterAtPoint(float nx, float ny)45     public void triggerFocusAndMeterAtPoint(float nx, float ny) {
46         PointF point = new PointF(nx, ny);
47         mMeteringParameters.update(PointMeteringParameters.createForNormalizedCoordinates(
48                 point /* afPoint */, point /* aePoint */, mSensorOrientation, mSettings3A));
49         mAFScanRunnable.run();
50     }
51 }
52