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