Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
draw_pattern_checkered-inl.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012 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: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 
19 template<size_t Rows, size_t Cols>
21 {
22  for (size_t i=0; i<Rows; i++)
23  std::memcpy(color_pattern[i], pattern[i], sizeof(uint32_t) * Cols);
24 }
25 
26 template<size_t Rows, size_t Cols>
28 {
30  throw(std::runtime_error("cannot draw region, incorrect format"));
31 
32  uint32_t *pixel = (uint32_t*) region.vaddr;
33  for(int i=0; i< region.width; i++)
34  {
35  for(int j=0; j<region.height; j++)
36  {
37  int key_row = i % Rows;
38  int key_col = j % Cols;
39  pixel[j*region.stride + i] = color_pattern[key_row][key_col];
40  }
41  }
42 }
43 
44 template<size_t Rows, size_t Cols>
46 {
48  throw(std::runtime_error("cannot check region, incorrect format"));
49 
50  uint32_t *pixel = (uint32_t*) region.vaddr;
51  for(int i=0; i< region.width; i++)
52  {
53  for(int j=0; j<region.height; j++)
54  {
55  int key_row = i % Rows;
56  int key_col = j % Cols;
57  if (pixel[j*region.stride + i] != color_pattern[key_row][key_col])
58  {
59  return false;
60  }
61  }
62  }
63 
64  return true;
65 }

Copyright © 2012,2013 Canonical Ltd.
Generated on Wed Oct 30 18:52:19 UTC 2013