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

Changeset 98406 in webkit


Ignore:
Timestamp:
Oct 25, 2011, 4:10:12 PM (15 years ago)
Author:
Beth Dakin
Message:

https://bugs.webkit.org/show_bug.cgi?id=70852
Setting up a HiDPI base-level GraphicsContext should be more straightforward for
WebKit2

Reviewed by Dan Bernstein.

Source/WebCore:

This patch removes the old cg-only GraphicsContext::setBaseCTM() api, and adds
platform-independent GraphicsContext::applyDeviceScaleFactor().

  • WebCore.exp.in:
  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContext::platformApplyDeviceScaleFactor):
(WebCore::GraphicsContext::applyDeviceScaleFactor):

  • platform/graphics/GraphicsContext.h:
  • platform/graphics/cg/GraphicsContextCG.cpp:

(WebCore::GraphicsContext::platformApplyDeviceScaleFactor):

Since this patch removes GraphicsContext::setBaseCTM(), this code has been
reverted to do what it used to do before that was added; it just calls into
WebCoreSystemInterface directly.

  • platform/graphics/cg/ImageCG.cpp:

(WebCore::Image::drawPattern):

Source/WebKit2:

When we need a base-level HiDPI GraphicsContext, call into new GraphicsContext api
GraphicsContext::applyDeviceScaleFactor() rather than manually scaling and
adjusting the base CTM.

  • WebProcess/WebPage/DrawingAreaImpl.cpp:

(WebKit::DrawingAreaImpl::display):

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::snapshotInViewCoordinates):
(WebKit::WebPage::scaledSnapshotInDocumentCoordinates):

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r98403 r98406  
     12011-10-25  Beth Dakin  <bdakin@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=70852
     4        Setting up a HiDPI base-level GraphicsContext should be more straightforward for
     5        WebKit2
     6
     7        Reviewed by Dan Bernstein.
     8
     9        This patch removes the old cg-only GraphicsContext::setBaseCTM() api, and adds
     10        platform-independent GraphicsContext::applyDeviceScaleFactor().
     11        * WebCore.exp.in:
     12        * platform/graphics/GraphicsContext.cpp:
     13        (WebCore::GraphicsContext::platformApplyDeviceScaleFactor):
     14        (WebCore::GraphicsContext::applyDeviceScaleFactor):
     15        * platform/graphics/GraphicsContext.h:
     16        * platform/graphics/cg/GraphicsContextCG.cpp:
     17        (WebCore::GraphicsContext::platformApplyDeviceScaleFactor):
     18
     19        Since this patch removes GraphicsContext::setBaseCTM(), this code has been
     20        reverted to do what it used to do before that was added; it just calls into
     21        WebCoreSystemInterface directly.
     22        * platform/graphics/cg/ImageCG.cpp:
     23        (WebCore::Image::drawPattern):
     24
    1252011-10-25  Anders Carlsson  <andersca@apple.com>
    226
  • trunk/Source/WebCore/WebCore.exp.in

    r98316 r98406  
    429429__ZN7WebCore15GraphicsContext20endTransparencyLayerEv
    430430__ZN7WebCore15GraphicsContext21setCompositeOperationENS_17CompositeOperatorE
     431__ZN7WebCore15GraphicsContext22applyDeviceScaleFactorEf
    431432__ZN7WebCore15GraphicsContext22beginTransparencyLayerEf
    432433__ZN7WebCore15GraphicsContext28setImageInterpolationQualityENS_20InterpolationQualityE
     
    12191220__ZNK7WebCore14SecurityOrigin5equalEPKS0_
    12201221__ZNK7WebCore15FocusController18focusedOrMainFrameEv
    1221 __ZN7WebCore15GraphicsContext10setBaseCTMERKNS_15AffineTransformE
    12221222__ZNK7WebCore15GraphicsContext15platformContextEv
    12231223__ZNK7WebCore15GraphicsContext16paintingDisabledEv
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r97487 r98406  
    765765}
    766766
    767 }
     767#if !USE(CG)
     768void GraphicsContext::platformApplyDeviceScaleFactor()
     769{
     770}
     771#endif
     772
     773void GraphicsContext::applyDeviceScaleFactor(float deviceScaleFactor)
     774{
     775    scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
     776    platformApplyDeviceScaleFactor();
     777}
     778
     779}
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r97886 r98406  
    270270
    271271        void setIsAcceleratedContext(bool);
    272 
    273         void setBaseCTM(const AffineTransform&);
    274272#endif
    275273        bool isAcceleratedContext() const;
     
    415413        // for drawing into the buffer and then into this context.
    416414        PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&) const;
     415
     416        // This function applies the device scale factor to the context, making the context capable of
     417        // acting as a base-level context for a HiDPI environment.
     418        void applyDeviceScaleFactor(float);
     419        void platformApplyDeviceScaleFactor();
    417420
    418421#if OS(WINCE) && !PLATFORM(QT)
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r97886 r98406  
    14711471}
    14721472
    1473 void GraphicsContext::setBaseCTM(const AffineTransform& transform)
    1474 {
    1475     wkSetBaseCTM(platformContext(), transform);
    1476 }
    1477 
    14781473void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags mode)
    14791474{
     
    15981593}
    15991594
    1600 }
     1595void GraphicsContext::platformApplyDeviceScaleFactor()
     1596{
     1597    // CoreGraphics expects the base CTM of a HiDPI context to have the scale factor applied to it.
     1598    // Failing to change the base level CTM will cause certain CG features, such as focus rings,
     1599    // to draw with a scale factor of 1 rather than the actual scale factor.
     1600    wkSetBaseCTM(platformContext(), getCTM());
     1601}
     1602
     1603}
  • trunk/Source/WebCore/platform/graphics/cg/ImageCG.cpp

    r97886 r98406  
    285285
    286286    // FIXME: Really want a public API for this.  It is just CGContextSetBaseCTM(context, CGAffineTransformIdentiy).
    287     AffineTransform identity;
    288     identity.makeIdentity();
    289     ctxt->setBaseCTM(identity);
     287    wkSetBaseCTM(context, CGAffineTransformIdentity);
    290288    CGContextSetPatternPhase(context, CGSizeZero);
    291289
  • trunk/Source/WebKit2/ChangeLog

    r98403 r98406  
     12011-10-25  Beth Dakin  <bdakin@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=70852
     4        Setting up a HiDPI base-level GraphicsContext should be more straightforward for
     5        WebKit2
     6
     7        Reviewed by Dan Bernstein.
     8
     9        When we need a base-level HiDPI GraphicsContext, call into new GraphicsContext api
     10        GraphicsContext::applyDeviceScaleFactor() rather than manually scaling and
     11        adjusting the base CTM.
     12        * WebProcess/WebPage/DrawingAreaImpl.cpp:
     13        (WebKit::DrawingAreaImpl::display):
     14        * WebProcess/WebPage/WebPage.cpp:
     15        (WebKit::WebPage::snapshotInViewCoordinates):
     16        (WebKit::WebPage::scaledSnapshotInDocumentCoordinates):
     17
    1182011-10-25  Anders Carlsson  <andersca@apple.com>
    219
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp

    r98113 r98406  
    647647
    648648    IntSize bitmapSize = bounds.size();
    649     bitmapSize.scale(m_webPage->corePage()->deviceScaleFactor());
     649    float deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
     650    bitmapSize.scale(deviceScaleFactor);
    650651    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bitmapSize, ShareableBitmap::SupportsAlpha);
    651652    if (!bitmap)
     
    670671
    671672    OwnPtr<GraphicsContext> graphicsContext = createGraphicsContext(bitmap.get());
    672     graphicsContext->scale(FloatSize(m_webPage->corePage()->deviceScaleFactor(), m_webPage->corePage()->deviceScaleFactor()));
    673 #if USE(CG)
    674     graphicsContext->setBaseCTM(graphicsContext->getCTM());
    675 #endif
     673    graphicsContext->applyDeviceScaleFactor(deviceScaleFactor);
    676674   
    677675    updateInfo.updateRectBounds = bounds;
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r98403 r98406  
    944944   
    945945    OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->bitmap()->createGraphicsContext();
    946     graphicsContext->scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
    947 #if USE(CG)
    948     graphicsContext->setBaseCTM(graphicsContext->getCTM());
    949 #endif
     946    graphicsContext->applyDeviceScaleFactor(deviceScaleFactor);
    950947    graphicsContext->translate(-rect.x(), -rect.y());
    951948
     
    973970
    974971    OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->bitmap()->createGraphicsContext();
    975     graphicsContext->scale(FloatSize(combinedScaleFactor, combinedScaleFactor));
    976 #if USE(CG)
    977     graphicsContext->setBaseCTM(graphicsContext->getCTM());
    978 #endif
     972    graphicsContext->applyDeviceScaleFactor(combinedScaleFactor);
    979973    graphicsContext->translate(-rect.x(), -rect.y());
    980974
Note: See TracChangeset for help on using the changeset viewer.