• 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 
16 #ifndef ROSEN_RENDER_SERVICE_BASE_ISURFACE_BUFFER_CALLBACK_H
17 #define ROSEN_RENDER_SERVICE_BASE_ISURFACE_BUFFER_CALLBACK_H
18 
19 #include <vector>
20 #include <iremote_broker.h>
21 
22 #include "common/rs_common_def.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 class RSISurfaceBufferCallback : public IRemoteBroker {
27 public:
28     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.rosen.SurfaceBufferListener");
29 
30     RSISurfaceBufferCallback() = default;
31     virtual ~RSISurfaceBufferCallback() noexcept = default;
32 
33     // Uid and BufferQueue are a one-to-one mapping relationship. This API is used
34     // when an application has multiple XComponent components, and it notifies ArkUI
35     // which BufferQueue's Buffer can be released after it has been consumed.
36     virtual void OnFinish(uint64_t uid, const std::vector<uint32_t>& surfaceBufferIds) = 0;
37 };
38 
39 class RSB_EXPORT RSDefaultSurfaceBufferCallback : public RSISurfaceBufferCallback {
40 public:
41     RSDefaultSurfaceBufferCallback(
42         std::function<void(uint64_t, const std::vector<uint32_t>&)> callback);
43     ~RSDefaultSurfaceBufferCallback() noexcept override = default;
44 
45     void OnFinish(uint64_t uid, const std::vector<uint32_t>& surfaceBufferIds) override;
46     sptr<IRemoteObject> AsObject() override;
47 private:
48     std::function<void(uint64_t, const std::vector<uint32_t>&)> callback_;
49 };
50 } // namespace Rosen
51 } // namespace OHOS
52 
53 #endif // ROSEN_RENDER_SERVICE_BASE_ISURFACE_BUFFER_CALLBACK_H
54