⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 90198 in webkit


Ignore:
Timestamp:
Jun 30, 2011, 8:06:44 PM (15 years ago)
Author:
Darin Adler
Message:

2011-06-30 Darin Adler <Darin Adler>

Reviewed by Anders Carlsson.

[WebKit2] Consider scale factor when allocating backing store
https://bugs.webkit.org/show_bug.cgi?id=63766

This is the first step in considering scale factor. It considers
scale factor for the primary backing store, not graphics layers,
and for CG only.

  • Platform/cg/CGUtilities.cpp: (WebKit::paintImage): Added a scale factor argument. (WebKit::paintBitmapContext): Pass 1 for scale factor.
  • Platform/cg/CGUtilities.h: Updated for above.
  • Shared/ShareableBitmap.h: Added an overload of paint that can handle a scale factor.
  • Shared/UpdateInfo.cpp: (WebKit::UpdateInfo::encode): Encode scale factor. (WebKit::UpdateInfo::decode): Decode scale factor.
  • Shared/UpdateInfo.h: Added scale factor.
  • Shared/cg/ShareableBitmapCG.cpp: (WebKit::ShareableBitmap::paint): Added the overload that can handle a scale factor.
  • UIProcess/BackingStore.cpp: (WebKit::BackingStore::create): Take a scale factor. (WebKit::BackingStore::BackingStore): Store the scale factor. (WebKit::BackingStore::incorporateUpdate): Consider the scale factor when asserting the size is correct.
  • UIProcess/BackingStore.h: Add a scale factor.
  • UIProcess/DrawingAreaProxyImpl.cpp: (WebKit::DrawingAreaProxyImpl::didUpdateBackingStoreState): Check the scale factor too when deciding whether to reuse a backing store. (WebKit::DrawingAreaProxyImpl::incorporateUpdate): Pass in the scale factor when creating a backing store.
  • UIProcess/mac/BackingStoreMac.mm: (WebKit::BackingStore::incorporateUpdate): Take the scale factor into account when painting.
  • WebProcess/WebPage/DrawingAreaImpl.cpp: (WebKit::DrawingAreaImpl::sendDidUpdateBackingStoreState): Put the scale factor into the UpdateInfo. (WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode): Ditto. (WebKit::DrawingAreaImpl::display): Take the scale factor into account when allocating the bitmap and creating a graphics context for it.
Location:
trunk/Source/WebKit2
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r90168 r90198  
     12011-06-30  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        [WebKit2] Consider scale factor when allocating backing store
     6        https://bugs.webkit.org/show_bug.cgi?id=63766
     7
     8        This is the first step in considering scale factor. It considers
     9        scale factor for the primary backing store, not graphics layers,
     10        and for CG only.
     11
     12        * Platform/cg/CGUtilities.cpp:
     13        (WebKit::paintImage): Added a scale factor argument.
     14        (WebKit::paintBitmapContext): Pass 1 for scale factor.
     15        * Platform/cg/CGUtilities.h: Updated for above.
     16
     17        * Shared/ShareableBitmap.h: Added an overload of paint that can handle
     18        a scale factor.
     19
     20        * Shared/UpdateInfo.cpp:
     21        (WebKit::UpdateInfo::encode): Encode scale factor.
     22        (WebKit::UpdateInfo::decode): Decode scale factor.
     23        * Shared/UpdateInfo.h: Added scale factor.
     24
     25        * Shared/cg/ShareableBitmapCG.cpp:
     26        (WebKit::ShareableBitmap::paint): Added the overload that can handle
     27        a scale factor.
     28
     29        * UIProcess/BackingStore.cpp:
     30        (WebKit::BackingStore::create): Take a scale factor.
     31        (WebKit::BackingStore::BackingStore): Store the scale factor.
     32        (WebKit::BackingStore::incorporateUpdate): Consider the scale factor
     33        when asserting the size is correct.
     34
     35        * UIProcess/BackingStore.h: Add a scale factor.
     36
     37        * UIProcess/DrawingAreaProxyImpl.cpp:
     38        (WebKit::DrawingAreaProxyImpl::didUpdateBackingStoreState): Check the
     39        scale factor too when deciding whether to reuse a backing store.
     40        (WebKit::DrawingAreaProxyImpl::incorporateUpdate): Pass in the scale
     41        factor when creating a backing store.
     42
     43        * UIProcess/mac/BackingStoreMac.mm:
     44        (WebKit::BackingStore::incorporateUpdate): Take the scale factor into
     45        account when painting.
     46
     47        * WebProcess/WebPage/DrawingAreaImpl.cpp:
     48        (WebKit::DrawingAreaImpl::sendDidUpdateBackingStoreState): Put the
     49        scale factor into the UpdateInfo.
     50        (WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode): Ditto.
     51        (WebKit::DrawingAreaImpl::display): Take the scale factor into account
     52        when allocating the bitmap and creating a graphics context for it.
     53
    1542011-06-30  Mark Rowe  <mrowe@apple.com>
    255
  • trunk/Source/WebKit2/Platform/cg/CGUtilities.cpp

    r82151 r90198  
    3131namespace WebKit {
    3232
    33 void paintImage(CGContextRef context, CGImageRef image, CGPoint destination, CGRect source)
     33void paintImage(CGContextRef context, CGImageRef image, CGFloat scaleFactor, CGPoint destination, CGRect source)
    3434{
    3535    CGContextSaveGState(context);
     
    3838    CGContextScaleCTM(context, 1, -1);
    3939
    40     size_t imageHeight = CGImageGetHeight(image);
    41     size_t imageWidth = CGImageGetWidth(image);
     40    CGFloat imageHeight = CGImageGetHeight(image) / scaleFactor;
     41    CGFloat imageWidth = CGImageGetWidth(image) / scaleFactor;
    4242
    4343    CGFloat destX = destination.x - source.origin.x;
    44     CGFloat destY = -static_cast<CGFloat>(imageHeight) - destination.y + source.origin.y;
     44    CGFloat destY = -imageHeight - destination.y + source.origin.y;
    4545
    4646    CGContextDrawImage(context, CGRectMake(destX, destY, imageWidth, imageHeight), image);
     47
    4748    CGContextRestoreGState(context);
    4849}
     
    5152{
    5253    RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(bitmapContext));
    53     paintImage(context, image.get(), destination, source);
     54    paintImage(context, image.get(), 1, destination, source);
    5455}
    5556
    5657} // namespace WebKit
    57 
  • trunk/Source/WebKit2/Platform/cg/CGUtilities.h

    r82151 r90198  
    2929namespace WebKit {
    3030
    31 void paintImage(CGContextRef, CGImageRef, CGPoint destination, CGRect source);
     31void paintImage(CGContextRef, CGImageRef, CGFloat scaleFactor, CGPoint destination, CGRect source);
    3232void paintBitmapContext(CGContextRef, CGContextRef bitmapContext, CGPoint destination, CGRect source);
    3333
  • trunk/Source/WebKit2/Shared/ShareableBitmap.h

    r88978 r90198  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    104104
    105105    // Paint the backing store into the given context.
    106     void paint(WebCore::GraphicsContext&, const WebCore::IntPoint& dstPoint, const WebCore::IntRect& srcRect);
     106    void paint(WebCore::GraphicsContext&, const WebCore::IntPoint& destination, const WebCore::IntRect& source);
     107    void paint(WebCore::GraphicsContext&, float scaleFactor, const WebCore::IntPoint& destination, const WebCore::IntRect& source);
    107108
    108109    bool isBackedBySharedMemory() const { return m_sharedMemory; }
     
    159160    // If the shareable bitmap is backed by fastMalloced memory, this points to the data.
    160161    void* m_data;
     162
    161163#if PLATFORM(WIN)
    162164    mutable OwnPtr<HDC> m_windowsContext;
  • trunk/Source/WebKit2/Shared/UpdateInfo.cpp

    r77533 r90198  
    3434{
    3535    encoder->encode(viewSize);
     36    encoder->encode(scaleFactor);
    3637    encoder->encode(scrollRect);
    3738    encoder->encode(scrollOffset);
     
    4445{
    4546    if (!decoder->decode(result.viewSize))
     47        return false;
     48    if (!decoder->decode(result.scaleFactor))
    4649        return false;
    4750    if (!decoder->decode(result.scrollRect))
  • trunk/Source/WebKit2/Shared/UpdateInfo.h

    r82441 r90198  
    4949    // The size of the web view.
    5050    WebCore::IntSize viewSize;
     51    float scaleFactor;
    5152
    5253    // The rect and delta to be scrolled.
  • trunk/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp

    r88967 r90198  
    6363}
    6464
    65 void ShareableBitmap::paint(WebCore::GraphicsContext& context, const IntPoint& dstPoint, const IntRect& srcRect)
     65void ShareableBitmap::paint(WebCore::GraphicsContext& context, const IntPoint& destination, const IntRect& source)
    6666{
    67     paintImage(context.platformContext(), makeCGImageCopy().get(), dstPoint, srcRect);
     67    paintImage(context.platformContext(), makeCGImageCopy().get(), 1, destination, source);
     68}
     69
     70void ShareableBitmap::paint(WebCore::GraphicsContext& context, float scaleFactor, const IntPoint& destination, const IntRect& source)
     71{
     72    paintImage(context.platformContext(), makeCGImageCopy().get(), scaleFactor, destination, source);
    6873}
    6974
  • trunk/Source/WebKit2/UIProcess/BackingStore.cpp

    r84524 r90198  
    3434namespace WebKit {
    3535
    36 PassOwnPtr<BackingStore> BackingStore::create(const IntSize& size, WebPageProxy* webPageProxy)
     36PassOwnPtr<BackingStore> BackingStore::create(const IntSize& size, float scaleFactor, WebPageProxy* webPageProxy)
    3737{
    38     return adoptPtr(new BackingStore(size, webPageProxy));
     38    return adoptPtr(new BackingStore(size, scaleFactor, webPageProxy));
    3939}
    4040
    41 BackingStore::BackingStore(const IntSize& size, WebPageProxy* webPageProxy)
     41BackingStore::BackingStore(const IntSize& size, float scaleFactor, WebPageProxy* webPageProxy)
    4242    : m_size(size)
     43    , m_scaleFactor(scaleFactor)
    4344    , m_webPageProxy(webPageProxy)
    4445{
     
    5758    if (!bitmap)
    5859        return;
    59     ASSERT(bitmap->size() == updateInfo.updateRectBounds.size());
     60
     61#if !ASSERT_DISABLED
     62    IntSize updateSize = updateInfo.updateRectBounds.size();
     63    updateSize.scale(m_scaleFactor);
     64    ASSERT(bitmap->size() == updateSize);
     65#endif
    6066   
    6167    incorporateUpdate(bitmap.get(), updateInfo);
  • trunk/Source/WebKit2/UIProcess/BackingStore.h

    r89442 r90198  
    6161
    6262public:
    63     static PassOwnPtr<BackingStore> create(const WebCore::IntSize&, WebPageProxy*);
     63    static PassOwnPtr<BackingStore> create(const WebCore::IntSize&, float scaleFactor, WebPageProxy*);
    6464    ~BackingStore();
    6565
    6666    const WebCore::IntSize& size() const { return m_size; }
     67    float scaleFactor() const { return m_scaleFactor; }
    6768
    6869#if PLATFORM(MAC)
     
    8081
    8182private:
    82     BackingStore(const WebCore::IntSize&, WebPageProxy*);
     83    BackingStore(const WebCore::IntSize&, float scaleFactor, WebPageProxy*);
    8384
    8485    void incorporateUpdate(ShareableBitmap*, const UpdateInfo&);
     
    8687
    8788    WebCore::IntSize m_size;
     89    float m_scaleFactor;
    8890    WebPageProxy* m_webPageProxy;
    8991
  • trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp

    r88463 r90198  
    206206
    207207    // If we have a backing store the right size, reuse it.
    208     if (m_backingStore && m_backingStore->size() != updateInfo.viewSize)
     208    if (m_backingStore && (m_backingStore->size() != updateInfo.viewSize || m_backingStore->scaleFactor() != updateInfo.scaleFactor))
    209209        m_backingStore = nullptr;
    210210    incorporateUpdate(updateInfo);
     
    243243
    244244    if (!m_backingStore)
    245         m_backingStore = BackingStore::create(updateInfo.viewSize, m_webPageProxy);
     245        m_backingStore = BackingStore::create(updateInfo.viewSize, updateInfo.scaleFactor, m_webPageProxy);
    246246
    247247    m_backingStore->incorporateUpdate(updateInfo);
  • trunk/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm

    r76991 r90198  
    110110        srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
    111111
    112         bitmap->paint(graphicsContext, updateRect.location(), srcRect);
     112        bitmap->paint(graphicsContext, updateInfo.scaleFactor, updateRect.location(), srcRect);
    113113    }
    114114}
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp

    r88978 r90198  
    358358    if (m_isPaintingSuspended || m_layerTreeHost) {
    359359        updateInfo.viewSize = m_webPage->size();
     360        updateInfo.scaleFactor = m_webPage->userSpaceScaleFactor();
    360361
    361362        if (m_layerTreeHost) {
     
    462463
    463464    UpdateInfo updateInfo;
    464     if (m_isPaintingSuspended)
     465    if (m_isPaintingSuspended) {
    465466        updateInfo.viewSize = m_webPage->size();
    466     else
     467        updateInfo.scaleFactor = m_webPage->userSpaceScaleFactor();
     468    } else
    467469        display(updateInfo);
    468470
     
    614616
    615617    updateInfo.viewSize = m_webPage->size();
     618    updateInfo.scaleFactor = m_webPage->userSpaceScaleFactor();
    616619
    617620    IntRect bounds = m_dirtyRegion.bounds();
    618621    ASSERT(m_webPage->bounds().contains(bounds));
    619622
    620     RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bounds.size(), ShareableBitmap::SupportsAlpha);
     623    IntSize bitmapSize = bounds.size();
     624    bitmapSize.scale(m_webPage->userSpaceScaleFactor());
     625    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bitmapSize, ShareableBitmap::SupportsAlpha);
    621626    if (!bitmap)
    622627        return;
     
    640645
    641646    OwnPtr<GraphicsContext> graphicsContext = createGraphicsContext(bitmap.get());
     647    graphicsContext->scale(FloatSize(m_webPage->userSpaceScaleFactor(), m_webPage->userSpaceScaleFactor()));
    642648
    643649    updateInfo.updateRectBounds = bounds;
Note: See TracChangeset for help on using the changeset viewer.