1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FRAMEWORKS_SURFACE_INCLUDE_BUFFER_QUEUE_CONSUMER_H 17 #define FRAMEWORKS_SURFACE_INCLUDE_BUFFER_QUEUE_CONSUMER_H 18 19 #include <refbase.h> 20 21 #include <surface_type.h> 22 #include "surface_buffer.h" 23 #include "buffer_queue.h" 24 25 namespace OHOS { 26 class BufferQueueConsumer : public RefBase { 27 public: 28 BufferQueueConsumer(sptr<BufferQueue>& bufferQueue); 29 virtual ~BufferQueueConsumer(); 30 31 GSError AcquireBuffer(sptr<SurfaceBuffer>& buffer, sptr<SyncFence>& fence, 32 int64_t ×tamp, Rect &damage); 33 34 GSError ReleaseBuffer(sptr<SurfaceBuffer>& buffer, const sptr<SyncFence>& fence); 35 36 GSError AttachBuffer(sptr<SurfaceBuffer>& buffer); 37 38 GSError DetachBuffer(sptr<SurfaceBuffer>& buffer); 39 40 GSError RegisterConsumerListener(sptr<IBufferConsumerListener>& listener); 41 GSError RegisterConsumerListener(IBufferConsumerListenerClazz *listener); 42 GSError RegisterReleaseListener(OnReleaseFunc func); 43 GSError RegisterDeleteBufferListener(OnDeleteBufferFunc func); 44 GSError UnregisterConsumerListener(); 45 46 GSError SetDefaultWidthAndHeight(int32_t width, int32_t height); 47 GSError SetDefaultUsage(uint32_t usage); 48 void Dump(std::string &result) const; 49 GraphicTransformType GetTransform() const; 50 GSError GetScalingMode(uint32_t sequence, ScalingMode &scalingMode) const; 51 GSError QueryMetaDataType(uint32_t sequence, HDRMetaDataType &type) const; 52 GSError GetMetaData(uint32_t sequence, std::vector<GraphicHDRMetaData> &metaData) const; 53 GSError GetMetaDataSet(uint32_t sequence, GraphicHDRMetadataKey &key, std::vector<uint8_t> &metaData) const; 54 sptr<SurfaceTunnelHandle> GetTunnelHandle() const; 55 GSError SetPresentTimestamp(uint32_t sequence, const GraphicPresentTimestamp ×tamp); 56 57 bool GetStatus() const; 58 void SetStatus(bool status); 59 GSError OnConsumerDied(); 60 GSError GoBackground(); 61 62 private: 63 sptr<BufferQueue> bufferQueue_ = nullptr; 64 std::string name_ = "not init"; 65 }; 66 } // namespace OHOS 67 68 #endif // FRAMEWORKS_SURFACE_INCLUDE_BUFFER_QUEUE_CONSUMER_H 69