Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 namespace android
31 {
32 class Fence;
33 
35 {
37  std::shared_ptr<ANativeWindowBuffer> const& handle,
38  std::shared_ptr<Fence> const& fence,
39  BufferAccess fence_access);
40 
41  ANativeWindowBuffer* anwb() const;
42  buffer_handle_t handle() const;
43  NativeFence copy_fence() const;
44 
46  void update_usage(NativeFence& merge_fd, BufferAccess);
47 
48 private:
49  std::shared_ptr<Fence> fence;
50  BufferAccess access;
51  std::shared_ptr<ANativeWindowBuffer> native_window_buffer;
52 };
53 
54 struct RefCountedNativeBuffer : public ANativeWindowBuffer
55 {
56  RefCountedNativeBuffer(std::shared_ptr<const native_handle_t> const& handle);
57 
58  void driver_reference();
59  void driver_dereference();
60  void mir_dereference();
61 private:
62  ~RefCountedNativeBuffer() = default;
63 
64  std::shared_ptr<const native_handle_t> const handle_resource;
65 
66  std::mutex mutex;
67  bool mir_reference;
68  int driver_references;
69 };
70 
71 }
72 }
73 }
74 
75 #endif /* MIR_GRAPHICS_ANDROID_ANDROID_NATIVE_BUFFER_H_ */
All things Mir.
Definition: aging_buffer.h:24
BufferAccess
Definition: native_buffer.h:32
NativeFence copy_fence() const
Definition: android_native_buffer.cpp:57
Definition: android_native_buffer.h:54
void ensure_available_for(BufferAccess)
Definition: android_native_buffer.cpp:33
ANativeWindowBuffer * anwb() const
Definition: android_native_buffer.cpp:47
Definition: native_buffer.h:39
void update_usage(NativeFence &merge_fd, BufferAccess)
Definition: android_native_buffer.cpp:41
RefCountedNativeBuffer(std::shared_ptr< const native_handle_t > const &handle)
Definition: refcounted_buffer.cpp:65
Definition: android_native_buffer.h:34
int NativeFence
Definition: fence.h:30
void driver_reference()
Definition: refcounted_buffer.cpp:37
buffer_handle_t handle() const
Definition: android_native_buffer.cpp:52
void mir_dereference()
Definition: refcounted_buffer.cpp:54
AndroidNativeBuffer(std::shared_ptr< ANativeWindowBuffer > const &handle, std::shared_ptr< Fence > const &fence, BufferAccess fence_access)
Definition: android_native_buffer.cpp:23
Definition: android_input_receiver.h:32
void driver_dereference()
Definition: refcounted_buffer.cpp:43

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014