Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups 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 
34 struct AndroidNativeBuffer : public graphics::NativeBuffer
35 {
36  AndroidNativeBuffer(std::shared_ptr<ANativeWindowBuffer> const& handle,
37  std::shared_ptr<Fence> const& fence);
38 
39  ANativeWindowBuffer* anwb() const;
40  buffer_handle_t handle() const;
41  NativeFence copy_fence() const;
42 
43  void wait_for_content();
44  void update_fence(NativeFence& merge_fd);
45 
46 private:
47  std::shared_ptr<Fence> fence;
48  std::shared_ptr<ANativeWindowBuffer> native_window_buffer;
49 };
50 
51 struct RefCountedNativeBuffer : public ANativeWindowBuffer
52 {
53  RefCountedNativeBuffer(std::shared_ptr<const native_handle_t> const& handle);
54 
55  void driver_reference();
56  void driver_dereference();
57  void mir_dereference();
58 private:
59  ~RefCountedNativeBuffer() = default;
60 
61  std::shared_ptr<const native_handle_t> const handle_resource;
62 
63  std::mutex mutex;
64  bool mir_reference;
65  int driver_references;
66 };
67 
68 }
69 }
70 }
71 
72 #endif /* MIR_GRAPHICS_ANDROID_ANDROID_NATIVE_BUFFER_H_ */

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Oct 15 00:23:28 UTC 2013