Mir
android_native_buffer.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 
19 #ifndef MIR_GRAPHICS_ANDROID_ANDROID_NATIVE_BUFFER_H_
20 #define MIR_GRAPHICS_ANDROID_ANDROID_NATIVE_BUFFER_H_
21 
22 #include "native_buffer.h"
23 #include <memory>
24 #include <mutex>
25 
26 namespace mir
27 {
28 namespace graphics
29 {
30 class CommandStreamSync;
31 namespace android
32 {
33 class Fence;
34 
36 {
38  std::shared_ptr<ANativeWindowBuffer> const& handle,
39  std::shared_ptr<CommandStreamSync> const& cmdstream_sync,
40  std::shared_ptr<Fence> const& fence,
41  BufferAccess fence_access);
42 
43  ANativeWindowBuffer* anwb() const;
44  buffer_handle_t handle() const;
45  NativeFence copy_fence() const;
46 
48  void update_usage(NativeFence& merge_fd, BufferAccess);
49 
50  void lock_for_gpu();
52 
53 private:
54  std::shared_ptr<CommandStreamSync> cmdstream_sync;
55  std::shared_ptr<Fence> fence;
56  BufferAccess access;
57  std::shared_ptr<ANativeWindowBuffer> native_window_buffer;
58 };
59 
60 struct RefCountedNativeBuffer : public ANativeWindowBuffer
61 {
62  RefCountedNativeBuffer(std::shared_ptr<const native_handle_t> const& handle);
63 
64  void driver_reference();
65  void driver_dereference();
66  void mir_dereference();
67 private:
68  ~RefCountedNativeBuffer() = default;
69 
70  std::shared_ptr<const native_handle_t> const handle_resource;
71 
72  std::mutex mutex;
73  bool mir_reference;
74  int driver_references;
75 };
76 
77 }
78 }
79 }
80 
81 #endif /* MIR_GRAPHICS_ANDROID_ANDROID_NATIVE_BUFFER_H_ */
All things Mir.
Definition: atomic_callback.h:25
BufferAccess
Definition: native_buffer.h:37
NativeFence copy_fence() const
Definition: android_native_buffer.cpp:60
void wait_for_unlock_by_gpu()
Definition: android_native_buffer.cpp:70
Definition: android_native_buffer.h:60
void ensure_available_for(BufferAccess)
Definition: android_native_buffer.cpp:36
ANativeWindowBuffer * anwb() const
Definition: android_native_buffer.cpp:50
Definition: native_buffer.h:44
void update_usage(NativeFence &merge_fd, BufferAccess)
Definition: android_native_buffer.cpp:44
Definition: android_native_buffer.h:35
int NativeFence
Definition: fence.h:30
void lock_for_gpu()
Definition: android_native_buffer.cpp:65
buffer_handle_t handle() const
Definition: android_native_buffer.cpp:55
AndroidNativeBuffer(std::shared_ptr< ANativeWindowBuffer > const &handle, std::shared_ptr< CommandStreamSync > const &cmdstream_sync, std::shared_ptr< Fence > const &fence, BufferAccess fence_access)
Definition: android_native_buffer.cpp:24
Definition: android_input_receiver.h:36

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016