Changeset 115266 in webkit


Ignore:
Timestamp:
Apr 25, 2012 5:46:26 PM (12 years ago)
Author:
Beth Dakin
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):

Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r115242 r115266  
     12012-04-25  Beth Dakin  <bdakin@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=84909
     4        Background tabs are fuzzy until repaint when deviceScaleFactor > 1
     5        -and corresponding-
     6        <rdar://problem/11312064>
     7
     8        Reviewed by Darin Adler.
     9
     10        BackingStoreMac paints into a Bitmap instead of a CGLayer when there is no
     11        containing window. That bitmap is used for the initial paint when a background tab
     12        first comes to he foreground, so it needs to be HiDPI-aware. 
     13
     14        paintBitmapContext() now takes a scale factor that it passes along to paintImage
     15        rather than hardcoding a scale factor of 1 for paintImage.
     16        * Platform/cg/CGUtilities.cpp:
     17        (WebKit::paintBitmapContext):
     18        * Platform/cg/CGUtilities.h:
     19        (WebKit):
     20
     21        When these functions fall into the bitmap case, they need to adopt the device
     22        scale factor, which means they need to scale in size by the scale factor, and also
     23        scale their context.
     24        * UIProcess/mac/BackingStoreMac.mm:
     25        (WebKit::BackingStore::resetScrolledRect):
     26        (WebKit::BackingStore::paint):
     27        (WebKit::BackingStore::backingStoreContext):
     28
    1292012-04-25  Enrica Casucci  <enrica@apple.com>
    230
  • trunk/Source/WebKit2/Platform/cg/CGUtilities.cpp

    r95901 r115266  
    4949}
    5050
    51 void paintBitmapContext(CGContextRef context, CGContextRef bitmapContext, CGPoint destination, CGRect source)
     51void paintBitmapContext(CGContextRef context, CGContextRef bitmapContext, CGPoint destination, CGRect source, CGFloat scaleFactor)
    5252{
    5353    RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(bitmapContext));
    54     paintImage(context, image.get(), 1, destination, source);
     54    paintImage(context, image.get(), scaleFactor, destination, source);
    5555}
    5656
  • trunk/Source/WebKit2/Platform/cg/CGUtilities.h

    r95901 r115266  
    3030
    3131void paintImage(CGContextRef, CGImageRef, CGFloat scaleFactor, CGPoint destination, CGRect source);
    32 void paintBitmapContext(CGContextRef, CGContextRef bitmapContext, CGPoint destination, CGRect source);
     32void paintBitmapContext(CGContextRef, CGContextRef bitmapContext, CGPoint destination, CGRect source, CGFloat scaleFactor);
    3333
    3434} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm

    r110412 r115266  
    9898    }
    9999
     100    IntSize scaledSize = m_scrolledRect.size();
     101    scaledSize.scale(m_deviceScaleFactor);
     102
    100103    RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
    101     RetainPtr<CGContextRef> context(AdoptCF, CGBitmapContextCreate(0, m_scrolledRect.size().width(), m_scrolledRect.size().height(), 8, m_scrolledRect.size().width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
     104    RetainPtr<CGContextRef> context(AdoptCF, CGBitmapContextCreate(0, scaledSize.width(), scaledSize.height(), 8, scaledSize.width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
     105
     106    CGContextScaleCTM(context.get(), m_deviceScaleFactor, m_deviceScaleFactor);
    102107
    103108    CGContextTranslateCTM(context.get(), -m_scrolledRect.location().x(), -m_scrolledRect.location().y());
     
    107112
    108113    IntRect sourceRect(IntPoint(), m_scrolledRect.size());
    109     paintBitmapContext(backingStoreContext(), context.get(), m_scrolledRect.location(), sourceRect);
     114    paintBitmapContext(backingStoreContext(), context.get(), m_scrolledRect.location(), sourceRect, m_deviceScaleFactor);
    110115
    111116    m_scrolledRect = IntRect();
     
    133138        source.origin.x += offset.width();
    134139        source.origin.y += offset.height();
    135         paintBitmapContext(context, m_bitmapContext.get(), part.location(), source);
     140        paintBitmapContext(context, m_bitmapContext.get(), part.location(), source, m_deviceScaleFactor);
    136141    });
    137142}
     
    155160        if (m_bitmapContext) {
    156161            // Paint the contents of the bitmap into the layer context.
    157             paintBitmapContext(layerContext, m_bitmapContext.get(), CGPointZero, CGRectMake(0, 0, m_size.width(), m_size.height()));
     162            paintBitmapContext(layerContext, m_bitmapContext.get(), CGPointZero, CGRectMake(0, 0, m_size.width(), m_size.height()), m_deviceScaleFactor);
    158163            m_bitmapContext = nullptr;
    159164        }
     
    164169    if (!m_bitmapContext) {
    165170        RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
    166        
    167         m_bitmapContext.adoptCF(CGBitmapContextCreate(0, m_size.width(), m_size.height(), 8, m_size.width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
     171
     172        IntSize scaledSize(m_size);
     173        scaledSize.scale(m_deviceScaleFactor);
     174        m_bitmapContext.adoptCF(CGBitmapContextCreate(0, scaledSize.width(), scaledSize.height(), 8, scaledSize.width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
    168175
    169176        CGContextSetBlendMode(m_bitmapContext.get(), kCGBlendModeCopy);
     177
     178        CGContextScaleCTM(m_bitmapContext.get(), m_deviceScaleFactor, m_deviceScaleFactor);
    170179
    171180        // We want the origin to be in the top left corner so flip the backing store context.
Note: See TracChangeset for help on using the changeset viewer.