DisplaySurface.h revision db89edc94bd2a78226b407f9f7261e202e7fa325
1/*
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:
33    // prepareFrame is called after the composition configuration is known but
34    // before composition takes place. The DisplaySurface can use the
35    // composition type to decide how to manage the flow of buffers between
36    // GLES and HWC for this frame.
37    enum CompositionType {
38        COMPOSITION_UNKNOWN = 0,
39        COMPOSITION_GLES    = 1,
40        COMPOSITION_HWC     = 2,
41        COMPOSITION_MIXED   = COMPOSITION_GLES | COMPOSITION_HWC
42    };
43    virtual status_t prepareFrame(CompositionType compositionType) = 0;
44
45    // Should be called when composition rendering is complete for a frame (but
46    // eglSwapBuffers hasn't necessarily been called). Required by certain
47    // older drivers for synchronization.
48    // TODO: Remove this when we drop support for HWC 1.0.
49    virtual status_t compositionComplete() = 0;
50
51    // Inform the surface that GLES composition is complete for this frame, and
52    // the surface should make sure that HWComposer has the correct buffer for
53    // this frame. Some implementations may only push a new buffer to
54    // HWComposer if GLES composition took place, others need to push a new
55    // buffer on every frame.
56    //
57    // advanceFrame must be followed by a call to  onFrameCommitted before
58    // advanceFrame may be called again.
59    virtual status_t advanceFrame() = 0;
60
61    // onFrameCommitted is called after the frame has been committed to the
62    // hardware composer. The surface collects the release fence for this
63    // frame's buffer.
64    virtual void onFrameCommitted() = 0;
65
66    virtual void dump(String8& result) const = 0;
67
68protected:
69    DisplaySurface() {}
70    virtual ~DisplaySurface() {}
71};
72
73// ---------------------------------------------------------------------------
74} // namespace android
75// ---------------------------------------------------------------------------
76
77#endif // ANDROID_SF_DISPLAY_SURFACE_H
78
79