~hikiko/mir/mir.unity8-desktop-session

« back to all changes in this revision

Viewing changes to include/test/mir_test/draw/draw_pattern_checkered-inl.h

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Daniel van Vugt, Ubuntu daily release
  • Date: 2014-01-08 02:04:38 UTC
  • mfrom: (1.1.54)
  • Revision ID: package-import@ubuntu.com-20140108020438-ikbu7qqm9v2l026y
Tags: 0.1.3+14.04.20140108-0ubuntu1
[ Daniel van Vugt ]
* Preparing for release 0.1.3

[ Ubuntu daily release ]
* Automatic snapshot from revision 1170

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17
17
 */
18
18
 
19
 
#include "mir/geometry/pixel_format.h"
20
 
namespace geom = mir::geometry;
 
19
#include "mir_toolkit/common.h"
21
20
 
22
21
template<size_t Rows, size_t Cols>
23
22
DrawPatternCheckered<Rows,Cols>::DrawPatternCheckered(uint32_t (&pattern) [Rows][Cols])
32
31
    if (region.pixel_format != mir_pixel_format_abgr_8888)
33
32
        throw(std::runtime_error("cannot draw region, incorrect format"));
34
33
 
35
 
    auto bpp = geom::bytes_per_pixel(geom::PixelFormat::abgr_8888);
 
34
    auto bpp = MIR_BYTES_PER_PIXEL(mir_pixel_format_abgr_8888);
36
35
    for(int i=0; i < region.width; i++)
37
36
    {
38
37
        for(int j=0; j<region.height; j++)
39
38
        {
40
39
            int key_row = i % Rows;
41
40
            int key_col = j % Cols;
42
 
            uint32_t *pixel = reinterpret_cast<uint32_t*>(&region.vaddr[j*region.stride + (i * bpp)]); 
 
41
            uint32_t *pixel = reinterpret_cast<uint32_t*>(&region.vaddr[j*region.stride + (i * bpp)]);
43
42
            *pixel = color_pattern[key_row][key_col];
44
43
        }
45
44
    }
51
50
    if (region.pixel_format != mir_pixel_format_abgr_8888)
52
51
        throw(std::runtime_error("cannot check region, incorrect format"));
53
52
 
54
 
    auto bpp = geom::bytes_per_pixel(geom::PixelFormat::abgr_8888);
 
53
    auto bpp = MIR_BYTES_PER_PIXEL(mir_pixel_format_abgr_8888);
55
54
    for(int i=0; i< region.width; i++)
56
55
    {
57
56
        for(int j=0; j<region.height; j++)
58
57
        {
59
58
            int key_row = i % Rows;
60
59
            int key_col = j % Cols;
61
 
            uint32_t *pixel = reinterpret_cast<uint32_t*>(&region.vaddr[j*region.stride + (i * bpp)]); 
 
60
            uint32_t *pixel = reinterpret_cast<uint32_t*>(&region.vaddr[j*region.stride + (i * bpp)]);
62
61
            if ( *pixel != color_pattern[key_row][key_col] )
63
62
            {
64
63
                return false;