Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
buffer.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012,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 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 General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by:
17  * Kevin DuBois <kevin.dubois@canonical.com>
18  */
19 
20 #ifndef MIR_GRAPHICS_ANDROID_BUFFER_H_
21 #define MIR_GRAPHICS_ANDROID_BUFFER_H_
22 
24 #include "buffer_usage.h"
25 
26 #include <mutex>
27 #include <condition_variable>
28 #include <map>
29 
30 #define GL_GLEXT_PROTOTYPES
31 #define EGL_EGLEXT_PROTOTYPES
32 #include <EGL/egl.h>
33 #include <EGL/eglext.h>
34 
35 namespace mir
36 {
37 namespace graphics
38 {
39 struct EGLExtensions;
40 namespace android
41 {
42 
43 class Buffer: public BufferBasic
44 {
45 public:
46  Buffer(std::shared_ptr<NativeBuffer> const& buffer_handle,
47  std::shared_ptr<EGLExtensions> const& extensions);
48  ~Buffer();
49 
50  geometry::Size size() const;
51  geometry::Stride stride() const;
52  geometry::PixelFormat pixel_format() const;
53  void bind_to_texture();
54  bool can_bypass() const override;
55 
56  //note, you will get the native representation of an android buffer, including
57  //the fences associated with the buffer. You must close these fences
58  std::shared_ptr<NativeBuffer> native_buffer_handle() const;
59 
60 private:
61  std::mutex mutable content_lock;
62 
63  std::map<EGLDisplay,EGLImageKHR> egl_image_map;
64 
65  std::shared_ptr<NativeBuffer> native_buffer;
66  std::shared_ptr<EGLExtensions> egl_extensions;
67 };
68 
69 }
70 }
71 }
72 
73 #endif /* MIR_GRAPHICS_ANDROID_BUFFER_H_ */

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