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"
23
22
#include "mir/graphics/display_buffer.h"
24
23
#include "mir/graphics/egl_resources.h"
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);
51
EGLSurface create_surface(mga::AndroidFramebufferWindowQuery& native_window,
52
EGLDisplay egl_display)
49
EGLSurface create_surface(EGLDisplay egl_display,
51
EGLNativeWindowType native_win)
54
auto egl_config = native_window.android_display_egl_config(egl_display);
55
auto native_win_type = native_window.android_native_window_type();
57
return eglCreateWindowSurface(egl_display, egl_config, native_win_type, NULL);
53
return eglCreateWindowSurface(egl_display, egl_config, native_win, NULL);
60
56
class GPUDisplayBuffer : public mg::DisplayBuffer
63
GPUDisplayBuffer(std::shared_ptr<mga::AndroidFramebufferWindowQuery> const& native_window,
59
GPUDisplayBuffer(std::shared_ptr<ANativeWindow> const& native_window,
64
60
EGLDisplay egl_display,
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())},
76
74
geom::Rectangle view_area() const
78
return {geom::Point{}, support_provider->display_size()};
76
return {geom::Point{}, display_device->display_size()};
81
79
void make_current()
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;
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;
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)
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);