• 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 #include <message_option.h>
16 #include <message_parcel.h>
17 #include "producer_surface_delegator.h"
18 #include "buffer_log.h"
19 #include "sync_fence.h"
20 
21 namespace OHOS {
~ProducerSurfaceDelegator()22 ProducerSurfaceDelegator::~ProducerSurfaceDelegator()
23 {
24     map_.clear();
25 }
DequeueBuffer(int32_t slot,sptr<SurfaceBuffer> buffer)26 GSError ProducerSurfaceDelegator::DequeueBuffer(int32_t slot, sptr<SurfaceBuffer> buffer)
27 {
28     return GSERROR_OK;
29 }
30 
QueueBuffer(int32_t slot,int32_t acquireFence)31 GSError ProducerSurfaceDelegator::QueueBuffer(int32_t slot, int32_t acquireFence)
32 {
33     return GSERROR_OK;
34 }
35 
ReleaseBuffer(const sptr<SurfaceBuffer> & buffer,const sptr<SyncFence> & fence)36 GSError ProducerSurfaceDelegator::ReleaseBuffer(const sptr<SurfaceBuffer> &buffer, const sptr<SyncFence> &fence)
37 {
38     return GSERROR_OK;
39 }
40 
ClearBufferSlot(int32_t slot)41 GSError ProducerSurfaceDelegator::ClearBufferSlot(int32_t slot)
42 {
43     (void)slot;
44     return GSERROR_OK;
45 }
46 
ClearAllBuffers()47 GSError ProducerSurfaceDelegator::ClearAllBuffers()
48 {
49     return GSERROR_OK;
50 }
51 
AddBufferLocked(const sptr<SurfaceBuffer> & buffer,int32_t slot)52 void ProducerSurfaceDelegator::AddBufferLocked(const sptr<SurfaceBuffer>& buffer, int32_t slot)
53 {
54     (void)buffer;
55     (void)slot;
56 }
57 
GetBufferLocked(int32_t slot)58 sptr<SurfaceBuffer> ProducerSurfaceDelegator::GetBufferLocked(int32_t slot)
59 {
60     (void)slot;
61     return nullptr;
62 }
63 
GetSlotLocked(const sptr<SurfaceBuffer> & buffer)64 int32_t ProducerSurfaceDelegator::GetSlotLocked(const sptr<SurfaceBuffer>& buffer)
65 {
66     (void)buffer;
67     return 0;
68 }
69 
CancelBuffer(int32_t slot,int32_t fenceFd)70 GSError ProducerSurfaceDelegator::CancelBuffer(int32_t slot, int32_t fenceFd)
71 {
72     return GSERROR_OK;
73 }
74 
DetachBuffer(int32_t slot)75 GSError ProducerSurfaceDelegator::DetachBuffer(int32_t slot)
76 {
77     return GSERROR_OK;
78 }
79 
OnSetBufferQueueSize(MessageParcel & data,MessageParcel & reply)80 int ProducerSurfaceDelegator::OnSetBufferQueueSize(MessageParcel &data, MessageParcel &reply)
81 {
82     return ERR_NONE;
83 }
84 
OnDequeueBuffer(MessageParcel & data,MessageParcel & reply)85 int ProducerSurfaceDelegator::OnDequeueBuffer(MessageParcel &data, MessageParcel &reply)
86 {
87     return ERR_NONE;
88 }
89 
OnSetDataspace(MessageParcel & data,MessageParcel & reply)90 int ProducerSurfaceDelegator::OnSetDataspace(MessageParcel& data, MessageParcel& reply)
91 {
92     mAncoDataspace = 0;
93     return ERR_NONE;
94 }
95 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)96 int ProducerSurfaceDelegator::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
97     MessageOption &option)
98 {
99     return ERR_NONE;
100 }
101 
RetryFlushBuffer(sptr<SurfaceBuffer> & buffer,int32_t fence,BufferFlushConfig & config)102 GSError ProducerSurfaceDelegator::RetryFlushBuffer(sptr<SurfaceBuffer>& buffer, int32_t fence,
103                                                    BufferFlushConfig& config)
104 {
105     return GSERROR_OK;
106 }
107 
HasSlotInSet(int32_t slot)108 bool ProducerSurfaceDelegator::HasSlotInSet(int32_t slot)
109 {
110     std::lock_guard<std::mutex> setLock(dequeueFailedSetMutex_);
111     return dequeueFailedSet_.find(slot) != dequeueFailedSet_.end();
112 }
113 
InsertSlotIntoSet(int32_t slot)114 void ProducerSurfaceDelegator::InsertSlotIntoSet(int32_t slot)
115 {
116     std::lock_guard<std::mutex> setLock(dequeueFailedSetMutex_);
117     dequeueFailedSet_.insert(slot);
118 }
119 
EraseSlotFromSet(int32_t slot)120 void ProducerSurfaceDelegator::EraseSlotFromSet(int32_t slot)
121 {
122     std::lock_guard<std::mutex> setLock(dequeueFailedSetMutex_);
123     dequeueFailedSet_.erase(slot);
124 }
125 
126 } // namespace OHOS
127