From 96b17b95cb6cf74ec2d977b82dd2788a7e50589d Mon Sep 17 00:00:00 2001 From: george82 Date: Tue, 5 Sep 2006 15:44:35 +0000 Subject: [PATCH] Small the ScaledDIBSectionBuffer class code improvements. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@647 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- win/rfb_win32/ScaledDIBSectionBuffer.cxx | 11 +++++++---- win/rfb_win32/ScaledDIBSectionBuffer.h | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/win/rfb_win32/ScaledDIBSectionBuffer.cxx b/win/rfb_win32/ScaledDIBSectionBuffer.cxx index e0091877..155de3de 100644 --- a/win/rfb_win32/ScaledDIBSectionBuffer.cxx +++ b/win/rfb_win32/ScaledDIBSectionBuffer.cxx @@ -45,6 +45,7 @@ void ScaledDIBSectionBuffer::setScaleRatio(double scale_ratio_) { if (scale_ratio_ != 1) scaling = true; else scaling = false; ScaledPixelBuffer::setScaleRatio(scale_ratio_); + calculateScaledBufferSize(); recreateBuffers(); } @@ -73,8 +74,6 @@ void ScaledDIBSectionBuffer::setSize(int src_width_, int src_height_) { } void ScaledDIBSectionBuffer::recreateScaledBuffer() { - width_ = scaled_width; - height_ = scaled_height; if (width_ && height_ && (format.depth != 0)) { DIBSectionBuffer::recreateBuffer(); scaled_data = data; @@ -82,8 +81,6 @@ void ScaledDIBSectionBuffer::recreateScaledBuffer() { } void ScaledDIBSectionBuffer::recreateBuffers() { - width_ = scaled_width; - height_ = scaled_height; if (scaled_width && scaled_height && format.depth != 0 && scale_ratio != 0) { if (scaling) { if (src_buffer) { @@ -111,6 +108,12 @@ void ScaledDIBSectionBuffer::recreateBuffers() { } } +void ScaledDIBSectionBuffer::calculateScaledBufferSize() { + ScaledPixelBuffer::calculateScaledBufferSize(); + width_ = scaled_width; + height_ = scaled_height; +} + void ScaledDIBSectionBuffer::fillRect(const Rect &dest, Pixel pix) { if (scaling) { src_buffer->fillRect(dest, pix); diff --git a/win/rfb_win32/ScaledDIBSectionBuffer.h b/win/rfb_win32/ScaledDIBSectionBuffer.h index c2b8ed7d..69c38481 100644 --- a/win/rfb_win32/ScaledDIBSectionBuffer.h +++ b/win/rfb_win32/ScaledDIBSectionBuffer.h @@ -51,6 +51,8 @@ namespace rfb { virtual void setScale(int scale) { setScaleRatio(double(scale)/100.0); }; virtual void setScaleRatio(double scale_ratio); + virtual void calculateScaledBufferSize(); + Rect getRect() const { return ScaledPixelBuffer::getRect(); } Rect getRect(const Point& pos) const { return ScaledPixelBuffer::getRect(pos); } -- 2.39.5