Changeset 92651 in webkit


Ignore:
Timestamp:
Aug 8, 2011 4:21:16 PM (13 years ago)
Author:
cmarrin@apple.com
Message:

Logic to compute visible display rect in GraphicsLayerCA::syncCompositingState
https://bugs.webkit.org/show_bug.cgi?id=65708

Source/WebCore:

Add logic to syncCompositingState to compute the visible rect for each
layer. This can be used to synchronously render the visible tiles of a
TiledLayer and avoid the flashing that often occurs when tiles are rendered
asynchronously. A new synchronouslyDisplayTilesInRect is also added to do
the actual rendering, but the call is not currently being made.

Reviewed by Simon Fraser.

  • page/FrameView.cpp:

(WebCore::FrameView::syncCompositingStateForThisFrame):

  • platform/graphics/GraphicsLayer.h:

(WebCore::GraphicsLayer::syncCompositingState):

  • platform/graphics/ca/GraphicsLayerCA.cpp:

(WebCore::GraphicsLayerCA::syncCompositingState):
(WebCore::GraphicsLayerCA::recursiveCommitChanges):
(WebCore::GraphicsLayerCA::platformCALayerPaintContents):
(WebCore::GraphicsLayerCA::updateSublayerList):
(WebCore::GraphicsLayerCA::swapFromOrToTiledLayer):

  • platform/graphics/ca/GraphicsLayerCA.h:
  • platform/graphics/ca/PlatformCALayer.h:
  • platform/graphics/ca/mac/PlatformCALayerMac.mm:

(PlatformCALayer::synchronouslyDisplayTilesInRect):

  • platform/graphics/transforms/TransformState.cpp:

(WebCore::TransformState::operator=):

  • platform/graphics/transforms/TransformState.h:

(WebCore::TransformState::TransformState):

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::flushPendingLayerChanges):

Source/WebKit/mac:

Supply initial display rects for the full-screen case

Reviewed by Simon Fraser.

  • WebView/WebFullScreenController.mm:

(-[WebFullScreenController enterFullscreen:]):
(-[WebFullScreenController exitFullscreen]):

Source/WebKit2:

Supply initial display rects for the full-screen case

Reviewed by Simon Fraser.

  • WebProcess/FullScreen/mac/WebFullScreenManagerMac.mm:

(WebKit::WebFullScreenManagerMac::setRootFullScreenLayer):
(WebKit::WebFullScreenManagerMac::beginEnterFullScreenAnimation):
(WebKit::WebFullScreenManagerMac::beginExitFullScreenAnimation):

Location:
trunk/Source
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r92643 r92651  
     1
     2        Logic to compute visible display rect in GraphicsLayerCA::syncCompositingState
     3        https://bugs.webkit.org/show_bug.cgi?id=65708
     4
     5        Add logic to syncCompositingState to compute the visible rect for each
     6        layer. This can be used to synchronously render the visible tiles of a
     7        TiledLayer and avoid the flashing that often occurs when tiles are rendered
     8        asynchronously. A new synchronouslyDisplayTilesInRect is also added to do
     9        the actual rendering, but the call is not currently being made.
     10
     11        Reviewed by Simon Fraser.
     12
     13        * page/FrameView.cpp:
     14        (WebCore::FrameView::syncCompositingStateForThisFrame):
     15        * platform/graphics/GraphicsLayer.h:
     16        (WebCore::GraphicsLayer::syncCompositingState):
     17        * platform/graphics/ca/GraphicsLayerCA.cpp:
     18        (WebCore::GraphicsLayerCA::syncCompositingState):
     19        (WebCore::GraphicsLayerCA::recursiveCommitChanges):
     20        (WebCore::GraphicsLayerCA::platformCALayerPaintContents):
     21        (WebCore::GraphicsLayerCA::updateSublayerList):
     22        (WebCore::GraphicsLayerCA::swapFromOrToTiledLayer):
     23        * platform/graphics/ca/GraphicsLayerCA.h:
     24        * platform/graphics/ca/PlatformCALayer.h:
     25        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
     26        (PlatformCALayer::synchronouslyDisplayTilesInRect):
     27        * platform/graphics/transforms/TransformState.cpp:
     28        (WebCore::TransformState::operator=):
     29        * platform/graphics/transforms/TransformState.h:
     30        (WebCore::TransformState::TransformState):
     31        * rendering/RenderLayerCompositor.cpp:
     32        (WebCore::RenderLayerCompositor::flushPendingLayerChanges):
     33
    1342011-08-08  Sheriff Bot  <webkit.review.bot@gmail.com>
    235
  • trunk/Source/WebCore/page/FrameView.cpp

    r92545 r92651  
    702702    if (isDocumentRunningFullScreenAnimation(document)) {
    703703        RenderLayerBacking* backing = document->fullScreenRenderer()->layer()->backing();
    704         if (GraphicsLayer* fullScreenLayer = backing->graphicsLayer())
    705             fullScreenLayer->syncCompositingState();
     704        if (GraphicsLayer* fullScreenLayer = backing->graphicsLayer()) {
     705            // FIXME: Passing frameRect() is correct only when RenderLayerCompositor uses a ScrollLayer (as in WebKit2)
     706            // otherwise, the passed clip rect needs to take scrolling into account
     707            fullScreenLayer->syncCompositingState(frameRect());
     708        }
    706709    }
    707710#endif
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r91161 r92651  
    366366    // with updates drawn into the window. These methods flush internal batched state on this layer
    367367    // and descendant layers, and this layer only.
    368     virtual void syncCompositingState() { }
     368    virtual void syncCompositingState(const FloatRect& /* clipRect */) { }
    369369    virtual void syncCompositingStateForThisLayerOnly() { }
    370370   
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r91623 r92651  
    3737#include "ScaleTransformOperation.h"
    3838#include "SystemTime.h"
     39#include "TransformState.h"
    3940#include "TranslateTransformOperation.h"
    4041#include <QuartzCore/CATransform3D.h>
     
    811812}
    812813
    813 void GraphicsLayerCA::syncCompositingState()
    814 {
    815     recursiveCommitChanges();
     814void GraphicsLayerCA::syncCompositingState(const FloatRect& clipRect)
     815{
     816    TransformState state(TransformState::UnapplyInverseTransformDirection, FloatQuad(clipRect));
     817    recursiveCommitChanges(state);
    816818}
    817819
     
    824826}
    825827
    826 void GraphicsLayerCA::recursiveCommitChanges(float pageScaleFactor, const FloatPoint& positionRelativeToBase, bool affectedByPageScale)
    827 {
     828void GraphicsLayerCA::recursiveCommitChanges(const TransformState& state, float pageScaleFactor, const FloatPoint& positionRelativeToBase, bool affectedByPageScale)
     829{
     830    // Save the state before sending down to kids and restore it after
     831    TransformState localState = state;
     832   
     833    TransformState::TransformAccumulation accumulation = preserves3D() ? TransformState::AccumulateTransform : TransformState::FlattenTransform;
     834    localState.move(-m_position.x(), -m_position.y(), accumulation);
     835   
     836    if (!transform().isIdentity()) {
     837        TransformationMatrix transformWithAnchorPoint;
     838        FloatPoint3D absoluteAnchorPoint(anchorPoint());
     839        absoluteAnchorPoint.scale(size().width(), size().height(), 1);
     840        transformWithAnchorPoint.translate3d(absoluteAnchorPoint.x(), absoluteAnchorPoint.y(), absoluteAnchorPoint.z());
     841        transformWithAnchorPoint.multiply(transform());
     842        transformWithAnchorPoint.translate3d(-absoluteAnchorPoint.x(), -absoluteAnchorPoint.y(), -absoluteAnchorPoint.z());
     843        localState.applyTransform(transformWithAnchorPoint, accumulation);
     844    }
     845   
     846    FloatRect clipRectForChildren = localState.lastPlanarQuad().boundingBox();
     847    FloatRect clipRectForSelf;
     848   
     849    if (masksToBounds()) {
     850        ASSERT(accumulation == TransformState::FlattenTransform);
     851       
     852        // Replace the quad in the TransformState with one that is clipped to this layer's bounds
     853        clipRectForSelf = FloatRect(0, 0, m_size.width(), m_size.height());
     854        clipRectForSelf.intersect(clipRectForChildren);
     855        localState.setQuad(clipRectForSelf);
     856    }
     857
     858#ifdef VISIBLE_TILE_WASH
     859    if (m_visibleTileWashLayer) {
     860        if (clipRectForSelf.isEmpty()) {
     861            clipRectForSelf = FloatRect(0, 0, m_size.width(), m_size.height());
     862            clipRectForSelf.intersect(clipRectForChildren);
     863        }
     864        m_visibleTileWashLayer->setFrame(clipRectForSelf);
     865    }
     866#endif
     867
    828868    bool hadChanges = m_uncommittedChanges;
    829869   
     
    845885    const Vector<GraphicsLayer*>& childLayers = children();
    846886    size_t numChildren = childLayers.size();
     887   
     888    if (!childrenTransform().isIdentity())   
     889        localState.applyTransform(childrenTransform(), accumulation);
     890   
    847891    for (size_t i = 0; i < numChildren; ++i) {
    848892        GraphicsLayerCA* curChild = static_cast<GraphicsLayerCA*>(childLayers[i]);
    849         curChild->recursiveCommitChanges(pageScaleFactor, baseRelativePosition, affectedByPageScale);
     893        curChild->recursiveCommitChanges(localState, pageScaleFactor, baseRelativePosition, affectedByPageScale);
    850894    }
    851895
    852896    if (m_replicaLayer)
    853         static_cast<GraphicsLayerCA*>(m_replicaLayer)->recursiveCommitChanges(pageScaleFactor, baseRelativePosition, affectedByPageScale);
     897        static_cast<GraphicsLayerCA*>(m_replicaLayer)->recursiveCommitChanges(localState, pageScaleFactor, baseRelativePosition, affectedByPageScale);
    854898
    855899    if (m_maskLayer)
     
    860904    if (hadChanges && client())
    861905        client()->didCommitChangesForLayer(this);
     906}
     907
     908void GraphicsLayerCA::platformCALayerPaintContents(GraphicsContext& context, const IntRect& clip)
     909{
     910    paintGraphicsLayerContents(context, clip);
    862911}
    863912
     
    9901039            newSublayers[i]->removeFromSuperlayer();
    9911040    }
     1041   
     1042#ifdef VISIBLE_TILE_WASH
     1043    if (m_visibleTileWashLayer)
     1044        newSublayers.append(m_visibleTileWashLayer);
     1045#endif
    9921046
    9931047    if (m_structuralLayer) {
     
    20632117    m_usingTiledLayer = useTiledLayer;
    20642118   
     2119#ifdef VISIBLE_TILE_WASH
     2120    if (useTiledLayer) {
     2121        static Color washFillColor(255, 0, 0, 50);
     2122        static Color washBorderColor(255, 0, 0, 100);
     2123       
     2124        m_visibleTileWashLayer = PlatformCALayer::create(PlatformCALayer::LayerTypeLayer, this);
     2125        m_visibleTileWashLayer->setName("Visible Tile Wash Layer");
     2126        m_visibleTileWashLayer->setAnchorPoint(FloatPoint3D(0, 0, 0));
     2127        m_visibleTileWashLayer->setBorderColor(washBorderColor);
     2128        m_visibleTileWashLayer->setBorderWidth(8);
     2129        m_visibleTileWashLayer->setBackgroundColor(washFillColor);
     2130    } else
     2131        m_visibleTileWashLayer = 0;
     2132#endif
     2133   
    20652134    if (useTiledLayer) {
    20662135#if !HAVE_MODERN_QUARTZCORE
     
    20752144
    20762145    m_layer->adoptSublayers(oldLayer.get());
    2077    
     2146
     2147#ifdef VISIBLE_TILE_WASH
     2148    if (m_visibleTileWashLayer)
     2149        m_layer->appendSublayer(m_visibleTileWashLayer.get());
     2150#endif
     2151
    20782152    // FIXME: Skip this step if we don't have a superlayer. This is problably a benign
    20792153    // case that happens while restructuring the layer tree.
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r91294 r92651  
    3838#include <wtf/text/StringHash.h>
    3939
     40// Enable this to add a light red wash over the visible portion of Tiled Layers, as computed
     41// by syncCompositingState().
     42// #define VISIBLE_TILE_WASH
     43
    4044namespace WebCore {
    4145
    4246class PlatformCALayer;
     47class TransformState;
    4348
    4449class GraphicsLayerCA : public GraphicsLayer, public PlatformCALayerClient {
     
    120125    virtual void pageScaleFactorChanged();
    121126
    122     void recursiveCommitChanges(float pageScaleFactor = 1, const FloatPoint& positionRelativeToBase = FloatPoint(), bool affectedByPageScale = false);
    123 
    124     virtual void syncCompositingState();
     127    void recursiveCommitChanges(const TransformState&, float pageScaleFactor = 1, const FloatPoint& positionRelativeToBase = FloatPoint(), bool affectedByPageScale = false);
     128
     129    virtual void syncCompositingState(const FloatRect&);
    125130    virtual void syncCompositingStateForThisLayerOnly();
    126131
     
    138143    virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime);
    139144    virtual CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return contentsOrientation(); }
    140     virtual void platformCALayerPaintContents(GraphicsContext& context, const IntRect& clip) { paintGraphicsLayerContents(context, clip); }
     145    virtual void platformCALayerPaintContents(GraphicsContext&, const IntRect& clip);
    141146    virtual bool platformCALayerShowDebugBorders() const { return showDebugBorders(); }
    142147    virtual bool platformCALayerShowRepaintCounter() const { return showRepaintCounter(); }
     
    349354    OwnPtr<LayerMap> m_structuralLayerClones;
    350355    OwnPtr<LayerMap> m_contentsLayerClones;
     356
     357#ifdef VISIBLE_TILE_WASH
     358    RefPtr<PlatformCALayer> m_visibleTileWashLayer;
     359#endif
    351360   
    352361    enum ContentsLayerPurpose {
  • trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h

    r84416 r92651  
    196196#endif
    197197
     198#if PLATFORM(MAC) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
     199    void synchronouslyDisplayTilesInRect(const FloatRect&);
     200#endif
     201
    198202protected:
    199203    PlatformCALayer(LayerType, PlatformLayer*, PlatformCALayerClient*);
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm

    r89651 r92651  
    9090@end
    9191
     92#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
     93@interface CATiledLayer(GraphicsLayerCAPrivate)
     94- (void)displayInRect:(CGRect)r levelOfDetail:(int)lod options:(NSDictionary *)dict;
     95- (BOOL)canDrawConcurrently;
     96- (void)setCanDrawConcurrently:(BOOL)flag;
     97@end
     98#endif
     99
    92100@interface CALayer(Private)
    93101- (void)setContentsChanged;
     
    751759}
    752760
     761#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
     762void PlatformCALayer::synchronouslyDisplayTilesInRect(const FloatRect& rect)
     763{
     764    if (m_layerType != LayerTypeWebTiledLayer)
     765        return;
     766
     767    WebTiledLayer *tiledLayer = static_cast<WebTiledLayer*>(m_layer.get());
     768
     769    BEGIN_BLOCK_OBJC_EXCEPTIONS
     770    BOOL oldCanDrawConcurrently = [tiledLayer canDrawConcurrently];
     771    [tiledLayer setCanDrawConcurrently:NO];
     772    [tiledLayer displayInRect:rect levelOfDetail:0 options:nil];
     773    [tiledLayer setCanDrawConcurrently:oldCanDrawConcurrently];
     774    END_BLOCK_OBJC_EXCEPTIONS
     775}
     776#endif
     777
    753778#endif // USE(ACCELERATED_COMPOSITING)
  • trunk/Source/WebCore/platform/graphics/transforms/TransformState.cpp

    r91130 r92651  
    3030
    3131namespace WebCore {
     32
     33TransformState& TransformState::operator=(const TransformState& other)
     34{
     35    m_mapPoint = other.m_mapPoint;
     36    m_mapQuad = other.m_mapQuad;
     37    if (m_mapPoint)
     38        m_lastPlanarPoint = other.m_lastPlanarPoint;
     39    if (m_mapQuad)
     40        m_lastPlanarQuad = other.m_lastPlanarQuad;
     41    m_accumulatingTransform = other.m_accumulatingTransform;
     42    m_direction = other.m_direction;
     43   
     44    m_accumulatedTransform.clear();
     45
     46    if (other.m_accumulatedTransform)
     47        m_accumulatedTransform = adoptPtr(new TransformationMatrix(*other.m_accumulatedTransform));
     48       
     49    return *this;
     50}
    3251
    3352void TransformState::move(int x, int y, TransformAccumulation accumulate)
  • trunk/Source/WebCore/platform/graphics/transforms/TransformState.h

    r91130 r92651  
    3737
    3838class TransformState {
    39     WTF_MAKE_NONCOPYABLE(TransformState);
    4039public:
    4140    enum TransformDirection { ApplyTransformDirection, UnapplyInverseTransformDirection };
     
    6968    {
    7069    }
     70   
     71    TransformState(const TransformState& other) { *this = other; }
     72
     73    TransformState& operator=(const TransformState&);
    7174   
    7275    void setQuad(const FloatQuad& quad) { m_lastPlanarQuad = quad; }
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r91542 r92651  
    204204    m_flushingLayers = true;
    205205
    206     if (GraphicsLayer* rootLayer = rootGraphicsLayer())
    207         rootLayer->syncCompositingState();
    208 
     206    if (GraphicsLayer* rootLayer = rootGraphicsLayer()) {
     207        FrameView* frameView = m_renderView ? m_renderView->frameView() : 0;
     208        if (frameView) {
     209            // FIXME: Passing frameRect() is correct only when RenderLayerCompositor uses a ScrollLayer (as in WebKit2)
     210            // otherwise, the passed clip rect needs to take scrolling into account
     211            rootLayer->syncCompositingState(frameView->frameRect());
     212        }
     213    }
     214   
    209215    ASSERT(m_flushingLayers);
    210216    m_flushingLayers = false;
  • trunk/Source/WebKit/mac/ChangeLog

    r92552 r92651  
     12011-08-08  Chris Marrin  <cmarrin@apple.com>
     2
     3        Logic to compute visible display rect in GraphicsLayerCA::syncCompositingState
     4        https://bugs.webkit.org/show_bug.cgi?id=65708
     5
     6        Supply initial display rects for the full-screen case
     7
     8        Reviewed by Simon Fraser.
     9
     10        * WebView/WebFullScreenController.mm:
     11        (-[WebFullScreenController enterFullscreen:]):
     12        (-[WebFullScreenController exitFullscreen]):
     13
    1142011-08-06  Joseph Pecoraro  <joepeck@webkit.org>
    215
  • trunk/Source/WebKit/mac/WebView/WebFullScreenController.mm

    r92347 r92651  
    422422    // tell the renderer's layer to sync it's compositing state:
    423423    GraphicsLayer* rendererGraphics = _renderer->layer()->backing()->graphicsLayer();
    424     rendererGraphics->syncCompositingState();   
     424    rendererGraphics->syncCompositingState(destinationFrame);   
    425425
    426426    CALayer* rendererLayer = rendererGraphics->platformLayer();
     
    573573    [self _document]->setFullScreenRendererBackgroundColor(Color::transparent);
    574574
    575     rendererGraphics->syncCompositingState();   
     575    rendererGraphics->syncCompositingState(layerEndFrame);   
    576576
    577577    CALayer* rendererLayer = rendererGraphics->platformLayer();
  • trunk/Source/WebKit2/ChangeLog

    r92603 r92651  
     12011-08-08  Chris Marrin  <cmarrin@apple.com>
     2
     3        Logic to compute visible display rect in GraphicsLayerCA::syncCompositingState
     4        https://bugs.webkit.org/show_bug.cgi?id=65708
     5
     6        Supply initial display rects for the full-screen case
     7
     8        Reviewed by Simon Fraser.
     9
     10        * WebProcess/FullScreen/mac/WebFullScreenManagerMac.mm:
     11        (WebKit::WebFullScreenManagerMac::setRootFullScreenLayer):
     12        (WebKit::WebFullScreenManagerMac::beginEnterFullScreenAnimation):
     13        (WebKit::WebFullScreenManagerMac::beginExitFullScreenAnimation):
     14
    1152011-08-08  Dan Bernstein  <mitz@apple.com>
    216
  • trunk/Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.mm

    r89398 r92651  
    174174    m_rootLayer->removeAllChildren();
    175175    m_rootLayer->addChild(layer);
    176     m_rootLayer->syncCompositingState();
     176    m_rootLayer->syncCompositingState(getFullScreenRect());
    177177    [CATransaction commit];
    178178
     
    204204    IntRect destinationFrame = getFullScreenRect();
    205205    m_element->document()->setFullScreenRendererSize(destinationFrame.size());
    206     m_rootLayer->syncCompositingState();
     206    m_rootLayer->syncCompositingState(destinationFrame);
    207207
    208208    // FIXME: Once we gain the ability to do native WebKit animations of generated
     
    227227    IntRect destinationFrame = getFullScreenRect();
    228228    m_element->document()->setFullScreenRendererSize(destinationFrame.size());
    229     m_rootLayer->syncCompositingState();
     229    m_rootLayer->syncCompositingState(destinationFrame);
    230230
    231231    // FIXME: Once we gain the ability to do native WebKit animations of generated
Note: See TracChangeset for help on using the changeset viewer.