| Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 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 |  | 
| Chia-I Wu | 06d63de | 2017-01-04 14:58:51 +0800 | [diff] [blame] | 28 | class Fence; | 
| Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 29 | class IGraphicBufferProducer; | 
 | 30 | class String8; | 
 | 31 |  | 
 | 32 | class DisplaySurface : public virtual RefBase { | 
 | 33 | public: | 
| Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 34 |     // beginFrame is called at the beginning of the composition loop, before | 
 | 35 |     // the configuration is known. The DisplaySurface should do anything it | 
 | 36 |     // needs to do to enable HWComposer to decide how to compose the frame. | 
| Dan Stoza | 7143316 | 2014-02-04 16:22:36 -0800 | [diff] [blame] | 37 |     // We pass in mustRecompose so we can keep VirtualDisplaySurface's state | 
 | 38 |     // machine happy without actually queueing a buffer if nothing has changed. | 
 | 39 |     virtual status_t beginFrame(bool mustRecompose) = 0; | 
| Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 40 |  | 
| Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 41 |     // prepareFrame is called after the composition configuration is known but | 
 | 42 |     // before composition takes place. The DisplaySurface can use the | 
 | 43 |     // composition type to decide how to manage the flow of buffers between | 
 | 44 |     // GLES and HWC for this frame. | 
 | 45 |     enum CompositionType { | 
 | 46 |         COMPOSITION_UNKNOWN = 0, | 
 | 47 |         COMPOSITION_GLES    = 1, | 
 | 48 |         COMPOSITION_HWC     = 2, | 
 | 49 |         COMPOSITION_MIXED   = COMPOSITION_GLES | COMPOSITION_HWC | 
 | 50 |     }; | 
 | 51 |     virtual status_t prepareFrame(CompositionType compositionType) = 0; | 
 | 52 |  | 
| Fabien Sanglard | 9d96de4 | 2016-10-11 00:15:18 +0000 | [diff] [blame] | 53 | #ifndef USE_HWC2 | 
 | 54 |     // Should be called when composition rendering is complete for a frame (but | 
 | 55 |     // eglSwapBuffers hasn't necessarily been called). Required by certain | 
 | 56 |     // older drivers for synchronization. | 
 | 57 |     // TODO: Remove this when we drop support for HWC 1.0. | 
 | 58 |     virtual status_t compositionComplete() = 0; | 
 | 59 | #endif | 
 | 60 |  | 
| Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 61 |     // Inform the surface that GLES composition is complete for this frame, and | 
 | 62 |     // the surface should make sure that HWComposer has the correct buffer for | 
 | 63 |     // this frame. Some implementations may only push a new buffer to | 
 | 64 |     // HWComposer if GLES composition took place, others need to push a new | 
 | 65 |     // buffer on every frame. | 
| Jesse Hall | 7414965 | 2013-03-19 17:18:09 -0700 | [diff] [blame] | 66 |     // | 
 | 67 |     // advanceFrame must be followed by a call to  onFrameCommitted before | 
 | 68 |     // advanceFrame may be called again. | 
| Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 69 |     virtual status_t advanceFrame() = 0; | 
 | 70 |  | 
| Jesse Hall | 7414965 | 2013-03-19 17:18:09 -0700 | [diff] [blame] | 71 |     // onFrameCommitted is called after the frame has been committed to the | 
| Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 72 |     // hardware composer. The surface collects the release fence for this | 
 | 73 |     // frame's buffer. | 
 | 74 |     virtual void onFrameCommitted() = 0; | 
| Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 75 |  | 
| Dan Stoza | f10c46e | 2014-11-11 10:32:31 -0800 | [diff] [blame] | 76 |     virtual void dumpAsString(String8& result) const = 0; | 
| Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 77 |  | 
| Michael Lentine | 47e4540 | 2014-07-18 15:34:25 -0700 | [diff] [blame] | 78 |     virtual void resizeBuffers(const uint32_t w, const uint32_t h) = 0; | 
 | 79 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 80 |     virtual const sp<Fence>& getClientTargetAcquireFence() const = 0; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 81 |  | 
| Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 82 | protected: | 
 | 83 |     DisplaySurface() {} | 
 | 84 |     virtual ~DisplaySurface() {} | 
 | 85 | }; | 
 | 86 |  | 
 | 87 | // --------------------------------------------------------------------------- | 
 | 88 | } // namespace android | 
 | 89 | // --------------------------------------------------------------------------- | 
 | 90 |  | 
 | 91 | #endif // ANDROID_SF_DISPLAY_SURFACE_H | 
 | 92 |  |