Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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_BUFFERLAYERCONSUMER_H |
| 18 | #define ANDROID_BUFFERLAYERCONSUMER_H |
| 19 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 20 | #include <gui/BufferQueueDefs.h> |
| 21 | #include <gui/ConsumerBase.h> |
Courtney Goeltzenleuchter | 9bad0d7 | 2017-12-19 12:34:34 -0700 | [diff] [blame] | 22 | #include <gui/HdrMetadata.h> |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 23 | |
| 24 | #include <ui/FenceTime.h> |
| 25 | #include <ui/GraphicBuffer.h> |
Peiyong Lin | 34beb7a | 2018-03-28 11:57:12 -0700 | [diff] [blame] | 26 | #include <ui/GraphicTypes.h> |
Chia-I Wu | 67dcc69 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 27 | #include <ui/Region.h> |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 28 | |
| 29 | #include <utils/String8.h> |
| 30 | #include <utils/Vector.h> |
| 31 | #include <utils/threads.h> |
| 32 | |
| 33 | namespace android { |
| 34 | // ---------------------------------------------------------------------------- |
| 35 | |
Chia-I Wu | da5c730 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 36 | class DispSync; |
Chia-I Wu | c75c44d | 2017-11-27 14:32:57 -0800 | [diff] [blame] | 37 | class Layer; |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 38 | class String8; |
| 39 | |
Peiyong Lin | 833074a | 2018-08-28 11:53:54 -0700 | [diff] [blame] | 40 | namespace renderengine { |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 41 | class RenderEngine; |
| 42 | class Image; |
Peiyong Lin | 833074a | 2018-08-28 11:53:54 -0700 | [diff] [blame] | 43 | } // namespace renderengine |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 44 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 45 | /* |
| 46 | * BufferLayerConsumer consumes buffers of graphics data from a BufferQueue, |
Chia-I Wu | 221b592 | 2017-12-14 13:59:16 -0800 | [diff] [blame] | 47 | * and makes them available to RenderEngine as a texture. |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 48 | * |
Chia-I Wu | 221b592 | 2017-12-14 13:59:16 -0800 | [diff] [blame] | 49 | * A typical usage pattern is to call updateTexImage() when a new frame is |
| 50 | * desired. If a new frame is available, the frame is latched. If not, the |
| 51 | * previous contents are retained. The texture is attached and updated after |
| 52 | * bindTextureImage() is called. |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 53 | * |
Chia-I Wu | 221b592 | 2017-12-14 13:59:16 -0800 | [diff] [blame] | 54 | * All calls to updateTexImage must be made with RenderEngine being current. |
| 55 | * The texture is attached to the TEXTURE_EXTERNAL texture target. |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 56 | */ |
| 57 | class BufferLayerConsumer : public ConsumerBase { |
| 58 | public: |
Chia-I Wu | da5c730 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 59 | static const status_t BUFFER_REJECTED = UNKNOWN_ERROR + 8; |
| 60 | |
| 61 | class BufferRejecter { |
| 62 | friend class BufferLayerConsumer; |
| 63 | virtual bool reject(const sp<GraphicBuffer>& buf, const BufferItem& item) = 0; |
| 64 | |
| 65 | protected: |
| 66 | virtual ~BufferRejecter() {} |
| 67 | }; |
| 68 | |
Chia-I Wu | fd257f8 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 69 | struct ContentsChangedListener : public FrameAvailableListener { |
| 70 | virtual void onSidebandStreamChanged() = 0; |
| 71 | }; |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 72 | |
Chia-I Wu | 221b592 | 2017-12-14 13:59:16 -0800 | [diff] [blame] | 73 | // BufferLayerConsumer constructs a new BufferLayerConsumer object. The |
| 74 | // tex parameter indicates the name of the RenderEngine texture to which |
| 75 | // images are to be streamed. |
Peiyong Lin | 833074a | 2018-08-28 11:53:54 -0700 | [diff] [blame] | 76 | BufferLayerConsumer(const sp<IGraphicBufferConsumer>& bq, renderengine::RenderEngine& engine, |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 77 | uint32_t tex, Layer* layer); |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 78 | |
Chia-I Wu | fd257f8 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 79 | // Sets the contents changed listener. This should be used instead of |
| 80 | // ConsumerBase::setFrameAvailableListener(). |
| 81 | void setContentsChangedListener(const wp<ContentsChangedListener>& listener); |
| 82 | |
Chia-I Wu | da5c730 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 83 | nsecs_t computeExpectedPresent(const DispSync& dispSync); |
| 84 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 85 | // updateTexImage acquires the most recently queued buffer, and sets the |
| 86 | // image contents of the target texture to it. |
| 87 | // |
Chia-I Wu | 221b592 | 2017-12-14 13:59:16 -0800 | [diff] [blame] | 88 | // This call may only be made while RenderEngine is current. |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 89 | // |
Chia-I Wu | 221b592 | 2017-12-14 13:59:16 -0800 | [diff] [blame] | 90 | // This calls doFenceWait to ensure proper synchronization unless native |
| 91 | // fence is supported. |
Chia-I Wu | da5c730 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 92 | // |
Chia-I Wu | 221b592 | 2017-12-14 13:59:16 -0800 | [diff] [blame] | 93 | // Unlike the GLConsumer version, this version takes a functor that may be |
| 94 | // used to reject the newly acquired buffer. It also does not bind the |
| 95 | // RenderEngine texture until bindTextureImage is called. |
Chia-I Wu | da5c730 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 96 | status_t updateTexImage(BufferRejecter* rejecter, const DispSync& dispSync, bool* autoRefresh, |
Alec Mouri | 86770e5 | 2018-09-24 22:40:58 +0000 | [diff] [blame] | 97 | bool* queuedBuffer, uint64_t maxFrameNumber, |
| 98 | const sp<Fence>& releaseFence); |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 99 | |
Chia-I Wu | 0cb75ac | 2017-11-27 15:56:04 -0800 | [diff] [blame] | 100 | // See BufferLayerConsumer::bindTextureImageLocked(). |
| 101 | status_t bindTextureImage(); |
| 102 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 103 | // setReleaseFence stores a fence that will signal when the current buffer |
| 104 | // is no longer being read. This fence will be returned to the producer |
| 105 | // when the current buffer is released by updateTexImage(). Multiple |
| 106 | // fences can be set for a given buffer; they will be merged into a single |
| 107 | // union fence. |
Chia-I Wu | da5c730 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 108 | void setReleaseFence(const sp<Fence>& fence); |
| 109 | |
| 110 | bool releasePendingBuffer(); |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 111 | |
Chia-I Wu | 0cb75ac | 2017-11-27 15:56:04 -0800 | [diff] [blame] | 112 | sp<Fence> getPrevFinalReleaseFence() const; |
| 113 | |
Chia-I Wu | 221b592 | 2017-12-14 13:59:16 -0800 | [diff] [blame] | 114 | // See GLConsumer::getTransformMatrix. |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 115 | void getTransformMatrix(float mtx[16]); |
| 116 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 117 | // getTimestamp retrieves the timestamp associated with the texture image |
| 118 | // set by the most recent call to updateTexImage. |
| 119 | // |
| 120 | // The timestamp is in nanoseconds, and is monotonically increasing. Its |
| 121 | // other semantics (zero point, etc) are source-dependent and should be |
| 122 | // documented by the source. |
| 123 | int64_t getTimestamp(); |
| 124 | |
| 125 | // getDataSpace retrieves the DataSpace associated with the texture image |
| 126 | // set by the most recent call to updateTexImage. |
Peiyong Lin | 34beb7a | 2018-03-28 11:57:12 -0700 | [diff] [blame] | 127 | ui::Dataspace getCurrentDataSpace(); |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 128 | |
Courtney Goeltzenleuchter | 9bad0d7 | 2017-12-19 12:34:34 -0700 | [diff] [blame] | 129 | // getCurrentHdrMetadata retrieves the HDR metadata associated with the |
| 130 | // texture image set by the most recent call to updateTexImage. |
| 131 | const HdrMetadata& getCurrentHdrMetadata() const; |
| 132 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 133 | // getFrameNumber retrieves the frame number associated with the texture |
| 134 | // image set by the most recent call to updateTexImage. |
| 135 | // |
| 136 | // The frame number is an incrementing counter set to 0 at the creation of |
| 137 | // the BufferQueue associated with this consumer. |
| 138 | uint64_t getFrameNumber(); |
| 139 | |
Chia-I Wu | 67dcc69 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 140 | bool getTransformToDisplayInverse() const; |
| 141 | |
| 142 | // must be called from SF main thread |
| 143 | const Region& getSurfaceDamage() const; |
| 144 | |
Chia-I Wu | 5c6e463 | 2018-01-11 08:54:38 -0800 | [diff] [blame] | 145 | // getCurrentApi retrieves the API which queues the current buffer. |
| 146 | int getCurrentApi() const; |
| 147 | |
Chia-I Wu | 221b592 | 2017-12-14 13:59:16 -0800 | [diff] [blame] | 148 | // See GLConsumer::setDefaultBufferSize. |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 149 | status_t setDefaultBufferSize(uint32_t width, uint32_t height); |
| 150 | |
| 151 | // setFilteringEnabled sets whether the transform matrix should be computed |
| 152 | // for use with bilinear filtering. |
| 153 | void setFilteringEnabled(bool enabled); |
| 154 | |
| 155 | // getCurrentBuffer returns the buffer associated with the current image. |
| 156 | // When outSlot is not nullptr, the current buffer slot index is also |
| 157 | // returned. |
| 158 | sp<GraphicBuffer> getCurrentBuffer(int* outSlot = nullptr) const; |
| 159 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 160 | // getCurrentCrop returns the cropping rectangle of the current buffer. |
| 161 | Rect getCurrentCrop() const; |
| 162 | |
| 163 | // getCurrentTransform returns the transform of the current buffer. |
| 164 | uint32_t getCurrentTransform() const; |
| 165 | |
| 166 | // getCurrentScalingMode returns the scaling mode of the current buffer. |
| 167 | uint32_t getCurrentScalingMode() const; |
| 168 | |
| 169 | // getCurrentFence returns the fence indicating when the current buffer is |
| 170 | // ready to be read from. |
| 171 | sp<Fence> getCurrentFence() const; |
| 172 | |
| 173 | // getCurrentFence returns the FenceTime indicating when the current |
| 174 | // buffer is ready to be read from. |
| 175 | std::shared_ptr<FenceTime> getCurrentFenceTime() const; |
| 176 | |
| 177 | // setConsumerUsageBits overrides the ConsumerBase method to OR |
| 178 | // DEFAULT_USAGE_FLAGS to usage. |
| 179 | status_t setConsumerUsageBits(uint64_t usage); |
| 180 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 181 | protected: |
| 182 | // abandonLocked overrides the ConsumerBase method to clear |
| 183 | // mCurrentTextureImage in addition to the ConsumerBase behavior. |
| 184 | virtual void abandonLocked(); |
| 185 | |
| 186 | // dumpLocked overrides the ConsumerBase method to dump BufferLayerConsumer- |
| 187 | // specific info in addition to the ConsumerBase behavior. |
| 188 | virtual void dumpLocked(String8& result, const char* prefix) const; |
| 189 | |
Alec Mouri | 39801c0 | 2018-10-10 10:44:47 -0700 | [diff] [blame^] | 190 | // See ConsumerBase::acquireBufferLocked |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 191 | virtual status_t acquireBufferLocked(BufferItem* item, nsecs_t presentWhen, |
| 192 | uint64_t maxFrameNumber = 0) override; |
| 193 | |
Chia-I Wu | 6748db4 | 2017-12-01 10:53:53 -0800 | [diff] [blame] | 194 | bool canUseImageCrop(const Rect& crop) const; |
| 195 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 196 | struct PendingRelease { |
Chia-I Wu | 6aff69b | 2017-11-27 14:08:48 -0800 | [diff] [blame] | 197 | PendingRelease() : isPending(false), currentTexture(-1), graphicBuffer() {} |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 198 | |
| 199 | bool isPending; |
| 200 | int currentTexture; |
| 201 | sp<GraphicBuffer> graphicBuffer; |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 202 | }; |
| 203 | |
| 204 | // This releases the buffer in the slot referenced by mCurrentTexture, |
| 205 | // then updates state to refer to the BufferItem, which must be a |
| 206 | // newly-acquired buffer. If pendingRelease is not null, the parameters |
| 207 | // which would have been passed to releaseBufferLocked upon the successful |
| 208 | // completion of the method will instead be returned to the caller, so that |
| 209 | // it may call releaseBufferLocked itself later. |
| 210 | status_t updateAndReleaseLocked(const BufferItem& item, |
Alec Mouri | 86770e5 | 2018-09-24 22:40:58 +0000 | [diff] [blame] | 211 | PendingRelease* pendingRelease = nullptr, |
| 212 | const sp<Fence>& releaseFence = Fence::NO_FENCE); |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 213 | |
Alec Mouri | 39801c0 | 2018-10-10 10:44:47 -0700 | [diff] [blame^] | 214 | // Binds mTexName and the current buffer to TEXTURE_EXTERNAL target. |
| 215 | // If the bind succeeds, this calls doFenceWait. |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 216 | status_t bindTextureImageLocked(); |
| 217 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 218 | private: |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 219 | // freeBufferLocked frees up the given buffer slot. If the slot has been |
Chia-I Wu | 221b592 | 2017-12-14 13:59:16 -0800 | [diff] [blame] | 220 | // initialized this will release the reference to the GraphicBuffer in |
Alec Mouri | 39801c0 | 2018-10-10 10:44:47 -0700 | [diff] [blame^] | 221 | // that slot. Otherwise it has no effect. |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 222 | // |
| 223 | // This method must be called with mMutex locked. |
| 224 | virtual void freeBufferLocked(int slotIndex); |
| 225 | |
Chia-I Wu | c75c44d | 2017-11-27 14:32:57 -0800 | [diff] [blame] | 226 | // IConsumerListener interface |
| 227 | void onDisconnect() override; |
Chia-I Wu | fd257f8 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 228 | void onSidebandStreamChanged() override; |
Chia-I Wu | c75c44d | 2017-11-27 14:32:57 -0800 | [diff] [blame] | 229 | void addAndGetFrameTimestamps(const NewFrameEventsEntry* newTimestamps, |
| 230 | FrameEventHistoryDelta* outDelta) override; |
| 231 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 232 | // computeCurrentTransformMatrixLocked computes the transform matrix for the |
| 233 | // current texture. It uses mCurrentTransform and the current GraphicBuffer |
| 234 | // to compute this matrix and stores it in mCurrentTransformMatrix. |
Peiyong Lin | 566a3b4 | 2018-01-09 18:22:43 -0800 | [diff] [blame] | 235 | // mCurrentTextureImage must not be nullptr. |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 236 | void computeCurrentTransformMatrixLocked(); |
| 237 | |
Chia-I Wu | 3498e3c | 2017-12-01 10:19:38 -0800 | [diff] [blame] | 238 | // doFenceWaitLocked inserts a wait command into the RenderEngine command |
| 239 | // stream to ensure that it is safe for future RenderEngine commands to |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 240 | // access the current texture buffer. |
Chia-I Wu | 3498e3c | 2017-12-01 10:19:38 -0800 | [diff] [blame] | 241 | status_t doFenceWaitLocked() const; |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 242 | |
| 243 | // syncForReleaseLocked performs the synchronization needed to release the |
Chia-I Wu | 3498e3c | 2017-12-01 10:19:38 -0800 | [diff] [blame] | 244 | // current slot from RenderEngine. If needed it will set the current |
| 245 | // slot's fence to guard against a producer accessing the buffer before |
| 246 | // the outstanding accesses have completed. |
Alec Mouri | 86770e5 | 2018-09-24 22:40:58 +0000 | [diff] [blame] | 247 | status_t syncForReleaseLocked(const sp<Fence>& releaseFence); |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 248 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 249 | // The default consumer usage flags that BufferLayerConsumer always sets on its |
| 250 | // BufferQueue instance; these will be OR:d with any additional flags passed |
| 251 | // from the BufferLayerConsumer user. In particular, BufferLayerConsumer will always |
| 252 | // consume buffers as hardware textures. |
| 253 | static const uint64_t DEFAULT_USAGE_FLAGS = GraphicBuffer::USAGE_HW_TEXTURE; |
| 254 | |
Alec Mouri | 39801c0 | 2018-10-10 10:44:47 -0700 | [diff] [blame^] | 255 | // mCurrentTextureImage is the buffer containing the current texture. It's |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 256 | // possible that this buffer is not associated with any buffer slot, so we |
| 257 | // must track it separately in order to support the getCurrentBuffer method. |
Alec Mouri | 39801c0 | 2018-10-10 10:44:47 -0700 | [diff] [blame^] | 258 | sp<GraphicBuffer> mCurrentTextureBuffer; |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 259 | |
| 260 | // mCurrentCrop is the crop rectangle that applies to the current texture. |
| 261 | // It gets set each time updateTexImage is called. |
| 262 | Rect mCurrentCrop; |
| 263 | |
| 264 | // mCurrentTransform is the transform identifier for the current texture. It |
| 265 | // gets set each time updateTexImage is called. |
| 266 | uint32_t mCurrentTransform; |
| 267 | |
| 268 | // mCurrentScalingMode is the scaling mode for the current texture. It gets |
| 269 | // set each time updateTexImage is called. |
| 270 | uint32_t mCurrentScalingMode; |
| 271 | |
| 272 | // mCurrentFence is the fence received from BufferQueue in updateTexImage. |
| 273 | sp<Fence> mCurrentFence; |
| 274 | |
| 275 | // The FenceTime wrapper around mCurrentFence. |
| 276 | std::shared_ptr<FenceTime> mCurrentFenceTime{FenceTime::NO_FENCE}; |
| 277 | |
| 278 | // mCurrentTransformMatrix is the transform matrix for the current texture. |
| 279 | // It gets computed by computeTransformMatrix each time updateTexImage is |
| 280 | // called. |
| 281 | float mCurrentTransformMatrix[16]; |
| 282 | |
| 283 | // mCurrentTimestamp is the timestamp for the current texture. It |
| 284 | // gets set each time updateTexImage is called. |
| 285 | int64_t mCurrentTimestamp; |
| 286 | |
| 287 | // mCurrentDataSpace is the dataspace for the current texture. It |
| 288 | // gets set each time updateTexImage is called. |
Peiyong Lin | 34beb7a | 2018-03-28 11:57:12 -0700 | [diff] [blame] | 289 | ui::Dataspace mCurrentDataSpace; |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 290 | |
Courtney Goeltzenleuchter | 9bad0d7 | 2017-12-19 12:34:34 -0700 | [diff] [blame] | 291 | // mCurrentHdrMetadata is the HDR metadata for the current texture. It |
| 292 | // gets set each time updateTexImage is called. |
| 293 | HdrMetadata mCurrentHdrMetadata; |
| 294 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 295 | // mCurrentFrameNumber is the frame counter for the current texture. |
| 296 | // It gets set each time updateTexImage is called. |
| 297 | uint64_t mCurrentFrameNumber; |
| 298 | |
Chia-I Wu | 67dcc69 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 299 | // Indicates this buffer must be transformed by the inverse transform of the screen |
| 300 | // it is displayed onto. This is applied after BufferLayerConsumer::mCurrentTransform. |
| 301 | // This must be set/read from SurfaceFlinger's main thread. |
| 302 | bool mCurrentTransformToDisplayInverse; |
| 303 | |
| 304 | // The portion of this surface that has changed since the previous frame |
| 305 | Region mCurrentSurfaceDamage; |
| 306 | |
Chia-I Wu | 5c6e463 | 2018-01-11 08:54:38 -0800 | [diff] [blame] | 307 | int mCurrentApi; |
| 308 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 309 | uint32_t mDefaultWidth, mDefaultHeight; |
| 310 | |
| 311 | // mFilteringEnabled indicates whether the transform matrix is computed for |
| 312 | // use with bilinear filtering. It defaults to true and is changed by |
| 313 | // setFilteringEnabled(). |
| 314 | bool mFilteringEnabled; |
| 315 | |
Peiyong Lin | 833074a | 2018-08-28 11:53:54 -0700 | [diff] [blame] | 316 | renderengine::RenderEngine& mRE; |
Chia-I Wu | 9f2db77 | 2017-11-30 21:06:50 -0800 | [diff] [blame] | 317 | |
Chia-I Wu | 221b592 | 2017-12-14 13:59:16 -0800 | [diff] [blame] | 318 | // mTexName is the name of the RenderEngine texture to which streamed |
| 319 | // images will be bound when bindTexImage is called. It is set at |
| 320 | // construction time. |
Chia-I Wu | c91077c | 2017-11-27 13:32:04 -0800 | [diff] [blame] | 321 | const uint32_t mTexName; |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 322 | |
Chia-I Wu | c75c44d | 2017-11-27 14:32:57 -0800 | [diff] [blame] | 323 | // The layer for this BufferLayerConsumer |
| 324 | const wp<Layer> mLayer; |
| 325 | |
Chia-I Wu | fd257f8 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 326 | wp<ContentsChangedListener> mContentsChangedListener; |
| 327 | |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 328 | // mCurrentTexture is the buffer slot index of the buffer that is currently |
Chia-I Wu | 221b592 | 2017-12-14 13:59:16 -0800 | [diff] [blame] | 329 | // bound to the RenderEngine texture. It is initialized to INVALID_BUFFER_SLOT, |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 330 | // indicating that no buffer slot is currently bound to the texture. Note, |
| 331 | // however, that a value of INVALID_BUFFER_SLOT does not necessarily mean |
| 332 | // that no buffer is bound to the texture. A call to setBufferCount will |
| 333 | // reset mCurrentTexture to INVALID_BUFFER_SLOT. |
| 334 | int mCurrentTexture; |
Chia-I Wu | da5c730 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 335 | |
Alec Mouri | 39801c0 | 2018-10-10 10:44:47 -0700 | [diff] [blame^] | 336 | // Cached image used for rendering the current texture through GPU |
| 337 | // composition, which contains the cached image after freeBufferLocked is |
| 338 | // called on the current buffer. Whenever latchBuffer is called, this is |
| 339 | // expected to be cleared. Then, if bindTexImage is called before the next |
| 340 | // buffer is acquired, then this image is bound. |
| 341 | std::unique_ptr<renderengine::Image> mCurrentTextureImageFreed; |
| 342 | |
| 343 | // Cached images used for rendering the current texture through GPU |
| 344 | // composition. |
| 345 | std::unique_ptr<renderengine::Image> mImages[BufferQueueDefs::NUM_BUFFER_SLOTS]; |
| 346 | |
Chia-I Wu | da5c730 | 2017-11-27 14:51:06 -0800 | [diff] [blame] | 347 | // A release that is pending on the receipt of a new release fence from |
| 348 | // presentDisplay |
| 349 | PendingRelease mPendingRelease; |
Chia-I Wu | f140518 | 2017-11-27 11:29:21 -0800 | [diff] [blame] | 350 | }; |
| 351 | |
| 352 | // ---------------------------------------------------------------------------- |
| 353 | }; // namespace android |
| 354 | |
| 355 | #endif // ANDROID_BUFFERLAYERCONSUMER_H |