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(false, false), 28 fBackBuffer(NULL), 29 fFrontBuffer(new(nothrow) BitmapBuffer(bitmap)) 30 { 31 } 32 33 34 BitmapHWInterface::~BitmapHWInterface() 35 { 36 delete fBackBuffer; 37 delete fFrontBuffer; 38 } 39 40 41 status_t 42 BitmapHWInterface::Initialize() 43 { 44 status_t ret = HWInterface::Initialize(); 45 if (ret < B_OK) 46 return ret; 47 48 ret = fFrontBuffer->InitCheck(); 49 if (ret < B_OK) 50 return ret; 51 52 // TODO: Remove once unnecessary... 53 // fall back to double buffered mode until Painter knows how 54 // to draw onto non 32-bit surfaces... 55 if (fFrontBuffer->ColorSpace() != B_RGB32 56 && fFrontBuffer->ColorSpace() != B_RGBA32) { 57 BBitmap* backBitmap = new BBitmap(fFrontBuffer->Bounds(), 58 B_BITMAP_NO_SERVER_LINK, B_RGBA32); 59 fBackBuffer = new BBitmapBuffer(backBitmap); 60 61 ret = fBackBuffer->InitCheck(); 62 if (ret < B_OK) { 63 delete fBackBuffer; 64 fBackBuffer = NULL; 65 } else { 66 // import the current contents of the bitmap 67 // into the back bitmap 68 backBitmap->ImportBits(fFrontBuffer->Bits(), 69 fFrontBuffer->BitsLength(), fFrontBuffer->BytesPerRow(), 0, 70 fFrontBuffer->ColorSpace()); 71 } 72 } 73 74 return ret; 75 } 76 77 78 status_t 79 BitmapHWInterface::Shutdown() 80 { 81 return B_OK; 82 } 83 84 85 status_t 86 BitmapHWInterface::SetMode(const display_mode& mode) 87 { 88 return B_UNSUPPORTED; 89 } 90 91 92 void 93 BitmapHWInterface::GetMode(display_mode* mode) 94 { 95 if (mode != NULL) 96 memset(mode, 0, sizeof(display_mode)); 97 } 98 99 100 status_t 101 BitmapHWInterface::GetDeviceInfo(accelerant_device_info* info) 102 { 103 return B_UNSUPPORTED; 104 } 105 106 107 status_t 108 BitmapHWInterface::GetFrameBufferConfig(frame_buffer_config& config) 109 { 110 return B_UNSUPPORTED; 111 } 112 113 114 status_t 115 BitmapHWInterface::GetModeList(display_mode** modes, uint32 *count) 116 { 117 return B_UNSUPPORTED; 118 } 119 120 121 status_t 122 BitmapHWInterface::GetPixelClockLimits(display_mode* mode, uint32* low, 123 uint32* high) 124 { 125 return B_UNSUPPORTED; 126 } 127 128 129 status_t 130 BitmapHWInterface::GetTimingConstraints(display_timing_constraints* constraints) 131 { 132 return B_UNSUPPORTED; 133 } 134 135 136 status_t 137 BitmapHWInterface::ProposeMode(display_mode* candidate, const display_mode* low, 138 const display_mode* high) 139 { 140 return B_UNSUPPORTED; 141 } 142 143 144 sem_id 145 BitmapHWInterface::RetraceSemaphore() 146 { 147 return B_ERROR; 148 } 149 150 151 status_t 152 BitmapHWInterface::WaitForRetrace(bigtime_t timeout) 153 { 154 return B_UNSUPPORTED; 155 } 156 157 158 status_t 159 BitmapHWInterface::SetDPMSMode(uint32 state) 160 { 161 return B_UNSUPPORTED; 162 } 163 164 165 uint32 166 BitmapHWInterface::DPMSMode() 167 { 168 return 0; 169 } 170 171 172 uint32 173 BitmapHWInterface::DPMSCapabilities() 174 { 175 return 0; 176 } 177 178 179 RenderingBuffer* 180 BitmapHWInterface::FrontBuffer() const 181 { 182 return fFrontBuffer; 183 } 184 185 186 RenderingBuffer* 187 BitmapHWInterface::BackBuffer() const 188 { 189 return fBackBuffer; 190 } 191 192 193 bool 194 BitmapHWInterface::IsDoubleBuffered() const 195 { 196 // overwrite double buffered preference 197 if (fFrontBuffer) 198 return fBackBuffer != NULL; 199 200 return HWInterface::IsDoubleBuffered(); 201 } 202