The Pedigree Project  0.1
Display.cc
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 #include "pedigree/kernel/machine/Display.h"
21 #include "pedigree/kernel/Log.h"
22 #include "pedigree/kernel/utilities/Iterator.h"
23 #include "pedigree/kernel/utilities/String.h"
24 #include "pedigree/kernel/utilities/utility.h"
25 
26 Display::ScreenMode::ScreenMode()
27  : id(0), width(0), height(0), refresh(0), framebuffer(0), pf(), pf2(),
28  bytesPerLine(0), bytesPerPixel(0), textMode(false)
29 {
30 }
31 
32 Display::Display()
33 {
34  m_SpecificType = "Generic Display";
35 }
36 
37 Display::Display(Device *p) : Device(p)
38 {
39 }
40 
41 Display::~Display()
42 {
43 }
44 
46 {
47  return Device::Display;
48 }
49 
51 {
52  str = "Generic Display";
53 }
54 
56 {
57  str = "Generic Display";
58 }
59 
61 {
62  return 0;
63 }
64 
66 {
67  return 0;
68 }
69 
71 {
72 }
73 
75  rgb_t *pBuffer, size_t x1, size_t y1, size_t x2, size_t y2)
76 {
77 }
78 
79 void Display::killBuffer(rgb_t *pBuffer)
80 {
81 }
82 
84  rgb_t *pBuffer, size_t fromX, size_t fromY, size_t toX, size_t toY,
85  size_t width, size_t height)
86 {
87 }
88 
90  rgb_t *pBuffer, size_t x, size_t y, size_t width, size_t height,
91  rgb_t colour)
92 {
93 }
94 
96 {
97  return false;
98 }
99 
101 {
102  return false;
103 }
104 
106 {
107  return false;
108 }
109 
111 {
112  return false;
113 }
114 
115 bool Display::setScreenMode(size_t modeId)
116 {
117  Display::ScreenMode *pSm = 0;
118 
120  if (!getScreenModes(modes))
121  return false;
123  it != modes.end(); it++)
124  {
125  if ((*it)->id == modeId)
126  {
127  pSm = *it;
128  break;
129  }
130  }
131  if (pSm == 0)
132  {
133  ERROR("Screenmode not found: " << modeId);
134  return false;
135  }
136 
137  return setScreenMode(*pSm);
138 }
139 
140 bool Display::setScreenMode(size_t nWidth, size_t nHeight, size_t nBpp)
141 {
142  // This default implementation is enough for VBE
145 
146  Display::ScreenMode *pSm = 0;
147 
149  if (!getScreenModes(modes))
150  return false;
152  it != modes.end(); it++)
153  {
154  if (((*it)->width == nWidth) && ((*it)->height == nHeight))
155  {
156  if ((*it)->pf.nBpp == nBpp)
157  {
158  pSm = *it;
159  break;
160  }
161  }
162  }
163  if (pSm == 0)
164  {
165  ERROR(
166  "Screenmode not found: " << Dec << nWidth << "x" << nHeight << "x"
167  << nBpp << Hex);
168  return false;
169  }
170 
171  return setScreenMode(*pSm);
172 }
virtual void getName(String &str)
Definition: Display.cc:50
String m_SpecificType
Definition: Device.h:372
virtual bool getCurrentScreenMode(ScreenMode &sm)
Definition: Display.cc:100
virtual rgb_t * newBuffer()
Definition: Display.cc:65
virtual void updateBuffer(rgb_t *pBuffer, size_t x1=~0UL, size_t y1=~0UL, size_t x2=~0UL, size_t y2=~0UL)
Definition: Display.cc:74
virtual void bitBlit(rgb_t *pBuffer, size_t fromX, size_t fromY, size_t toX, size_t toY, size_t width, size_t height)
Definition: Display.cc:83
virtual void killBuffer(rgb_t *pBuffer)
Definition: Display.cc:79
Definition: String.h:49
virtual bool getPixelFormat(PixelFormat &pf)
Definition: Display.cc:95
Definition: Device.h:43
virtual void fillRectangle(rgb_t *pBuffer, size_t x, size_t y, size_t width, size_t height, rgb_t colour)
Definition: Display.cc:89
Definition: List.h:64
Definition: Log.h:136
virtual Type getType()
Definition: Display.cc:45
Iterator begin()
Definition: List.h:123
virtual bool getScreenModes(List< ScreenMode * > &sms)
Definition: Display.cc:105
virtual void setCurrentBuffer(rgb_t *pBuffer)
Definition: Display.cc:70
#define ERROR(text)
Definition: Log.h:82
Definition: Log.h:138
virtual void dump(String &str)
Definition: Display.cc:55
Type
Definition: Device.h:50
Iterator end()
Definition: List.h:135
virtual bool setScreenMode(ScreenMode sm)
Definition: Display.cc:110
virtual void * getFramebuffer()
Definition: Display.cc:60