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