Title: [115266] trunk/Source/WebKit2
Revision
115266
Author
bda...@apple.com
Date
2012-04-25 17:46:26 -0700 (Wed, 25 Apr 2012)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=84909
Background tabs are fuzzy until repaint when deviceScaleFactor > 1
-and corresponding-
<rdar://problem/11312064>

Reviewed by Darin Adler.

BackingStoreMac paints into a Bitmap instead of a CGLayer when there is no 
containing window. That bitmap is used for the initial paint when a background tab 
first comes to he foreground, so it needs to be HiDPI-aware.  

paintBitmapContext() now takes a scale factor that it passes along to paintImage 
rather than hardcoding a scale factor of 1 for paintImage.
* Platform/cg/CGUtilities.cpp:
(WebKit::paintBitmapContext):
* Platform/cg/CGUtilities.h:
(WebKit):

When these functions fall into the bitmap case, they need to adopt the device 
scale factor, which means they need to scale in size by the scale factor, and also 
scale their context. 
* UIProcess/mac/BackingStoreMac.mm:
(WebKit::BackingStore::resetScrolledRect):
(WebKit::BackingStore::paint):
(WebKit::BackingStore::backingStoreContext):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (115265 => 115266)


--- trunk/Source/WebKit2/ChangeLog	2012-04-26 00:29:41 UTC (rev 115265)
+++ trunk/Source/WebKit2/ChangeLog	2012-04-26 00:46:26 UTC (rev 115266)
@@ -1,3 +1,31 @@
+2012-04-25  Beth Dakin  <bda...@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=84909
+        Background tabs are fuzzy until repaint when deviceScaleFactor > 1
+        -and corresponding-
+        <rdar://problem/11312064>
+
+        Reviewed by Darin Adler.
+
+        BackingStoreMac paints into a Bitmap instead of a CGLayer when there is no 
+        containing window. That bitmap is used for the initial paint when a background tab 
+        first comes to he foreground, so it needs to be HiDPI-aware.  
+
+        paintBitmapContext() now takes a scale factor that it passes along to paintImage 
+        rather than hardcoding a scale factor of 1 for paintImage.
+        * Platform/cg/CGUtilities.cpp:
+        (WebKit::paintBitmapContext):
+        * Platform/cg/CGUtilities.h:
+        (WebKit):
+
+        When these functions fall into the bitmap case, they need to adopt the device 
+        scale factor, which means they need to scale in size by the scale factor, and also 
+        scale their context. 
+        * UIProcess/mac/BackingStoreMac.mm:
+        (WebKit::BackingStore::resetScrolledRect):
+        (WebKit::BackingStore::paint):
+        (WebKit::BackingStore::backingStoreContext):
+
 2012-04-25  Enrica Casucci  <enr...@apple.com>
 
         REGRESSION (r110494): Dragging images from Safari to Finder results in .webloc rather than image file

Modified: trunk/Source/WebKit2/Platform/cg/CGUtilities.cpp (115265 => 115266)


--- trunk/Source/WebKit2/Platform/cg/CGUtilities.cpp	2012-04-26 00:29:41 UTC (rev 115265)
+++ trunk/Source/WebKit2/Platform/cg/CGUtilities.cpp	2012-04-26 00:46:26 UTC (rev 115266)
@@ -48,10 +48,10 @@
     CGContextRestoreGState(context);
 }
 
-void paintBitmapContext(CGContextRef context, CGContextRef bitmapContext, CGPoint destination, CGRect source)
+void paintBitmapContext(CGContextRef context, CGContextRef bitmapContext, CGPoint destination, CGRect source, CGFloat scaleFactor)
 {
     RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(bitmapContext));
-    paintImage(context, image.get(), 1, destination, source);
+    paintImage(context, image.get(), scaleFactor, destination, source);
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/Platform/cg/CGUtilities.h (115265 => 115266)


--- trunk/Source/WebKit2/Platform/cg/CGUtilities.h	2012-04-26 00:29:41 UTC (rev 115265)
+++ trunk/Source/WebKit2/Platform/cg/CGUtilities.h	2012-04-26 00:46:26 UTC (rev 115266)
@@ -29,7 +29,7 @@
 namespace WebKit {
 
 void paintImage(CGContextRef, CGImageRef, CGFloat scaleFactor, CGPoint destination, CGRect source);
-void paintBitmapContext(CGContextRef, CGContextRef bitmapContext, CGPoint destination, CGRect source);
+void paintBitmapContext(CGContextRef, CGContextRef bitmapContext, CGPoint destination, CGRect source, CGFloat scaleFactor);
 
 } // namespace WebKit
 

Modified: trunk/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm (115265 => 115266)


--- trunk/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm	2012-04-26 00:29:41 UTC (rev 115265)
+++ trunk/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm	2012-04-26 00:46:26 UTC (rev 115266)
@@ -97,16 +97,21 @@
         return;
     }
 
+    IntSize scaledSize = m_scrolledRect.size();
+    scaledSize.scale(m_deviceScaleFactor);
+
     RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
-    RetainPtr<CGContextRef> context(AdoptCF, CGBitmapContextCreate(0, m_scrolledRect.size().width(), m_scrolledRect.size().height(), 8, m_scrolledRect.size().width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
+    RetainPtr<CGContextRef> context(AdoptCF, CGBitmapContextCreate(0, scaledSize.width(), scaledSize.height(), 8, scaledSize.width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
 
+    CGContextScaleCTM(context.get(), m_deviceScaleFactor, m_deviceScaleFactor);
+
     CGContextTranslateCTM(context.get(), -m_scrolledRect.location().x(), -m_scrolledRect.location().y());
     CGContextTranslateCTM(context.get(), 0, m_scrolledRect.size().height());
     CGContextScaleCTM(context.get(), 1, -1);
     paint(context.get(), m_scrolledRect);
 
     IntRect sourceRect(IntPoint(), m_scrolledRect.size());
-    paintBitmapContext(backingStoreContext(), context.get(), m_scrolledRect.location(), sourceRect);
+    paintBitmapContext(backingStoreContext(), context.get(), m_scrolledRect.location(), sourceRect, m_deviceScaleFactor);
 
     m_scrolledRect = IntRect();
     m_scrolledRectOffset = IntSize();
@@ -132,7 +137,7 @@
         source = part;
         source.origin.x += offset.width();
         source.origin.y += offset.height();
-        paintBitmapContext(context, m_bitmapContext.get(), part.location(), source);
+        paintBitmapContext(context, m_bitmapContext.get(), part.location(), source, m_deviceScaleFactor);
     });
 }
 
@@ -154,7 +159,7 @@
 
         if (m_bitmapContext) {
             // Paint the contents of the bitmap into the layer context.
-            paintBitmapContext(layerContext, m_bitmapContext.get(), CGPointZero, CGRectMake(0, 0, m_size.width(), m_size.height()));
+            paintBitmapContext(layerContext, m_bitmapContext.get(), CGPointZero, CGRectMake(0, 0, m_size.width(), m_size.height()), m_deviceScaleFactor);
             m_bitmapContext = nullptr;
         }
 
@@ -163,11 +168,15 @@
 
     if (!m_bitmapContext) {
         RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
-        
-        m_bitmapContext.adoptCF(CGBitmapContextCreate(0, m_size.width(), m_size.height(), 8, m_size.width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
 
+        IntSize scaledSize(m_size);
+        scaledSize.scale(m_deviceScaleFactor);
+        m_bitmapContext.adoptCF(CGBitmapContextCreate(0, scaledSize.width(), scaledSize.height(), 8, scaledSize.width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
+
         CGContextSetBlendMode(m_bitmapContext.get(), kCGBlendModeCopy);
 
+        CGContextScaleCTM(m_bitmapContext.get(), m_deviceScaleFactor, m_deviceScaleFactor);
+
         // We want the origin to be in the top left corner so flip the backing store context.
         CGContextTranslateCTM(m_bitmapContext.get(), 0, m_size.height());
         CGContextScaleCTM(m_bitmapContext.get(), 1, -1);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to