]> source.dussan.org Git - tigervnc.git/commitdiff
Small ScaledPixelBuffer class improvements.
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Sun, 12 Feb 2006 11:03:48 +0000 (11:03 +0000)
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Sun, 12 Feb 2006 11:03:48 +0000 (11:03 +0000)
Renamed width_ to scaled_width and height_ to scaled_height.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@486 3789f03b-4d11-0410-bbf8-ca57d06f2519

rfb/ScaledPixelBuffer.cxx
rfb/ScaledPixelBuffer.h

index 2aedb829840f64043e4109991594ed4dbd285fa4..0c4d5abf4fb740e61605a99f73fb7ce45e7b5622 100644 (file)
@@ -33,10 +33,10 @@ ScaledPixelBuffer::ScaledPixelBuffer(U8 **src_data_, int src_width_,
 
   scale_ratio = double(scale) / 100;
 
-  width_  = (int)ceil(src_width  * scale_ratio);
-  height_ = (int)ceil(src_height * scale_ratio);
+  scaled_width  = (int)ceil(src_width  * scale_ratio);
+  scaled_height = (int)ceil(src_height * scale_ratio);
   
-  scaled_data = new U8[width_ * height_ * 4];
+  scaled_data = new U8[scaled_width * scaled_height * 4];
 }
 
 ScaledPixelBuffer::ScaledPixelBuffer() 
@@ -75,13 +75,13 @@ void ScaledPixelBuffer::setScale(int scale) {
   if (scale != scale_ratio * 100) {
     scale_ratio = double(scale) / 100;
 
-    width_  = (int)ceil(src_width  * scale_ratio);
-    height_ = (int)ceil(src_height * scale_ratio);
+    scaled_width  = (int)ceil(src_width  * scale_ratio);
+    scaled_height = (int)ceil(src_height * scale_ratio);
 
     if (scaled_data) delete [] scaled_data;
-    scaled_data = new U8[width_ * height_ * 4];
+    scaled_data = new U8[scaled_width * scaled_height * 4];
 
-    scaleRect(Rect(0, 0, width_, height_));
+    scaleRect(Rect(0, 0, scaled_width, scaled_height));
   }
 }
 
@@ -98,12 +98,12 @@ void ScaledPixelBuffer::scaleRect(const Rect& r) {
   // Calculate the scale boundaries
   x_start = vncmax(0, (r.tl.x-1) * scale_ratio);
   (x_start==int(x_start)) ? true : x_start=(int)(x_start+1);
-  x_end = vncmin(width_ - 1, r.br.x * scale_ratio);
-  ((x_end==int(x_end))&&(x_end!=width_-1)&&(x_end>0)) ? x_end-=1:x_end=(int)(x_end);
+  x_end = vncmin(scaled_width - 1, r.br.x * scale_ratio);
+  ((x_end==int(x_end))&&(x_end!=scaled_width-1)&&(x_end>0)) ? x_end-=1:x_end=(int)(x_end);
   y_start = vncmax(0, (r.tl.y-1) * scale_ratio);
   (y_start==int(y_start)) ? true : y_start=(int)(y_start+1);
-  y_end = vncmin(height_ - 1, r.br.y * scale_ratio);
-  ((y_end==int(y_end))&&(y_end!=height_-1)&&(y_end>0)) ? y_end-=1:y_end=(int)(y_end);
+  y_end = vncmin(scaled_height - 1, r.br.y * scale_ratio);
+  ((y_end==int(y_end))&&(y_end!=scaled_height-1)&&(y_end>0)) ? y_end-=1:y_end=(int)(y_end);
 
   // Scale the source rect to the destination image buffer using
   // bilinear interplation
@@ -113,7 +113,7 @@ void ScaledPixelBuffer::scaleRect(const Rect& r) {
     c1_sub_dy = 1 - dy;
 
     for (int x = (int)x_start; x <= x_end; x++) {
-      ptr = &scaled_data[(x + y*width_) * 4];
+      ptr = &scaled_data[(x + y*scaled_width) * 4];
 
       i = (int)(dx = x / scale_ratio);
       dx -= i;
index 4051a380c2b69c20926f8c372c84bd93f8c12aac..588d102b3d1666bf2b486329c4560ccdc8e28623 100644 (file)
@@ -36,16 +36,16 @@ namespace rfb {
     virtual ~ScaledPixelBuffer();
 
     // Get width, height, number of pixels and scale
-    int width()  const { return width_; }
-    int height() const { return height_; }
-    int area() const { return width_ * height_; }
+    int width()  const { return scaled_width; }
+    int height() const { return scaled_height; }
+    int area() const { return scaled_width * scaled_height; }
     int scale() const { return (int)(scale_ratio * 100); }
 
     // Get rectangle encompassing this buffer
     //   Top-left of rectangle is either at (0,0), or the specified point.
-    Rect getRect() const { return Rect(0, 0, width_, height_); }
+    Rect getRect() const { return Rect(0, 0, scaled_width, scaled_height); }
     Rect getRect(const Point& pos) const {
-      return Rect(pos, pos.translate(Point(width_, height_)));
+      return Rect(pos, pos.translate(Point(scaled_width, scaled_height)));
     }
 
     // Get the number of pixels per row in the actual pixel buffer data area
@@ -69,10 +69,10 @@ namespace rfb {
     virtual void scaleRect(const Rect& r);
 
   protected:
-    int width_;
-    int height_;
     int src_width;
     int src_height;
+    int scaled_width;
+    int scaled_height;
     int bpp;
     double scale_ratio;
     U8 **src_data;