Mir

Merge lp:~afrantzis/mir/texture-bindable-over-native-buffer-base into lp:mir

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Cemil Azizoglu
Approved revision: no longer in the source branch.
Merged at revision: 2911
Proposed branch: lp:~afrantzis/mir/texture-bindable-over-native-buffer-base
Merge into: lp:mir
Prerequisite: lp:~afrantzis/mir/update-mirplatform-abi-standalone
Diff against target: 942 lines (+312/-56)
33 files modified
examples/CMakeLists.txt (+2/-0)
examples/buffer_render_target.cpp (+7/-1)
examples/server_example_adorning_compositor.cpp (+12/-1)
include/platform/mir/graphics/buffer.h (+0/-1)
src/platform/symbols.map (+0/-1)
src/platforms/CMakeLists.txt (+1/-0)
src/platforms/android/server/buffer.h (+3/-1)
src/platforms/mesa/server/common/gbm_buffer.h (+3/-1)
src/platforms/mesa/server/common/shm_buffer.h (+3/-1)
src/renderers/gl/include/mir/renderer/gl/texture_source.h (+46/-0)
src/server/compositor/CMakeLists.txt (+4/-0)
src/server/compositor/recently_used_cache.cpp (+11/-1)
src/server/compositor/screencast_display_buffer.cpp (+8/-2)
src/server/compositor/screencast_display_buffer.h (+2/-0)
src/server/compositor/temporary_buffers.cpp (+0/-5)
src/server/compositor/temporary_buffers.h (+0/-1)
src/server/scene/CMakeLists.txt (+4/-0)
src/server/scene/gl_pixel_buffer.cpp (+7/-1)
tests/CMakeLists.txt (+1/-0)
tests/include/mir/test/doubles/mock_buffer.h (+0/-1)
tests/include/mir/test/doubles/mock_gl_buffer.h (+45/-0)
tests/include/mir/test/doubles/stub_buffer.h (+0/-1)
tests/include/mir/test/doubles/stub_gl_buffer.h (+45/-0)
tests/include/mir/test/doubles/stub_gl_buffer_allocator.h (+45/-0)
tests/integration-tests/graphics/mesa/test_buffer_integration.cpp (+12/-3)
tests/integration-tests/test_session.cpp (+21/-1)
tests/unit-tests/compositor/test_compositing_screencast.cpp (+6/-6)
tests/unit-tests/compositor/test_gl_renderer.cpp (+3/-3)
tests/unit-tests/compositor/test_gl_texture_cache.cpp (+4/-3)
tests/unit-tests/compositor/test_screencast_display_buffer.cpp (+8/-8)
tests/unit-tests/compositor/test_temporary_buffers.cpp (+0/-9)
tests/unit-tests/graphics/mesa/kms/test_gbm_buffer.cpp (+7/-2)
tests/unit-tests/scene/test_gl_pixel_buffer.cpp (+2/-2)
To merge this branch: bzr merge lp:~afrantzis/mir/texture-bindable-over-native-buffer-base
Reviewer Review Type Date Requested Status
Cemil Azizoglu (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Kevin DuBois (community) Approve
Alan Griffiths Abstain
Review via email: mp+269739@code.launchpad.net

Commit message

platform: Move gl_bind_to_texture method from Buffer to mir::renderer::gl::TextureBindable

Description of the change

platform: Move gl_bind_to_texture method from Buffer to mir::renderer::gl::TextureBindable

This MP makes the Buffer class agnostic of rendering technology, by moving the gl_bind_to_buffer() method to a renderer specific interface (TextureBindable). This interface is implemented by the native buffer types and accessed by components that need it by dynamically casting Buffer::native_buffer_base() to it. This will hopefully give an idea to the team about how other renderer types are expected to function.

The definition of TextureBindable will eventually be made public (e.g. shipped in a mir-renderer-gl-dev package), so I have made it accessible from most of the non-core codebase (tests and examples). The core (libmirserver), however, should not be aware of the rendering-specific technologies, so I've tried to limit exposure to TextureBindable only to parts that currently need it (e.g. scene, compositor). These components will be eventually cleaned to remove this dependency.

Next steps involve isolating the GL dependencies from our core, so they can be moved into a different shared object (i.e. plugin).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Failure is caused problem in parent branch, which has now been fixed. Rebuilding.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

@Cemil

> 1) src/renderers/gl/include/mir/renderer/gl/texture_bindable.h
> Do we need both 'gl's in the path?

Yes, so that files can '#include <mir/renderer/gl/texture_bindable.h> regardless of whether they are building from inside the mir tree or outside of it.

> 2) Have you built and tested with mesa-x11 as the first platform on the list?

Yes, works fine.

@Alan

> I'd be happier with putting the header under include and making it public than
> having this "temporary" solution.

The header placement is not a temporary solution, only the dependency of core components on the gl renderer is temporary.

The reason I've kept the header inside src/renderers/gl is because I want to treat the renderers in src/renderers/* as independent/isolated plug-in components, that could conceptually be moved out of tree, like we did with the platforms a while back [1]. The idea is that there should be no dependency on the renderer from the mir core side, and the renderers should only depend on public mir interfaces. We are not there yet, hence the exceptions for the scene and compositor components, which will be eventually removed.

You could argue that placing the header in, e.g., include/renderers/mir/renderer/gl/ is more consistent with the current project structure, and I agree, but that's also what I want to avoid in order to stress the independence of the renderers and their renderer-specific public headers from the rest of the project.

[1] For example see src/platforms/mesa/include/... which contains platform specific client headers shipped in mir-client-platform-mesa-dev

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> You could argue that placing the header in, e.g.,
> include/renderers/mir/renderer/gl/ is more consistent with the current project
> structure, and I agree, but that's also what I want to avoid in order to
> stress the independence of the renderers and their renderer-specific public
> headers from the rest of the project.

I so argue.

> [1] For example see src/platforms/mesa/include/... which contains platform
> specific client headers shipped in mir-client-platform-mesa-dev

I don't like that either. Burying "public" header files under ./src is confusing.

Abstaining because there's a precedent for this approach.

review: Abstain
Revision history for this message
Kevin DuBois (kdub) wrote :

224 +class TextureBindable
seems like its just a Texture

LGTM otherwise, needs-info/discussion on TextureBindable->Texture

review: Needs Information
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> 224 +class TextureBindable
> seems like its just a Texture

I don't know... Texture::gl_bind_to_texture() sounds incorrect since if we are a texture why do we need to bind to one?

Texture::bind_to_gl_texture() sounds a bit better, since it implies that there is a generic Texture entity (the object) and a separate but related entity "gl texture" that the Texture object can be bound to.

Another alternative TextureSource::(gl_)bind_to_(gl_)texture()

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

> > 224 +class TextureBindable
> > seems like its just a Texture
>
> I don't know... Texture::gl_bind_to_texture() sounds incorrect since if we are
> a texture why do we need to bind to one?
>
> Texture::bind_to_gl_texture() sounds a bit better, since it implies that there
> is a generic Texture entity (the object) and a separate but related entity "gl
> texture" that the Texture object can be bound to.
>
> Another alternative TextureSource::(gl_)bind_to_(gl_)texture()

I like TextureSource (or TextureContent) better than TextureBindable. (pre-approve)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> > Another alternative TextureSource::(gl_)bind_to_(gl_)texture()
>
> I like TextureSource (or TextureContent) better than TextureBindable. (pre-approve)

Renamed to TextureSource.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

ok

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/CMakeLists.txt'
--- examples/CMakeLists.txt 2015-08-12 09:52:57 +0000
+++ examples/CMakeLists.txt 2015-09-04 06:51:35 +0000
@@ -3,6 +3,7 @@
3 buffer_render_target.cpp3 buffer_render_target.cpp
4 image_renderer.cpp4 image_renderer.cpp
5)5)
6
6target_link_libraries(mir_demo_standalone_render_surfaces7target_link_libraries(mir_demo_standalone_render_surfaces
7 mirserver8 mirserver
8 exampleserverconfig9 exampleserverconfig
@@ -168,6 +169,7 @@
168 ${PROJECT_SOURCE_DIR}/include/server169 ${PROJECT_SOURCE_DIR}/include/server
169 ${PROJECT_SOURCE_DIR}/include/client170 ${PROJECT_SOURCE_DIR}/include/client
170 ${PROJECT_SOURCE_DIR}/include/platform171 ${PROJECT_SOURCE_DIR}/include/platform
172 ${PROJECT_SOURCE_DIR}/src/renderers/gl/include
171 ${GLESv2_INCLUDE_DIRS}173 ${GLESv2_INCLUDE_DIRS}
172)174)
173175
174176
=== modified file 'examples/buffer_render_target.cpp'
--- examples/buffer_render_target.cpp 2015-02-22 07:46:25 +0000
+++ examples/buffer_render_target.cpp 2015-09-04 06:51:35 +0000
@@ -18,6 +18,7 @@
1818
19#include "buffer_render_target.h"19#include "buffer_render_target.h"
20#include "mir/graphics/buffer.h"20#include "mir/graphics/buffer.h"
21#include "mir/renderer/gl/texture_source.h"
2122
22#include <GLES2/gl2ext.h>23#include <GLES2/gl2ext.h>
23#include <stdexcept>24#include <stdexcept>
@@ -71,13 +72,18 @@
7172
72 if (fbo == 0)73 if (fbo == 0)
73 {74 {
75 auto const texture_source =
76 dynamic_cast<mir::renderer::gl::TextureSource*>(buffer.native_buffer_base());
77 if (!texture_source)
78 throw std::logic_error("Buffer does not support GL rendering");
79
74 glGenFramebuffers(1, &fbo);80 glGenFramebuffers(1, &fbo);
75 glBindFramebuffer(GL_FRAMEBUFFER, fbo);81 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
7682
77 /* Set up color buffer... */83 /* Set up color buffer... */
78 glGenTextures(1, &color_tex);84 glGenTextures(1, &color_tex);
79 glBindTexture(GL_TEXTURE_2D, color_tex);85 glBindTexture(GL_TEXTURE_2D, color_tex);
80 buffer.gl_bind_to_texture();86 texture_source->gl_bind_to_texture();
81 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,87 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
82 GL_TEXTURE_2D, color_tex, 0);88 GL_TEXTURE_2D, color_tex, 0);
8389
8490
=== modified file 'examples/server_example_adorning_compositor.cpp'
--- examples/server_example_adorning_compositor.cpp 2015-04-07 13:19:22 +0000
+++ examples/server_example_adorning_compositor.cpp 2015-09-04 06:51:35 +0000
@@ -20,6 +20,11 @@
20#include "mir/graphics/display_buffer.h"20#include "mir/graphics/display_buffer.h"
21#include "mir/graphics/buffer.h"21#include "mir/graphics/buffer.h"
22#include "mir/compositor/scene_element.h"22#include "mir/compositor/scene_element.h"
23#include "mir/renderer/gl/texture_source.h"
24
25#include <stdexcept>
26#include <boost/throw_exception.hpp>
27
23#include <GLES2/gl2.h>28#include <GLES2/gl2.h>
2429
25namespace me = mir::examples;30namespace me = mir::examples;
@@ -150,7 +155,13 @@
150155
151 glActiveTexture(GL_TEXTURE0);156 glActiveTexture(GL_TEXTURE0);
152 glBindTexture(GL_TEXTURE_2D, texture);157 glBindTexture(GL_TEXTURE_2D, texture);
153 renderable->buffer()->gl_bind_to_texture();158
159 auto const texture_source =
160 dynamic_cast<mir::renderer::gl::TextureSource*>(
161 renderable->buffer()->native_buffer_base());
162 if (!texture_source)
163 BOOST_THROW_EXCEPTION(std::logic_error("Buffer does not support GL rendering"));
164 texture_source->gl_bind_to_texture();
154165
155 glEnableVertexAttribArray(vPositionAttr);166 glEnableVertexAttribArray(vPositionAttr);
156 glEnableVertexAttribArray(uvCoord);167 glEnableVertexAttribArray(uvCoord);
157168
=== modified file 'include/platform/mir/graphics/buffer.h'
--- include/platform/mir/graphics/buffer.h 2015-08-27 13:41:02 +0000
+++ include/platform/mir/graphics/buffer.h 2015-09-04 06:51:35 +0000
@@ -51,7 +51,6 @@
51 virtual geometry::Size size() const = 0;51 virtual geometry::Size size() const = 0;
52 virtual geometry::Stride stride() const = 0;52 virtual geometry::Stride stride() const = 0;
53 virtual MirPixelFormat pixel_format() const = 0;53 virtual MirPixelFormat pixel_format() const = 0;
54 virtual void gl_bind_to_texture() = 0;
55 //FIXME: correct mg::Buffer::write, it requires that the user does too much to use it correctly,54 //FIXME: correct mg::Buffer::write, it requires that the user does too much to use it correctly,
56 // (ie, it forces them to figure out what size is proper, alloc a buffer, fill it, and then55 // (ie, it forces them to figure out what size is proper, alloc a buffer, fill it, and then
57 // copy the data into the buffer)56 // copy the data into the buffer)
5857
=== modified file 'src/platform/symbols.map'
--- src/platform/symbols.map 2015-09-04 06:51:35 +0000
+++ src/platform/symbols.map 2015-09-04 06:51:35 +0000
@@ -5,7 +5,6 @@
5# ../tools/process_doxygen_xml.py doc/xml/*.xml | grep "^mirplatform public" | sed "s/mirplatform public: / /" | sort 5# ../tools/process_doxygen_xml.py doc/xml/*.xml | grep "^mirplatform public" | sed "s/mirplatform public: / /" | sort
6 mir::graphics::BufferBasic::BufferBasic*;6 mir::graphics::BufferBasic::BufferBasic*;
7 mir::graphics::Buffer::Buffer*;7 mir::graphics::Buffer::Buffer*;
8 mir::graphics::Buffer::gl_bind_to_texture*;
9 mir::graphics::Buffer::id*;8 mir::graphics::Buffer::id*;
10 mir::graphics::Buffer::native_buffer_base*;9 mir::graphics::Buffer::native_buffer_base*;
11 mir::graphics::Buffer::native_buffer_handle*;10 mir::graphics::Buffer::native_buffer_handle*;
1211
=== modified file 'src/platforms/CMakeLists.txt'
--- src/platforms/CMakeLists.txt 2015-09-04 06:51:35 +0000
+++ src/platforms/CMakeLists.txt 2015-09-04 06:51:35 +0000
@@ -27,6 +27,7 @@
2727
28set(server_common_include_dirs28set(server_common_include_dirs
29 ${PROJECT_SOURCE_DIR}/include/platform29 ${PROJECT_SOURCE_DIR}/include/platform
30 ${PROJECT_SOURCE_DIR}/src/renderers/gl/include
30)31)
3132
32# TODO platform implementations shouldn't depend on private APIs33# TODO platform implementations shouldn't depend on private APIs
3334
=== modified file 'src/platforms/android/server/buffer.h'
--- src/platforms/android/server/buffer.h 2015-08-27 13:41:02 +0000
+++ src/platforms/android/server/buffer.h 2015-09-04 06:51:35 +0000
@@ -21,6 +21,7 @@
21#define MIR_GRAPHICS_ANDROID_BUFFER_H_21#define MIR_GRAPHICS_ANDROID_BUFFER_H_
2222
23#include "mir/graphics/buffer_basic.h"23#include "mir/graphics/buffer_basic.h"
24#include "mir/renderer/gl/texture_source.h"
24#include "buffer_usage.h"25#include "buffer_usage.h"
2526
26#include <hardware/gralloc.h>27#include <hardware/gralloc.h>
@@ -42,7 +43,8 @@
42namespace android43namespace android
43{44{
4445
45class Buffer: public BufferBasic, public NativeBufferBase46class Buffer: public BufferBasic, public NativeBufferBase,
47 public renderer::gl::TextureSource
46{48{
47public:49public:
48 Buffer(gralloc_module_t const* hw_module,50 Buffer(gralloc_module_t const* hw_module,
4951
=== modified file 'src/platforms/mesa/server/common/gbm_buffer.h'
--- src/platforms/mesa/server/common/gbm_buffer.h 2015-08-27 13:41:02 +0000
+++ src/platforms/mesa/server/common/gbm_buffer.h 2015-09-04 06:51:35 +0000
@@ -21,6 +21,7 @@
21#define MIR_GRAPHICS_MESA_GBM_BUFFER_H_21#define MIR_GRAPHICS_MESA_GBM_BUFFER_H_
2222
23#include "mir/graphics/buffer_basic.h"23#include "mir/graphics/buffer_basic.h"
24#include "mir/renderer/gl/texture_source.h"
2425
25#include <gbm.h>26#include <gbm.h>
2627
@@ -45,7 +46,8 @@
4546
46class BufferTextureBinder;47class BufferTextureBinder;
4748
48class GBMBuffer: public BufferBasic, public NativeBufferBase49class GBMBuffer: public BufferBasic, public NativeBufferBase,
50 public renderer::gl::TextureSource
49{51{
50public:52public:
51 GBMBuffer(std::shared_ptr<gbm_bo> const& handle,53 GBMBuffer(std::shared_ptr<gbm_bo> const& handle,
5254
=== modified file 'src/platforms/mesa/server/common/shm_buffer.h'
--- src/platforms/mesa/server/common/shm_buffer.h 2015-08-27 13:41:02 +0000
+++ src/platforms/mesa/server/common/shm_buffer.h 2015-09-04 06:51:35 +0000
@@ -24,6 +24,7 @@
24#include "mir/geometry/dimensions.h"24#include "mir/geometry/dimensions.h"
25#include "mir/geometry/size.h"25#include "mir/geometry/size.h"
26#include "mir_toolkit/common.h"26#include "mir_toolkit/common.h"
27#include "mir/renderer/gl/texture_source.h"
2728
28namespace mir29namespace mir
29{30{
@@ -34,7 +35,8 @@
3435
35class ShmFile;36class ShmFile;
3637
37class ShmBuffer : public BufferBasic, public NativeBufferBase38class ShmBuffer : public BufferBasic, public NativeBufferBase,
39 public renderer::gl::TextureSource
38{40{
39public:41public:
40 static bool supports(MirPixelFormat);42 static bool supports(MirPixelFormat);
4143
=== added directory 'src/renderers'
=== added directory 'src/renderers/gl'
=== added directory 'src/renderers/gl/include'
=== added directory 'src/renderers/gl/include/mir'
=== added directory 'src/renderers/gl/include/mir/renderer'
=== added directory 'src/renderers/gl/include/mir/renderer/gl'
=== added file 'src/renderers/gl/include/mir/renderer/gl/texture_source.h'
--- src/renderers/gl/include/mir/renderer/gl/texture_source.h 1970-01-01 00:00:00 +0000
+++ src/renderers/gl/include/mir/renderer/gl/texture_source.h 2015-09-04 06:51:35 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright © 2015 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: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#ifndef MIR_RENDERER_GL_TEXTURE_SOURCE_H_
20#define MIR_RENDERER_GL_TEXTURE_SOURCE_H_
21
22namespace mir
23{
24namespace renderer
25{
26namespace gl
27{
28
29class TextureSource
30{
31public:
32 virtual ~TextureSource() = default;
33
34 virtual void gl_bind_to_texture() = 0;
35
36protected:
37 TextureSource() = default;
38 TextureSource(TextureSource const&) = delete;
39 TextureSource& operator=(TextureSource const&) = delete;
40};
41
42}
43}
44}
45
46#endif
047
=== modified file 'src/server/compositor/CMakeLists.txt'
--- src/server/compositor/CMakeLists.txt 2015-08-10 07:14:58 +0000
+++ src/server/compositor/CMakeLists.txt 2015-09-04 06:51:35 +0000
@@ -1,3 +1,7 @@
1include_directories(
2 ${PROJECT_SOURCE_DIR}/src/renderers/gl/include
3)
4
1set(5set(
2 MIR_COMPOSITOR_SRCS6 MIR_COMPOSITOR_SRCS
37
48
=== modified file 'src/server/compositor/recently_used_cache.cpp'
--- src/server/compositor/recently_used_cache.cpp 2015-06-17 05:20:42 +0000
+++ src/server/compositor/recently_used_cache.cpp 2015-09-04 06:51:35 +0000
@@ -19,6 +19,10 @@
1919
20#include "mir/compositor/recently_used_cache.h"20#include "mir/compositor/recently_used_cache.h"
21#include "mir/graphics/buffer.h"21#include "mir/graphics/buffer.h"
22#include "mir/renderer/gl/texture_source.h"
23
24#include <stdexcept>
25#include <boost/throw_exception.hpp>
2226
23namespace mg = mir::graphics;27namespace mg = mir::graphics;
24namespace mc = mir::compositor;28namespace mc = mir::compositor;
@@ -33,7 +37,13 @@
3337
34 if ((texture.last_bound_buffer != buffer_id) || (!texture.valid_binding))38 if ((texture.last_bound_buffer != buffer_id) || (!texture.valid_binding))
35 {39 {
36 buffer->gl_bind_to_texture();40 auto const texture_source =
41 dynamic_cast<mir::renderer::gl::TextureSource*>(
42 buffer->native_buffer_base());
43 if (!texture_source)
44 BOOST_THROW_EXCEPTION(std::logic_error("Buffer does not support GL rendering"));
45
46 texture_source->gl_bind_to_texture();
37 texture.resource = buffer;47 texture.resource = buffer;
38 texture.last_bound_buffer = buffer_id;48 texture.last_bound_buffer = buffer_id;
39 }49 }
4050
=== modified file 'src/server/compositor/screencast_display_buffer.cpp'
--- src/server/compositor/screencast_display_buffer.cpp 2015-06-24 08:17:02 +0000
+++ src/server/compositor/screencast_display_buffer.cpp 2015-09-04 06:51:35 +0000
@@ -28,8 +28,14 @@
28mc::ScreencastDisplayBuffer::ScreencastDisplayBuffer(28mc::ScreencastDisplayBuffer::ScreencastDisplayBuffer(
29 geom::Rectangle const& rect,29 geom::Rectangle const& rect,
30 mg::Buffer& buffer)30 mg::Buffer& buffer)
31 : rect(rect), buffer(buffer), old_fbo(), old_viewport()31 : rect(rect), buffer(buffer),
32 texture_source(
33 dynamic_cast<mir::renderer::gl::TextureSource*>(
34 buffer.native_buffer_base())),
35 old_fbo(), old_viewport()
32{36{
37 if (!texture_source)
38 BOOST_THROW_EXCEPTION(std::logic_error("Buffer does not support GL rendering"));
33 glGetIntegerv(GL_VIEWPORT, old_viewport);39 glGetIntegerv(GL_VIEWPORT, old_viewport);
34 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &old_fbo);40 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &old_fbo);
3541
@@ -68,7 +74,7 @@
68void mc::ScreencastDisplayBuffer::make_current()74void mc::ScreencastDisplayBuffer::make_current()
69{75{
70 glBindTexture(GL_TEXTURE_2D, color_tex);76 glBindTexture(GL_TEXTURE_2D, color_tex);
71 buffer.gl_bind_to_texture();77 texture_source->gl_bind_to_texture();
72 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,78 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
73 GL_TEXTURE_2D, color_tex, 0);79 GL_TEXTURE_2D, color_tex, 0);
7480
7581
=== modified file 'src/server/compositor/screencast_display_buffer.h'
--- src/server/compositor/screencast_display_buffer.h 2015-06-24 08:17:02 +0000
+++ src/server/compositor/screencast_display_buffer.h 2015-09-04 06:51:35 +0000
@@ -20,6 +20,7 @@
20#define MIR_COMPOSITOR_SCREENCAST_DISPLAY_BUFFER_H_20#define MIR_COMPOSITOR_SCREENCAST_DISPLAY_BUFFER_H_
2121
22#include "mir/graphics/display_buffer.h"22#include "mir/graphics/display_buffer.h"
23#include "mir/renderer/gl/texture_source.h"
2324
24#include <GLES2/gl2.h>25#include <GLES2/gl2.h>
2526
@@ -68,6 +69,7 @@
68private:69private:
69 geometry::Rectangle const rect;70 geometry::Rectangle const rect;
70 graphics::Buffer& buffer;71 graphics::Buffer& buffer;
72 renderer::gl::TextureSource* texture_source;
71 GLint old_fbo;73 GLint old_fbo;
72 GLint old_viewport[4];74 GLint old_viewport[4];
73 detail::GLResource<glGenTextures,glDeleteTextures> const color_tex;75 detail::GLResource<glGenTextures,glDeleteTextures> const color_tex;
7476
=== modified file 'src/server/compositor/temporary_buffers.cpp'
--- src/server/compositor/temporary_buffers.cpp 2015-08-27 13:41:02 +0000
+++ src/server/compositor/temporary_buffers.cpp 2015-09-04 06:51:35 +0000
@@ -75,11 +75,6 @@
75 return buffer->id();75 return buffer->id();
76}76}
7777
78void mc::TemporaryBuffer::gl_bind_to_texture()
79{
80 buffer->gl_bind_to_texture();
81}
82
83std::shared_ptr<mg::NativeBuffer> mc::TemporaryBuffer::native_buffer_handle() const78std::shared_ptr<mg::NativeBuffer> mc::TemporaryBuffer::native_buffer_handle() const
84{79{
85 return buffer->native_buffer_handle();80 return buffer->native_buffer_handle();
8681
=== modified file 'src/server/compositor/temporary_buffers.h'
--- src/server/compositor/temporary_buffers.h 2015-08-27 13:41:02 +0000
+++ src/server/compositor/temporary_buffers.h 2015-09-04 06:51:35 +0000
@@ -39,7 +39,6 @@
39 geometry::Stride stride() const override;39 geometry::Stride stride() const override;
40 MirPixelFormat pixel_format() const override;40 MirPixelFormat pixel_format() const override;
41 mg::BufferID id() const override;41 mg::BufferID id() const override;
42 void gl_bind_to_texture() override;
43 std::shared_ptr<mg::NativeBuffer> native_buffer_handle() const override;42 std::shared_ptr<mg::NativeBuffer> native_buffer_handle() const override;
44 void write (unsigned char const* data, size_t size) override;43 void write (unsigned char const* data, size_t size) override;
45 void read (std::function<void(unsigned char const*)> const& do_with_pixels) override;44 void read (std::function<void(unsigned char const*)> const& do_with_pixels) override;
4645
=== modified file 'src/server/scene/CMakeLists.txt'
--- src/server/scene/CMakeLists.txt 2015-06-18 04:38:28 +0000
+++ src/server/scene/CMakeLists.txt 2015-09-04 06:51:35 +0000
@@ -1,3 +1,7 @@
1include_directories(
2 ${PROJECT_SOURCE_DIR}/src/renderers/gl/include
3)
4
1ADD_LIBRARY(5ADD_LIBRARY(
2 mirscene OBJECT6 mirscene OBJECT
37
48
=== modified file 'src/server/scene/gl_pixel_buffer.cpp'
--- src/server/scene/gl_pixel_buffer.cpp 2015-02-22 07:46:25 +0000
+++ src/server/scene/gl_pixel_buffer.cpp 2015-09-04 06:51:35 +0000
@@ -19,6 +19,7 @@
19#include "gl_pixel_buffer.h"19#include "gl_pixel_buffer.h"
20#include "mir/graphics/gl_context.h"20#include "mir/graphics/gl_context.h"
21#include "mir/graphics/buffer.h"21#include "mir/graphics/buffer.h"
22#include "mir/renderer/gl/texture_source.h"
2223
23#include <stdexcept>24#include <stdexcept>
24#include <boost/throw_exception.hpp>25#include <boost/throw_exception.hpp>
@@ -103,7 +104,12 @@
103104
104 prepare();105 prepare();
105106
106 buffer.gl_bind_to_texture();107 auto const texture_source =
108 dynamic_cast<mir::renderer::gl::TextureSource*>(
109 buffer.native_buffer_base());
110 if (!texture_source)
111 BOOST_THROW_EXCEPTION(std::logic_error("Buffer does not support GL rendering"));
112 texture_source->gl_bind_to_texture();
107113
108 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);114 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
109115
110116
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2015-07-27 07:24:50 +0000
+++ tests/CMakeLists.txt 2015-09-04 06:51:35 +0000
@@ -54,6 +54,7 @@
54 ${PROJECT_SOURCE_DIR}/include/client54 ${PROJECT_SOURCE_DIR}/include/client
55 ${PROJECT_SOURCE_DIR}/include/common55 ${PROJECT_SOURCE_DIR}/include/common
56 ${PROJECT_SOURCE_DIR}/include/test56 ${PROJECT_SOURCE_DIR}/include/test
57 ${PROJECT_SOURCE_DIR}/src/renderers/gl/include
57)58)
5859
59option(MIR_BUILD_ACCEPTANCE_TESTS "Build acceptance tests" ON)60option(MIR_BUILD_ACCEPTANCE_TESTS "Build acceptance tests" ON)
6061
=== modified file 'tests/include/mir/test/doubles/mock_buffer.h'
--- tests/include/mir/test/doubles/mock_buffer.h 2015-08-27 13:41:02 +0000
+++ tests/include/mir/test/doubles/mock_buffer.h 2015-09-04 06:51:35 +0000
@@ -67,7 +67,6 @@
67 MOCK_CONST_METHOD0(pixel_format, MirPixelFormat());67 MOCK_CONST_METHOD0(pixel_format, MirPixelFormat());
68 MOCK_CONST_METHOD0(native_buffer_handle, std::shared_ptr<graphics::NativeBuffer>());68 MOCK_CONST_METHOD0(native_buffer_handle, std::shared_ptr<graphics::NativeBuffer>());
6969
70 MOCK_METHOD0(gl_bind_to_texture, void());
71 MOCK_CONST_METHOD0(id, graphics::BufferID());70 MOCK_CONST_METHOD0(id, graphics::BufferID());
7271
73 MOCK_METHOD2(write, void(unsigned char const*, size_t));72 MOCK_METHOD2(write, void(unsigned char const*, size_t));
7473
=== added file 'tests/include/mir/test/doubles/mock_gl_buffer.h'
--- tests/include/mir/test/doubles/mock_gl_buffer.h 1970-01-01 00:00:00 +0000
+++ tests/include/mir/test/doubles/mock_gl_buffer.h 2015-09-04 06:51:35 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright © 2015 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: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_MOCK_GL_BUFFER_H_
20#define MIR_TEST_DOUBLES_MOCK_GL_BUFFER_H_
21
22#include "mock_buffer.h"
23#include "mir/renderer/gl/texture_source.h"
24
25namespace mir
26{
27namespace test
28{
29namespace doubles
30{
31
32struct MockGLBuffer : public MockBuffer,
33 public renderer::gl::TextureSource
34{
35 public:
36 using MockBuffer::MockBuffer;
37
38 MOCK_METHOD0(gl_bind_to_texture, void());
39};
40
41}
42}
43}
44
45#endif
046
=== modified file 'tests/include/mir/test/doubles/stub_buffer.h'
--- tests/include/mir/test/doubles/stub_buffer.h 2015-08-27 13:41:02 +0000
+++ tests/include/mir/test/doubles/stub_buffer.h 2015-09-04 06:51:35 +0000
@@ -99,7 +99,6 @@
99 virtual MirPixelFormat pixel_format() const override { return buf_pixel_format; }99 virtual MirPixelFormat pixel_format() const override { return buf_pixel_format; }
100100
101 virtual std::shared_ptr<graphics::NativeBuffer> native_buffer_handle() const override { return native_buffer; }101 virtual std::shared_ptr<graphics::NativeBuffer> native_buffer_handle() const override { return native_buffer; }
102 virtual void gl_bind_to_texture() override {}
103102
104 void write(unsigned char const* pixels, size_t len) override103 void write(unsigned char const* pixels, size_t len) override
105 {104 {
106105
=== added file 'tests/include/mir/test/doubles/stub_gl_buffer.h'
--- tests/include/mir/test/doubles/stub_gl_buffer.h 1970-01-01 00:00:00 +0000
+++ tests/include/mir/test/doubles/stub_gl_buffer.h 2015-09-04 06:51:35 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright © 2015 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: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_STUB_GL_BUFFER_H_
20#define MIR_TEST_DOUBLES_STUB_GL_BUFFER_H_
21
22#include "stub_buffer.h"
23#include "mir/renderer/gl/texture_source.h"
24
25namespace mir
26{
27namespace test
28{
29namespace doubles
30{
31
32class StubGLBuffer : public StubBuffer,
33 public renderer::gl::TextureSource
34{
35public:
36 using StubBuffer::StubBuffer;
37
38 void gl_bind_to_texture() {}
39};
40
41}
42}
43}
44
45#endif
046
=== added file 'tests/include/mir/test/doubles/stub_gl_buffer_allocator.h'
--- tests/include/mir/test/doubles/stub_gl_buffer_allocator.h 1970-01-01 00:00:00 +0000
+++ tests/include/mir/test/doubles/stub_gl_buffer_allocator.h 2015-09-04 06:51:35 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright © 2015 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: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_STUB_GL_BUFFER_ALLOCATOR_H_
20#define MIR_TEST_DOUBLES_STUB_GL_BUFFER_ALLOCATOR_H_
21
22#include "stub_buffer_allocator.h"
23#include "stub_gl_buffer.h"
24
25namespace mir
26{
27namespace test
28{
29namespace doubles
30{
31
32struct StubGLBufferAllocator : public StubBufferAllocator
33{
34 std::shared_ptr<graphics::Buffer> alloc_buffer(
35 graphics::BufferProperties const& properties) override
36 {
37 return std::make_shared<StubGLBuffer>(properties);
38 }
39};
40
41}
42}
43}
44
45#endif
046
=== modified file 'tests/integration-tests/graphics/mesa/test_buffer_integration.cpp'
--- tests/integration-tests/graphics/mesa/test_buffer_integration.cpp 2015-06-25 13:43:43 +0000
+++ tests/integration-tests/graphics/mesa/test_buffer_integration.cpp 2015-09-04 06:51:35 +0000
@@ -28,6 +28,7 @@
28#include "mir/test/doubles/stub_gl_program_factory.h"28#include "mir/test/doubles/stub_gl_program_factory.h"
29#include "mir/test/doubles/null_emergency_cleanup.h"29#include "mir/test/doubles/null_emergency_cleanup.h"
30#include "mir/graphics/default_display_configuration_policy.h"30#include "mir/graphics/default_display_configuration_policy.h"
31#include "mir/renderer/gl/texture_source.h"
31#include "src/server/report/null_report_factory.h"32#include "src/server/report/null_report_factory.h"
3233
33#include "mir_test_framework/testing_server_configuration.h"34#include "mir_test_framework/testing_server_configuration.h"
@@ -46,7 +47,15 @@
46namespace mir47namespace mir
47{48{
4849
49class StubBufferThread : public mtd::StubBuffer50mir::renderer::gl::TextureSource* as_texture_source(
51 std::shared_ptr<mg::Buffer> const& buffer)
52{
53 return dynamic_cast<mir::renderer::gl::TextureSource*>(
54 buffer->native_buffer_base());
55}
56
57class StubBufferThread : public mtd::StubBuffer,
58 public mir::renderer::gl::TextureSource
50{59{
51public:60public:
52 StubBufferThread() :61 StubBufferThread() :
@@ -179,7 +188,7 @@
179188
180 try189 try
181 {190 {
182 buffer->gl_bind_to_texture();191 as_texture_source(buffer)->gl_bind_to_texture();
183 }192 }
184 catch(std::runtime_error const&)193 catch(std::runtime_error const&)
185 {194 {
@@ -211,7 +220,7 @@
211220
212 EXPECT_NO_THROW({221 EXPECT_NO_THROW({
213 auto buffer = allocator->alloc_buffer(buffer_properties);222 auto buffer = allocator->alloc_buffer(buffer_properties);
214 buffer->gl_bind_to_texture();223 as_texture_source(buffer)->gl_bind_to_texture();
215 ASSERT_EQ(EGL_SUCCESS, eglGetError());224 ASSERT_EQ(EGL_SUCCESS, eglGetError());
216225
217 BufferDestructorThread destructor{std::move(buffer)};226 BufferDestructorThread destructor{std::move(buffer)};
218227
=== modified file 'tests/integration-tests/test_session.cpp'
--- tests/integration-tests/test_session.cpp 2015-06-26 08:00:59 +0000
+++ tests/integration-tests/test_session.cpp 2015-09-04 06:51:35 +0000
@@ -30,6 +30,7 @@
30#include "mir/frontend/connector.h"30#include "mir/frontend/connector.h"
3131
32#include "mir/test/doubles/stub_buffer_allocator.h"32#include "mir/test/doubles/stub_buffer_allocator.h"
33#include "mir/test/doubles/stub_gl_buffer.h"
33#include "mir/test/doubles/stub_buffer_stream_factory.h"34#include "mir/test/doubles/stub_buffer_stream_factory.h"
34#include "mir/test/doubles/stub_display.h"35#include "mir/test/doubles/stub_display.h"
35#include "mir/test/doubles/null_event_sink.h"36#include "mir/test/doubles/null_event_sink.h"
@@ -86,6 +87,25 @@
86 cv.wait(lock, [&]{ return done; });87 cv.wait(lock, [&]{ return done; });
87}88}
8889
90struct StubGLBufferStream : public mtd::StubBufferStream
91{
92public:
93 StubGLBufferStream()
94 {
95 stub_compositor_buffer = std::make_shared<mtd::StubGLBuffer>();
96 }
97};
98
99struct StubGLBufferStreamFactory : public mtd::StubBufferStreamFactory
100{
101 std::shared_ptr<mc::BufferStream> create_buffer_stream(
102 mf::BufferStreamId, std::shared_ptr<mf::BufferSink> const&,
103 mg::BufferProperties const&) override
104 {
105 return std::make_shared<StubGLBufferStream>();
106 }
107};
108
89} // anonymouse namespace109} // anonymouse namespace
90110
91TEST(ApplicationSession, stress_test_take_snapshot)111TEST(ApplicationSession, stress_test_take_snapshot)
@@ -97,7 +117,7 @@
97 ms::ApplicationSession session{117 ms::ApplicationSession session{
98 conf.the_surface_coordinator(),118 conf.the_surface_coordinator(),
99 conf.the_surface_factory(),119 conf.the_surface_factory(),
100 std::make_shared<mtd::StubBufferStreamFactory>(),120 std::make_shared<StubGLBufferStreamFactory>(),
101 __LINE__,121 __LINE__,
102 "stress",122 "stress",
103 conf.the_snapshot_strategy(),123 conf.the_snapshot_strategy(),
104124
=== modified file 'tests/unit-tests/compositor/test_compositing_screencast.cpp'
--- tests/unit-tests/compositor/test_compositing_screencast.cpp 2015-06-25 03:00:08 +0000
+++ tests/unit-tests/compositor/test_compositing_screencast.cpp 2015-09-04 06:51:35 +0000
@@ -27,7 +27,7 @@
27#include "mir/test/doubles/null_display.h"27#include "mir/test/doubles/null_display.h"
28#include "mir/test/doubles/null_display_buffer_compositor_factory.h"28#include "mir/test/doubles/null_display_buffer_compositor_factory.h"
29#include "mir/test/doubles/stub_display_configuration.h"29#include "mir/test/doubles/stub_display_configuration.h"
30#include "mir/test/doubles/stub_buffer_allocator.h"30#include "mir/test/doubles/stub_gl_buffer_allocator.h"
31#include "mir/test/doubles/mock_buffer.h"31#include "mir/test/doubles/mock_buffer.h"
32#include "mir/test/doubles/mock_gl.h"32#include "mir/test/doubles/mock_gl.h"
33#include "mir/test/doubles/stub_scene.h"33#include "mir/test/doubles/stub_scene.h"
@@ -170,7 +170,7 @@
170 testing::NiceMock<mtd::MockGL> mock_gl;170 testing::NiceMock<mtd::MockGL> mock_gl;
171 mtd::StubScene stub_scene;171 mtd::StubScene stub_scene;
172 StubDisplay stub_display;172 StubDisplay stub_display;
173 mtd::StubBufferAllocator stub_buffer_allocator;173 mtd::StubGLBufferAllocator stub_buffer_allocator;
174 mtd::NullDisplayBufferCompositorFactory stub_db_compositor_factory;174 mtd::NullDisplayBufferCompositorFactory stub_db_compositor_factory;
175 mc::CompositingScreencast screencast;175 mc::CompositingScreencast screencast;
176 geom::Size const default_size;176 geom::Size const default_size;
@@ -250,7 +250,7 @@
250 using namespace testing;250 using namespace testing;
251251
252 MockBufferAllocator mock_buffer_allocator;252 MockBufferAllocator mock_buffer_allocator;
253 mtd::StubBuffer stub_buffer;253 mtd::StubGLBuffer stub_buffer;
254254
255 InSequence s;255 InSequence s;
256 EXPECT_CALL(mock_buffer_allocator,256 EXPECT_CALL(mock_buffer_allocator,
@@ -274,8 +274,8 @@
274 using namespace testing;274 using namespace testing;
275275
276 MockBufferAllocator mock_buffer_allocator;276 MockBufferAllocator mock_buffer_allocator;
277 mtd::StubBuffer stub_buffer1;277 mtd::StubGLBuffer stub_buffer1;
278 mtd::StubBuffer stub_buffer2;278 mtd::StubGLBuffer stub_buffer2;
279279
280 EXPECT_CALL(mock_buffer_allocator, alloc_buffer(_))280 EXPECT_CALL(mock_buffer_allocator, alloc_buffer(_))
281 .WillOnce(Return(mt::fake_shared(stub_buffer1)))281 .WillOnce(Return(mt::fake_shared(stub_buffer1)))
@@ -306,7 +306,7 @@
306 NiceMock<mtd::MockScene> mock_scene;306 NiceMock<mtd::MockScene> mock_scene;
307 NiceMock<MockBufferAllocator> mock_buffer_allocator;307 NiceMock<MockBufferAllocator> mock_buffer_allocator;
308 ON_CALL(mock_buffer_allocator, alloc_buffer(_))308 ON_CALL(mock_buffer_allocator, alloc_buffer(_))
309 .WillByDefault(Return(std::make_shared<mtd::StubBuffer>()));309 .WillByDefault(Return(std::make_shared<mtd::StubGLBuffer>()));
310310
311 EXPECT_CALL(mock_scene, register_compositor(_))311 EXPECT_CALL(mock_scene, register_compositor(_))
312 .Times(1);312 .Times(1);
313313
=== modified file 'tests/unit-tests/compositor/test_gl_renderer.cpp'
--- tests/unit-tests/compositor/test_gl_renderer.cpp 2015-06-25 03:00:08 +0000
+++ tests/unit-tests/compositor/test_gl_renderer.cpp 2015-09-04 06:51:35 +0000
@@ -24,7 +24,7 @@
24#include <mir/graphics/gl_texture.h>24#include <mir/graphics/gl_texture.h>
25#include <mir/compositor/gl_renderer.h>25#include <mir/compositor/gl_renderer.h>
26#include <mir/test/fake_shared.h>26#include <mir/test/fake_shared.h>
27#include <mir/test/doubles/mock_buffer.h>27#include <mir/test/doubles/mock_gl_buffer.h>
28#include <mir/test/doubles/mock_renderable.h>28#include <mir/test/doubles/mock_renderable.h>
29#include <mir/test/doubles/mock_buffer_stream.h>29#include <mir/test/doubles/mock_buffer_stream.h>
30#include <mir/compositor/buffer_stream.h>30#include <mir/compositor/buffer_stream.h>
@@ -114,7 +114,7 @@
114 EXPECT_CALL(mock_gl, glDrawArrays(_, _, _)).Times(AnyNumber());114 EXPECT_CALL(mock_gl, glDrawArrays(_, _, _)).Times(AnyNumber());
115 EXPECT_CALL(mock_gl, glDisableVertexAttribArray(_)).Times(AnyNumber());115 EXPECT_CALL(mock_gl, glDisableVertexAttribArray(_)).Times(AnyNumber());
116116
117 mock_buffer = std::make_shared<mtd::MockBuffer>();117 mock_buffer = std::make_shared<mtd::MockGLBuffer>();
118 EXPECT_CALL(*mock_buffer, gl_bind_to_texture()).Times(AnyNumber());118 EXPECT_CALL(*mock_buffer, gl_bind_to_texture()).Times(AnyNumber());
119 EXPECT_CALL(*mock_buffer, id())119 EXPECT_CALL(*mock_buffer, id())
120 .WillRepeatedly(Return(mir::graphics::BufferID(789)));120 .WillRepeatedly(Return(mir::graphics::BufferID(789)));
@@ -144,7 +144,7 @@
144144
145 testing::NiceMock<mtd::MockGL> mock_gl;145 testing::NiceMock<mtd::MockGL> mock_gl;
146 testing::NiceMock<mtd::MockEGL> mock_egl;146 testing::NiceMock<mtd::MockEGL> mock_egl;
147 std::shared_ptr<mtd::MockBuffer> mock_buffer;147 std::shared_ptr<mtd::MockGLBuffer> mock_buffer;
148 mir::geometry::Rectangle display_area;148 mir::geometry::Rectangle display_area;
149 std::shared_ptr<testing::NiceMock<mtd::MockRenderable>> renderable;149 std::shared_ptr<testing::NiceMock<mtd::MockRenderable>> renderable;
150 mg::RenderableList renderable_list;150 mg::RenderableList renderable_list;
151151
=== modified file 'tests/unit-tests/compositor/test_gl_texture_cache.cpp'
--- tests/unit-tests/compositor/test_gl_texture_cache.cpp 2015-06-25 03:00:08 +0000
+++ tests/unit-tests/compositor/test_gl_texture_cache.cpp 2015-09-04 06:51:35 +0000
@@ -18,7 +18,7 @@
18 */18 */
1919
20#include "mir/compositor/recently_used_cache.h"20#include "mir/compositor/recently_used_cache.h"
21#include "mir/test/doubles/mock_buffer.h"21#include "mir/test/doubles/mock_gl_buffer.h"
22#include "mir/test/doubles/mock_renderable.h"22#include "mir/test/doubles/mock_renderable.h"
23#include "mir/test/doubles/mock_gl.h"23#include "mir/test/doubles/mock_gl.h"
24#include <gtest/gtest.h>24#include <gtest/gtest.h>
@@ -29,13 +29,14 @@
2929
30namespace30namespace
31{31{
32
32class RecentlyUsedCache : public testing::Test33class RecentlyUsedCache : public testing::Test
33{34{
34public:35public:
35 RecentlyUsedCache()36 RecentlyUsedCache()
36 {37 {
37 using namespace testing;38 using namespace testing;
38 mock_buffer = std::make_shared<NiceMock<mtd::MockBuffer>>();39 mock_buffer = std::make_shared<NiceMock<mtd::MockGLBuffer>>();
39 renderable = std::make_shared<NiceMock<mtd::MockRenderable>>();40 renderable = std::make_shared<NiceMock<mtd::MockRenderable>>();
40 ON_CALL(*renderable, buffer())41 ON_CALL(*renderable, buffer())
41 .WillByDefault(Return(mock_buffer));42 .WillByDefault(Return(mock_buffer));
@@ -44,7 +45,7 @@
44 }45 }
4546
46 testing::NiceMock<mtd::MockGL> mock_gl;47 testing::NiceMock<mtd::MockGL> mock_gl;
47 std::shared_ptr<mtd::MockBuffer> mock_buffer;48 std::shared_ptr<mtd::MockGLBuffer> mock_buffer;
48 std::shared_ptr<testing::NiceMock<mtd::MockRenderable>> renderable;49 std::shared_ptr<testing::NiceMock<mtd::MockRenderable>> renderable;
49 GLuint const stub_texture{1};50 GLuint const stub_texture{1};
50};51};
5152
=== modified file 'tests/unit-tests/compositor/test_screencast_display_buffer.cpp'
--- tests/unit-tests/compositor/test_screencast_display_buffer.cpp 2015-06-25 03:00:08 +0000
+++ tests/unit-tests/compositor/test_screencast_display_buffer.cpp 2015-09-04 06:51:35 +0000
@@ -18,8 +18,8 @@
1818
19#include "src/server/compositor/screencast_display_buffer.h"19#include "src/server/compositor/screencast_display_buffer.h"
2020
21#include "mir/test/doubles/mock_buffer.h"21#include "mir/test/doubles/mock_gl_buffer.h"
22#include "mir/test/doubles/stub_buffer.h"22#include "mir/test/doubles/stub_gl_buffer.h"
23#include "mir/test/doubles/mock_gl.h"23#include "mir/test/doubles/mock_gl.h"
24#include "mir/test/doubles/stub_renderable.h"24#include "mir/test/doubles/stub_renderable.h"
2525
@@ -60,7 +60,7 @@
60 EXPECT_CALL(mock_gl, glDeleteFramebuffers(1,Pointee(framebuffer)));60 EXPECT_CALL(mock_gl, glDeleteFramebuffers(1,Pointee(framebuffer)));
6161
62 geom::Rectangle const rect{{100,100}, {800,600}};62 geom::Rectangle const rect{{100,100}, {800,600}};
63 mtd::StubBuffer stub_buffer;63 mtd::StubGLBuffer stub_buffer;
6464
65 mc::ScreencastDisplayBuffer db{rect, stub_buffer};65 mc::ScreencastDisplayBuffer db{rect, stub_buffer};
66}66}
@@ -87,7 +87,7 @@
87 EXPECT_CALL(mock_gl, glDeleteFramebuffers(1,Pointee(framebuffer)));87 EXPECT_CALL(mock_gl, glDeleteFramebuffers(1,Pointee(framebuffer)));
8888
89 geom::Rectangle const rect{{100,100}, {800,600}};89 geom::Rectangle const rect{{100,100}, {800,600}};
90 mtd::StubBuffer stub_buffer;90 mtd::StubGLBuffer stub_buffer;
9191
92 EXPECT_THROW({92 EXPECT_THROW({
93 mc::ScreencastDisplayBuffer db(rect, stub_buffer);93 mc::ScreencastDisplayBuffer db(rect, stub_buffer);
@@ -99,7 +99,7 @@
99 using namespace testing;99 using namespace testing;
100100
101 geom::Rectangle const rect{{100,100}, {800,600}};101 geom::Rectangle const rect{{100,100}, {800,600}};
102 testing::NiceMock<mtd::MockBuffer> mock_buffer{102 testing::NiceMock<mtd::MockGLBuffer> mock_buffer{
103 rect.size, geom::Stride{100}, mir_pixel_format_xbgr_8888};103 rect.size, geom::Stride{100}, mir_pixel_format_xbgr_8888};
104104
105 /* Set the buffer as rendering target */105 /* Set the buffer as rendering target */
@@ -116,7 +116,7 @@
116 using namespace testing;116 using namespace testing;
117117
118 geom::Rectangle const rect{{100,100}, {800,600}};118 geom::Rectangle const rect{{100,100}, {800,600}};
119 testing::NiceMock<mtd::MockBuffer> mock_buffer{119 testing::NiceMock<mtd::MockGLBuffer> mock_buffer{
120 rect.size, geom::Stride{100}, mir_pixel_format_xbgr_8888};120 rect.size, geom::Stride{100}, mir_pixel_format_xbgr_8888};
121121
122 InSequence s;122 InSequence s;
@@ -138,7 +138,7 @@
138 using namespace testing;138 using namespace testing;
139139
140 geom::Rectangle const rect{{100,100}, {800,600}};140 geom::Rectangle const rect{{100,100}, {800,600}};
141 mtd::StubBuffer stub_buffer;141 mtd::StubGLBuffer stub_buffer;
142142
143 mc::ScreencastDisplayBuffer db{rect, stub_buffer};143 mc::ScreencastDisplayBuffer db{rect, stub_buffer};
144144
@@ -151,7 +151,7 @@
151TEST_F(ScreencastDisplayBufferTest, rejects_attempt_to_optimize)151TEST_F(ScreencastDisplayBufferTest, rejects_attempt_to_optimize)
152{152{
153 geom::Rectangle const rect{{100,100}, {800,600}};153 geom::Rectangle const rect{{100,100}, {800,600}};
154 mtd::StubBuffer stub_buffer;154 mtd::StubGLBuffer stub_buffer;
155155
156 mg::RenderableList renderables{156 mg::RenderableList renderables{
157 std::make_shared<mtd::StubRenderable>(),157 std::make_shared<mtd::StubRenderable>(),
158158
=== modified file 'tests/unit-tests/compositor/test_temporary_buffers.cpp'
--- tests/unit-tests/compositor/test_temporary_buffers.cpp 2015-08-27 13:41:02 +0000
+++ tests/unit-tests/compositor/test_temporary_buffers.cpp 2015-09-04 06:51:35 +0000
@@ -126,15 +126,6 @@
126 EXPECT_EQ(buffer_pixel_format, pixel_format);126 EXPECT_EQ(buffer_pixel_format, pixel_format);
127}127}
128128
129TEST_F(TemporaryBuffersTest, base_gl_bind_to_texture)
130{
131 TemporaryTestBuffer proxy_buffer(mock_buffer);
132 EXPECT_CALL(*mock_buffer, gl_bind_to_texture())
133 .Times(1);
134
135 proxy_buffer.gl_bind_to_texture();
136}
137
138TEST_F(TemporaryBuffersTest, base_test_id)129TEST_F(TemporaryBuffersTest, base_test_id)
139{130{
140 TemporaryTestBuffer proxy_buffer(mock_buffer);131 TemporaryTestBuffer proxy_buffer(mock_buffer);
141132
=== modified file 'tests/unit-tests/graphics/mesa/kms/test_gbm_buffer.cpp'
--- tests/unit-tests/graphics/mesa/kms/test_gbm_buffer.cpp 2015-07-23 02:39:20 +0000
+++ tests/unit-tests/graphics/mesa/kms/test_gbm_buffer.cpp 2015-09-04 06:51:35 +0000
@@ -75,6 +75,11 @@
75 allocator.reset(new mgm::BufferAllocator(platform->gbm.device, mgm::BypassOption::allowed, mgm::BufferImportMethod::gbm_native_pixmap));75 allocator.reset(new mgm::BufferAllocator(platform->gbm.device, mgm::BypassOption::allowed, mgm::BufferImportMethod::gbm_native_pixmap));
76 }76 }
7777
78 mir::renderer::gl::TextureSource* as_texture_source(std::shared_ptr<mg::Buffer> const& buffer)
79 {
80 return dynamic_cast<mir::renderer::gl::TextureSource*>(buffer->native_buffer_base());
81 }
82
78 ::testing::NiceMock<mtd::MockDRM> mock_drm;83 ::testing::NiceMock<mtd::MockDRM> mock_drm;
79 ::testing::NiceMock<mtd::MockGBM> mock_gbm;84 ::testing::NiceMock<mtd::MockGBM> mock_gbm;
80 ::testing::NiceMock<mtd::MockEGL> mock_egl;85 ::testing::NiceMock<mtd::MockEGL> mock_egl;
@@ -196,7 +201,7 @@
196201
197 EXPECT_THROW({202 EXPECT_THROW({
198 auto buffer = allocator->alloc_buffer(buffer_properties);203 auto buffer = allocator->alloc_buffer(buffer_properties);
199 buffer->gl_bind_to_texture();204 as_texture_source(buffer)->gl_bind_to_texture();
200 }, std::runtime_error);205 }, std::runtime_error);
201}206}
202207
@@ -219,6 +224,6 @@
219224
220 EXPECT_NO_THROW({225 EXPECT_NO_THROW({
221 auto buffer = allocator->alloc_buffer(buffer_properties);226 auto buffer = allocator->alloc_buffer(buffer_properties);
222 buffer->gl_bind_to_texture();227 as_texture_source(buffer)->gl_bind_to_texture();
223 });228 });
224}229}
225230
=== modified file 'tests/unit-tests/scene/test_gl_pixel_buffer.cpp'
--- tests/unit-tests/scene/test_gl_pixel_buffer.cpp 2015-06-25 03:00:08 +0000
+++ tests/unit-tests/scene/test_gl_pixel_buffer.cpp 2015-09-04 06:51:35 +0000
@@ -19,7 +19,7 @@
19#include "src/server/scene/gl_pixel_buffer.h"19#include "src/server/scene/gl_pixel_buffer.h"
20#include "mir/graphics/gl_context.h"20#include "mir/graphics/gl_context.h"
2121
22#include "mir/test/doubles/mock_buffer.h"22#include "mir/test/doubles/mock_gl_buffer.h"
23#include "mir/test/doubles/mock_gl.h"23#include "mir/test/doubles/mock_gl.h"
2424
25#include <gmock/gmock.h>25#include <gmock/gmock.h>
@@ -68,7 +68,7 @@
68 }68 }
6969
70 testing::NiceMock<mtd::MockGL> mock_gl;70 testing::NiceMock<mtd::MockGL> mock_gl;
71 testing::NiceMock<mtd::MockBuffer> mock_buffer;71 testing::NiceMock<mtd::MockGLBuffer> mock_buffer;
72 MockGLContext mock_context;72 MockGLContext mock_context;
73 std::unique_ptr<WrappingGLContext> context;73 std::unique_ptr<WrappingGLContext> context;
74};74};

Subscribers

People subscribed via source and target branches