xref: /haiku/src/servers/app/drawing/BitmapHWInterface.cpp (revision 13581b3d2a71545960b98fefebc5225b5bf29072)
1 /*
2  * Copyright 2002-2009, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Michael Lotz <mmlr@mlotz.ch>
7  *		DarkWyrm <bpmagic@columbus.rr.com>
8  *		Stephan Aßmus <superstippi@gmx.de>
9  */
10 
11 
12 #include <new>
13 #include <stdio.h>
14 #include <string.h>
15 
16 #include "Bitmap.h"
17 #include "BitmapBuffer.h"
18 #include "BBitmapBuffer.h"
19 
20 #include "BitmapHWInterface.h"
21 
22 using std::nothrow;
23 
24 
25 BitmapHWInterface::BitmapHWInterface(ServerBitmap* bitmap)
26 	:
27 	HWInterface(),
28 	fBackBuffer(NULL),
29 	fFrontBuffer(new(nothrow) BitmapBuffer(bitmap))
30 {
31 }
32 
33 
34 BitmapHWInterface::~BitmapHWInterface()
35 {
36 }
37 
38 
39 status_t
40 BitmapHWInterface::Initialize()
41 {
42 	status_t ret = HWInterface::Initialize();
43 	if (ret < B_OK)
44 		return ret;
45 
46 	ret = fFrontBuffer->InitCheck();
47 	if (ret < B_OK)
48 		return ret;
49 
50 // TODO: Remove once unnecessary...
51 	// fall back to double buffered mode until Painter knows how
52 	// to draw onto non 32-bit surfaces...
53 	if (fFrontBuffer->ColorSpace() != B_RGB32
54 		&& fFrontBuffer->ColorSpace() != B_RGBA32) {
55 		BBitmap* backBitmap = new BBitmap(fFrontBuffer->Bounds(),
56 			B_BITMAP_NO_SERVER_LINK, B_RGBA32);
57 		fBackBuffer.SetTo(new BBitmapBuffer(backBitmap));
58 
59 		ret = fBackBuffer->InitCheck();
60 		if (ret < B_OK) {
61 			fBackBuffer.Unset();
62 		} else {
63 			// import the current contents of the bitmap
64 			// into the back bitmap
65 			backBitmap->ImportBits(fFrontBuffer->Bits(),
66 				fFrontBuffer->BitsLength(), fFrontBuffer->BytesPerRow(), 0,
67 				fFrontBuffer->ColorSpace());
68 		}
69 	}
70 
71 	return ret;
72 }
73 
74 
75 status_t
76 BitmapHWInterface::Shutdown()
77 {
78 	return B_OK;
79 }
80 
81 
82 status_t
83 BitmapHWInterface::SetMode(const display_mode& mode)
84 {
85 	return B_UNSUPPORTED;
86 }
87 
88 
89 void
90 BitmapHWInterface::GetMode(display_mode* mode)
91 {
92 	if (mode != NULL)
93 		memset(mode, 0, sizeof(display_mode));
94 }
95 
96 
97 status_t
98 BitmapHWInterface::GetDeviceInfo(accelerant_device_info* info)
99 {
100 	return B_UNSUPPORTED;
101 }
102 
103 
104 status_t
105 BitmapHWInterface::GetFrameBufferConfig(frame_buffer_config& config)
106 {
107 	return B_UNSUPPORTED;
108 }
109 
110 
111 status_t
112 BitmapHWInterface::GetModeList(display_mode** modes, uint32 *count)
113 {
114 	return B_UNSUPPORTED;
115 }
116 
117 
118 status_t
119 BitmapHWInterface::GetPixelClockLimits(display_mode* mode, uint32* low,
120 	uint32* high)
121 {
122 	return B_UNSUPPORTED;
123 }
124 
125 
126 status_t
127 BitmapHWInterface::GetTimingConstraints(display_timing_constraints* constraints)
128 {
129 	return B_UNSUPPORTED;
130 }
131 
132 
133 status_t
134 BitmapHWInterface::ProposeMode(display_mode* candidate, const display_mode* low,
135 	const display_mode* high)
136 {
137 	return B_UNSUPPORTED;
138 }
139 
140 
141 sem_id
142 BitmapHWInterface::RetraceSemaphore()
143 {
144 	return -1;
145 }
146 
147 
148 status_t
149 BitmapHWInterface::WaitForRetrace(bigtime_t timeout)
150 {
151 	return B_UNSUPPORTED;
152 }
153 
154 
155 status_t
156 BitmapHWInterface::SetDPMSMode(uint32 state)
157 {
158 	return B_UNSUPPORTED;
159 }
160 
161 
162 uint32
163 BitmapHWInterface::DPMSMode()
164 {
165 	return 0;
166 }
167 
168 
169 uint32
170 BitmapHWInterface::DPMSCapabilities()
171 {
172 	return 0;
173 }
174 
175 
176 status_t
177 BitmapHWInterface::SetBrightness(float)
178 {
179 	return B_UNSUPPORTED;
180 }
181 
182 
183 status_t
184 BitmapHWInterface::GetBrightness(float*)
185 {
186 	return B_UNSUPPORTED;
187 }
188 
189 
190 RenderingBuffer*
191 BitmapHWInterface::FrontBuffer() const
192 {
193 	return fFrontBuffer.Get();
194 }
195 
196 
197 RenderingBuffer*
198 BitmapHWInterface::BackBuffer() const
199 {
200 	return fBackBuffer.Get();
201 }
202 
203 
204 bool
205 BitmapHWInterface::IsDoubleBuffered() const
206 {
207 	if (fFrontBuffer.IsSet())
208 		return fBackBuffer.IsSet();
209 
210 	return false;
211 }
212