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
OnSetDataspace(MessageParcel & data,MessageParcel & reply)93 int ProducerSurfaceDelegator::OnSetDataspace(MessageParcel& data, MessageParcel& reply)
94 {
95 mAncoDataspace = 0;
96 return ERR_NONE;
97 }
98
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)99 int ProducerSurfaceDelegator::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
100 MessageOption &option)
101 {
102 return ERR_NONE;
103 }
104
RetryFlushBuffer(sptr<SurfaceBuffer> & buffer,int32_t fence,BufferFlushConfig & config)105 GSError ProducerSurfaceDelegator::RetryFlushBuffer(sptr<SurfaceBuffer>& buffer, int32_t fence,
106 BufferFlushConfig& config)
107 {
108 return GSERROR_OK;
109 }
110
HasSlotInSet(int32_t slot)111 bool ProducerSurfaceDelegator::HasSlotInSet(int32_t slot)
112 {
113 std::lock_guard<std::mutex> setLock(dequeueFailedSetMutex_);
114 return dequeueFailedSet_.find(slot) != dequeueFailedSet_.end();
115 }
116
InsertSlotIntoSet(int32_t slot)117 void ProducerSurfaceDelegator::InsertSlotIntoSet(int32_t slot)
118 {
119 std::lock_guard<std::mutex> setLock(dequeueFailedSetMutex_);
120 dequeueFailedSet_.insert(slot);
121 }
122
EraseSlotFromSet(int32_t slot)123 void ProducerSurfaceDelegator::EraseSlotFromSet(int32_t slot)
124 {
125 std::lock_guard<std::mutex> setLock(dequeueFailedSetMutex_);
126 dequeueFailedSet_.erase(slot);
127 }
128
SetDisplayRotation(int32_t rotation)129 void ProducerSurfaceDelegator::SetDisplayRotation(int32_t rotation)
130 {
131 mDisplayRotation_.store(rotation);
132 }
133
UpdateBufferTransform()134 void ProducerSurfaceDelegator::UpdateBufferTransform()
135 {
136 }
137
ConvertTransformToHmos(uint32_t transform)138 GraphicTransformType ProducerSurfaceDelegator::ConvertTransformToHmos(uint32_t transform)
139 {
140 mTransform_ = transform;
141 return mLastTransform_;
142 }
143
144 } // namespace OHOS
145