2 * Copyright (C) 2015 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef DRM_HWCOMPOSER_COMPOSITOR_H_
18 #define DRM_HWCOMPOSER_COMPOSITOR_H_
33 // Prepares the given framebuffer for use as output of this compositor. On
34 // success, takes a reference to the given buffer and returns a non- negative
35 // integer that is used as a handle to the prepared target. On failure,
36 // returns a negative integer.
37 virtual int CreateTarget(sp<android::GraphicBuffer> &buffer) = 0;
39 // Sets the target framebuffer of all subsequent composite calls. The target
40 // must be an integer previously returned by a successful call to createTarget
41 // of this compositor or the target can be -1 to indicate that no custom
42 // buffer should be used for subsequent calls.
43 virtual void SetTarget(int target) = 0;
45 // Releases the reference to the buffer underlying the given target. The given
46 // target will no longer be valid for use for setTarget. Calling this on a
47 // target that was used in the last setTarget call or that is the target of a
48 // composition that has not yet signaled its fence is undefined behavior.
49 virtual void ForgetTarget(int target) = 0;
57 // Releases and invalidates the composition.
58 virtual ~Composition();
60 // Adds the given layer, whose handle has been imported into the given buffer
61 // object, to the given display of the composition. The layer may be modified
62 // to include a releaseFenceFd.
64 // Upon success, the compositor takes ownership of bo and is responsible
65 // for calling importer->ReleaseBuffer(bo), where importer is the importer
66 // provided on CreateComposition(). Returns 0 on success.
67 virtual int AddLayer(int display, hwc_layer_1 *layer, hwc_drm_bo *bo) = 0;
69 // Gets the number of successful AddLayer calls that can be made on the
70 // composition and display, up to num_needed.
71 virtual unsigned GetRemainingLayers(int display,
72 unsigned num_needed) const = 0;
77 virtual ~Compositor();
79 // This must be called once before any other methods called. It must be called
80 // on the thread the Compositor is meant to operate on to initialize thread
81 // local variables. Returns 0 on success.
82 virtual int Init() = 0;
84 // If this compositor supports targeting to output buffers, this returns a
85 // non-null pointer. Otherwise, returns null.
86 virtual Targeting *targeting() = 0;
88 // Starts a fresh composition.
89 virtual Composition *CreateComposition(Importer *importer) = 0;
91 // On success returns a syncpoint fd that will be signaled when composition is
92 // complete or -1 if compositing was completed by this method's return. On
93 // error returns an integer less than -1. The composition is invalid after
95 virtual int QueueComposition(Composition *composition) = 0;
97 // compositors require that every QueueComposition be paired with a Composite
98 // on a worker thread. Each Composite call handles one composition that was
99 // submitted via QueueComposition in FIFO order. Returns 0 on success.
100 virtual int Composite() = 0;
103 } // namespace android