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.processing.imagebackend;
18 
19 import java.util.Set;
20 import java.util.concurrent.Executor;
21 
22 /**
23  * The interface by which Task derived off of TaskImageContainer can describe
24  * its task dependencies and manage its image references.
25  *
26  */
27 public interface ImageTaskManager {
28 
29     /**
30      * Spawns dependent tasks from internal implementation of set of tasks. If a
31      * dependent task does NOT require the image reference, it should be passed
32      * a null pointer as an image reference. In general, this method should be
33      * called after the task has completed its own computations, but before it
34      * has released its own image reference (via the releaseSemaphoreReference
35      * call).
36      *
37      * @param tasks The set of tasks to be run
38      * @return whether tasks are successfully submitted.
39      */
appendTasks(ImageToProcess img, Set<TaskImageContainer> tasks)40     public boolean appendTasks(ImageToProcess img, Set<TaskImageContainer> tasks);
41 
42     /**
43      * Spawns a single dependent task from internal implementation of a task.
44      *
45      * @param task The task to be run
46      * @return whether tasks are successfully submitted.
47      */
appendTasks(ImageToProcess img, TaskImageContainer task)48     public boolean appendTasks(ImageToProcess img, TaskImageContainer task);
49 
50     /**
51      * Signals the ImageTaskManager that a task has released a reference to the
52      * image. ImageTaskManager determines whether all references have been
53      * released and applies its specified release protocol of closing image
54      * and/or unblocking the caller. Should ONLY be called by the tasks running
55      * on this manager.
56      *
57      * @param img the image to be released by the task.
58      * @param executor the executor on which the image close is run. if null,
59      *            image close is run by the calling thread (usually the main
60      *            task thread).
61      */
releaseSemaphoreReference(final ImageToProcess img, Executor executor)62     public void releaseSemaphoreReference(final ImageToProcess img, Executor executor);
63 
64     /**
65      * Simple getter for the associated listener object associated with this
66      * instance that handles registration of event listeners.
67      *
68      * @return listener proxy that handles events messaging for this object.
69      */
getProxyListener()70     public ImageProcessorProxyListener getProxyListener();
71 }
72