• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 INTERFACES_INNERKITS_SURFACE_IBUFFER_PRODUCER_H
17 #define INTERFACES_INNERKITS_SURFACE_IBUFFER_PRODUCER_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include <iremote_broker.h>
23 
24 #include "buffer_extra_data.h"
25 #include "surface_buffer.h"
26 #include "surface_type.h"
27 
28 namespace OHOS {
29 class IBufferProducer : public IRemoteBroker {
30 public:
31     struct RequestBufferReturnValue {
32         int32_t sequence;
33         sptr<SurfaceBuffer> buffer;
34         int32_t fence;
35         std::vector<int32_t> deletingBuffers;
36     };
37     virtual GSError RequestBuffer(const BufferRequestConfig &config, BufferExtraData &bedata,
38                                        RequestBufferReturnValue &retval) = 0;
39 
40     virtual GSError CancelBuffer(int32_t sequence, BufferExtraData &bedata) = 0;
41 
42     virtual GSError FlushBuffer(int32_t sequence, BufferExtraData &bedata,
43                                      int32_t fence, BufferFlushConfig &config) = 0;
44 
45     virtual GSError AttachBuffer(sptr<SurfaceBuffer>& buffer) = 0;
46     virtual GSError DetachBuffer(sptr<SurfaceBuffer>& buffer) = 0;
47 
48     virtual uint32_t GetQueueSize() = 0;
49     virtual GSError SetQueueSize(uint32_t queueSize) = 0;
50 
51     virtual GSError GetName(std::string &name) = 0;
52 
53     virtual int32_t GetDefaultWidth() = 0;
54     virtual int32_t GetDefaultHeight() = 0;
55     virtual uint32_t GetDefaultUsage() = 0;
56 
57     virtual uint64_t GetUniqueId() = 0;
58     virtual GSError CleanCache() = 0;
59 
60     virtual GSError RegisterReleaseListener(OnReleaseFunc func) = 0;
61 
62     DECLARE_INTERFACE_DESCRIPTOR(u"surf.IBufferProducer");
63 
64 protected:
65     enum {
66         BUFFER_PRODUCER_REQUEST_BUFFER = 0,
67         BUFFER_PRODUCER_CANCEL_BUFFER = 1,
68         BUFFER_PRODUCER_FLUSH_BUFFER = 2,
69         BUFFER_PRODUCER_GET_QUEUE_SIZE = 3,
70         BUFFER_PRODUCER_SET_QUEUE_SIZE = 4,
71         BUFFER_PRODUCER_GET_NAME = 5,
72         BUFFER_PRODUCER_GET_DEFAULT_WIDTH = 6,
73         BUFFER_PRODUCER_GET_DEFAULT_HEIGHT = 7,
74         BUFFER_PRODUCER_GET_DEFAULT_USAGE = 8,
75         BUFFER_PRODUCER_CLEAN_CACHE = 9,
76         BUFFER_PRODUCER_ATTACH_BUFFER = 10,
77         BUFFER_PRODUCER_DETACH_BUFFER = 11,
78         BUFFER_PRODUCER_REGISTER_RELEASE_LISTENER = 12,
79         BUFFER_PRODUCER_GET_UNIQUE_ID = 13,
80     };
81 };
82 } // namespace OHOS
83 
84 #endif // INTERFACES_INNERKITS_SURFACE_IBUFFER_PRODUCER_H
85