• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 &timestamp, std::vector<Rect> &damages);
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     bool QueryIfBufferAvailable();
41 
42     GSError RegisterConsumerListener(sptr<IBufferConsumerListener>& listener);
43     GSError RegisterConsumerListener(IBufferConsumerListenerClazz *listener);
44     GSError RegisterReleaseListener(OnReleaseFunc func);
45     GSError RegisterDeleteBufferListener(OnDeleteBufferFunc func, bool isForUniRedraw = false);
46     GSError UnregisterConsumerListener();
47 
48     GSError SetDefaultWidthAndHeight(int32_t width, int32_t height);
49     GSError SetDefaultUsage(uint32_t usage);
50     void Dump(std::string &result) const;
51     GraphicTransformType GetTransform() const;
52     GSError GetScalingMode(uint32_t sequence, ScalingMode &scalingMode) const;
53     GSError QueryMetaDataType(uint32_t sequence, HDRMetaDataType &type) const;
54     GSError GetMetaData(uint32_t sequence, std::vector<GraphicHDRMetaData> &metaData) const;
55     GSError GetMetaDataSet(uint32_t sequence, GraphicHDRMetadataKey &key, std::vector<uint8_t> &metaData) const;
56     sptr<SurfaceTunnelHandle> GetTunnelHandle() const;
57     GSError SetPresentTimestamp(uint32_t sequence, const GraphicPresentTimestamp &timestamp);
58 
59     bool GetStatus() const;
60     void SetStatus(bool status);
61     GSError OnConsumerDied();
62     GSError GoBackground();
63 
64 private:
65     sptr<BufferQueue> bufferQueue_ = nullptr;
66     std::string name_ = "not init";
67 };
68 } // namespace OHOS
69 
70 #endif // FRAMEWORKS_SURFACE_INCLUDE_BUFFER_QUEUE_CONSUMER_H
71