~ubuntu-branches/ubuntu/vivid/mir/vivid

« back to all changes in this revision

Viewing changes to src/platform/graphics/android/buffer.h

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-01-08 02:04:38 UTC
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: package-import@ubuntu.com-20140108020438-e1npu0pm7qdv5wc4
Tags: upstream-0.1.3+14.04.20140108
Import upstream version 0.1.3+14.04.20140108

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 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_BUFFER_H_
 
21
#define MIR_GRAPHICS_ANDROID_BUFFER_H_
 
22
 
 
23
#include "mir/graphics/buffer_basic.h"
 
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
    MirPixelFormat 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_ */