summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2014-01-30 17:57:27 +0100
committerPierre Ossman <ossman@cendio.se>2014-07-07 14:50:29 +0200
commit2e5a10608394186fd1324c97b17d7f08e0c0aaf6 (patch)
treebdd76744f7d2d68bceb9b662c7ab85478510cdd7 /common
parentff9eb5a949f7af0198db8c563a7d9d735ad083c3 (diff)
downloadtigervnc-2e5a10608394186fd1324c97b17d7f08e0c0aaf6.tar.gz
tigervnc-2e5a10608394186fd1324c97b17d7f08e0c0aaf6.zip
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.
Diffstat (limited to 'common')
-rw-r--r--common/rfb/PixelBuffer.cxx17
-rw-r--r--common/rfb/PixelBuffer.h8
2 files changed, 11 insertions, 14 deletions
diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx
index ace0934d..ea19d183 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 @@ 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();
};
diff --git a/common/rfb/PixelBuffer.h b/common/rfb/PixelBuffer.h
index 94230247..59d71c79 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 @@ 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