• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #ifndef PRODUCER_SURFACE_DELEGATOR_H
16 #define PRODUCER_SURFACE_DELEGATOR_H
17 
18 #include <map>
19 #include <vector>
20 #include <mutex>
21 
22 #include "transact_surface_delegator_stub.h"
23 
24 namespace OHOS {
25 class ProducerSurfaceDelegator : public TransactSurfaceDelegatorStub {
26 public:
27     ~ProducerSurfaceDelegator() = default;
Create()28     static sptr<ProducerSurfaceDelegator> Create()
29     {
30         return sptr<ProducerSurfaceDelegator>(new ProducerSurfaceDelegator());
31     }
32     GSError DequeueBuffer(int32_t slot, sptr<SurfaceBuffer> buffer);
33     GSError QueueBuffer(int32_t slot, int32_t acquireFence);
34     GSError ReleaseBuffer(const sptr<SurfaceBuffer> &buffer, const sptr<SyncFence> &fence);
35     GSError ClearBufferSlot(int32_t slot);
36     GSError CancelBuffer(int32_t slot, int32_t fenceFd);
37     GSError DetachBuffer(int32_t slot);
38     int OnDequeueBuffer(MessageParcel &data, MessageParcel &reply);
39     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
40 
41 private:
42     std::map<int32_t, sptr<SurfaceBuffer>> map_;
43     std::vector<sptr<SurfaceBuffer>> pendingReleaseBuffer_;
44     std::mutex mapMutex_;
45     std::mutex mstate_;
46 };
47 } // namespace OHOS
48 #endif // PRODUCER_SURFACE_DELEGATOR_H
49