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