~kdub/mir/mali-client-render-support

« back to all changes in this revision

Viewing changes to src/server/graphics/android/display_buffer_factory.cpp

  • Committer: Kevin DuBois
  • Date: 2013-11-05 21:44:14 UTC
  • mfrom: (1062.1.137 dev)
  • Revision ID: kevin.dubois@canonical.com-20131105214414-d32r52joqrs8tsmo
merge dev branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 */
18
18
 
19
19
#include "display_buffer_factory.h"
20
 
#include "android_framebuffer_window_query.h"
21
 
#include "display_support_provider.h"
 
20
#include "display_device.h"
22
21
 
23
22
#include "mir/graphics/display_buffer.h"
24
23
#include "mir/graphics/egl_resources.h"
33
32
namespace
34
33
{
35
34
 
36
 
EGLContext create_context(mga::AndroidFramebufferWindowQuery& native_window,
37
 
                          EGLDisplay egl_display,
 
35
EGLContext create_context(EGLDisplay egl_display,
 
36
                          EGLConfig egl_config,
38
37
                          EGLContext egl_context_shared)
39
38
{
40
39
    static EGLint const default_egl_context_attr[] =
43
42
        EGL_NONE
44
43
    };
45
44
 
46
 
    auto egl_config = native_window.android_display_egl_config(egl_display);
47
45
    return eglCreateContext(egl_display, egl_config, egl_context_shared,
48
46
                            default_egl_context_attr);
49
47
}
50
48
 
51
 
EGLSurface create_surface(mga::AndroidFramebufferWindowQuery& native_window,
52
 
                          EGLDisplay egl_display)
 
49
EGLSurface create_surface(EGLDisplay egl_display,
 
50
                          EGLConfig egl_config,
 
51
                          EGLNativeWindowType native_win)
53
52
{
54
 
    auto egl_config = native_window.android_display_egl_config(egl_display);
55
 
    auto native_win_type = native_window.android_native_window_type();
56
 
 
57
 
    return eglCreateWindowSurface(egl_display, egl_config, native_win_type, NULL);
 
53
    return eglCreateWindowSurface(egl_display, egl_config, native_win, NULL);
58
54
}
59
55
 
60
56
class GPUDisplayBuffer : public mg::DisplayBuffer
61
57
{
62
58
public:
63
 
    GPUDisplayBuffer(std::shared_ptr<mga::AndroidFramebufferWindowQuery> const& native_window,
 
59
    GPUDisplayBuffer(std::shared_ptr<ANativeWindow> const& native_window,
64
60
                     EGLDisplay egl_display,
 
61
                     EGLConfig egl_config,
65
62
                     EGLContext egl_context_shared,
66
 
                     std::shared_ptr<mga::DisplaySupportProvider> const& support_provider)
 
63
                     std::shared_ptr<mga::DisplayDevice> const& display_device)
67
64
        : native_window{native_window},
68
 
          support_provider{support_provider},
 
65
          display_device{display_device},
69
66
          egl_display{egl_display},
70
 
          egl_context{egl_display, create_context(*native_window, egl_display, egl_context_shared)},
71
 
          egl_surface{egl_display, create_surface(*native_window, egl_display)},
 
67
          egl_config{egl_config},
 
68
          egl_context{egl_display, create_context(egl_display, egl_config, egl_context_shared)},
 
69
          egl_surface{egl_display, create_surface(egl_display, egl_config, native_window.get())},
72
70
          blanked(false)
73
71
    {
74
72
    }
75
73
 
76
74
    geom::Rectangle view_area() const
77
75
    {
78
 
        return {geom::Point{}, support_provider->display_size()};
 
76
        return {geom::Point{}, display_device->display_size()};
79
77
    }
80
78
 
81
79
    void make_current()
95
93
 
96
94
    void post_update()
97
95
    {
98
 
        support_provider->commit_frame(egl_display, egl_surface);
 
96
        display_device->commit_frame(egl_display, egl_surface);
99
97
    }
100
98
 
101
99
    bool can_bypass() const override
104
102
    }
105
103
    
106
104
protected:
107
 
    std::shared_ptr<mga::AndroidFramebufferWindowQuery> const native_window;
108
 
    std::shared_ptr<mga::DisplaySupportProvider> const support_provider;
 
105
    std::shared_ptr<ANativeWindow> const native_window;
 
106
 
 
107
    std::shared_ptr<mga::DisplayDevice> const display_device;
109
108
    EGLDisplay const egl_display;
 
109
    EGLConfig const egl_config;
110
110
    mg::EGLContextStore const egl_context;
111
111
    mg::EGLSurfaceStore const egl_surface;
112
112
    bool blanked;
 
113
 
113
114
};
114
115
 
115
116
}
116
117
 
117
118
std::unique_ptr<mg::DisplayBuffer> mga::DisplayBufferFactory::create_display_buffer(
118
 
    std::shared_ptr<AndroidFramebufferWindowQuery> const& native_window,
119
 
    std::shared_ptr<DisplaySupportProvider> const& hwc_device,
120
 
    EGLDisplay egl_display,
 
119
    std::shared_ptr<ANativeWindow> const& native_window,
 
120
    std::shared_ptr<DisplayDevice> const& display_device,
 
121
    EGLDisplay egl_display, EGLConfig egl_config,
121
122
    EGLContext egl_context_shared)
122
123
{
123
 
    auto raw = new GPUDisplayBuffer(native_window, egl_display, egl_context_shared, hwc_device);
 
124
    auto raw = new GPUDisplayBuffer(
 
125
        native_window, egl_display, egl_config, egl_context_shared, display_device);
124
126
    return std::unique_ptr<mg::DisplayBuffer>(raw);
125
127
}