The Pedigree Project  0.1
environment.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef ENVIRONMENT_H
21 #define ENVIRONMENT_H
22 
23 #include <stdint.h>
24 #include <stdlib.h>
25 
26 #include <Widget.h>
27 
28 struct rgb_t
29 {
30  uint8_t b;
31  uint8_t g;
32  uint8_t r;
33  uint8_t a;
34 } __attribute__((packed));
35 
36 namespace Keyboard
37 {
38 enum KeyFlags
39 {
40  Special = 1ULL << 63,
41  Ctrl = 1ULL << 62,
42  Shift = 1ULL << 61,
43  Alt = 1ULL << 60,
44  AltGr = 1ULL << 59
45 };
46 }
47 
48 namespace Display
49 {
51 struct PixelFormat
52 {
53  uint8_t mRed;
54  uint8_t pRed;
55  uint8_t mGreen;
56  uint8_t pGreen;
57  uint8_t mBlue;
58  uint8_t pBlue;
59  uint8_t mAlpha;
60  uint8_t pAlpha;
61  uint8_t nBpp;
62  uint32_t nPitch;
63 };
64 
66 struct ScreenMode
67 {
68  uint32_t id;
69  uint32_t width;
70  uint32_t height;
71  uint32_t refresh;
72  uintptr_t framebuffer;
73  PixelFormat pf;
74 };
75 } // namespace Display
76 
77 class DirtyRectangle
78 {
79  public:
81  ~DirtyRectangle();
82 
83  void point(size_t x, size_t y);
84 
85  size_t getX()
86  {
87  return m_X;
88  }
89  size_t getY()
90  {
91  return m_Y;
92  }
93  size_t getX2()
94  {
95  return m_X2;
96  }
97  size_t getY2()
98  {
99  return m_Y2;
100  }
101  size_t getWidth()
102  {
103  return m_X2 - m_X + 1;
104  }
105  size_t getHeight()
106  {
107  return m_Y2 - m_Y + 1;
108  }
109 
110  void reset()
111  {
112  m_X = 0;
113  m_Y = 0;
114  m_X2 = 0;
115  m_X2 = 0;
116  }
117 
118  private:
119  size_t m_X, m_Y, m_X2, m_Y2;
120 };
121 
122 rgb_t interpolateColour(rgb_t col1, rgb_t col2, uint16_t a);
123 
124 extern void log(const char *);
125 
126 #endif