blob: 0e67acf2ee8bb85072d001fb0f33ff072e60277a [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
Lloyd Pique542307f2018-10-19 13:24:08 -070017#pragma once
Jesse Hall99c7dbb2013-03-14 14:29:29 -070018
19#include <utils/Errors.h>
20#include <utils/RefBase.h>
21#include <utils/StrongPointer.h>
22
Jesse Hall99c7dbb2013-03-14 14:29:29 -070023namespace android {
Jesse Hall99c7dbb2013-03-14 14:29:29 -070024
Chia-I Wu06d63de2017-01-04 14:58:51 +080025class Fence;
Jesse Hall99c7dbb2013-03-14 14:29:29 -070026class IGraphicBufferProducer;
27class String8;
28
Lloyd Pique542307f2018-10-19 13:24:08 -070029namespace compositionengine {
30
31/**
32 * An abstraction for working with a display surface (buffer queue)
33 */
Jesse Hall99c7dbb2013-03-14 14:29:29 -070034class DisplaySurface : public virtual RefBase {
35public:
Lloyd Pique542307f2018-10-19 13:24:08 -070036 virtual ~DisplaySurface();
37
Jesse Hall028dc8f2013-08-20 16:35:32 -070038 // beginFrame is called at the beginning of the composition loop, before
39 // the configuration is known. The DisplaySurface should do anything it
40 // needs to do to enable HWComposer to decide how to compose the frame.
Dan Stoza71433162014-02-04 16:22:36 -080041 // We pass in mustRecompose so we can keep VirtualDisplaySurface's state
42 // machine happy without actually queueing a buffer if nothing has changed.
43 virtual status_t beginFrame(bool mustRecompose) = 0;
Jesse Hall028dc8f2013-08-20 16:35:32 -070044
Jesse Hall38efe862013-04-06 23:12:29 -070045 // prepareFrame is called after the composition configuration is known but
46 // before composition takes place. The DisplaySurface can use the
47 // composition type to decide how to manage the flow of buffers between
48 // GLES and HWC for this frame.
49 enum CompositionType {
50 COMPOSITION_UNKNOWN = 0,
Lloyd Pique542307f2018-10-19 13:24:08 -070051 COMPOSITION_GLES = 1,
52 COMPOSITION_HWC = 2,
53 COMPOSITION_MIXED = COMPOSITION_GLES | COMPOSITION_HWC
Jesse Hall38efe862013-04-06 23:12:29 -070054 };
55 virtual status_t prepareFrame(CompositionType compositionType) = 0;
56
Jesse Hall99c7dbb2013-03-14 14:29:29 -070057 // Inform the surface that GLES composition is complete for this frame, and
58 // the surface should make sure that HWComposer has the correct buffer for
59 // this frame. Some implementations may only push a new buffer to
60 // HWComposer if GLES composition took place, others need to push a new
61 // buffer on every frame.
Jesse Hall74149652013-03-19 17:18:09 -070062 //
63 // advanceFrame must be followed by a call to onFrameCommitted before
64 // advanceFrame may be called again.
Jesse Hall99c7dbb2013-03-14 14:29:29 -070065 virtual status_t advanceFrame() = 0;
66
Jesse Hall74149652013-03-19 17:18:09 -070067 // onFrameCommitted is called after the frame has been committed to the
Jesse Hall851cfe82013-03-20 13:44:00 -070068 // hardware composer. The surface collects the release fence for this
69 // frame's buffer.
70 virtual void onFrameCommitted() = 0;
Jesse Hall99c7dbb2013-03-14 14:29:29 -070071
Dan Stozaf10c46e2014-11-11 10:32:31 -080072 virtual void dumpAsString(String8& result) const = 0;
Jesse Hall99c7dbb2013-03-14 14:29:29 -070073
Michael Lentine47e45402014-07-18 15:34:25 -070074 virtual void resizeBuffers(const uint32_t w, const uint32_t h) = 0;
75
Dan Stoza9e56aa02015-11-02 13:00:03 -080076 virtual const sp<Fence>& getClientTargetAcquireFence() const = 0;
Jesse Hall99c7dbb2013-03-14 14:29:29 -070077};
78
Lloyd Pique542307f2018-10-19 13:24:08 -070079} // namespace compositionengine
Jesse Hall99c7dbb2013-03-14 14:29:29 -070080} // namespace android