• 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_CLIENT_PRODUCER_H
17 #define FRAMEWORKS_SURFACE_INCLUDE_BUFFER_CLIENT_PRODUCER_H
18 
19 #include <map>
20 #include <vector>
21 #include <mutex>
22 
23 #include <iremote_proxy.h>
24 #include <iremote_object.h>
25 
26 #include <ibuffer_producer.h>
27 
28 #include "surface_buffer_impl.h"
29 
30 namespace OHOS {
31 class BufferClientProducer : public IRemoteProxy<IBufferProducer> {
32 public:
33     BufferClientProducer(const sptr<IRemoteObject>& impl);
34     virtual ~BufferClientProducer();
35 
36     GSError RequestBuffer(const BufferRequestConfig &config, sptr<BufferExtraData> &bedata,
37                           RequestBufferReturnValue &retval) override;
38 
39     GSError CancelBuffer(uint32_t sequence, const sptr<BufferExtraData> &bedata) override;
40 
41     GSError FlushBuffer(uint32_t sequence, const sptr<BufferExtraData> &bedata,
42                         const sptr<SyncFence>& fence, BufferFlushConfigWithDamages &config) override;
43     GSError GetLastFlushedBuffer(sptr<SurfaceBuffer>& buffer,
44                                   sptr<SyncFence>& fence, float matrix[16]) override;
45     uint32_t GetQueueSize() override;
46     GSError SetQueueSize(uint32_t queueSize) override;
47 
48     GSError GetName(std::string &name) override;
49     uint64_t GetUniqueId() override;
50     GSError GetNameAndUniqueId(std::string& name, uint64_t& uniqueId) override;
51 
52     int32_t GetDefaultWidth() override;
53     int32_t GetDefaultHeight() override;
54     uint32_t GetDefaultUsage() override;
55     GSError SetTransform(GraphicTransformType transform) override;
56 
57     GSError AttachBuffer(sptr<SurfaceBuffer>& buffer) override;
58     GSError DetachBuffer(sptr<SurfaceBuffer>& buffer) override;
59     GSError RegisterReleaseListener(sptr<IProducerListener> listener) override;
60     GSError UnRegisterReleaseListener() override;
61 
62     GSError IsSupportedAlloc(const std::vector<BufferVerifyAllocInfo> &infos, std::vector<bool> &supporteds) override;
63 
64     // Call carefully. This interface will empty all caches of the current process
65     GSError CleanCache() override;
66     GSError Disconnect() override;
67     GSError GoBackground() override;
68 
69     GSError SetScalingMode(uint32_t sequence, ScalingMode scalingMode) override;
70     GSError SetMetaData(uint32_t sequence, const std::vector<GraphicHDRMetaData> &metaData) override;
71     GSError SetMetaDataSet(uint32_t sequence, GraphicHDRMetadataKey key,
72                            const std::vector<uint8_t> &metaData) override;
73     GSError SetTunnelHandle(const GraphicExtDataHandle *handle) override;
74     GSError GetPresentTimestamp(uint32_t sequence, GraphicPresentTimestampType type, int64_t &time) override;
75 
76     sptr<NativeSurface> GetNativeSurface() override;
77 
78     GSError SendDeathRecipientObject() override;
79 
80 private:
81     static inline BrokerDelegator<BufferClientProducer> delegator_;
82     std::string name_ = "not init";
83     uint64_t uniqueId_ = 0;
84     std::mutex mutex_;
85     sptr<IBufferProducerToken> token_;
86 };
87 }; // namespace OHOS
88 
89 #endif // FRAMEWORKS_SURFACE_INCLUDE_BUFFER_CLIENT_PRODUCER_H
90