• 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 {
22 
23 std::atomic<int32_t> ProducerSurfaceDelegator::mDisplayRotation_ = 0;
24 
~ProducerSurfaceDelegator()25 ProducerSurfaceDelegator::~ProducerSurfaceDelegator()
26 {
27     map_.clear();
28 }
DequeueBuffer(int32_t slot,sptr<SurfaceBuffer> buffer)29 GSError ProducerSurfaceDelegator::DequeueBuffer(int32_t slot, sptr<SurfaceBuffer> buffer)
30 {
31     return GSERROR_OK;
32 }
33 
QueueBuffer(int32_t slot,int32_t acquireFence)34 GSError ProducerSurfaceDelegator::QueueBuffer(int32_t slot, int32_t acquireFence)
35 {
36     return GSERROR_OK;
37 }
38 
ReleaseBuffer(const sptr<SurfaceBuffer> & buffer,const sptr<SyncFence> & fence)39 GSError ProducerSurfaceDelegator::ReleaseBuffer(const sptr<SurfaceBuffer> &buffer, const sptr<SyncFence> &fence)
40 {
41     return GSERROR_OK;
42 }
43 
ClearBufferSlot(int32_t slot)44 GSError ProducerSurfaceDelegator::ClearBufferSlot(int32_t slot)
45 {
46     (void)slot;
47     return GSERROR_OK;
48 }
49 
ClearAllBuffers()50 GSError ProducerSurfaceDelegator::ClearAllBuffers()
51 {
52     return GSERROR_OK;
53 }
54 
AddBufferLocked(const sptr<SurfaceBuffer> & buffer,int32_t slot)55 void ProducerSurfaceDelegator::AddBufferLocked(const sptr<SurfaceBuffer>& buffer, int32_t slot)
56 {
57     (void)buffer;
58     (void)slot;
59 }
60 
GetBufferLocked(int32_t slot)61 sptr<SurfaceBuffer> ProducerSurfaceDelegator::GetBufferLocked(int32_t slot)
62 {
63     (void)slot;
64     return nullptr;
65 }
66 
GetSlotLocked(const sptr<SurfaceBuffer> & buffer)67 int32_t ProducerSurfaceDelegator::GetSlotLocked(const sptr<SurfaceBuffer>& buffer)
68 {
69     (void)buffer;
70     return 0;
71 }
72 
CancelBuffer(int32_t slot,int32_t fenceFd)73 GSError ProducerSurfaceDelegator::CancelBuffer(int32_t slot, int32_t fenceFd)
74 {
75     return GSERROR_OK;
76 }
77 
DetachBuffer(int32_t slot)78 GSError ProducerSurfaceDelegator::DetachBuffer(int32_t slot)
79 {
80     return GSERROR_OK;
81 }
82 
OnSetBufferQueueSize(MessageParcel & data,MessageParcel & reply)83 int ProducerSurfaceDelegator::OnSetBufferQueueSize(MessageParcel &data, MessageParcel &reply)
84 {
85     return ERR_NONE;
86 }
87 
OnDequeueBuffer(MessageParcel & data,MessageParcel & reply)88 int ProducerSurfaceDelegator::OnDequeueBuffer(MessageParcel &data, MessageParcel &reply)
89 {
90     return ERR_NONE;
91 }
92 
OnQueueBuffer(MessageParcel & data,MessageParcel & reply)93 int ProducerSurfaceDelegator::OnQueueBuffer(MessageParcel &data, MessageParcel &reply)
94 {
95     (void)data;
96     (void)reply;
97     return ERR_NONE;
98 }
99 
OnSetDataspace(MessageParcel & data,MessageParcel & reply)100 int ProducerSurfaceDelegator::OnSetDataspace(MessageParcel& data, MessageParcel& reply)
101 {
102     mAncoDataspace = -1;
103     return ERR_NONE;
104 }
105 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)106 int ProducerSurfaceDelegator::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
107     MessageOption &option)
108 {
109     return ERR_NONE;
110 }
111 
OnNdkFlushBuffer(MessageParcel & data,MessageParcel & reply)112 int32_t ProducerSurfaceDelegator::OnNdkFlushBuffer(MessageParcel &data, MessageParcel &reply)
113 {
114     (void)data;
115     (void)reply;
116     return GSERROR_OK;
117 }
118 
RetryFlushBuffer(sptr<SurfaceBuffer> & buffer,int32_t fence,BufferFlushConfig & config)119 GSError ProducerSurfaceDelegator::RetryFlushBuffer(sptr<SurfaceBuffer>& buffer, int32_t fence,
120                                                    BufferFlushConfig& config)
121 {
122     return GSERROR_OK;
123 }
124 
HasSlotInSet(int32_t slot)125 bool ProducerSurfaceDelegator::HasSlotInSet(int32_t slot)
126 {
127     std::lock_guard<std::mutex> setLock(dequeueFailedSetMutex_);
128     return dequeueFailedSet_.find(slot) != dequeueFailedSet_.end();
129 }
130 
InsertSlotIntoSet(int32_t slot)131 void ProducerSurfaceDelegator::InsertSlotIntoSet(int32_t slot)
132 {
133     std::lock_guard<std::mutex> setLock(dequeueFailedSetMutex_);
134     dequeueFailedSet_.insert(slot);
135 }
136 
EraseSlotFromSet(int32_t slot)137 void ProducerSurfaceDelegator::EraseSlotFromSet(int32_t slot)
138 {
139     std::lock_guard<std::mutex> setLock(dequeueFailedSetMutex_);
140     dequeueFailedSet_.erase(slot);
141 }
142 
SetDisplayRotation(int32_t rotation)143 void ProducerSurfaceDelegator::SetDisplayRotation(int32_t rotation)
144 {
145     mDisplayRotation_.store(rotation);
146 }
147 
UpdateBufferTransform()148 void ProducerSurfaceDelegator::UpdateBufferTransform()
149 {
150 }
151 
ConvertTransformToHmos(uint32_t transform)152 GraphicTransformType ProducerSurfaceDelegator::ConvertTransformToHmos(uint32_t transform)
153 {
154     mTransform_ = transform;
155     return mLastTransform_;
156 }
157 
NdkFlushBuffer(sptr<SurfaceBuffer> & buffer,int32_t slot,const sptr<SyncFence> & fence)158 int32_t ProducerSurfaceDelegator::NdkFlushBuffer(
159     sptr<SurfaceBuffer>& buffer, int32_t slot, const sptr<SyncFence>& fence)
160 {
161     (void)buffer;
162     (void)slot;
163     (void)fence;
164     return GSERROR_OK;
165 }
166 
NdkConvertBuffer(MessageParcel & data,int32_t hasNewBuffer,int32_t slot)167 sptr<SurfaceBuffer> ProducerSurfaceDelegator::NdkConvertBuffer(
168     MessageParcel& data, int32_t hasNewBuffer, int32_t slot)
169 {
170     (void)data;
171     (void)hasNewBuffer;
172     (void)slot;
173     return nullptr;
174 }
175 
NdkClearBuffer(int32_t slot,uint32_t seqNum)176 void ProducerSurfaceDelegator::NdkClearBuffer(int32_t slot, uint32_t seqNum)
177 {
178     mIsNdk = false;
179     (void)slot;
180     (void)seqNum;
181 }
182 } // namespace OHOS
183