Merge lp:~kdub/mir/no-mirtestdraw into lp:mir
- no-mirtestdraw
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Alberto Aguirre |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2081 |
Proposed branch: | lp:~kdub/mir/no-mirtestdraw |
Merge into: | lp:mir |
Diff against target: |
837 lines (+125/-379) 16 files modified
examples/CMakeLists.txt (+0/-3) examples/render_overlays.cpp (+46/-11) examples/testdraw/mesa_graphics_region_factory.cpp (+0/-42) tests/integration-tests/CMakeLists.txt (+1/-1) tests/integration-tests/client/CMakeLists.txt (+0/-8) tests/integration-tests/graphics/android/CMakeLists.txt (+6/-0) tests/integration-tests/graphics/android/android_graphics_region_factory.cpp (+43/-77) tests/integration-tests/graphics/android/graphics_region_factory.h (+9/-11) tests/integration-tests/graphics/android/patterns.cpp (+5/-5) tests/integration-tests/graphics/android/patterns.h (+0/-4) tests/integration-tests/graphics/android/test_buffer_integration.cpp (+6/-9) tests/integration-tests/graphics/android/test_client_render.cpp (+9/-10) tests/integration-tests/graphics/android/testdraw/CMakeLists.txt (+0/-34) tests/unit-tests/CMakeLists.txt (+0/-2) tests/unit-tests/draw/CMakeLists.txt (+0/-5) tests/unit-tests/draw/test_draw_patterns.cpp (+0/-157) |
To merge this branch: | bzr merge lp:~kdub/mir/no-mirtestdraw |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alberto Aguirre (community) | Approve | ||
Alan Griffiths | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Cemil Azizoglu (community) | Approve | ||
Review via email: mp+242078@code.launchpad.net |
Commit message
clean up tests by removing the mostly-
Description of the change
clean up tests by removing the mostly-
The primary point of this branch is to clean up examples/ so some of the android headers can be privatized, but it also lessens (but does not fix) the problems mentioned lp: 1367435
I still think the BufferWriter interface should be improved upon (point 3 in my review here: https:/
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
Looks good.
Nits:
58 + size_t pixel_size()
59 + {
60 + return size * sizeof(uint32_t);
61 + }
The name is confusing. Something like size_in_bytes() would be better (pixel_size makes one think it's size_in_pixels). Also, why not multiply by 4 (as is done in other places) instead of sizeof(uint32_t). It's not like size of uint32_t differs between architectures.
125 + *buffer_allocator, buffer_writer, buffer_
126 + auto client2 = std::make_
127 + *buffer_allocator, buffer_writer, buffer_
Perhaps, add a space after commas?
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2068
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2069
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alberto Aguirre (albaguirre) wrote : | # |
333 + module = (gralloc_module_t*) hw_module;
C-style cast.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2069
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Kevin DuBois (kdub) wrote : | # |
> Looks good.
>
>
> Nits:
>
> 58 + size_t pixel_size()
> 59 + {
> 60 + return size * sizeof(uint32_t);
> 61 + }
>
> The name is confusing. Something like size_in_bytes() would be better
> (pixel_size makes one think it's size_in_pixels). Also, why not multiply by 4
> (as is done in other places) instead of sizeof(uint32_t). It's not like size
> of uint32_t differs between architectures.
>
size_t is size in bytes, so I left the name just size, and size_t should imply that the size is in bytes. (esp alongside data being an unsigned char*) I also improved the names so that pixel has been removed.
I'll also re-hash that issues like this are exactly why BufferWriter is tricky to actually use in its current form...(https:/
> 125 + *buffer_allocator, buffer_writer,
> buffer_
> 126 + auto client2 = std::make_
> 127 + *buffer_allocator, buffer_writer,
> buffer_
>
> Perhaps, add a space after commas?
fixed
Kevin DuBois (kdub) wrote : | # |
> 333 + module = (gralloc_module_t*) hw_module;
>
> C-style cast.
Move of existing code, but I may as well clean-as-I-go. (other improvements made too)
Alberto Aguirre (albaguirre) wrote : | # |
Alright pre-existing...LGTM then.
Preview Diff
1 | === modified file 'examples/CMakeLists.txt' |
2 | --- examples/CMakeLists.txt 2014-11-12 11:24:53 +0000 |
3 | +++ examples/CMakeLists.txt 2014-11-18 17:55:53 +0000 |
4 | @@ -181,12 +181,9 @@ |
5 | |
6 | target_link_libraries(mir_demo_standalone_render_overlays |
7 | mirserver |
8 | - mirtestdraw |
9 | mircommon |
10 | ) |
11 | |
12 | install(TARGETS mir_demo_standalone_render_overlays |
13 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
14 | ) |
15 | - |
16 | -add_subdirectory(testdraw/) |
17 | |
18 | === modified file 'examples/render_overlays.cpp' |
19 | --- examples/render_overlays.cpp 2014-11-11 13:29:41 +0000 |
20 | +++ examples/render_overlays.cpp 2014-11-18 17:55:53 +0000 |
21 | @@ -24,9 +24,8 @@ |
22 | #include "mir/graphics/platform.h" |
23 | #include "mir/graphics/graphic_buffer_allocator.h" |
24 | #include "mir/graphics/buffer_properties.h" |
25 | - |
26 | -#include "testdraw/graphics_region_factory.h" |
27 | -#include "testdraw/patterns.h" |
28 | +#include "mir/graphics/buffer_writer.h" |
29 | +#include "mir_image.h" |
30 | |
31 | #include <chrono> |
32 | #include <csignal> |
33 | @@ -45,17 +44,49 @@ |
34 | running = false; |
35 | } |
36 | |
37 | +class PixelBufferABGR |
38 | +{ |
39 | +public: |
40 | + PixelBufferABGR(geom::Size sz, uint32_t color) : |
41 | + size{sz.width.as_uint32_t() * sz.height.as_uint32_t()}, |
42 | + data{new uint32_t[size]} |
43 | + { |
44 | + fill(color); |
45 | + } |
46 | + |
47 | + void fill(uint32_t color) |
48 | + { |
49 | + for(auto i = 0u; i < size; i++) |
50 | + data[i] = color; |
51 | + } |
52 | + |
53 | + unsigned char* pixels() |
54 | + { |
55 | + return reinterpret_cast<unsigned char*>(data.get()); |
56 | + } |
57 | + |
58 | + size_t pixel_size() |
59 | + { |
60 | + return size * sizeof(uint32_t); |
61 | + } |
62 | +private: |
63 | + size_t size; |
64 | + std::unique_ptr<uint32_t[]> data; |
65 | +}; |
66 | + |
67 | class DemoOverlayClient |
68 | { |
69 | public: |
70 | DemoOverlayClient( |
71 | mg::GraphicBufferAllocator& buffer_allocator, |
72 | + std::shared_ptr<mg::BufferWriter> const& buffer_writer, |
73 | mg::BufferProperties const& buffer_properties, uint32_t color) |
74 | : front_buffer(buffer_allocator.alloc_buffer(buffer_properties)), |
75 | back_buffer(buffer_allocator.alloc_buffer(buffer_properties)), |
76 | - region_factory(mir::test::draw::create_graphics_region_factory()), |
77 | color{color}, |
78 | - last_tick{std::chrono::high_resolution_clock::now()} |
79 | + last_tick{std::chrono::high_resolution_clock::now()}, |
80 | + buffer_writer{buffer_writer}, |
81 | + pixel_buffer{buffer_properties.size, color} |
82 | { |
83 | } |
84 | |
85 | @@ -65,9 +96,9 @@ |
86 | green_value += compute_update_value(); |
87 | color &= 0xFFFF00FF; |
88 | color |= (green_value << 8); |
89 | + pixel_buffer.fill(color); |
90 | |
91 | - mir::test::draw::DrawPatternSolid fill{color}; |
92 | - fill.draw(*region_factory->graphic_region_from_handle(*back_buffer->native_buffer_handle())); |
93 | + buffer_writer->write(*back_buffer, pixel_buffer.pixels(), pixel_buffer.pixel_size()); |
94 | std::swap(front_buffer, back_buffer); |
95 | } |
96 | |
97 | @@ -90,9 +121,10 @@ |
98 | |
99 | std::shared_ptr<mg::Buffer> front_buffer; |
100 | std::shared_ptr<mg::Buffer> back_buffer; |
101 | - std::shared_ptr<mir::test::draw::GraphicsRegionFactory> region_factory; |
102 | unsigned int color; |
103 | std::chrono::time_point<std::chrono::high_resolution_clock> last_tick; |
104 | + std::shared_ptr<mg::BufferWriter> const buffer_writer; |
105 | + PixelBufferABGR pixel_buffer; |
106 | }; |
107 | |
108 | class DemoRenderable : public mg::Renderable |
109 | @@ -164,15 +196,18 @@ |
110 | auto platform = server.the_graphics_platform(); |
111 | auto display = server.the_display(); |
112 | auto buffer_allocator = platform->create_buffer_allocator(); |
113 | + auto buffer_writer = platform->make_buffer_writer(); |
114 | |
115 | - mg::BufferProperties buffer_properties{ |
116 | + mg::BufferProperties buffer_properties{ |
117 | geom::Size{512, 512}, |
118 | mir_pixel_format_abgr_8888, |
119 | mg::BufferUsage::hardware |
120 | }; |
121 | |
122 | - auto client1 = std::make_shared<DemoOverlayClient>(*buffer_allocator, buffer_properties,0xFF0000FF); |
123 | - auto client2 = std::make_shared<DemoOverlayClient>(*buffer_allocator, buffer_properties,0xFFFFFF00); |
124 | + auto client1 = std::make_shared<DemoOverlayClient>( |
125 | + *buffer_allocator, buffer_writer, buffer_properties,0xFF0000FF); |
126 | + auto client2 = std::make_shared<DemoOverlayClient>( |
127 | + *buffer_allocator, buffer_writer, buffer_properties,0xFFFFFF00); |
128 | |
129 | std::list<std::shared_ptr<mg::Renderable>> renderlist |
130 | { |
131 | |
132 | === removed file 'examples/testdraw/mesa_graphics_region_factory.cpp' |
133 | --- examples/testdraw/mesa_graphics_region_factory.cpp 2014-10-01 06:25:56 +0000 |
134 | +++ examples/testdraw/mesa_graphics_region_factory.cpp 1970-01-01 00:00:00 +0000 |
135 | @@ -1,42 +0,0 @@ |
136 | -/* |
137 | - * Copyright © 2014 Canonical Ltd. |
138 | - * |
139 | - * This program is free software: you can redistribute it and/or modify |
140 | - * it under the terms of the GNU General Public License version 3 as |
141 | - * published by the Free Software Foundation. |
142 | - * |
143 | - * This program is distributed in the hope that it will be useful, |
144 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
145 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
146 | - * GNU General Public License for more details. |
147 | - * |
148 | - * You should have received a copy of the GNU General Public License |
149 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
150 | - * |
151 | - * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
152 | - */ |
153 | - |
154 | -#include "graphics_region_factory.h" |
155 | -#include <boost/throw_exception.hpp> |
156 | -#include <stdexcept> |
157 | - |
158 | -namespace mtd=mir::test::draw; |
159 | - |
160 | -namespace |
161 | -{ |
162 | - |
163 | -class MesaGraphicsRegionFactory : public mir::test::draw::GraphicsRegionFactory |
164 | -{ |
165 | -public: |
166 | - std::shared_ptr<MirGraphicsRegion> graphic_region_from_handle(mir::graphics::NativeBuffer&) |
167 | - { |
168 | - BOOST_THROW_EXCEPTION(std::runtime_error("cannot map graphic region yet")); |
169 | - } |
170 | -}; |
171 | - |
172 | -} |
173 | - |
174 | -std::shared_ptr<mtd::GraphicsRegionFactory> mtd::create_graphics_region_factory() |
175 | -{ |
176 | - return std::make_shared<MesaGraphicsRegionFactory>(); |
177 | -} |
178 | |
179 | === renamed file 'src/include/platform/mir/graphics/buffer_writer.h' => 'include/platform/mir/graphics/buffer_writer.h' |
180 | === modified file 'tests/integration-tests/CMakeLists.txt' |
181 | --- tests/integration-tests/CMakeLists.txt 2014-11-18 03:21:20 +0000 |
182 | +++ tests/integration-tests/CMakeLists.txt 2014-11-18 17:55:53 +0000 |
183 | @@ -87,7 +87,6 @@ |
184 | mirclient-debug-extension |
185 | |
186 | mirdraw |
187 | - mirtestdraw |
188 | mirclientrpc |
189 | mirclientlttngstatic |
190 | |
191 | @@ -101,6 +100,7 @@ |
192 | ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. |
193 | ${DRM_LDFLAGS} ${DRM_LIBRARIES} |
194 | ${GBM_LDFLAGS} ${GBM_LIBRARIES} |
195 | + ${LIBHARDWARE_LIBRARIES} |
196 | ${MIR_PLATFORM_REFERENCES} |
197 | ${MIR_COMMON_REFERENCES} |
198 | ${MIR_SERVER_REFERENCES} |
199 | |
200 | === modified file 'tests/integration-tests/client/CMakeLists.txt' |
201 | --- tests/integration-tests/client/CMakeLists.txt 2014-03-06 06:05:17 +0000 |
202 | +++ tests/integration-tests/client/CMakeLists.txt 2014-11-18 17:55:53 +0000 |
203 | @@ -1,11 +1,3 @@ |
204 | -# TODO(tvoss): These tests are failing for me when run in an emulator |
205 | -if( MIR_TEST_PLATFORM STREQUAL "android") |
206 | -list( |
207 | - APPEND INTEGRATION_TESTS_SRCS |
208 | - ${CMAKE_CURRENT_SOURCE_DIR}/test_client_render.cpp |
209 | -) |
210 | -endif() |
211 | - |
212 | list( |
213 | APPEND INTEGRATION_TESTS_SRCS |
214 | ${CMAKE_CURRENT_SOURCE_DIR}/test_screencast.cpp |
215 | |
216 | === modified file 'tests/integration-tests/graphics/android/CMakeLists.txt' |
217 | --- tests/integration-tests/graphics/android/CMakeLists.txt 2014-10-01 06:25:56 +0000 |
218 | +++ tests/integration-tests/graphics/android/CMakeLists.txt 2014-11-18 17:55:53 +0000 |
219 | @@ -1,11 +1,17 @@ |
220 | list( |
221 | APPEND INTEGRATION_TESTS_SRCS |
222 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_client_render.cpp |
223 | + ${CMAKE_CURRENT_SOURCE_DIR}/patterns.cpp |
224 | + ${CMAKE_CURRENT_SOURCE_DIR}/android_graphics_region_factory.cpp |
225 | ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_integration.cpp |
226 | ${CMAKE_CURRENT_SOURCE_DIR}/test_display_integration.cpp |
227 | ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client.cpp |
228 | $<TARGET_OBJECTS:mirplatformgraphicsandroidobjects> |
229 | ) |
230 | |
231 | +#include_directories(SYSTEM ${LIBHARDWARE_INCLUDE_DIRS}) |
232 | +#add_definitions(-DANDROID) |
233 | + |
234 | set( |
235 | INTEGRATION_TESTS_SRCS |
236 | ${INTEGRATION_TESTS_SRCS} |
237 | |
238 | === renamed file 'examples/testdraw/android_graphics_region_factory.cpp' => 'tests/integration-tests/graphics/android/android_graphics_region_factory.cpp' |
239 | --- examples/testdraw/android_graphics_region_factory.cpp 2014-10-01 06:25:56 +0000 |
240 | +++ tests/integration-tests/graphics/android/android_graphics_region_factory.cpp 2014-11-18 17:55:53 +0000 |
241 | @@ -20,83 +20,49 @@ |
242 | #include "mir_toolkit/mir_client_library.h" |
243 | #include "mir/graphics/android/native_buffer.h" |
244 | #include "mir_toolkit/common.h" |
245 | - |
246 | -#include <hardware/gralloc.h> |
247 | #include <stdexcept> |
248 | |
249 | -namespace mtd=mir::test::draw; |
250 | -namespace mga=mir::graphics::android; |
251 | - |
252 | -namespace |
253 | -{ |
254 | -struct RegionDeleter |
255 | -{ |
256 | - RegionDeleter(gralloc_module_t* grmod, native_handle_t const* handle) |
257 | - : grmod(grmod), |
258 | - handle(handle) |
259 | - { |
260 | - } |
261 | - |
262 | - void operator()(MirGraphicsRegion* region) |
263 | - { |
264 | - grmod->unlock(grmod, handle); |
265 | - delete region; |
266 | - } |
267 | - |
268 | - gralloc_module_t *grmod; |
269 | - native_handle_t const* handle; |
270 | -}; |
271 | - |
272 | -class AndroidGraphicsRegionFactory : public mir::test::draw::GraphicsRegionFactory |
273 | -{ |
274 | -public: |
275 | - AndroidGraphicsRegionFactory() |
276 | - { |
277 | - const hw_module_t *hw_module; |
278 | - if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &hw_module) != 0) |
279 | - throw std::runtime_error("error, hw module not available!\n"); |
280 | - gralloc_open(hw_module, &alloc_dev); |
281 | - module = (gralloc_module_t*) hw_module; |
282 | - } |
283 | - |
284 | - ~AndroidGraphicsRegionFactory() |
285 | - { |
286 | - gralloc_close(alloc_dev); |
287 | - } |
288 | - |
289 | - std::shared_ptr<MirGraphicsRegion> graphic_region_from_handle( |
290 | - mir::graphics::NativeBuffer& native_buffer) |
291 | - { |
292 | - native_buffer.ensure_available_for(mga::BufferAccess::write); |
293 | - auto anwb = native_buffer.anwb(); |
294 | - int *vaddr; |
295 | - int usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN; |
296 | - module->lock( |
297 | - module, |
298 | - anwb->handle, usage, |
299 | - 0, 0, anwb->width, anwb->height, |
300 | - (void**) &vaddr); |
301 | - |
302 | - MirGraphicsRegion* region = new MirGraphicsRegion; |
303 | - RegionDeleter del(module, anwb->handle); |
304 | - |
305 | - region->vaddr = (char*) vaddr; |
306 | - region->stride = anwb->stride * MIR_BYTES_PER_PIXEL(mir_pixel_format_abgr_8888); |
307 | - region->width = anwb->width; |
308 | - region->height = anwb->height; |
309 | - region->pixel_format = mir_pixel_format_abgr_8888; |
310 | - |
311 | - return std::shared_ptr<MirGraphicsRegion>(region, del); |
312 | - } |
313 | - |
314 | -private: |
315 | - gralloc_module_t* module; |
316 | - alloc_device_t* alloc_dev; |
317 | -}; |
318 | - |
319 | -} |
320 | - |
321 | -std::shared_ptr<mtd::GraphicsRegionFactory> mtd::create_graphics_region_factory() |
322 | -{ |
323 | - return std::make_shared<AndroidGraphicsRegionFactory>(); |
324 | +namespace mga = mir::graphics::android; |
325 | +namespace mt = mir::test; |
326 | + |
327 | +mt::GraphicsRegionFactory::GraphicsRegionFactory() |
328 | +{ |
329 | + const hw_module_t *hw_module; |
330 | + if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &hw_module) != 0) |
331 | + throw std::runtime_error("error, hw module not available!\n"); |
332 | + gralloc_open(hw_module, &alloc_dev); |
333 | + module = (gralloc_module_t*) hw_module; |
334 | +} |
335 | + |
336 | +mt::GraphicsRegionFactory::~GraphicsRegionFactory() |
337 | +{ |
338 | + gralloc_close(alloc_dev); |
339 | +} |
340 | + |
341 | +std::shared_ptr<MirGraphicsRegion> mt::GraphicsRegionFactory::graphic_region_from_handle( |
342 | + mir::graphics::NativeBuffer& native_buffer) |
343 | +{ |
344 | + native_buffer.ensure_available_for(mga::BufferAccess::write); |
345 | + auto anwb = native_buffer.anwb(); |
346 | + char* vaddr; |
347 | + int usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN; |
348 | + module->lock( |
349 | + module, |
350 | + anwb->handle, usage, |
351 | + 0, 0, anwb->width, anwb->height, |
352 | + reinterpret_cast<void**>(&vaddr)); |
353 | + |
354 | + auto* region = new MirGraphicsRegion; |
355 | + region->vaddr = vaddr; |
356 | + region->stride = anwb->stride * MIR_BYTES_PER_PIXEL(mir_pixel_format_abgr_8888); |
357 | + region->width = anwb->width; |
358 | + region->height = anwb->height; |
359 | + region->pixel_format = mir_pixel_format_abgr_8888; |
360 | + |
361 | + return std::shared_ptr<MirGraphicsRegion>(region, |
362 | + [this, anwb](MirGraphicsRegion* region) |
363 | + { |
364 | + module->unlock(module, anwb->handle); |
365 | + delete region; |
366 | + }); |
367 | } |
368 | |
369 | === renamed file 'examples/testdraw/draw_pattern_checkered-inl.h' => 'tests/integration-tests/graphics/android/draw_pattern_checkered-inl.h' |
370 | === renamed file 'examples/testdraw/graphics_region_factory.h' => 'tests/integration-tests/graphics/android/graphics_region_factory.h' |
371 | --- examples/testdraw/graphics_region_factory.h 2014-10-01 06:25:56 +0000 |
372 | +++ tests/integration-tests/graphics/android/graphics_region_factory.h 2014-11-18 17:55:53 +0000 |
373 | @@ -20,31 +20,29 @@ |
374 | |
375 | #include "mir/graphics/native_buffer.h" |
376 | #include "mir_toolkit/mir_client_library.h" |
377 | +#include <hardware/gralloc.h> |
378 | #include <memory> |
379 | |
380 | namespace mir |
381 | { |
382 | namespace test |
383 | { |
384 | -namespace draw |
385 | -{ |
386 | - |
387 | class GraphicsRegionFactory |
388 | { |
389 | public: |
390 | - virtual ~GraphicsRegionFactory() {} |
391 | - virtual std::shared_ptr<MirGraphicsRegion> graphic_region_from_handle( |
392 | - graphics::NativeBuffer& native_buffer) = 0; |
393 | + GraphicsRegionFactory(); |
394 | + ~GraphicsRegionFactory(); |
395 | + std::shared_ptr<MirGraphicsRegion> graphic_region_from_handle( |
396 | + graphics::NativeBuffer& native_buffer); |
397 | |
398 | protected: |
399 | - GraphicsRegionFactory() = default; |
400 | GraphicsRegionFactory(GraphicsRegionFactory const&) = delete; |
401 | GraphicsRegionFactory& operator=(GraphicsRegionFactory const&) = delete; |
402 | + |
403 | +private: |
404 | + gralloc_module_t* module; |
405 | + alloc_device_t* alloc_dev; |
406 | }; |
407 | - |
408 | -std::shared_ptr<GraphicsRegionFactory> create_graphics_region_factory(); |
409 | - |
410 | -} |
411 | } |
412 | } |
413 | #endif /* MIR_TEST_DRAW_GRAPHICS_REGION_FACTORY */ |
414 | |
415 | === renamed file 'examples/testdraw/patterns.cpp' => 'tests/integration-tests/graphics/android/patterns.cpp' |
416 | --- examples/testdraw/patterns.cpp 2014-10-01 06:25:56 +0000 |
417 | +++ tests/integration-tests/graphics/android/patterns.cpp 2014-11-18 17:55:53 +0000 |
418 | @@ -19,14 +19,14 @@ |
419 | #include "patterns.h" |
420 | #include "mir_toolkit/common.h" |
421 | |
422 | -namespace mtd=mir::test::draw; |
423 | +namespace mt=mir::test; |
424 | |
425 | -mtd::DrawPatternSolid::DrawPatternSolid(uint32_t color_value) |
426 | - : color_value(color_value) |
427 | +mt::DrawPatternSolid::DrawPatternSolid(uint32_t color_value) : |
428 | + color_value(color_value) |
429 | { |
430 | } |
431 | |
432 | -void mtd::DrawPatternSolid::draw(MirGraphicsRegion const& region) const |
433 | +void mt::DrawPatternSolid::draw(MirGraphicsRegion const& region) const |
434 | { |
435 | if (region.pixel_format != mir_pixel_format_abgr_8888 ) |
436 | throw(std::runtime_error("cannot draw region, incorrect format")); |
437 | @@ -42,7 +42,7 @@ |
438 | } |
439 | } |
440 | |
441 | -bool mtd::DrawPatternSolid::check(MirGraphicsRegion const& region) const |
442 | +bool mt::DrawPatternSolid::check(MirGraphicsRegion const& region) const |
443 | { |
444 | if (region.pixel_format != mir_pixel_format_abgr_8888 ) |
445 | throw(std::runtime_error("cannot check region, incorrect format")); |
446 | |
447 | === renamed file 'examples/testdraw/patterns.h' => 'tests/integration-tests/graphics/android/patterns.h' |
448 | --- examples/testdraw/patterns.h 2014-10-01 06:25:56 +0000 |
449 | +++ tests/integration-tests/graphics/android/patterns.h 2014-11-18 17:55:53 +0000 |
450 | @@ -22,7 +22,6 @@ |
451 | |
452 | #include <memory> |
453 | #include <stdexcept> |
454 | -/* todo: replace with color value types */ |
455 | #include <stdint.h> |
456 | #include <cstring> |
457 | |
458 | @@ -30,8 +29,6 @@ |
459 | { |
460 | namespace test |
461 | { |
462 | -namespace draw |
463 | -{ |
464 | |
465 | class DrawPattern |
466 | { |
467 | @@ -76,6 +73,5 @@ |
468 | |
469 | } |
470 | } |
471 | -} |
472 | |
473 | #endif /*MIR_TEST_DRAW_PATTERNS_H */ |
474 | |
475 | === modified file 'tests/integration-tests/graphics/android/test_buffer_integration.cpp' |
476 | --- tests/integration-tests/graphics/android/test_buffer_integration.cpp 2014-10-21 16:21:14 +0000 |
477 | +++ tests/integration-tests/graphics/android/test_buffer_integration.cpp 2014-11-18 17:55:53 +0000 |
478 | @@ -21,23 +21,20 @@ |
479 | #include "src/server/report/null_report_factory.h" |
480 | #include "mir/graphics/android/native_buffer.h" |
481 | #include "mir/graphics/buffer_properties.h" |
482 | - |
483 | -#include "examples/testdraw/graphics_region_factory.h" |
484 | -#include "examples/testdraw/patterns.h" |
485 | +#include "graphics_region_factory.h" |
486 | +#include "patterns.h" |
487 | |
488 | #include "mir_test_doubles/stub_frame_dropping_policy_factory.h" |
489 | - |
490 | #include <gtest/gtest.h> |
491 | |
492 | namespace mc=mir::compositor; |
493 | namespace geom=mir::geometry; |
494 | namespace mga=mir::graphics::android; |
495 | namespace mg=mir::graphics; |
496 | -namespace mtd=mir::test::draw; |
497 | +namespace mt=mir::test; |
498 | |
499 | namespace |
500 | { |
501 | - |
502 | class AndroidBufferIntegration : public ::testing::Test |
503 | { |
504 | protected: |
505 | @@ -46,13 +43,13 @@ |
506 | size = geom::Size{334, 122}; |
507 | pf = mir_pixel_format_abgr_8888; |
508 | buffer_properties = mg::BufferProperties{size, pf, mg::BufferUsage::software}; |
509 | - graphics_region_factory = mtd::create_graphics_region_factory(); |
510 | + graphics_region_factory = std::make_shared<mt::GraphicsRegionFactory>(); |
511 | } |
512 | |
513 | geom::Size size; |
514 | MirPixelFormat pf; |
515 | mg::BufferProperties buffer_properties; |
516 | - std::shared_ptr<mtd::GraphicsRegionFactory> graphics_region_factory; |
517 | + std::shared_ptr<mt::GraphicsRegionFactory> graphics_region_factory; |
518 | mir::test::doubles::StubFrameDroppingPolicyFactory policy_factory; |
519 | }; |
520 | |
521 | @@ -93,7 +90,7 @@ |
522 | |
523 | auto region = graphics_region_factory->graphic_region_from_handle( |
524 | *test_buffer->native_buffer_handle()); |
525 | - mtd::DrawPatternSolid red_pattern(0xFF0000FF); |
526 | + mt::DrawPatternSolid red_pattern(0xFF0000FF); |
527 | red_pattern.draw(*region); |
528 | EXPECT_TRUE(red_pattern.check(*region)); |
529 | } |
530 | |
531 | === renamed file 'tests/integration-tests/client/test_client_render.cpp' => 'tests/integration-tests/graphics/android/test_client_render.cpp' |
532 | --- tests/integration-tests/client/test_client_render.cpp 2014-11-11 15:50:11 +0000 |
533 | +++ tests/integration-tests/graphics/android/test_client_render.cpp 2014-11-18 17:55:53 +0000 |
534 | @@ -24,11 +24,11 @@ |
535 | #include "src/platform/graphics/android/android_graphic_buffer_allocator.h" |
536 | |
537 | #include "mir_test_framework/cross_process_sync.h" |
538 | -#include "examples/testdraw/graphics_region_factory.h" |
539 | -#include "examples/testdraw/patterns.h" |
540 | #include "mir_test/stub_server_tool.h" |
541 | #include "mir_test/test_protobuf_server.h" |
542 | #include "mir_test/validity_matchers.h" |
543 | +#include "patterns.h" |
544 | +#include "graphics_region_factory.h" |
545 | |
546 | #include "mir/frontend/connector.h" |
547 | |
548 | @@ -40,7 +40,6 @@ |
549 | |
550 | namespace mtf = mir_test_framework; |
551 | namespace mt=mir::test; |
552 | -namespace mtd=mir::test::draw; |
553 | namespace mga=mir::graphics::android; |
554 | namespace mg=mir::graphics; |
555 | namespace geom=mir::geometry; |
556 | @@ -53,8 +52,8 @@ |
557 | {0x34567890, 0x45678901}}; |
558 | static uint32_t pattern1 [2][2] = {{0xFFFFFFFF, 0xFFFF0000}, |
559 | {0xFF00FF00, 0xFF0000FF}}; |
560 | -static mtd::DrawPatternCheckered<2,2> draw_pattern0(pattern0); |
561 | -static mtd::DrawPatternCheckered<2,2> draw_pattern1(pattern1); |
562 | +static mt::DrawPatternCheckered<2,2> draw_pattern0(pattern0); |
563 | +static mt::DrawPatternCheckered<2,2> draw_pattern1(pattern1); |
564 | static const char socket_file[] = "./test_client_ipc_render_socket"; |
565 | |
566 | struct TestClient |
567 | @@ -327,7 +326,7 @@ |
568 | } |
569 | |
570 | void SetUp() { |
571 | - buffer_converter = mtd::create_graphics_region_factory(); |
572 | + buffer_converter = std::make_shared<mt::GraphicsRegionFactory>(); |
573 | |
574 | /* start a server */ |
575 | mock_server = std::make_shared<StubServerGenerator>(); |
576 | @@ -344,7 +343,7 @@ |
577 | std::shared_ptr<mt::TestProtobufServer> test_server; |
578 | std::shared_ptr<StubServerGenerator> mock_server; |
579 | |
580 | - std::shared_ptr<mtd::GraphicsRegionFactory> buffer_converter; |
581 | + std::shared_ptr<mt::GraphicsRegionFactory> buffer_converter; |
582 | |
583 | static std::shared_ptr<mtf::Process> render_single_client_process; |
584 | static std::shared_ptr<mtf::Process> render_double_client_process; |
585 | @@ -393,7 +392,7 @@ |
586 | |
587 | TEST_F(TestClientIPCRender, test_accelerated_render) |
588 | { |
589 | - mtd::DrawPatternSolid red_pattern(0xFF0000FF); |
590 | + mt::DrawPatternSolid red_pattern(0xFF0000FF); |
591 | |
592 | sync3.try_signal_ready_for(); |
593 | /* wait for client to finish */ |
594 | @@ -407,8 +406,8 @@ |
595 | |
596 | TEST_F(TestClientIPCRender, test_accelerated_render_double) |
597 | { |
598 | - mtd::DrawPatternSolid red_pattern(0xFF0000FF); |
599 | - mtd::DrawPatternSolid green_pattern(0xFF00FF00); |
600 | + mt::DrawPatternSolid red_pattern(0xFF0000FF); |
601 | + mt::DrawPatternSolid green_pattern(0xFF00FF00); |
602 | |
603 | sync4.try_signal_ready_for(); |
604 | /* wait for client to finish */ |
605 | |
606 | === renamed directory 'examples/testdraw' => 'tests/integration-tests/graphics/android/testdraw' |
607 | === modified file 'tests/integration-tests/graphics/android/testdraw/CMakeLists.txt' |
608 | --- examples/testdraw/CMakeLists.txt 2014-03-26 05:48:59 +0000 |
609 | +++ tests/integration-tests/graphics/android/testdraw/CMakeLists.txt 2014-11-18 17:55:53 +0000 |
610 | @@ -1,34 +0,0 @@ |
611 | -include_directories( |
612 | - ${Boost_INCLUDE_DIRS} |
613 | - ${GLESv2_INCLUDE_DIRS} |
614 | - ${CMAKE_SOURCE_DIR} |
615 | - ${PROJECT_SOURCE_DIR}/include/client |
616 | -) |
617 | - |
618 | -set( |
619 | - DRAW_SRCS |
620 | - |
621 | - patterns.cpp |
622 | -) |
623 | - |
624 | -if (MIR_TEST_PLATFORM STREQUAL "android") |
625 | - include_directories(SYSTEM ${LIBHARDWARE_INCLUDE_DIRS}) |
626 | - add_definitions(-DANDROID) |
627 | - set(DRAW_SRCS |
628 | - android_graphics_region_factory.cpp |
629 | - ${DRAW_SRCS}) |
630 | -else() |
631 | - set(DRAW_SRCS |
632 | - mesa_graphics_region_factory.cpp |
633 | - ${DRAW_SRCS}) |
634 | -endif() |
635 | - |
636 | -add_library( |
637 | - mirtestdraw STATIC |
638 | - ${DRAW_SRCS}) |
639 | - |
640 | -target_link_libraries( |
641 | - mirtestdraw |
642 | - |
643 | - ${LIBHARDWARE_LIBRARIES} |
644 | - ) |
645 | |
646 | === modified file 'tests/unit-tests/CMakeLists.txt' |
647 | --- tests/unit-tests/CMakeLists.txt 2014-11-06 03:56:24 +0000 |
648 | +++ tests/unit-tests/CMakeLists.txt 2014-11-18 17:55:53 +0000 |
649 | @@ -50,7 +50,6 @@ |
650 | add_subdirectory(input/) |
651 | add_subdirectory(android_input/) |
652 | add_subdirectory(scene/) |
653 | -add_subdirectory(draw/) |
654 | add_subdirectory(examples/) |
655 | add_subdirectory(thread/) |
656 | |
657 | @@ -74,7 +73,6 @@ |
658 | mir_unit_tests |
659 | |
660 | mirdraw |
661 | - mirtestdraw |
662 | mirclientrpc |
663 | mirclientlttngstatic |
664 | demo-shell |
665 | |
666 | === removed directory 'tests/unit-tests/draw' |
667 | === removed file 'tests/unit-tests/draw/CMakeLists.txt' |
668 | --- tests/unit-tests/draw/CMakeLists.txt 2013-03-13 04:54:15 +0000 |
669 | +++ tests/unit-tests/draw/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
670 | @@ -1,5 +0,0 @@ |
671 | -list(APPEND UNIT_TEST_SOURCES |
672 | - ${CMAKE_CURRENT_SOURCE_DIR}/test_draw_patterns.cpp |
673 | -) |
674 | - |
675 | -set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE) |
676 | |
677 | === removed file 'tests/unit-tests/draw/test_draw_patterns.cpp' |
678 | --- tests/unit-tests/draw/test_draw_patterns.cpp 2014-10-21 16:21:14 +0000 |
679 | +++ tests/unit-tests/draw/test_draw_patterns.cpp 1970-01-01 00:00:00 +0000 |
680 | @@ -1,157 +0,0 @@ |
681 | -/* |
682 | - * Copyright © 2012 Canonical Ltd. |
683 | - * |
684 | - * This program is free software: you can redistribute it and/or modify |
685 | - * it under the terms of the GNU General Public License version 3 as |
686 | - * published by the Free Software Foundation. |
687 | - * |
688 | - * This program is distributed in the hope that it will be useful, |
689 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
690 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
691 | - * GNU General Public License for more details. |
692 | - * |
693 | - * You should have received a copy of the GNU General Public License |
694 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
695 | - * |
696 | - * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
697 | - */ |
698 | - |
699 | -#include "mir_toolkit/mir_client_library.h" |
700 | -#include "examples/testdraw/patterns.h" |
701 | - |
702 | -#include <gtest/gtest.h> |
703 | -#include <stdexcept> |
704 | - |
705 | -namespace mtd=mir::test::draw; |
706 | - |
707 | -class DrawPatternsTest : public ::testing::Test |
708 | -{ |
709 | -protected: |
710 | - DrawPatternsTest() |
711 | - : stride_color(0x77) |
712 | - {} |
713 | - |
714 | - virtual void SetUp() |
715 | - { |
716 | - |
717 | - test_region.pixel_format = mir_pixel_format_abgr_8888; |
718 | - bytes_pp = 4; |
719 | - test_region.width = 100; |
720 | - /* misaligned stride to tease out stride problems */ |
721 | - test_region.stride = (test_region.width * bytes_pp) + 2; |
722 | - test_region.height = 50; |
723 | - auto region_size = |
724 | - sizeof(char) * bytes_pp * test_region.height * test_region.stride; |
725 | - region = std::shared_ptr<char>(static_cast<char*>(::operator new(region_size))); |
726 | - test_region.vaddr = region.get(); |
727 | - |
728 | - uint32_t colors[2][2] = {{0x12345678, 0x23456789}, |
729 | - {0x34567890, 0x45678901}}; |
730 | - memcpy(pattern_colors, colors, sizeof(uint32_t)*4); |
731 | - |
732 | - write_stride_region(); |
733 | - } |
734 | - virtual void TearDown() |
735 | - { |
736 | - EXPECT_TRUE(check_stride_region_unaltered()); |
737 | - } |
738 | - |
739 | - MirGraphicsRegion test_region; |
740 | - uint32_t pattern_colors [2][2]; |
741 | - int bytes_pp; |
742 | - std::shared_ptr<char> region; |
743 | -private: |
744 | - /* check that no pattern writes or checks the stride region */ |
745 | - void write_stride_region() |
746 | - { |
747 | - for(auto i = 0; i < test_region.height; i++) |
748 | - { |
749 | - for(auto j = test_region.width * bytes_pp; j < test_region.stride; j++) |
750 | - { |
751 | - test_region.vaddr[ (i * test_region.stride) + j ] = stride_color; |
752 | - } |
753 | - } |
754 | - } |
755 | - |
756 | - bool check_stride_region_unaltered() |
757 | - { |
758 | - for(auto i=0; i < test_region.height; i++) |
759 | - { |
760 | - for(auto j=test_region.width * bytes_pp; j < test_region.stride; j++) |
761 | - { |
762 | - if(test_region.vaddr[ ((i * test_region.stride) + j) ] != stride_color) |
763 | - { |
764 | - return false; |
765 | - } |
766 | - } |
767 | - } |
768 | - return true; |
769 | - } |
770 | - |
771 | - const char stride_color; |
772 | -}; |
773 | - |
774 | -TEST_F(DrawPatternsTest, solid_color_unaccelerated) |
775 | -{ |
776 | - mtd::DrawPatternSolid pattern(0x43214321); |
777 | - |
778 | - pattern.draw(test_region); |
779 | - EXPECT_TRUE(pattern.check(test_region)); |
780 | -} |
781 | - |
782 | -TEST_F(DrawPatternsTest, solid_color_unaccelerated_error) |
783 | -{ |
784 | - mtd::DrawPatternSolid pattern(0x43214321); |
785 | - |
786 | - pattern.draw(test_region); |
787 | - test_region.vaddr[0]++; |
788 | - EXPECT_FALSE(pattern.check(test_region)); |
789 | -} |
790 | - |
791 | -TEST_F(DrawPatternsTest, solid_bad_pixel_formats) |
792 | -{ |
793 | - test_region.pixel_format = mir_pixel_format_xbgr_8888; |
794 | - |
795 | - mtd::DrawPatternSolid pattern(0x43214321); |
796 | - |
797 | - EXPECT_THROW({ |
798 | - pattern.draw(test_region); |
799 | - }, std::runtime_error); |
800 | - |
801 | - EXPECT_THROW({ |
802 | - pattern.check(test_region); |
803 | - }, std::runtime_error); |
804 | - |
805 | -} |
806 | - |
807 | -TEST_F(DrawPatternsTest, checkered_pattern) |
808 | -{ |
809 | - mtd::DrawPatternCheckered<2,2> pattern(pattern_colors); |
810 | - pattern.draw(test_region); |
811 | - EXPECT_TRUE(pattern.check(test_region)); |
812 | -} |
813 | - |
814 | -TEST_F(DrawPatternsTest, checkered_pattern_error) |
815 | -{ |
816 | - mtd::DrawPatternCheckered<2,2> pattern(pattern_colors); |
817 | - |
818 | - pattern.draw(test_region); |
819 | - test_region.vaddr[0]++; |
820 | - EXPECT_FALSE(pattern.check(test_region)); |
821 | -} |
822 | - |
823 | -TEST_F(DrawPatternsTest, checkered_bad_pixel_formats) |
824 | -{ |
825 | - test_region.pixel_format = mir_pixel_format_xbgr_8888; |
826 | - |
827 | - mtd::DrawPatternCheckered<2,2> pattern(pattern_colors); |
828 | - |
829 | - EXPECT_THROW({ |
830 | - pattern.draw(test_region); |
831 | - }, std::runtime_error); |
832 | - |
833 | - EXPECT_THROW({ |
834 | - pattern.check(test_region); |
835 | - }, std::runtime_error); |
836 | - |
837 | -} |
63 + std::shared_ ptr<uint32_ t> data;
This ought to be:
std: :unique_ ptr<uint32_ t[]> const data;
Which can be initialized normally:
data{new uint32_t[size]}