It was confusing and not properly used everywhere. Callers should use the stride they get when they get the buffer pointer.tags/v1.3.90
@@ -1,4 +1,5 @@ | |||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||
* Copyright 2014 Pierre Ossman for Cendio AB | |||
* | |||
* This is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
@@ -61,8 +62,8 @@ PixelBuffer::getImage(void* imageBuf, const Rect& r, int outStride) { | |||
FullFramePixelBuffer::FullFramePixelBuffer(const PixelFormat& pf, int w, int h, | |||
rdr::U8* data_) | |||
: PixelBuffer(pf, w, h), data(data_) | |||
rdr::U8* data_, int stride_) | |||
: PixelBuffer(pf, w, h), data(data_), stride(stride_) | |||
{ | |||
} | |||
@@ -71,12 +72,10 @@ FullFramePixelBuffer::FullFramePixelBuffer() : data(0) {} | |||
FullFramePixelBuffer::~FullFramePixelBuffer() {} | |||
int FullFramePixelBuffer::getStride() const { return width(); } | |||
rdr::U8* FullFramePixelBuffer::getBufferRW(const Rect& r, int* stride) | |||
rdr::U8* FullFramePixelBuffer::getBufferRW(const Rect& r, int* stride_) | |||
{ | |||
*stride = getStride(); | |||
return &data[(r.tl.x + (r.tl.y * *stride)) * format.bpp/8]; | |||
*stride_ = stride; | |||
return &data[(r.tl.x + (r.tl.y * stride)) * format.bpp/8]; | |||
} | |||
@@ -255,7 +254,7 @@ ManagedPixelBuffer::ManagedPixelBuffer() | |||
}; | |||
ManagedPixelBuffer::ManagedPixelBuffer(const PixelFormat& pf, int w, int h) | |||
: FullFramePixelBuffer(pf, w, h, 0), datasize(0) | |||
: FullFramePixelBuffer(pf, w, h, NULL, w), datasize(0) | |||
{ | |||
checkDataSize(); | |||
}; | |||
@@ -271,7 +270,7 @@ ManagedPixelBuffer::setPF(const PixelFormat &pf) { | |||
}; | |||
void | |||
ManagedPixelBuffer::setSize(int w, int h) { | |||
width_ = w; height_ = h; checkDataSize(); | |||
width_ = w; height_ = h; stride = w; checkDataSize(); | |||
}; | |||
@@ -1,4 +1,5 @@ | |||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||
* Copyright 2014 Pierre Ossman for Cendio AB | |||
* | |||
* This is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
@@ -93,14 +94,10 @@ namespace rfb { | |||
class FullFramePixelBuffer : public PixelBuffer { | |||
public: | |||
FullFramePixelBuffer(const PixelFormat& pf, int width, int height, | |||
rdr::U8* data_); | |||
rdr::U8* data, int stride); | |||
virtual ~FullFramePixelBuffer(); | |||
public: | |||
// - Get the number of pixels per row in the actual pixel buffer data area | |||
// This may in some cases NOT be the same as width(). | |||
virtual int getStride() const; | |||
// Get a pointer to specified pixel data | |||
virtual const rdr::U8* getBuffer(const Rect& r, int* stride) { | |||
return getBufferRW(r, stride); | |||
@@ -134,6 +131,7 @@ namespace rfb { | |||
FullFramePixelBuffer(); | |||
rdr::U8* data; | |||
int stride; | |||
}; | |||
// -=- Managed pixel buffer class |
@@ -35,8 +35,7 @@ XPixelBuffer::XPixelBuffer(Display *dpy, ImageFactory &factory, | |||
m_dpy(dpy), | |||
m_image(factory.newImage(dpy, rect.width(), rect.height())), | |||
m_offsetLeft(rect.tl.x), | |||
m_offsetTop(rect.tl.y), | |||
m_stride(0) | |||
m_offsetTop(rect.tl.y) | |||
{ | |||
// Fill in the PixelFormat structure of the parent class. | |||
format = PixelFormat(m_image->xim->bits_per_pixel, | |||
@@ -57,7 +56,7 @@ XPixelBuffer::XPixelBuffer(Display *dpy, ImageFactory &factory, | |||
// Calculate the distance in pixels between two subsequent scan | |||
// lines of the framebuffer. This may differ from image width. | |||
m_stride = m_image->xim->bytes_per_line * 8 / m_image->xim->bits_per_pixel; | |||
stride = m_image->xim->bytes_per_line * 8 / m_image->xim->bits_per_pixel; | |||
// Get initial screen image from the X display. | |||
m_image->get(DefaultRootWindow(m_dpy), m_offsetLeft, m_offsetTop); |
@@ -46,9 +46,6 @@ public: | |||
// Detect changed pixels, notify the server. | |||
inline void poll(VNCServer *server) { m_poller->poll(server); } | |||
// Override PixelBuffer::getStride(). | |||
virtual int getStride() const { return m_stride; } | |||
// Override PixelBuffer::grabRegion(). | |||
virtual void grabRegion(const rfb::Region& region); | |||
@@ -60,9 +57,6 @@ protected: | |||
int m_offsetLeft; | |||
int m_offsetTop; | |||
// The number of pixels in a row, with padding included. | |||
int m_stride; | |||
// Copy pixels from the screen to the pixel buffer, | |||
// for the specified rectangular area of the buffer. | |||
inline void grabRect(const Rect &r) { |
@@ -177,7 +177,7 @@ void XserverDesktop::unblockUpdates() | |||
server->unblockUpdates(); | |||
} | |||
void XserverDesktop::setFramebuffer(int w, int h, void* fbptr, int stride) | |||
void XserverDesktop::setFramebuffer(int w, int h, void* fbptr, int stride_) | |||
{ | |||
ScreenSet layout; | |||
@@ -191,12 +191,12 @@ void XserverDesktop::setFramebuffer(int w, int h, void* fbptr, int stride) | |||
if (!fbptr) { | |||
fbptr = new rdr::U8[w * h * (format.bpp/8)]; | |||
stride = w; | |||
stride_ = w; | |||
directFbptr = false; | |||
} | |||
data = (rdr::U8*)fbptr; | |||
stride_ = stride; | |||
stride = stride_; | |||
layout = computeScreenLayout(); | |||
@@ -1044,11 +1044,6 @@ void XserverDesktop::grabRegion(const rfb::Region& region) | |||
grabbing = false; | |||
} | |||
int XserverDesktop::getStride() const | |||
{ | |||
return stride_; | |||
} | |||
void XserverDesktop::keyEvent(rdr::U32 keysym, bool down) | |||
{ | |||
if (down) |
@@ -109,7 +109,6 @@ public: | |||
// rfb::PixelBuffer callbacks | |||
virtual void grabRegion(const rfb::Region& r); | |||
virtual int getStride() const; | |||
// rdr::Substitutor callback | |||
virtual char* substitute(const char* varName); | |||
@@ -131,7 +130,6 @@ private: | |||
rfb::HTTPServer* httpServer; | |||
network::TcpListener* listener; | |||
network::TcpListener* httpListener; | |||
int stride_; | |||
bool deferredUpdateTimerSet; | |||
bool grabbing; | |||
bool ignoreHooks_; |
@@ -25,7 +25,7 @@ | |||
FLTKPixelBuffer::FLTKPixelBuffer(int width, int height) : | |||
PlatformPixelBuffer(rfb::PixelFormat(32, 24, false, true, | |||
255, 255, 255, 0, 8, 16), | |||
width, height, NULL) | |||
width, height, NULL, width) | |||
{ | |||
data = new rdr::U8[width * height * format.bpp/8]; | |||
if (data == NULL) | |||
@@ -43,7 +43,7 @@ void FLTKPixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h) | |||
const uchar *buf_start; | |||
pixel_bytes = format.bpp/8; | |||
stride_bytes = pixel_bytes * getStride(); | |||
stride_bytes = pixel_bytes * stride; | |||
buf_start = data + | |||
pixel_bytes * src_x + | |||
stride_bytes * src_y; |
@@ -39,7 +39,7 @@ static rfb::LogWriter vlog("OSXPixelBuffer"); | |||
OSXPixelBuffer::OSXPixelBuffer(int width, int height) : | |||
PlatformPixelBuffer(rfb::PixelFormat(32, 24, false, true, | |||
255, 255, 255, 16, 8, 0), | |||
width, height, NULL), | |||
width, height, NULL, width), | |||
bitmap(NULL) | |||
{ | |||
CGColorSpaceRef lut; |
@@ -20,7 +20,7 @@ | |||
PlatformPixelBuffer::PlatformPixelBuffer(const rfb::PixelFormat& pf, | |||
int width, int height, | |||
rdr::U8* data) : | |||
FullFramePixelBuffer(pf, width, height, data) | |||
rdr::U8* data, int stride) : | |||
FullFramePixelBuffer(pf, width, height, data, stride) | |||
{ | |||
} |
@@ -24,12 +24,10 @@ | |||
class PlatformPixelBuffer: public rfb::FullFramePixelBuffer { | |||
public: | |||
PlatformPixelBuffer(const rfb::PixelFormat& pf, int width, int height, | |||
rdr::U8* data); | |||
rdr::U8* data, int stride); | |||
virtual void draw(int src_x, int src_y, int x, int y, int w, int h) = 0; | |||
protected: | |||
int stride; | |||
}; | |||
#endif |
@@ -40,7 +40,7 @@ static rfb::LogWriter vlog("Win32PixelBuffer"); | |||
Win32PixelBuffer::Win32PixelBuffer(int width, int height) : | |||
PlatformPixelBuffer(rfb::PixelFormat(32, 24, false, true, | |||
255, 255, 255, 16, 8, 0), | |||
width, height, NULL), | |||
width, height, NULL, width), | |||
bitmap(NULL) | |||
{ | |||
BITMAPINFOHEADER bih; |
@@ -94,7 +94,7 @@ static PixelFormat display_pf() | |||
} | |||
X11PixelBuffer::X11PixelBuffer(int width, int height) : | |||
PlatformPixelBuffer(display_pf(), width, height, NULL), | |||
PlatformPixelBuffer(display_pf(), width, height, NULL, 0), | |||
shminfo(NULL), xim(NULL) | |||
{ | |||
// Might not be open at this point | |||
@@ -110,6 +110,7 @@ X11PixelBuffer::X11PixelBuffer(int width, int height) : | |||
} | |||
data = (rdr::U8*)xim->data; | |||
stride = xim->bytes_per_line / (getPF().bpp/8); | |||
} | |||
@@ -139,11 +140,6 @@ void X11PixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h) | |||
} | |||
int X11PixelBuffer::getStride() const | |||
{ | |||
return xim->bytes_per_line / (getPF().bpp/8); | |||
} | |||
static bool caughtError; | |||
static int XShmAttachErrorHandler(Display *dpy, XErrorEvent *error) |
@@ -33,8 +33,6 @@ public: | |||
virtual void draw(int src_x, int src_y, int x, int y, int w, int h); | |||
int getStride() const; | |||
protected: | |||
int setupShm(); | |||
@@ -47,14 +47,11 @@ namespace rfb { | |||
virtual void setPF(const PixelFormat &pf); | |||
virtual void setSize(int w, int h); | |||
virtual int getStride() const {return stride;} | |||
// *** virtual void copyRect(const Rect &dest, const Point &move_by_delta); | |||
public: | |||
HBITMAP bitmap; | |||
protected: | |||
void recreateBuffer(); | |||
int stride; | |||
HWND window; | |||
HDC device; | |||
}; |