It was confusing and not properly used everywhere.
Callers should use the stride they get when they get
the buffer pointer.
/* 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
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_)
{
}
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];
}
};
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();
};
};
void
ManagedPixelBuffer::setSize(int w, int h) {
- width_ = w; height_ = h; checkDataSize();
+ width_ = w; height_ = h; stride = w; checkDataSize();
};
/* 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
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);
FullFramePixelBuffer();
rdr::U8* data;
+ int stride;
};
// -=- Managed pixel buffer class
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,
// 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);
// 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);
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) {
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;
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();
grabbing = false;
}
-int XserverDesktop::getStride() const
-{
- return stride_;
-}
-
void XserverDesktop::keyEvent(rdr::U32 keysym, bool down)
{
if (down)
// rfb::PixelBuffer callbacks
virtual void grabRegion(const rfb::Region& r);
- virtual int getStride() const;
// rdr::Substitutor callback
virtual char* substitute(const char* varName);
rfb::HTTPServer* httpServer;
network::TcpListener* listener;
network::TcpListener* httpListener;
- int stride_;
bool deferredUpdateTimerSet;
bool grabbing;
bool ignoreHooks_;
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)
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;
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;
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)
{
}
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
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;
}
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
}
data = (rdr::U8*)xim->data;
+ stride = xim->bytes_per_line / (getPF().bpp/8);
}
}
-int X11PixelBuffer::getStride() const
-{
- return xim->bytes_per_line / (getPF().bpp/8);
-}
-
static bool caughtError;
static int XShmAttachErrorHandler(Display *dpy, XErrorEvent *error)
virtual void draw(int src_x, int src_y, int x, int y, int w, int h);
- int getStride() const;
-
protected:
int setupShm();
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;
};