Get rid of getStride()
It was confusing and not properly used everywhere.
Callers should use the stride they get when they get
the buffer pointer.
diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx
index ace0934..ea19d18 100644
--- a/common/rfb/PixelBuffer.cxx
+++ b/common/rfb/PixelBuffer.cxx
@@ -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 @@
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() {}
-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(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 @@
};
void
ManagedPixelBuffer::setSize(int w, int h) {
- width_ = w; height_ = h; checkDataSize();
+ width_ = w; height_ = h; stride = w; checkDataSize();
};
diff --git a/common/rfb/PixelBuffer.h b/common/rfb/PixelBuffer.h
index 9423024..59d71c7 100644
--- a/common/rfb/PixelBuffer.h
+++ b/common/rfb/PixelBuffer.h
@@ -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 @@
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 @@
FullFramePixelBuffer();
rdr::U8* data;
+ int stride;
};
// -=- Managed pixel buffer class