Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
framebuffers.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:
17  * Kevin DuBois <kevin.dubois@canonical.com>
18  */
19 
20 #ifndef MIR_GRAPHICS_ANDROID_FB_SIMPLE_SWAPPER_H_
21 #define MIR_GRAPHICS_ANDROID_FB_SIMPLE_SWAPPER_H_
22 
23 #include "framebuffer_bundle.h"
24 
25 #include <hardware/gralloc.h>
26 #include <hardware/fb.h>
27 #include <hardware/hwcomposer.h>
28 #include <condition_variable>
29 #include <queue>
30 #include <vector>
31 #include <mutex>
32 
33 namespace mir
34 {
35 namespace graphics
36 {
37 namespace android
38 {
39 class GraphicBufferAllocator;
40 
42 {
43 public:
44  Framebuffers(std::shared_ptr<GraphicBufferAllocator> const& buffer_allocator,
45  std::shared_ptr<hwc_composer_device_1> const& hwc, unsigned int num_framebuffers);
46  Framebuffers(std::shared_ptr<GraphicBufferAllocator> const& buffer_allocator,
47  std::shared_ptr<framebuffer_device_t> const& fb);
48 
51  double fb_refresh_rate();
52  std::shared_ptr<Buffer> buffer_for_render();
53  std::shared_ptr<Buffer> last_rendered_buffer();
54  void wait_for_consumed_buffer(bool);
55 
56 private:
57  MirPixelFormat const format;
58  geometry::Size size;
59  double refresh_rate_hz;
60 
61  std::mutex queue_lock;
62  std::shared_ptr<Buffer> buffer_being_rendered;
63  std::condition_variable cv;
64  std::queue<std::shared_ptr<graphics::Buffer>> queue;
65 };
66 
67 }
68 }
69 }
70 
71 #endif /* MIR_GRAPHICS_ANDROID_FB_SIMPLE_SWAPPER_H_ */
Definition: size.h:30
All things Mir.
Definition: aging_buffer.h:24
std::shared_ptr< Buffer > buffer_for_render()
Definition: framebuffers.cpp:150
Definition: framebuffers.h:41
geometry::Size fb_size()
Definition: framebuffers.cpp:140
Framebuffers(std::shared_ptr< GraphicBufferAllocator > const &buffer_allocator, std::shared_ptr< hwc_composer_device_1 > const &hwc, unsigned int num_framebuffers)
std::shared_ptr< Buffer > last_rendered_buffer()
Definition: framebuffers.cpp:170
Definition: framebuffer_bundle.h:36
double fb_refresh_rate()
Definition: framebuffers.cpp:145
MirPixelFormat
The order of components in a format enum matches the order of the components as they would be written...
Definition: common.h:119
Definition: android_input_receiver.h:32
void wait_for_consumed_buffer(bool)
Definition: framebuffers.cpp:176
MirPixelFormat fb_format()
Definition: framebuffers.cpp:136

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