• 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 FRAMEWORKS_WM_INCLUDE_WL_BUFFER_H
17 #define FRAMEWORKS_WM_INCLUDE_WL_BUFFER_H
18 
19 #include <map>
20 
21 #include <linux-explicit-synchronization-unstable-v1-client-protocol.h>
22 #include <refbase.h>
23 #include <wayland-client-protocol.h>
24 
25 namespace OHOS {
26 class IWlBufferReleaseClazz {
27 public:
28     virtual void OnWlBufferRelease(struct wl_buffer *buffer, int32_t fence) = 0;
29 };
30 
31 class WlBuffer : public RefBase {
32 public:
33     WlBuffer(struct wl_buffer *wb);
34     virtual ~WlBuffer() override;
35 
36     struct wl_buffer *GetRawPtr() const;
37 
38     void SetBufferRelease(struct zwp_linux_buffer_release_v1 *br);
39     void OnRelease(IWlBufferReleaseClazz *func);
40 
41 protected:
42     struct wl_buffer *buffer = nullptr;
43     struct zwp_linux_buffer_release_v1 *release = nullptr;
44     IWlBufferReleaseClazz *onRelease = nullptr;
45 
46 private:
47     static void Release(void *, struct wl_buffer *buffer);
48     static void FencedRelease(void *, struct zwp_linux_buffer_release_v1 *release, int32_t fence);
49     static void ImmediateRelease(void *, struct zwp_linux_buffer_release_v1 *release);
50 };
51 } // namespace OHOS
52 
53 #endif // FRAMEWORKS_WM_INCLUDE_WL_BUFFER_H
54