We had an unintentional conflict with PixelBuffer::setSize() here.
But we can simplify this further as this initialization is only used
by the subclass DeviceFrameBuffer, and only once.
}
-void DIBSectionBuffer::setPF(const PixelFormat& pf) {
- if (memcmp(&getPF(), &pf, sizeof(pf)) == 0) {
- vlog.debug("pixel format unchanged by setPF()");
- return;
- }
- if (!pf.trueColour)
- throw rfb::Exception("palette format not supported");
- format = pf;
- setSize(width(), height());
-}
-
inline void initMaxAndShift(DWORD mask, int* max, int* shift) {
for ((*shift) = 0; (mask & 1) == 0; (*shift)++) mask >>= 1;
(*max) = (rdr::U16)mask;
}
-void DIBSectionBuffer::setSize(int w, int h) {
+void DIBSectionBuffer::initBuffer(const PixelFormat& pf, int w, int h) {
HBITMAP new_bitmap = 0;
rdr::U8* new_data = 0;
+ if (!pf.trueColour)
+ throw rfb::Exception("palette format not supported");
+
+ format = pf;
+
if (w && h && (format.depth != 0)) {
BitmapInfo bi;
memset(&bi, 0, sizeof(bi));
DIBSectionBuffer(HDC device);
virtual ~DIBSectionBuffer();
- virtual void setPF(const PixelFormat &pf);
- virtual void setSize(int w, int h);
-
- // *** virtual void copyRect(const Rect &dest, const Point &move_by_delta);
public:
HBITMAP bitmap;
protected:
- void recreateBuffer();
+ void initBuffer(const PixelFormat& pf, int w, int h);
HWND window;
HDC device;
};
if (w % 2) w--;
// Configure the underlying DIB to match the device
- DIBSectionBuffer::setPF(DeviceContext::getPF(device));
- DIBSectionBuffer::setSize(w, h);
+ initBuffer(DeviceContext::getPF(device), w, h);
}
DeviceFrameBuffer::~DeviceFrameBuffer() {
}
-void
-DeviceFrameBuffer::setPF(const PixelFormat &pf) {
- throw Exception("setPF not supported");
-}
-
-void
-DeviceFrameBuffer::setSize(int w, int h) {
- throw Exception("setSize not supported");
-}
-
-
#ifndef CAPTUREBLT
#define CAPTUREBLT 0x40000000
#endif
virtual void grabRect(const Rect &rect);
virtual void grabRegion(const Region ®ion);
- // - DIBSectionBuffer overrides
-
- virtual void setPF(const PixelFormat& pf);
- virtual void setSize(int w, int h);
-
// - DeviceFrameBuffer specific methods
void setCursor(HCURSOR c, VNCServer* server);