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 AttachBuffer(sptr<SurfaceBuffer>& buffer, int32_t timeOut) override; 59 GSError DetachBuffer(sptr<SurfaceBuffer>& buffer) override; 60 GSError RegisterReleaseListener(sptr<IProducerListener> listener) override; 61 GSError UnRegisterReleaseListener() override; 62 63 GSError IsSupportedAlloc(const std::vector<BufferVerifyAllocInfo> &infos, std::vector<bool> &supporteds) override; 64 65 // Call carefully. This interface will empty all caches of the current process 66 GSError CleanCache() override; 67 GSError Disconnect() override; 68 GSError GoBackground() override; 69 70 GSError SetScalingMode(uint32_t sequence, ScalingMode scalingMode) override; 71 GSError SetMetaData(uint32_t sequence, const std::vector<GraphicHDRMetaData> &metaData) override; 72 GSError SetMetaDataSet(uint32_t sequence, GraphicHDRMetadataKey key, 73 const std::vector<uint8_t> &metaData) override; 74 GSError SetTunnelHandle(const GraphicExtDataHandle *handle) override; 75 GSError GetPresentTimestamp(uint32_t sequence, GraphicPresentTimestampType type, int64_t &time) override; 76 77 sptr<NativeSurface> GetNativeSurface() override; 78 79 GSError SendDeathRecipientObject() override; 80 81 GSError GetTransform(GraphicTransformType &transform) override; 82 83 private: 84 static inline BrokerDelegator<BufferClientProducer> delegator_; 85 std::string name_ = "not init"; 86 uint64_t uniqueId_ = 0; 87 std::mutex mutex_; 88 sptr<IBufferProducerToken> token_; 89 }; 90 }; // namespace OHOS 91 92 #endif // FRAMEWORKS_SURFACE_INCLUDE_BUFFER_CLIENT_PRODUCER_H 93