Mir

Merge lp:~andreas-pokorny/mir/pixel-format-utils into lp:mir/0.1

Proposed by Andreas Pokorny
Status: Superseded
Proposed branch: lp:~andreas-pokorny/mir/pixel-format-utils
Merge into: lp:mir/0.1
Diff against target: 886 lines (+444/-102)
22 files modified
benchmarks/CMakeLists.txt (+3/-1)
doc/building_source_for_android.md (+21/-32)
include/platform/mir/graphics/pixel_format_utils.h (+45/-0)
include/shared/mir/logging/input_timestamp.h (+35/-0)
include/test/mir_test_doubles/mock_surface_renderer.h (+2/-1)
src/client/logging/input_receiver_report.cpp (+3/-2)
src/platform/graphics/CMakeLists.txt (+1/-0)
src/platform/graphics/pixel_format_utils.cpp (+71/-0)
src/server/compositor/default_display_buffer_compositor.cpp (+2/-1)
src/server/compositor/gl_renderer.cpp (+28/-33)
src/server/compositor/gl_renderer.h (+12/-22)
src/server/compositor/renderer.h (+2/-1)
src/server/logging/input_report.cpp (+4/-3)
src/shared/logging/CMakeLists.txt (+1/-0)
src/shared/logging/input_timestamp.cpp (+41/-0)
tests/acceptance-tests/test_server_shutdown.cpp (+5/-1)
tests/integration-tests/test_session.cpp (+4/-1)
tests/integration-tests/test_surface_first_frame_sync.cpp (+5/-1)
tests/mir_test_framework/stubbed_server_configuration.cpp (+5/-1)
tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp (+63/-2)
tests/unit-tests/graphics/CMakeLists.txt (+1/-0)
tests/unit-tests/graphics/test_pixel_format_utils.cpp (+90/-0)
To merge this branch: bzr merge lp:~andreas-pokorny/mir/pixel-format-utils
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+200277@code.launchpad.net

This proposal has been superseded by a proposal from 2014-01-02.

Commit message

Add mir pixel format utility functions

Description of the change

Add mir pixel format utility functions

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'benchmarks/CMakeLists.txt'
--- benchmarks/CMakeLists.txt 2013-10-15 10:10:05 +0000
+++ benchmarks/CMakeLists.txt 2014-01-02 07:37:29 +0000
@@ -2,7 +2,9 @@
2 benchmarks2 benchmarks
3)3)
44
5add_subdirectory(android-input)5if (MIR_ENABLE_TESTS)
6 add_subdirectory(android-input)
7endif ()
6add_subdirectory(cpu)8add_subdirectory(cpu)
7add_subdirectory(memory)9add_subdirectory(memory)
810
911
=== modified file 'doc/building_source_for_android.md'
--- doc/building_source_for_android.md 2013-12-17 18:24:51 +0000
+++ doc/building_source_for_android.md 2014-01-02 07:37:29 +0000
@@ -51,35 +51,24 @@
51ubuntu package) to produce armhf code. This is typically the quickest way to51ubuntu package) to produce armhf code. This is typically the quickest way to
52compile and run code, and is well suited for a development workflow.52compile and run code, and is well suited for a development workflow.
5353
54- Be sure that the cross compiler that you are using matches the target54Initial setup of a desktop machine for cross-compiling to armhf is simple:
55 environment. (eg, make sure you're using the trusty toolchain if you're55
56 targeting a trusty phablet image) You can specify the toolchain version56 $ sudo apt-get install g++-arm-linux-gnueabihf/trusty debootstrap
57 thusly:57 $ sudo sh -c 'echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted universe multiverse" > /etc/apt/sources.list.d/armhf-xcompile.list'
5858 $ sudo apt-get update
59 $ apt-get install g++-arm-linux-gnueabihf/trusty59
6060Now to test that everything is working you can try downloading a package like
61- Get access to armhf packages via apt-get. On an amd64/ia32 system, you can61this:
62 do this by adding a file like the one below to /etc/apt/sources.list.d/62
6363 $ apt-get download gcc:armhf
64 #example sources.list with armhf dependencies64
65 deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted universe multiverse65Once you're able to download armhf packages from the repository, the
66 66cross-compile-chroot.sh script provides an example of how to build Mir for
67 Then you should run:67armhf:
6868
69 $ apt-get update69 $ ./cross-compile-chroot.sh
7070 $ ls -l build-android-arm/* # binaries to copy to your device
71 To test, try downloading a package like this:71
7272To speed up the process for future branches you may wish to cache the files
73 $ apt-get download my-package:armhf73downloaded by setting environment variable MIR_NDK_PATH to point to a directory
7474that cross-compile-chroot.sh should reuse each time.
75- Once you're able to download armhf packages from the repository, the
76 cross-compile-chroot.sh script provides an example of how to download
77 a partial chroot with the mir dependencies, and compile the source for
78 android targets.
79
80 The script sets up a partial chroot via tools/setup-partial-armhf-chroot.sh
81 and then runs build commands similar to this:
82
83 $ mkdir mir/build; cd mir/build
84 $ MIR_NDK_PATH=/path/to/depenendcies/chroot cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/LinuxCrossCompile.cmake -DBoost_COMPILER=-gcc -DMIR_PLATFORM=android ..
85 $ make
8675
=== added file 'include/platform/mir/graphics/pixel_format_utils.h'
--- include/platform/mir/graphics/pixel_format_utils.h 1970-01-01 00:00:00 +0000
+++ include/platform/mir/graphics/pixel_format_utils.h 2014-01-02 07:37:29 +0000
@@ -0,0 +1,45 @@
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: Andreas Pokorny <andreas.pokorny@canonical.com>
17 */
18
19#include "mir_toolkit/common.h"
20
21namespace mir
22{
23namespace graphics
24{
25
26/*!
27 * \name MirPixelFormat utility functions
28 *
29 * A set of functions to query details of MirPixelFormat
30 * TODO improve this through https://bugs.launchpad.net/mir/+bug/1236254
31 * \{
32 */
33bool contains_alpha(MirPixelFormat format);
34int red_channel_depth(MirPixelFormat format);
35int blue_channel_depth(MirPixelFormat format);
36int green_channel_depth(MirPixelFormat format);
37int alpha_channel_depth(MirPixelFormat format);
38bool valid_format(MirPixelFormat format);
39/*!
40 * \}
41 */
42
43
44}
45}
046
=== added file 'include/shared/mir/logging/input_timestamp.h'
--- include/shared/mir/logging/input_timestamp.h 1970-01-01 00:00:00 +0000
+++ include/shared/mir/logging/input_timestamp.h 2014-01-02 07:37:29 +0000
@@ -0,0 +1,35 @@
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: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */
18
19#ifndef MIR_LOGGING_INPUT_TIMESTAMP_H_
20#define MIR_LOGGING_INPUT_TIMESTAMP_H_
21
22#include "mir_toolkit/event.h"
23#include <string>
24
25namespace mir
26{
27namespace logging
28{
29
30std::string input_timestamp(nsecs_t when);
31
32}
33}
34
35#endif // MIR_LOGGING_INPUT_TIMESTAMP_H_
036
=== modified file 'include/test/mir_test_doubles/mock_surface_renderer.h'
--- include/test/mir_test_doubles/mock_surface_renderer.h 2013-12-17 18:24:51 +0000
+++ include/test/mir_test_doubles/mock_surface_renderer.h 2014-01-02 07:37:29 +0000
@@ -31,8 +31,9 @@
3131
32struct MockSurfaceRenderer : public compositor::Renderer32struct MockSurfaceRenderer : public compositor::Renderer
33{33{
34 MOCK_CONST_METHOD0(begin, void());
34 MOCK_CONST_METHOD2(render, void(compositor::CompositingCriteria const&, graphics::Buffer&));35 MOCK_CONST_METHOD2(render, void(compositor::CompositingCriteria const&, graphics::Buffer&));
35 MOCK_CONST_METHOD0(clear, void());36 MOCK_CONST_METHOD0(end, void());
3637
37 ~MockSurfaceRenderer() noexcept {}38 ~MockSurfaceRenderer() noexcept {}
38};39};
3940
=== modified file 'src/client/logging/input_receiver_report.cpp'
--- src/client/logging/input_receiver_report.cpp 2013-12-17 18:24:51 +0000
+++ src/client/logging/input_receiver_report.cpp 2014-01-02 07:37:29 +0000
@@ -19,6 +19,7 @@
19#include "input_receiver_report.h"19#include "input_receiver_report.h"
2020
21#include "mir/logging/logger.h"21#include "mir/logging/logger.h"
22#include "mir/logging/input_timestamp.h"
2223
23#include <boost/throw_exception.hpp>24#include <boost/throw_exception.hpp>
2425
@@ -53,7 +54,7 @@
53 ss << " scan_code: " << ev.scan_code << std::endl;54 ss << " scan_code: " << ev.scan_code << std::endl;
54 ss << " repeat_count: " << ev.repeat_count << std::endl;55 ss << " repeat_count: " << ev.repeat_count << std::endl;
55 ss << " down_time: " << ev.down_time << std::endl;56 ss << " down_time: " << ev.down_time << std::endl;
56 ss << " event_time: " << ev.event_time << std::endl;57 ss << " event_time: " << ml::input_timestamp(ev.event_time) << std::endl;
57 ss << " is_system_key: " << ev.is_system_key << std::endl;58 ss << " is_system_key: " << ev.is_system_key << std::endl;
58 ss << "}";59 ss << "}";
59}60}
@@ -73,7 +74,7 @@
73 ss << " x_precision: " << ev.x_precision << std::endl;74 ss << " x_precision: " << ev.x_precision << std::endl;
74 ss << " y_precision: " << ev.y_precision << std::endl;75 ss << " y_precision: " << ev.y_precision << std::endl;
75 ss << " down_time: " << ev.down_time << std::endl;76 ss << " down_time: " << ev.down_time << std::endl;
76 ss << " event_time: " << ev.event_time << std::endl;77 ss << " event_time: " << ml::input_timestamp(ev.event_time) << std::endl;
77 ss << " pointer_count: " << ev.pointer_count << std::endl;78 ss << " pointer_count: " << ev.pointer_count << std::endl;
78 for (unsigned int i = 0; i < ev.pointer_count; i++)79 for (unsigned int i = 0; i < ev.pointer_count; i++)
79 {80 {
8081
=== modified file 'src/platform/graphics/CMakeLists.txt'
--- src/platform/graphics/CMakeLists.txt 2013-12-17 18:24:51 +0000
+++ src/platform/graphics/CMakeLists.txt 2014-01-02 07:37:29 +0000
@@ -10,6 +10,7 @@
10 display_configuration.cpp10 display_configuration.cpp
11 null_display_report.cpp11 null_display_report.cpp
12 buffer_basic.cpp12 buffer_basic.cpp
13 pixel_format_utils.cpp
13)14)
1415
15add_library(16add_library(
1617
=== added file 'src/platform/graphics/pixel_format_utils.cpp'
--- src/platform/graphics/pixel_format_utils.cpp 1970-01-01 00:00:00 +0000
+++ src/platform/graphics/pixel_format_utils.cpp 2014-01-02 07:37:29 +0000
@@ -0,0 +1,71 @@
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: Andreas Pokorny <andreas.pokorny@canonical.com>
17 */
18
19#include "mir/graphics/pixel_format_utils.h"
20
21namespace mir
22{
23namespace graphics
24{
25
26bool contains_alpha(MirPixelFormat format)
27{
28 return (format == mir_pixel_format_abgr_8888 ||
29 format == mir_pixel_format_argb_8888);
30}
31
32int red_channel_depth(MirPixelFormat format)
33{
34 if (mir_pixel_format_invalid < format &&
35 format < mir_pixel_formats)
36 return 8;
37 return 0;
38}
39
40int blue_channel_depth(MirPixelFormat format)
41{
42 if (mir_pixel_format_invalid < format &&
43 format < mir_pixel_formats)
44 return 8;
45 return 0;
46}
47
48int green_channel_depth(MirPixelFormat format)
49{
50 if (mir_pixel_format_invalid < format &&
51 format < mir_pixel_formats)
52 return 8;
53 return 0;
54}
55
56int alpha_channel_depth(MirPixelFormat format)
57{
58 if (format == mir_pixel_format_abgr_8888 ||
59 format == mir_pixel_format_argb_8888)
60 return 8;
61 return 0;
62}
63
64bool valid_format(MirPixelFormat format)
65{
66 return (format > mir_pixel_format_invalid &&
67 format < mir_pixel_formats);
68}
69
70}
71}
072
=== modified file 'src/server/compositor/default_display_buffer_compositor.cpp'
--- src/server/compositor/default_display_buffer_compositor.cpp 2013-12-17 18:24:51 +0000
+++ src/server/compositor/default_display_buffer_compositor.cpp 2014-01-02 07:37:29 +0000
@@ -135,10 +135,11 @@
135 mc::OcclusionMatch occlusion_match;135 mc::OcclusionMatch occlusion_match;
136 scene->reverse_for_each_if(occlusion_search, occlusion_match);136 scene->reverse_for_each_if(occlusion_search, occlusion_match);
137137
138 renderer->clear();138 renderer->begin();
139 mc::RenderingOperator applicator(*renderer, save_resource, local_frameno);139 mc::RenderingOperator applicator(*renderer, save_resource, local_frameno);
140 FilterForVisibleSceneInRegion selector(view_area, occlusion_match);140 FilterForVisibleSceneInRegion selector(view_area, occlusion_match);
141 scene->for_each_if(selector, applicator);141 scene->for_each_if(selector, applicator);
142 renderer->end();
142143
143 display_buffer.post_update();144 display_buffer.post_update();
144 }145 }
145146
=== modified file 'src/server/compositor/gl_renderer.cpp'
--- src/server/compositor/gl_renderer.cpp 2013-12-17 18:24:51 +0000
+++ src/server/compositor/gl_renderer.cpp 2014-01-02 07:37:29 +0000
@@ -117,7 +117,7 @@
117117
118}118}
119119
120mc::GLRenderer::Resources::Resources() :120mc::GLRenderer::GLRenderer(geom::Rectangle const& display_area) :
121 vertex_shader(0),121 vertex_shader(0),
122 fragment_shader(0),122 fragment_shader(0),
123 program(0),123 program(0),
@@ -128,24 +128,6 @@
128 vertex_attribs_vbo(0),128 vertex_attribs_vbo(0),
129 texture(0)129 texture(0)
130{130{
131}
132
133mc::GLRenderer::Resources::~Resources()
134{
135 if (vertex_shader)
136 glDeleteShader(vertex_shader);
137 if (fragment_shader)
138 glDeleteShader(fragment_shader);
139 if (program)
140 glDeleteProgram(program);
141 if (vertex_attribs_vbo)
142 glDeleteBuffers(1, &vertex_attribs_vbo);
143 if (texture)
144 glDeleteTextures(1, &texture);
145}
146
147void mc::GLRenderer::Resources::setup(geometry::Rectangle const& display_area)
148{
149 GLint param = 0;131 GLint param = 0;
150132
151 /* Create shaders and program */133 /* Create shaders and program */
@@ -235,14 +217,23 @@
235 glUseProgram(0);217 glUseProgram(0);
236}218}
237219
238mc::GLRenderer::GLRenderer(geom::Rectangle const& display_area)220mc::GLRenderer::~GLRenderer() noexcept
239{221{
240 resources.setup(display_area);222 if (vertex_shader)
223 glDeleteShader(vertex_shader);
224 if (fragment_shader)
225 glDeleteShader(fragment_shader);
226 if (program)
227 glDeleteProgram(program);
228 if (vertex_attribs_vbo)
229 glDeleteBuffers(1, &vertex_attribs_vbo);
230 if (texture)
231 glDeleteTextures(1, &texture);
241}232}
242233
243void mc::GLRenderer::render(CompositingCriteria const& criteria, mg::Buffer& buffer) const234void mc::GLRenderer::render(CompositingCriteria const& criteria, mg::Buffer& buffer) const
244{235{
245 glUseProgram(resources.program);236 glUseProgram(program);
246237
247 if (criteria.shaped() || criteria.alpha() < 1.0f)238 if (criteria.shaped() || criteria.alpha() < 1.0f)
248 {239 {
@@ -255,32 +246,36 @@
255 }246 }
256 glActiveTexture(GL_TEXTURE0);247 glActiveTexture(GL_TEXTURE0);
257248
258 glUniformMatrix4fv(resources.transform_uniform_loc, 1, GL_FALSE,249 glUniformMatrix4fv(transform_uniform_loc, 1, GL_FALSE,
259 glm::value_ptr(criteria.transformation()));250 glm::value_ptr(criteria.transformation()));
260 glUniform1f(resources.alpha_uniform_loc, criteria.alpha());251 glUniform1f(alpha_uniform_loc, criteria.alpha());
261252
262 /* Set up vertex attribute data */253 /* Set up vertex attribute data */
263 glBindBuffer(GL_ARRAY_BUFFER, resources.vertex_attribs_vbo);254 glBindBuffer(GL_ARRAY_BUFFER, vertex_attribs_vbo);
264 glVertexAttribPointer(resources.position_attr_loc, 3, GL_FLOAT,255 glVertexAttribPointer(position_attr_loc, 3, GL_FLOAT,
265 GL_FALSE, sizeof(VertexAttributes), 0);256 GL_FALSE, sizeof(VertexAttributes), 0);
266 glVertexAttribPointer(resources.texcoord_attr_loc, 2, GL_FLOAT,257 glVertexAttribPointer(texcoord_attr_loc, 2, GL_FLOAT,
267 GL_FALSE, sizeof(VertexAttributes),258 GL_FALSE, sizeof(VertexAttributes),
268 reinterpret_cast<void*>(sizeof(glm::vec3)));259 reinterpret_cast<void*>(sizeof(glm::vec3)));
269260
270 /* Use the renderable's texture */261 /* Use the renderable's texture */
271 glBindTexture(GL_TEXTURE_2D, resources.texture);262 glBindTexture(GL_TEXTURE_2D, texture);
272263
273 buffer.bind_to_texture();264 buffer.bind_to_texture();
274265
275 /* Draw */266 /* Draw */
276 glEnableVertexAttribArray(resources.position_attr_loc);267 glEnableVertexAttribArray(position_attr_loc);
277 glEnableVertexAttribArray(resources.texcoord_attr_loc);268 glEnableVertexAttribArray(texcoord_attr_loc);
278 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);269 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
279 glDisableVertexAttribArray(resources.texcoord_attr_loc);270 glDisableVertexAttribArray(texcoord_attr_loc);
280 glDisableVertexAttribArray(resources.position_attr_loc);271 glDisableVertexAttribArray(position_attr_loc);
281}272}
282273
283void mc::GLRenderer::clear() const274void mc::GLRenderer::begin() const
284{275{
285 glClear(GL_COLOR_BUFFER_BIT);276 glClear(GL_COLOR_BUFFER_BIT);
286}277}
278
279void mc::GLRenderer::end() const
280{
281}
287282
=== modified file 'src/server/compositor/gl_renderer.h'
--- src/server/compositor/gl_renderer.h 2013-12-17 18:24:51 +0000
+++ src/server/compositor/gl_renderer.h 2014-01-02 07:37:29 +0000
@@ -32,32 +32,22 @@
32{32{
33public:33public:
34 GLRenderer(geometry::Rectangle const& display_area);34 GLRenderer(geometry::Rectangle const& display_area);
35 virtual ~GLRenderer() noexcept;
3536
37 void begin() const override;
36 void render(CompositingCriteria const& info, graphics::Buffer& buffer) const override;38 void render(CompositingCriteria const& info, graphics::Buffer& buffer) const override;
37 void clear() const override;39 void end() const override;
38
39 ~GLRenderer() noexcept {}
4040
41private:41private:
42 class Resources42 GLuint vertex_shader;
43 {43 GLuint fragment_shader;
44 public:44 GLuint program;
45 Resources();45 GLuint position_attr_loc;
46 ~Resources();46 GLuint texcoord_attr_loc;
47 void setup(geometry::Rectangle const& display_area);47 GLuint transform_uniform_loc;
4848 GLuint alpha_uniform_loc;
49 GLuint vertex_shader;49 GLuint vertex_attribs_vbo;
50 GLuint fragment_shader;50 GLuint texture;
51 GLuint program;
52 GLuint position_attr_loc;
53 GLuint texcoord_attr_loc;
54 GLuint transform_uniform_loc;
55 GLuint alpha_uniform_loc;
56 GLuint vertex_attribs_vbo;
57 GLuint texture;
58 };
59
60 Resources resources;
61};51};
6252
63}53}
6454
=== modified file 'src/server/compositor/renderer.h'
--- src/server/compositor/renderer.h 2013-12-17 18:24:51 +0000
+++ src/server/compositor/renderer.h 2014-01-02 07:37:29 +0000
@@ -34,8 +34,9 @@
34public:34public:
35 virtual ~Renderer() = default;35 virtual ~Renderer() = default;
3636
37 virtual void clear() const = 0;37 virtual void begin() const = 0;
38 virtual void render(CompositingCriteria const& info, graphics::Buffer& buffer) const = 0;38 virtual void render(CompositingCriteria const& info, graphics::Buffer& buffer) const = 0;
39 virtual void end() const = 0;
3940
40protected:41protected:
41 Renderer() = default;42 Renderer() = default;
4243
=== modified file 'src/server/logging/input_report.cpp'
--- src/server/logging/input_report.cpp 2013-12-19 16:33:56 +0000
+++ src/server/logging/input_report.cpp 2014-01-02 07:37:29 +0000
@@ -18,6 +18,7 @@
1818
19#include "mir/logging/input_report.h"19#include "mir/logging/input_report.h"
20#include "mir/logging/logger.h"20#include "mir/logging/logger.h"
21#include "mir/logging/input_timestamp.h"
2122
22#include "std/MirLog.h"23#include "std/MirLog.h"
23#include <std/Log.h>24#include <std/Log.h>
@@ -108,7 +109,7 @@
108 std::stringstream ss;109 std::stringstream ss;
109110
110 ss << "Received event"111 ss << "Received event"
111 << " time=" << when112 << " time=" << ml::input_timestamp(when)
112 << " type=" << type113 << " type=" << type
113 << " code=" << code114 << " code=" << code
114 << " value=" << value;115 << " value=" << value;
@@ -122,7 +123,7 @@
122123
123 ss << "Published key event"124 ss << "Published key event"
124 << " seq_id=" << seq_id125 << " seq_id=" << seq_id
125 << " time=" << event_time126 << " time=" << ml::input_timestamp(event_time)
126 << " dest_fd=" << dest_fd;127 << " dest_fd=" << dest_fd;
127128
128 logger->log(Logger::informational, ss.str(), component());129 logger->log(Logger::informational, ss.str(), component());
@@ -134,7 +135,7 @@
134135
135 ss << "Published motion event"136 ss << "Published motion event"
136 << " seq_id=" << seq_id137 << " seq_id=" << seq_id
137 << " time=" << event_time138 << " time=" << ml::input_timestamp(event_time)
138 << " dest_fd=" << dest_fd;139 << " dest_fd=" << dest_fd;
139140
140 logger->log(Logger::informational, ss.str(), component());141 logger->log(Logger::informational, ss.str(), component());
141142
=== modified file 'src/shared/logging/CMakeLists.txt'
--- src/shared/logging/CMakeLists.txt 2013-12-12 07:51:12 +0000
+++ src/shared/logging/CMakeLists.txt 2014-01-02 07:37:29 +0000
@@ -16,4 +16,5 @@
1616
17add_library(mirsharedlogging STATIC17add_library(mirsharedlogging STATIC
18 dumb_console_logger.cpp18 dumb_console_logger.cpp
19 input_timestamp.cpp
19)20)
2021
=== added file 'src/shared/logging/input_timestamp.cpp'
--- src/shared/logging/input_timestamp.cpp 1970-01-01 00:00:00 +0000
+++ src/shared/logging/input_timestamp.cpp 2014-01-02 07:37:29 +0000
@@ -0,0 +1,41 @@
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: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */
18
19#include "mir/logging/input_timestamp.h"
20#include <ctime>
21#include <cstdio>
22#include <string>
23
24std::string mir::logging::input_timestamp(nsecs_t when)
25{
26 // Input events use CLOCK_REALTIME, and so we must...
27 struct timespec ts;
28 clock_gettime(CLOCK_REALTIME, &ts);
29
30 nsecs_t now = ts.tv_sec * 1000000000LL + ts.tv_nsec;
31 nsecs_t age = now - when;
32
33 char str[64];
34 snprintf(str, sizeof str, "%lld (%ld.%06ld ms ago)",
35 static_cast<long long>(when),
36 static_cast<long>(age / 1000000LL),
37 static_cast<long>(age % 1000000LL));
38
39 return std::string(str);
40}
41
042
=== modified file 'tests/acceptance-tests/test_server_shutdown.cpp'
--- tests/acceptance-tests/test_server_shutdown.cpp 2013-12-17 18:24:51 +0000
+++ tests/acceptance-tests/test_server_shutdown.cpp 2014-01-02 07:37:29 +0000
@@ -48,6 +48,10 @@
48class NullRenderer : public mc::Renderer48class NullRenderer : public mc::Renderer
49{49{
50public:50public:
51 void begin() const override
52 {
53 }
54
51 void render(mc::CompositingCriteria const&, mg::Buffer&) const override55 void render(mc::CompositingCriteria const&, mg::Buffer&) const override
52 {56 {
53 /*57 /*
@@ -58,7 +62,7 @@
58 std::this_thread::yield();62 std::this_thread::yield();
59 }63 }
6064
61 void clear() const override65 void end() const override
62 {66 {
63 }67 }
64};68};
6569
=== modified file 'tests/integration-tests/test_session.cpp'
--- tests/integration-tests/test_session.cpp 2013-12-17 18:24:51 +0000
+++ tests/integration-tests/test_session.cpp 2014-01-02 07:37:29 +0000
@@ -87,12 +87,15 @@
87 {87 {
88 struct StubRenderer : public mc::Renderer88 struct StubRenderer : public mc::Renderer
89 {89 {
90 void clear() const override90 void begin() const override
91 {91 {
92 }92 }
93 void render(mc::CompositingCriteria const&, mg::Buffer&) const override93 void render(mc::CompositingCriteria const&, mg::Buffer&) const override
94 {94 {
95 }95 }
96 void end() const override
97 {
98 }
96 };99 };
97100
98 struct StubRendererFactory : public mc::RendererFactory101 struct StubRendererFactory : public mc::RendererFactory
99102
=== modified file 'tests/integration-tests/test_surface_first_frame_sync.cpp'
--- tests/integration-tests/test_surface_first_frame_sync.cpp 2013-12-17 18:24:51 +0000
+++ tests/integration-tests/test_surface_first_frame_sync.cpp 2014-01-02 07:37:29 +0000
@@ -96,7 +96,7 @@
96 {96 {
97 }97 }
9898
99 void clear() const override99 void begin() const override
100 {100 {
101 }101 }
102102
@@ -105,6 +105,10 @@
105 while (write(render_operations_fd, "a", 1) != 1) continue;105 while (write(render_operations_fd, "a", 1) != 1) continue;
106 }106 }
107107
108 void end() const override
109 {
110 }
111
108private:112private:
109 int render_operations_fd;113 int render_operations_fd;
110};114};
111115
=== modified file 'tests/mir_test_framework/stubbed_server_configuration.cpp'
--- tests/mir_test_framework/stubbed_server_configuration.cpp 2013-12-19 16:34:53 +0000
+++ tests/mir_test_framework/stubbed_server_configuration.cpp 2014-01-02 07:37:29 +0000
@@ -201,11 +201,15 @@
201class StubRenderer : public mc::Renderer201class StubRenderer : public mc::Renderer
202{202{
203public:203public:
204 void begin() const override
205 {
206 }
207
204 void render(mc::CompositingCriteria const&, mg::Buffer&) const override208 void render(mc::CompositingCriteria const&, mg::Buffer&) const override
205 {209 {
206 }210 }
207211
208 void clear() const override212 void end() const override
209 {213 {
210 }214 }
211};215};
212216
=== modified file 'tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp'
--- tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp 2013-12-17 18:24:51 +0000
+++ tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp 2014-01-02 07:37:29 +0000
@@ -106,9 +106,9 @@
106 {106 {
107 }107 }
108108
109 void clear() const override109 void begin() const override
110 {110 {
111 renderer->clear();111 renderer->begin();
112 }112 }
113113
114 void render(mc::CompositingCriteria const& criteria, mg::Buffer& buffer) const override114 void render(mc::CompositingCriteria const& criteria, mg::Buffer& buffer) const override
@@ -116,6 +116,11 @@
116 renderer->render(criteria, buffer);116 renderer->render(criteria, buffer);
117 }117 }
118118
119 void end() const override
120 {
121 renderer->end();
122 }
123
119 mc::Renderer* const renderer;124 mc::Renderer* const renderer;
120};125};
121126
@@ -241,10 +246,14 @@
241 renderable_vec.push_back(&small);246 renderable_vec.push_back(&small);
242 renderable_vec.push_back(&fullscreen);247 renderable_vec.push_back(&fullscreen);
243248
249 EXPECT_CALL(renderer_factory.mock_renderer, begin())
250 .Times(0);
244 EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(small),_))251 EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(small),_))
245 .Times(0);252 .Times(0);
246 EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(fullscreen),_))253 EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(fullscreen),_))
247 .Times(0);254 .Times(0);
255 EXPECT_CALL(renderer_factory.mock_renderer, end())
256 .Times(0);
248257
249 FakeScene scene(renderable_vec);258 FakeScene scene(renderable_vec);
250259
@@ -263,6 +272,58 @@
263 comp->composite();272 comp->composite();
264}273}
265274
275TEST(DefaultDisplayBufferCompositor, calls_renderer_in_sequence)
276{
277 using namespace testing;
278
279 StubRendererFactory renderer_factory;
280
281 geom::Rectangle screen{{0, 0}, {1366, 768}};
282
283 mtd::MockDisplayBuffer display_buffer;
284
285 EXPECT_CALL(display_buffer, view_area())
286 .WillRepeatedly(Return(screen));
287 EXPECT_CALL(display_buffer, can_bypass())
288 .WillRepeatedly(Return(false));
289
290 mtd::StubCompositingCriteria big(5, 10, 100, 200);
291 mtd::StubCompositingCriteria small(10, 20, 30, 40);
292
293 std::vector<mc::CompositingCriteria*> renderable_vec;
294 renderable_vec.push_back(&big);
295 renderable_vec.push_back(&small);
296
297 Sequence render_seq;
298
299 EXPECT_CALL(display_buffer, make_current())
300 .InSequence(render_seq);
301 EXPECT_CALL(renderer_factory.mock_renderer, begin())
302 .InSequence(render_seq);
303 EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(big),_))
304 .InSequence(render_seq);
305 EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(small),_))
306 .InSequence(render_seq);
307 EXPECT_CALL(renderer_factory.mock_renderer, end())
308 .InSequence(render_seq);
309 EXPECT_CALL(display_buffer, post_update())
310 .InSequence(render_seq);
311
312 FakeScene scene(renderable_vec);
313
314 auto compositor_buffer = std::make_shared<mtd::MockBuffer>();
315 EXPECT_CALL(*compositor_buffer, can_bypass())
316 .Times(0);
317
318 mc::DefaultDisplayBufferCompositorFactory factory(
319 mt::fake_shared(scene),
320 mt::fake_shared(renderer_factory));
321
322 auto comp = factory.create_compositor_for(display_buffer);
323
324 comp->composite();
325}
326
266TEST(DefaultDisplayBufferCompositor, obscured_fullscreen_does_not_bypass)327TEST(DefaultDisplayBufferCompositor, obscured_fullscreen_does_not_bypass)
267{328{
268 using namespace testing;329 using namespace testing;
269330
=== modified file 'tests/unit-tests/graphics/CMakeLists.txt'
--- tests/unit-tests/graphics/CMakeLists.txt 2013-12-19 19:05:57 +0000
+++ tests/unit-tests/graphics/CMakeLists.txt 2014-01-02 07:37:29 +0000
@@ -6,6 +6,7 @@
6 ${CMAKE_CURRENT_SOURCE_DIR}/test_default_display_configuration_policy.cpp6 ${CMAKE_CURRENT_SOURCE_DIR}/test_default_display_configuration_policy.cpp
7 ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_id.cpp7 ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_id.cpp
8 ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_properties.cpp8 ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_properties.cpp
9 ${CMAKE_CURRENT_SOURCE_DIR}/test_pixel_format_utils.cpp
9 ${CMAKE_CURRENT_SOURCE_DIR}/test_surfaceless_egl_context.cpp10 ${CMAKE_CURRENT_SOURCE_DIR}/test_surfaceless_egl_context.cpp
10)11)
1112
1213
=== added file 'tests/unit-tests/graphics/test_pixel_format_utils.cpp'
--- tests/unit-tests/graphics/test_pixel_format_utils.cpp 1970-01-01 00:00:00 +0000
+++ tests/unit-tests/graphics/test_pixel_format_utils.cpp 2014-01-02 07:37:29 +0000
@@ -0,0 +1,90 @@
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 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: Andreas Pokorny <andreas.pokorny@canonical.com>
17 */
18
19#include "mir_toolkit/common.h"
20#include "mir/graphics/pixel_format_utils.h"
21#include <gmock/gmock.h>
22#include <gtest/gtest.h>
23
24using namespace mir::graphics;
25TEST(MirPixelformat, contains_alpha)
26{
27 EXPECT_FALSE(contains_alpha(mir_pixel_format_xbgr_8888));
28 EXPECT_FALSE(contains_alpha(mir_pixel_format_bgr_888));
29 EXPECT_FALSE(contains_alpha(mir_pixel_format_xrgb_8888));
30 EXPECT_FALSE(contains_alpha(mir_pixel_format_xbgr_8888));
31 EXPECT_TRUE(contains_alpha(mir_pixel_format_argb_8888));
32 EXPECT_TRUE(contains_alpha(mir_pixel_format_abgr_8888));
33 EXPECT_FALSE(contains_alpha(mir_pixel_format_invalid));
34}
35
36TEST(MirPixelformat, red_channel_depths)
37{
38 EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xbgr_8888));
39 EXPECT_EQ(8, red_channel_depth(mir_pixel_format_bgr_888));
40 EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xrgb_8888));
41 EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xbgr_8888));
42 EXPECT_EQ(8, red_channel_depth(mir_pixel_format_argb_8888));
43 EXPECT_EQ(8, red_channel_depth(mir_pixel_format_abgr_8888));
44 EXPECT_EQ(0, red_channel_depth(mir_pixel_format_invalid));
45}
46
47TEST(MirPixelformat, blue_channel_depths)
48{
49 EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xbgr_8888));
50 EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_bgr_888));
51 EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xrgb_8888));
52 EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xbgr_8888));
53 EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_argb_8888));
54 EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_abgr_8888));
55 EXPECT_EQ(0, blue_channel_depth(mir_pixel_format_invalid));
56}
57
58TEST(MirPixelformat, green_channel_depths)
59{
60 EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xbgr_8888));
61 EXPECT_EQ(8, green_channel_depth(mir_pixel_format_bgr_888));
62 EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xrgb_8888));
63 EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xbgr_8888));
64 EXPECT_EQ(8, green_channel_depth(mir_pixel_format_argb_8888));
65 EXPECT_EQ(8, green_channel_depth(mir_pixel_format_abgr_8888));
66 EXPECT_EQ(0, green_channel_depth(mir_pixel_format_invalid));
67}
68
69
70TEST(MirPixelformat, alpha_channel_depths)
71{
72 EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xbgr_8888));
73 EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_bgr_888));
74 EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xrgb_8888));
75 EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xbgr_8888));
76 EXPECT_EQ(8, alpha_channel_depth(mir_pixel_format_argb_8888));
77 EXPECT_EQ(8, alpha_channel_depth(mir_pixel_format_abgr_8888));
78 EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_invalid));
79}
80
81TEST(MirPixelformat, valid_format)
82{
83 EXPECT_TRUE(valid_format(mir_pixel_format_xbgr_8888));
84 EXPECT_TRUE(valid_format(mir_pixel_format_bgr_888));
85 EXPECT_TRUE(valid_format(mir_pixel_format_xrgb_8888));
86 EXPECT_TRUE(valid_format(mir_pixel_format_xbgr_8888));
87 EXPECT_TRUE(valid_format(mir_pixel_format_argb_8888));
88 EXPECT_TRUE(valid_format(mir_pixel_format_abgr_8888));
89 EXPECT_FALSE(valid_format(mir_pixel_format_invalid));
90}

Subscribers

People subscribed via source and target branches