blob: e60c4fb7b90a871ddac0dc707fe338dfc52672ab [file] [log] [blame]
Jesse Hall99c7dbb2013-03-14 14:29:29 -07001/*
2 * Copyright 2013 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#ifndef ANDROID_SF_DISPLAY_SURFACE_H
18#define ANDROID_SF_DISPLAY_SURFACE_H
19
20#include <utils/Errors.h>
21#include <utils/RefBase.h>
22#include <utils/StrongPointer.h>
23
24// ---------------------------------------------------------------------------
25namespace android {
26// ---------------------------------------------------------------------------
27
28class IGraphicBufferProducer;
29class String8;
30
31class DisplaySurface : public virtual RefBase {
32public:
Jesse Hall028dc8f2013-08-20 16:35:32 -070033 // beginFrame is called at the beginning of the composition loop, before
34 // the configuration is known. The DisplaySurface should do anything it
35 // needs to do to enable HWComposer to decide how to compose the frame.
Dan Stoza71433162014-02-04 16:22:36 -080036 // We pass in mustRecompose so we can keep VirtualDisplaySurface's state
37 // machine happy without actually queueing a buffer if nothing has changed.
38 virtual status_t beginFrame(bool mustRecompose) = 0;
Jesse Hall028dc8f2013-08-20 16:35:32 -070039
Jesse Hall38efe862013-04-06 23:12:29 -070040 // prepareFrame is called after the composition configuration is known but
41 // before composition takes place. The DisplaySurface can use the
42 // composition type to decide how to manage the flow of buffers between
43 // GLES and HWC for this frame.
44 enum CompositionType {
45 COMPOSITION_UNKNOWN = 0,
46 COMPOSITION_GLES = 1,
47 COMPOSITION_HWC = 2,
48 COMPOSITION_MIXED = COMPOSITION_GLES | COMPOSITION_HWC
49 };
50 virtual status_t prepareFrame(CompositionType compositionType) = 0;
51
Jesse Hall99c7dbb2013-03-14 14:29:29 -070052 // Should be called when composition rendering is complete for a frame (but
53 // eglSwapBuffers hasn't necessarily been called). Required by certain
54 // older drivers for synchronization.
55 // TODO: Remove this when we drop support for HWC 1.0.
56 virtual status_t compositionComplete() = 0;
57
58 // Inform the surface that GLES composition is complete for this frame, and
59 // the surface should make sure that HWComposer has the correct buffer for
60 // this frame. Some implementations may only push a new buffer to
61 // HWComposer if GLES composition took place, others need to push a new
62 // buffer on every frame.
Jesse Hall74149652013-03-19 17:18:09 -070063 //
64 // advanceFrame must be followed by a call to onFrameCommitted before
65 // advanceFrame may be called again.
Jesse Hall99c7dbb2013-03-14 14:29:29 -070066 virtual status_t advanceFrame() = 0;
67
Jesse Hall74149652013-03-19 17:18:09 -070068 // onFrameCommitted is called after the frame has been committed to the
Jesse Hall851cfe82013-03-20 13:44:00 -070069 // hardware composer. The surface collects the release fence for this
70 // frame's buffer.
71 virtual void onFrameCommitted() = 0;
Jesse Hall99c7dbb2013-03-14 14:29:29 -070072
73 virtual void dump(String8& result) const = 0;
74
Michael Lentine47e45402014-07-18 15:34:25 -070075 virtual void resizeBuffers(const uint32_t w, const uint32_t h) = 0;
76
Jesse Hall99c7dbb2013-03-14 14:29:29 -070077protected:
78 DisplaySurface() {}
79 virtual ~DisplaySurface() {}
80};
81
82// ---------------------------------------------------------------------------
83} // namespace android
84// ---------------------------------------------------------------------------
85
86#endif // ANDROID_SF_DISPLAY_SURFACE_H
87