]> source.dussan.org Git - tigervnc.git/commitdiff
Small the ScaledDIBSectionBuffer class code improvements.
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Tue, 5 Sep 2006 15:44:35 +0000 (15:44 +0000)
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Tue, 5 Sep 2006 15:44:35 +0000 (15:44 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@647 3789f03b-4d11-0410-bbf8-ca57d06f2519

win/rfb_win32/ScaledDIBSectionBuffer.cxx
win/rfb_win32/ScaledDIBSectionBuffer.h

index e0091877783a70d71a9e81c84c788e19a9bb89a0..155de3de0a3226130440b75900e62e47c946cf82 100644 (file)
@@ -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);
index c2b8ed7d7288deed7b1f6a663a40a7c0f1fc0dc0..69c38481f80680c1a33d0cb9bc474298b8f6058f 100644 (file)
@@ -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); }