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, BufferFlushConfig &config) override; 43 44 uint32_t GetQueueSize() override; 45 GSError SetQueueSize(uint32_t queueSize) override; 46 47 GSError GetName(std::string &name) override; 48 uint64_t GetUniqueId() override; 49 GSError GetNameAndUniqueId(std::string& name, uint64_t& uniqueId) override; 50 51 int32_t GetDefaultWidth() override; 52 int32_t GetDefaultHeight() override; 53 uint32_t GetDefaultUsage() override; 54 GSError SetTransform(GraphicTransformType transform) override; 55 56 GSError AttachBuffer(sptr<SurfaceBuffer>& buffer) override; 57 GSError DetachBuffer(sptr<SurfaceBuffer>& buffer) override; 58 GSError RegisterReleaseListener(OnReleaseFunc func) override; 59 60 GSError IsSupportedAlloc(const std::vector<BufferVerifyAllocInfo> &infos, std::vector<bool> &supporteds) override; 61 62 // Call carefully. This interface will empty all caches of the current process 63 GSError CleanCache() override; 64 GSError Disconnect() override; 65 GSError GoBackground() override; 66 67 GSError SetScalingMode(uint32_t sequence, ScalingMode scalingMode) override; 68 GSError SetMetaData(uint32_t sequence, const std::vector<GraphicHDRMetaData> &metaData) override; 69 GSError SetMetaDataSet(uint32_t sequence, GraphicHDRMetadataKey key, 70 const std::vector<uint8_t> &metaData) override; 71 GSError SetTunnelHandle(const GraphicExtDataHandle *handle) override; 72 GSError GetPresentTimestamp(uint32_t sequence, GraphicPresentTimestampType type, int64_t &time) override; 73 74 sptr<NativeSurface> GetNativeSurface() override; 75 76 private: 77 static inline BrokerDelegator<BufferClientProducer> delegator_; 78 std::string name_ = "not init"; 79 uint64_t uniqueId_ = 0; 80 std::mutex mutex_; 81 }; 82 }; // namespace OHOS 83 84 #endif // FRAMEWORKS_SURFACE_INCLUDE_BUFFER_CLIENT_PRODUCER_H 85