Changeset 91137 in webkit


Ignore:
Timestamp:
Jul 15, 2011 6:30:13 PM (13 years ago)
Author:
Simon Fraser
Message:

2011-07-15 Simon Fraser <Simon Fraser>

Have GraphicsLayer pull their contentsScale, rather than pushing it onto them
https://bugs.webkit.org/show_bug.cgi?id=64643

Reviewed by Darin Adler.

RenderLayerBacking would set the contentsScale on GraphicsLayers
on creation, and update it when the pageScaleFactor changed. However,
RenderLayerBacking doesn't really know what contentsScale is best
for a layer, so instead, have GraphicsLayers call back through the
GraphicsLayerClient to get the two relevant scale factors, and do
their own computation of contentsScale.

No testable behavior changes.

  • page/Frame.cpp: (WebCore::Frame::pageScaleFactorChanged): No need to pass the scale.
  • platform/graphics/GraphicsLayer.cpp: (WebCore::GraphicsLayer::notePageScaleFactorChangedIncludingDescendants): Recurse through the GraphicsLayer tree, calling pageScaleFactorChanged() on each layer.
  • platform/graphics/GraphicsLayer.h: (WebCore::GraphicsLayer::pageScaleFactorChanged): Remove contentsScale/setContentsScale
  • platform/graphics/GraphicsLayerClient.h: Add methods to fetch the backingScaleFactor() and pageScaleFactor().
  • platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::GraphicsLayerCA::GraphicsLayerCA): m_uncommittedChanges defaults to ContentsScaleChanged so we update contentsScale on the first flush.

(WebCore::GraphicsLayerCA::setContentsToBackgroundColor):
This was the wrong time to call updateContentsRect() and setupContentsLayer();
those should be done at commit time, so moved to updateLayerBackgroundColor().
(WebCore::GraphicsLayerCA::recursiveCommitChanges): Note whether we
have any changes, and call didCommitChangesForLayer() on the client.
(WebCore::GraphicsLayerCA::updateLayerBackgroundColor): Code moved to here.
(WebCore::clampedContentsScaleForScale): No longer has any hysteresis
on the scale, and now just clamps.
(WebCore::GraphicsLayerCA::updateContentsScale): Fetch the scales
from the client, and multiply them, then clamp.
(WebCore::GraphicsLayerCA::requiresTiledLayer): This now takes
contentsScale into account when deciding to use tiled layer,
so that zooming in will cause layers to start tiling.
(WebCore::GraphicsLayerCA::swapFromOrToTiledLayer): Don't call
setContentsScale(), but rather updateContentsScale().
(WebCore::GraphicsLayerCA::pageScaleFactorChanged): Set the bits
for properties that depend on the scale.
(WebCore::GraphicsLayerCA::noteChangesForScaleSensitiveProperties):
Note that contentsScale needs to be updated. At some point we might also
need to dirty other properties.

  • platform/graphics/ca/GraphicsLayerCA.h: Moved the m_allowTiledLayer bool for better packing. No need for a m_contentsScale member now.
  • rendering/RenderLayer.cpp: Removed pageScaleFactorChanged().
  • rendering/RenderLayer.h: Ditto.
  • rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::createPrimaryGraphicsLayer): No need to push the contents scale. (WebCore::RenderLayerBacking::updateForegroundLayer): Ditto. (WebCore::RenderLayerBacking::updateMaskLayer): Ditto. (WebCore::RenderLayerBacking::pageScaleFactor): GraphicsLayerClient method. (WebCore::RenderLayerBacking::backingScaleFactor): GraphicsLayerClient method. (WebCore::RenderLayerBacking::didCommitChangesForLayer): Send through to the compositor.
  • rendering/RenderLayerBacking.h: GraphicsLayerClient methods.
  • rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::didFlushChangesForLayer): We'll use this later. (WebCore::RenderLayerCompositor::backingScaleFactor): GraphicsLayerClient method. (WebCore::RenderLayerCompositor::pageScaleFactor): Ditto. (WebCore::RenderLayerCompositor::didCommitChangesForLayer): Ditto. (WebCore::RenderLayerCompositor::ensureRootLayer): No need to push the contents scale. (WebCore::RenderLayerCompositor::pageScaleFactorChanged): Just call notePageScaleFactorChangedIncludingDescendants() on the root GraphicsLayer.
  • rendering/RenderLayerCompositor.h: Added GraphicsLayerClient methods.

2011-07-15 Simon Fraser <Simon Fraser>

Have GraphicsLayer pull their contentsScale, rather than pushing it onto them
https://bugs.webkit.org/show_bug.cgi?id=64643

Reviewed by Darin Adler.

Impement new GraphicsLayerClient methods related to contents scale,
and don't push the scale.

  • WebProcess/WebPage/ca/LayerTreeHostCA.cpp: (WebKit::LayerTreeHostCA::initialize): (WebKit::LayerTreeHostCA::backingScaleFactor): (WebKit::LayerTreeHostCA::pageScaleFactor): (WebKit::LayerTreeHostCA::createPageOverlayLayer):
  • WebProcess/WebPage/ca/LayerTreeHostCA.h: (WebKit::LayerTreeHostCA::didCommitChangesForLayer):

2011-07-15 Simon Fraser <Simon Fraser>

Have GraphicsLayer pull their contentsScale, rather than pushing it onto them
https://bugs.webkit.org/show_bug.cgi?id=64643

Reviewed by Darin Adler.

Impement new GraphicsLayerClient methods related to contents scale.

  • src/PageOverlay.cpp: (WebKit::OverlayGraphicsLayerClientImpl::backingScaleFactor): (WebKit::OverlayGraphicsLayerClientImpl::pageScaleFactor):
Location:
trunk/Source
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r91135 r91137  
     12011-07-15  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Have GraphicsLayer pull their contentsScale, rather than pushing it onto them
     4        https://bugs.webkit.org/show_bug.cgi?id=64643
     5
     6        Reviewed by Darin Adler.
     7
     8        RenderLayerBacking would set the contentsScale on GraphicsLayers
     9        on creation, and update it when the pageScaleFactor changed. However,
     10        RenderLayerBacking doesn't really know what contentsScale is best
     11        for a layer, so instead, have GraphicsLayers call back through the
     12        GraphicsLayerClient to get the two relevant scale factors, and do
     13        their own computation of contentsScale.
     14
     15        No testable behavior changes.
     16
     17        * page/Frame.cpp:
     18        (WebCore::Frame::pageScaleFactorChanged): No need to pass the scale.
     19
     20        * platform/graphics/GraphicsLayer.cpp:
     21        (WebCore::GraphicsLayer::notePageScaleFactorChangedIncludingDescendants):
     22        Recurse through the GraphicsLayer tree, calling pageScaleFactorChanged() on
     23        each layer.
     24
     25        * platform/graphics/GraphicsLayer.h:
     26        (WebCore::GraphicsLayer::pageScaleFactorChanged):
     27        Remove contentsScale/setContentsScale
     28       
     29        * platform/graphics/GraphicsLayerClient.h:
     30        Add methods to fetch the backingScaleFactor() and pageScaleFactor().
     31       
     32        * platform/graphics/ca/GraphicsLayerCA.cpp:
     33        (WebCore::GraphicsLayerCA::GraphicsLayerCA): m_uncommittedChanges
     34        defaults to ContentsScaleChanged so we update contentsScale on
     35        the first flush.
     36       
     37        (WebCore::GraphicsLayerCA::setContentsToBackgroundColor):
     38        This was the wrong time to call updateContentsRect() and setupContentsLayer();
     39        those should be done at commit time, so moved to updateLayerBackgroundColor().
     40        (WebCore::GraphicsLayerCA::recursiveCommitChanges): Note whether we
     41        have any changes, and call didCommitChangesForLayer() on the client.
     42        (WebCore::GraphicsLayerCA::updateLayerBackgroundColor): Code moved to here.
     43        (WebCore::clampedContentsScaleForScale): No longer has any hysteresis
     44        on the scale, and now just clamps.
     45        (WebCore::GraphicsLayerCA::updateContentsScale): Fetch the scales
     46        from the client, and multiply them, then clamp.
     47        (WebCore::GraphicsLayerCA::requiresTiledLayer): This now takes
     48        contentsScale into account when deciding to use tiled layer,
     49        so that zooming in will cause layers to start tiling.
     50        (WebCore::GraphicsLayerCA::swapFromOrToTiledLayer): Don't call
     51        setContentsScale(), but rather updateContentsScale().
     52        (WebCore::GraphicsLayerCA::pageScaleFactorChanged): Set the bits
     53        for properties that depend on the scale.
     54        (WebCore::GraphicsLayerCA::noteChangesForScaleSensitiveProperties):
     55        Note that contentsScale needs to be updated. At some point we might also
     56        need to dirty other properties.
     57        * platform/graphics/ca/GraphicsLayerCA.h: Moved the m_allowTiledLayer
     58        bool for better packing. No need for a m_contentsScale member now.
     59        * rendering/RenderLayer.cpp: Removed pageScaleFactorChanged().
     60        * rendering/RenderLayer.h: Ditto.
     61        * rendering/RenderLayerBacking.cpp:
     62        (WebCore::RenderLayerBacking::createPrimaryGraphicsLayer): No need
     63        to push the contents scale.
     64        (WebCore::RenderLayerBacking::updateForegroundLayer): Ditto.
     65        (WebCore::RenderLayerBacking::updateMaskLayer): Ditto.
     66        (WebCore::RenderLayerBacking::pageScaleFactor): GraphicsLayerClient method.
     67        (WebCore::RenderLayerBacking::backingScaleFactor): GraphicsLayerClient method.
     68        (WebCore::RenderLayerBacking::didCommitChangesForLayer): Send through
     69        to the compositor.
     70        * rendering/RenderLayerBacking.h: GraphicsLayerClient methods.
     71        * rendering/RenderLayerCompositor.cpp:
     72        (WebCore::RenderLayerCompositor::didFlushChangesForLayer): We'll use
     73        this later.
     74        (WebCore::RenderLayerCompositor::backingScaleFactor): GraphicsLayerClient method.
     75        (WebCore::RenderLayerCompositor::pageScaleFactor): Ditto.
     76        (WebCore::RenderLayerCompositor::didCommitChangesForLayer): Ditto.
     77        (WebCore::RenderLayerCompositor::ensureRootLayer): No need to push the contents scale.
     78        (WebCore::RenderLayerCompositor::pageScaleFactorChanged): Just call notePageScaleFactorChangedIncludingDescendants()
     79        on the root GraphicsLayer.
     80        * rendering/RenderLayerCompositor.h: Added GraphicsLayerClient methods.
     81
    1822011-07-15  Jon Honeycutt  <jhoneycutt@apple.com>
    283
  • trunk/Source/WebCore/page/Frame.cpp

    r90925 r91137  
    11121112    RenderView* root = contentRenderer();
    11131113    if (root && root->compositor())
    1114         root->compositor()->pageScaleFactorChanged(scale);
     1114        root->compositor()->pageScaleFactorChanged();
    11151115}
    11161116#endif
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp

    r88664 r91137  
    221221        setParent(0);
    222222    }
     223}
     224
     225void GraphicsLayer::notePageScaleFactorChangedIncludingDescendants()
     226{
     227    pageScaleFactorChanged();
     228
     229    if (m_maskLayer)
     230        m_maskLayer->pageScaleFactorChanged();
     231
     232    if (m_replicaLayer)
     233        m_replicaLayer->notePageScaleFactorChangedIncludingDescendants();
     234
     235    const Vector<GraphicsLayer*>& childLayers = children();
     236    size_t numChildren = childLayers.size();
     237    for (size_t i = 0; i < numChildren; ++i)
     238        childLayers[i]->notePageScaleFactorChangedIncludingDescendants();
    223239}
    224240
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r88653 r91137  
    326326    virtual PlatformLayer* platformLayer() const { return 0; }
    327327   
    328     // Change the scale at which the contents are rendered. Note that contentsScale may not return
    329     // the same value passed to setContentsScale(), because of clamping and hysteresis.
    330     virtual float contentsScale() const { return 1; }
    331     virtual void setContentsScale(float) { }
    332 
    333328    void dumpLayer(TextStream&, int indent = 0, LayerTreeAsTextBehavior = LayerTreeAsTextBehaviorNormal) const;
    334329
     
    355350    virtual void distributeOpacity(float);
    356351    virtual float accumulatedOpacity() const;
     352
     353    virtual void pageScaleFactorChanged() { }
     354    void notePageScaleFactorChangedIncludingDescendants();
    357355
    358356    // Some compositing systems may do internal batching to synchronize compositing updates
  • trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h

    r51122 r91137  
    6363   
    6464    virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip) = 0;
     65    virtual void didCommitChangesForLayer(const GraphicsLayer*) const = 0;
     66
     67    // Multiplier for backing store size, related to high DPI.
     68    virtual float backingScaleFactor() const = 0;
     69    // Scaling factor of the page.
     70    virtual float pageScaleFactor() const = 0;
    6571   
    6672    virtual bool showDebugBorders() const = 0;
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r90293 r91137  
    250250    , m_contentsLayerPurpose(NoContentsLayer)
    251251    , m_contentsLayerHasBackgroundColor(false)
    252     , m_uncommittedChanges(NoChange)
    253     , m_contentsScale(1)
    254252    , m_allowTiledLayer(true)
     253    , m_uncommittedChanges(ContentsScaleChanged)
    255254{
    256255    m_layer = PlatformCALayer::create(PlatformCALayer::LayerTypeWebLayer, this);
     
    680679        m_contentsLayer->setName("Background Color Layer");
    681680#endif
    682         updateContentsRect();
    683         setupContentsLayer(m_contentsLayer.get());
    684681    } else {
    685682        m_contentsLayerPurpose = NoContentsLayer;
     
    808805void GraphicsLayerCA::recursiveCommitChanges()
    809806{
     807    bool hadChanges = m_uncommittedChanges;
     808   
    810809    commitLayerChangesBeforeSublayers();
    811810
     
    827826
    828827    commitLayerChangesAfterSublayers();
     828
     829    if (hadChanges && client())
     830        client()->didCommitChangesForLayer(this);
    829831}
    830832
     
    12471249    if (!m_contentsLayer)
    12481250        return;
     1251
     1252    setupContentsLayer(m_contentsLayer.get());
     1253    updateContentsRect();
    12491254
    12501255    if (m_backgroundColorSet)
     
    19381943}
    19391944
    1940 void GraphicsLayerCA::setContentsScale(float scale)
    1941 {
    1942     float newScale = clampedContentsScaleForScale(scale);
    1943     if (newScale == m_contentsScale)
    1944         return;
    1945 
    1946     m_contentsScale = newScale;
    1947     noteLayerPropertyChanged(ContentsScaleChanged);
    1948 }
    1949 
    1950 float GraphicsLayerCA::clampedContentsScaleForScale(float scale) const
     1945static float clampedContentsScaleForScale(float scale)
    19511946{
    19521947    // Define some limits as a sanity check for the incoming scale value
     
    19541949    const float maxScale = 10.0f;
    19551950    const float minScale = 0.01f;
    1956    
    1957     // Avoid very slight scale changes that would be doing extra work for no benefit
    1958     const float maxAllowableDelta = 0.05f;
    1959 
    1960     // Clamp
    1961     float result = max(minScale, min(scale, maxScale));
    1962 
    1963     // If it hasn't changed much, don't do any work
    1964     return ((fabs(result - m_contentsScale) / m_contentsScale) < maxAllowableDelta) ? m_contentsScale : result;
     1951    return max(minScale, min(scale, maxScale));
    19651952}
    19661953
     
    19711958        swapFromOrToTiledLayer(needTiledLayer);
    19721959
    1973     m_layer->setContentsScale(m_contentsScale);
     1960    float backingScaleFactor = m_client ? m_client->backingScaleFactor() : 1;
     1961    float pageScaleFactor = m_client ? m_client->pageScaleFactor() : 1;
     1962
     1963    float contentsScale = clampedContentsScaleForScale(pageScaleFactor * backingScaleFactor);
     1964   
     1965    m_layer->setContentsScale(contentsScale);
    19741966    if (drawsContent())
    19751967        m_layer->setNeedsDisplay();
     
    20242016        return false;
    20252017
     2018    float contentsScale = m_client ? m_client->backingScaleFactor() * m_client->pageScaleFactor() : 1;
     2019
    20262020    // FIXME: catch zero-size height or width here (or earlier)?
    2027     return size.width() > cMaxPixelDimension || size.height() > cMaxPixelDimension;
     2021    return size.width() * contentsScale > cMaxPixelDimension || size.height() * contentsScale > cMaxPixelDimension;
    20282022}
    20292023
     
    20342028   
    20352029    m_layer = PlatformCALayer::create(useTiledLayer ? PlatformCALayer::LayerTypeWebTiledLayer : PlatformCALayer::LayerTypeWebLayer, this);
    2036     m_layer->setContentsScale(m_contentsScale);
    2037 
    20382030    m_usingTiledLayer = useTiledLayer;
    20392031   
     
    20662058    updateBackfaceVisibility();
    20672059    updateLayerBackgroundColor();
    2068    
     2060    updateContentsScale();
    20692061    updateOpacityOnLayer();
    20702062   
     
    23712363}
    23722364
     2365void GraphicsLayerCA::pageScaleFactorChanged()
     2366{
     2367    noteChangesForScaleSensitiveProperties();
     2368}
     2369
     2370void GraphicsLayerCA::noteChangesForScaleSensitiveProperties()
     2371{
     2372    noteLayerPropertyChanged(ContentsScaleChanged);
     2373}
     2374
    23732375void GraphicsLayerCA::noteSublayersChanged()
    23742376{
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r89441 r91137  
    5757    virtual PlatformCALayer* platformCALayer() const { return primaryLayer(); }
    5858
    59     virtual float contentsScale() const { return m_contentsScale; }
    60     virtual void setContentsScale(float);
    61 
    6259    virtual bool setChildren(const Vector<GraphicsLayer*>&);
    6360    virtual void addChild(GraphicsLayer*);
     
    119116
    120117    virtual void layerDidDisplay(PlatformLayer*);
     118
     119    virtual void pageScaleFactorChanged();
    121120
    122121    void recursiveCommitChanges();
     
    332331    void noteLayerPropertyChanged(LayerChangeFlags flags);
    333332    void noteSublayersChanged();
     333    void noteChangesForScaleSensitiveProperties();
    334334
    335335    void repaintLayerDirtyRects();
     
    354354    ContentsLayerPurpose m_contentsLayerPurpose;
    355355    bool m_contentsLayerHasBackgroundColor : 1;
     356    bool m_allowTiledLayer : 1;
    356357
    357358    RetainPtr<CGImageRef> m_uncorrectedContentsImage;
     
    397398
    398399    Vector<FloatRect> m_dirtyRects;
     400    FloatSize m_pixelAlignmentOffset;
    399401   
    400402    LayerChangeFlags m_uncommittedChanges;
    401 
    402     float clampedContentsScaleForScale(float) const;
    403     float m_contentsScale;
    404    
    405     bool m_allowTiledLayer;
    406403};
    407404
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r91110 r91137  
    41664166}
    41674167
    4168 void RenderLayer::pageScaleFactorChanged(float scale)
    4169 {
    4170 #if USE(ACCELERATED_COMPOSITING)
    4171     if (m_backing)
    4172         m_backing->pageScaleFactorChanged(scale);
    4173 #endif
    4174 }
    4175 
    41764168} // namespace WebCore
    41774169
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r90925 r91137  
    614614#endif
    615615
    616     void pageScaleFactorChanged(float);
    617 
    618616    friend class RenderLayerBacking;
    619617    friend class RenderLayerCompositor;
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r90959 r91137  
    117117    m_graphicsLayer = createGraphicsLayer(layerName);
    118118   
    119     ASSERT(renderer());
    120     ASSERT(renderer()->document());
    121     ASSERT(renderer()->document()->frame());
    122     m_graphicsLayer->setContentsScale(pageScaleFactor() * backingScaleFactor());
    123 
    124119    updateLayerOpacity(renderer()->style());
    125120    updateLayerTransform(renderer()->style());
     
    653648            m_foregroundLayer->setDrawsContent(true);
    654649            m_foregroundLayer->setPaintingPhase(GraphicsLayerPaintForeground);
    655             m_foregroundLayer->setContentsScale(pageScaleFactor() * backingScaleFactor());
    656650            layerChanged = true;
    657651        }
     
    676670            m_maskLayer->setDrawsContent(true);
    677671            m_maskLayer->setPaintingPhase(GraphicsLayerPaintMask);
    678             m_maskLayer->setContentsScale(pageScaleFactor() * backingScaleFactor());
    679672            layerChanged = true;
    680673        }
     
    12491242}
    12501243
     1244float RenderLayerBacking::pageScaleFactor() const
     1245{
     1246    return compositor()->pageScaleFactor();
     1247}
     1248
     1249float RenderLayerBacking::backingScaleFactor() const
     1250{
     1251    return compositor()->backingScaleFactor();
     1252}
     1253
     1254void RenderLayerBacking::didCommitChangesForLayer(const GraphicsLayer*) const
     1255{
     1256    compositor()->didFlushChangesForLayer(m_owningLayer);
     1257}
     1258
    12511259bool RenderLayerBacking::showDebugBorders() const
    12521260{
     
    14681476}
    14691477
    1470 void RenderLayerBacking::pageScaleFactorChanged(float scale)
    1471 {
    1472     float combinedScale = scale * backingScaleFactor();
    1473 
    1474     if (m_graphicsLayer)
    1475         m_graphicsLayer->setContentsScale(combinedScale);
    1476 
    1477     if (m_foregroundLayer)
    1478         m_foregroundLayer->setContentsScale(combinedScale);
    1479 
    1480     if (m_maskLayer)
    1481         m_maskLayer->setContentsScale(combinedScale);
    1482 }
    1483 
    1484 float RenderLayerBacking::pageScaleFactor() const
    1485 {
    1486     Frame* frame = renderer()->document()->frame();
    1487     if (!frame)
    1488         return 1;
    1489     return frame->pageScaleFactor();
    1490 }
    1491 
    1492 float RenderLayerBacking::backingScaleFactor() const
    1493 {
    1494     Frame* frame = renderer()->document()->frame();
    1495     if (!frame)
    1496         return 1;
    1497     Page* page = frame->page();
    1498     if (!page)
    1499         return 1;
    1500     return page->chrome()->scaleFactor();
    1501 }
    1502 
    15031478} // namespace WebCore
    15041479
  • trunk/Source/WebCore/rendering/RenderLayerBacking.h

    r90954 r91137  
    129129    virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& clip);
    130130
     131    virtual float backingScaleFactor() const;
     132    virtual float pageScaleFactor() const;
     133    virtual void didCommitChangesForLayer(const GraphicsLayer*) const;
     134
    131135    virtual bool showDebugBorders() const;
    132136    virtual bool showRepaintCounter() const;
     
    137141    CompositingLayerType compositingLayerType() const;
    138142   
    139     void pageScaleFactorChanged(float);
    140 
    141143    GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizontalScrollbar.get(); }
    142144    GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVerticalScrollbar.get(); }
     
    194196    static AnimatedPropertyID cssToGraphicsLayerProperty(int);
    195197
    196     float pageScaleFactor() const;
    197     float backingScaleFactor() const;
    198 
    199198#ifndef NDEBUG
    200199    String nameForLayer() const;
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r91114 r91137  
    208208}
    209209
     210void RenderLayerCompositor::didFlushChangesForLayer(RenderLayer*)
     211{
     212}
     213
    210214RenderLayerCompositor* RenderLayerCompositor::enclosingCompositorFlushingLayers() const
    211215{
     
    15331537}
    15341538
     1539float RenderLayerCompositor::backingScaleFactor() const
     1540{
     1541    Frame* frame = m_renderView->frameView()->frame();
     1542    if (!frame)
     1543        return 1;
     1544    Page* page = frame->page();
     1545    if (!page)
     1546        return 1;
     1547    return page->chrome()->scaleFactor();
     1548}
     1549
     1550float RenderLayerCompositor::pageScaleFactor() const
     1551{
     1552    Frame* frame = m_renderView->frameView()->frame();
     1553    if (!frame)
     1554        return 1;
     1555    Page* page = frame->page();
     1556    if (!page)
     1557        return 1;
     1558    return page->mainFrame()->pageScaleFactor();
     1559}
     1560
     1561void RenderLayerCompositor::didCommitChangesForLayer(const GraphicsLayer*) const
     1562{
     1563    // Nothing to do here yet.
     1564}
     1565
    15351566static bool shouldCompositeOverflowControls(ScrollView* view)
    15361567{
     
    16181649        m_rootContentLayer = GraphicsLayer::create(0);
    16191650#ifndef NDEBUG
    1620         m_rootContentLayer->setName("Root platform");
     1651        m_rootContentLayer->setName("content root");
    16211652#endif
    16221653        m_rootContentLayer->setSize(FloatSize(m_renderView->maxXLayoutOverflow(), m_renderView->maxYLayoutOverflow()));
     
    16411672            m_clipLayer = GraphicsLayer::create(this);
    16421673#ifndef NDEBUG
    1643             m_clipLayer->setName("iframe Clipping");
     1674            m_clipLayer->setName("frame clipping");
    16441675#endif
    16451676            m_clipLayer->setMasksToBounds(true);
     
    16471678            m_scrollLayer = GraphicsLayer::create(this);
    16481679#ifndef NDEBUG
    1649             m_scrollLayer->setName("iframe scrolling");
     1680            m_scrollLayer->setName("frame scrolling");
    16501681#endif
    16511682
     
    18481879}
    18491880
    1850 void RenderLayerCompositor::pageScaleFactorChanged(float scale, RenderLayer* layer)
    1851 {
    1852     if (!layer)
    1853         layer = rootRenderLayer();
    1854 
    1855     layer->pageScaleFactorChanged(scale);
    1856 
    1857     if (layer->isStackingContext()) {
    1858         if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) {
    1859             size_t listSize = negZOrderList->size();
    1860             for (size_t i = 0; i < listSize; ++i)
    1861                 pageScaleFactorChanged(scale, negZOrderList->at(i));
    1862         }
    1863 
    1864         if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) {
    1865             size_t listSize = posZOrderList->size();
    1866             for (size_t i = 0; i < listSize; ++i)
    1867                 pageScaleFactorChanged(scale, posZOrderList->at(i));
    1868         }
    1869     }
    1870 
    1871     if (Vector<RenderLayer*>* normalFlowList = layer->normalFlowList()) {
    1872         size_t listSize = normalFlowList->size();
    1873         for (size_t i = 0; i < listSize; ++i)
    1874             pageScaleFactorChanged(scale, normalFlowList->at(i));
    1875     }
     1881void RenderLayerCompositor::pageScaleFactorChanged()
     1882{
     1883    // Start at the RenderView's layer, since that's where the scale is applied.
     1884    RenderLayer* viewLayer = m_renderView->layer();
     1885    if (!viewLayer->isComposited())
     1886        return;
     1887
     1888    if (GraphicsLayer* rootLayer = viewLayer->backing()->graphicsLayer())
     1889        rootLayer->notePageScaleFactorChangedIncludingDescendants();
    18761890}
    18771891
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.h

    r91114 r91137  
    9494    // This call returns the rootmost compositor that is being flushed (including self).
    9595    RenderLayerCompositor* enclosingCompositorFlushingLayers() const;
     96
     97    // Called when the GraphicsLayer for the given RenderLayer has flushed changes inside of flushPendingLayerChanges().
     98    void didFlushChangesForLayer(RenderLayer*);
    9699   
    97100    // Rebuild the tree of compositing layers
     
    185188    bool compositorShowRepaintCounter() const { return m_showRepaintCounter; }
    186189
    187     void pageScaleFactorChanged(float, RenderLayer* = 0);
     190    virtual float backingScaleFactor() const;
     191    virtual float pageScaleFactor() const;
     192    virtual void didCommitChangesForLayer(const GraphicsLayer*) const;
     193   
     194    void pageScaleFactorChanged();
    188195
    189196    GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizontalScrollbar.get(); }
  • trunk/Source/WebKit/chromium/ChangeLog

    r91127 r91137  
     12011-07-15  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Have GraphicsLayer pull their contentsScale, rather than pushing it onto them
     4        https://bugs.webkit.org/show_bug.cgi?id=64643
     5
     6        Reviewed by Darin Adler.
     7       
     8        Impement new GraphicsLayerClient methods related to contents scale.
     9
     10        * src/PageOverlay.cpp:
     11        (WebKit::OverlayGraphicsLayerClientImpl::backingScaleFactor):
     12        (WebKit::OverlayGraphicsLayerClientImpl::pageScaleFactor):
     13
    1142011-07-15  Sheriff Bot  <webkit.review.bot@gmail.com>
    215
  • trunk/Source/WebKit/chromium/src/PageOverlay.cpp

    r88582 r91137  
    6969    {
    7070        m_pageOverlayClient->paintPageOverlay(context);
     71    }
     72
     73    // Multiplier for backing store size, related to high DPI.
     74    virtual float backingScaleFactor() const
     75    {
     76        return 1;
     77    }
     78
     79    virtual float pageScaleFactor() const
     80    {
     81        return 1;
    7182    }
    7283
  • trunk/Source/WebKit2/ChangeLog

    r91108 r91137  
     12011-07-15  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Have GraphicsLayer pull their contentsScale, rather than pushing it onto them
     4        https://bugs.webkit.org/show_bug.cgi?id=64643
     5
     6        Reviewed by Darin Adler.
     7       
     8        Impement new GraphicsLayerClient methods related to contents scale,
     9        and don't push the scale.
     10
     11        * WebProcess/WebPage/ca/LayerTreeHostCA.cpp:
     12        (WebKit::LayerTreeHostCA::initialize):
     13        (WebKit::LayerTreeHostCA::backingScaleFactor):
     14        (WebKit::LayerTreeHostCA::pageScaleFactor):
     15        (WebKit::LayerTreeHostCA::createPageOverlayLayer):
     16        * WebProcess/WebPage/ca/LayerTreeHostCA.h:
     17        (WebKit::LayerTreeHostCA::didCommitChangesForLayer):
     18
    1192011-07-15  Ada Chan  <adachan@apple.com>
    220
  • trunk/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp

    r90293 r91137  
    6868    m_nonCompositedContentLayer->setContentsOpaque(m_webPage->drawsBackground() && !m_webPage->drawsTransparentBackground());
    6969    m_nonCompositedContentLayer->setSize(m_webPage->size());
    70     m_nonCompositedContentLayer->setContentsScale(m_webPage->userSpaceScaleFactor());
    7170    if (m_webPage->corePage()->settings()->acceleratedDrawingEnabled())
    7271        m_nonCompositedContentLayer->setAcceleratesDrawing(true);
     
    208207}
    209208
     209float LayerTreeHostCA::backingScaleFactor() const
     210{
     211    return m_webPage->userSpaceScaleFactor();
     212}
     213
     214float LayerTreeHostCA::pageScaleFactor() const
     215{
     216    return 1;
     217}
     218
    210219void LayerTreeHostCA::performScheduledLayerFlush()
    211220{
     
    254263    m_pageOverlayLayer->setDrawsContent(true);
    255264    m_pageOverlayLayer->setSize(m_webPage->size());
    256     m_pageOverlayLayer->setContentsScale(m_webPage->userSpaceScaleFactor());
    257265
    258266    m_rootLayer->addChild(m_pageOverlayLayer.get());
  • trunk/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h

    r87755 r91137  
    7575    virtual bool showDebugBorders() const;
    7676    virtual bool showRepaintCounter() const;
     77    virtual float backingScaleFactor() const;
     78    virtual float pageScaleFactor() const;
     79    virtual void didCommitChangesForLayer(const WebCore::GraphicsLayer*) const { }
    7780
    7881    // LayerTreeHostCA
Note: See TracChangeset for help on using the changeset viewer.