[haiku-webkit-commits] r358 - webkit/trunk/WebKit/haiku/WebPositive

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Sun, 28 Mar 2010 11:32:14 +0000

Author: stippi
Date: Sun Mar 28 11:32:14 2010
New Revision: 358
URL: http://mmlr.dyndns.org/changeset/358

Log:
Use a better algorithm to figure out the final favicon display size. Icons which
can be scaled down by an even factor will now be displayed better. Also enable
smooth scaling and use a better drawing mode. The net result is that icons will
be displayed between 14x14 and 18x18 with the best suitable scaling factor.

Modified:
   webkit/trunk/WebKit/haiku/WebPositive/WebTabView.cpp

Modified: webkit/trunk/WebKit/haiku/WebPositive/WebTabView.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/WebTabView.cpp        Wed Mar 24 
22:32:04 2010        (r357)
+++ webkit/trunk/WebKit/haiku/WebPositive/WebTabView.cpp        Sun Mar 28 
11:32:14 2010        (r358)
@@ -874,11 +874,28 @@
                // clip to icon bounds, if they are smaller
                if (iconBounds.Contains(fIcon->Bounds()))
                        iconBounds = fIcon->Bounds();
+               else {
+                       // Try to scale down the icon by an even factor so the
+                       // final size is between 14 and 18 pixel size. If this 
fails,
+                       // the icon will simply be displayed at 18x18.
+                       float scale = 2;
+                       while ((fIcon->Bounds().Width() + 1) / scale > 
kIconSize)
+                               scale *= 2;
+                       if ((fIcon->Bounds().Width() + 1) / scale >= kIconSize 
- 4
+                               && (fIcon->Bounds().Height() + 1) / scale >= 
kIconSize - 4
+                               && (fIcon->Bounds().Height() + 1) / scale <= 
kIconSize) {
+                               iconBounds.right = (fIcon->Bounds().Width() + 
1) / scale - 1;
+                               iconBounds.bottom = (fIcon->Bounds().Height() + 
1) / scale - 1;
+                       }
+               }
                BPoint iconPos(frame.left + kIconInset - 1,
                        frame.top + floorf((frame.Height() - 
iconBounds.Height()) / 2));
                iconBounds.OffsetTo(iconPos);
-               owner->SetDrawingMode(B_OP_OVER);
-               owner->DrawBitmap(fIcon, fIcon->Bounds(), iconBounds);
+               owner->SetDrawingMode(B_OP_ALPHA);
+               owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
+               owner->DrawBitmap(fIcon, fIcon->Bounds(), iconBounds,
+                       B_FILTER_BITMAP_BILINEAR);
+               owner->SetDrawingMode(B_OP_COPY);
                frame.left = frame.left + kIconSize + kIconInset * 2;
        }
 

Other related posts:

  • » [haiku-webkit-commits] r358 - webkit/trunk/WebKit/haiku/WebPositive - webkit