Changeset 183274 in webkit


Ignore:
Timestamp:
Apr 24, 2015 12:01:48 PM (9 years ago)
Author:
Simon Fraser
Message:

Make it possible to map a secondary quad through TransformState
https://bugs.webkit.org/show_bug.cgi?id=144156

Reviewed by Dean Jackson.

A future patch will need to map two quads simultaneously through TransformState,
so add the ability to provide an optional secondary quad.

This patch also firms up the setQuad() contract, fixing webkit.org/b/106680,
requiring the state to be flattened when setting the quad (and now, the secondary quad).
Previously, setQuad implicitly flattened but failed to update m_mapPoint when
doing so.

  • platform/graphics/ca/GraphicsLayerCA.cpp:

(WebCore::GraphicsLayerCA::computeVisibleRect): Now we have to explicitly flatten
before setting the quad.

  • platform/graphics/ca/GraphicsLayerCA.h: Drive-up #include removal.
  • platform/graphics/transforms/TransformState.cpp:

(WebCore::TransformState::operator=): Copy the secondary quad if we have one.
(WebCore::TransformState::translateMappedCoordinates): Move the secondary quad
if we have one.
(WebCore::TransformState::mappedQuad): Code factored into mapQuad().
(WebCore::TransformState::mappedSecondaryQuad): Return the secondary quad mapped
into the state's current coordinate space.
(WebCore::TransformState::mapQuad): Factored code.

  • platform/graphics/transforms/TransformState.h:

(WebCore::TransformState::setQuad): Make the contract more explicit with assertions.
(WebCore::TransformState::setSecondaryQuad): Ditto when setting the secondary quad.
(WebCore::TransformState::lastPlanarSecondaryQuad):
(WebCore::TransformState::lastPlanarQuad): Deleted.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r183271 r183274  
     12015-04-24  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make it possible to map a secondary quad through TransformState
     4        https://bugs.webkit.org/show_bug.cgi?id=144156
     5
     6        Reviewed by Dean Jackson.
     7
     8        A future patch will need to map two quads simultaneously through TransformState,
     9        so add the ability to provide an optional secondary quad.
     10       
     11        This patch also firms up the setQuad() contract, fixing webkit.org/b/106680,
     12        requiring the state to be flattened when setting the quad (and now, the secondary quad).
     13        Previously, setQuad implicitly flattened but failed to update m_mapPoint when
     14        doing so.
     15
     16        * platform/graphics/ca/GraphicsLayerCA.cpp:
     17        (WebCore::GraphicsLayerCA::computeVisibleRect): Now we have to explicitly flatten
     18        before setting the quad.
     19        * platform/graphics/ca/GraphicsLayerCA.h: Drive-up #include removal.
     20        * platform/graphics/transforms/TransformState.cpp:
     21        (WebCore::TransformState::operator=): Copy the secondary quad if we have one.
     22        (WebCore::TransformState::translateMappedCoordinates): Move the secondary quad
     23        if we have one.
     24        (WebCore::TransformState::mappedQuad): Code factored into mapQuad().
     25        (WebCore::TransformState::mappedSecondaryQuad): Return the secondary quad mapped
     26        into the state's current coordinate space.
     27        (WebCore::TransformState::mapQuad): Factored code.
     28        * platform/graphics/transforms/TransformState.h:
     29        (WebCore::TransformState::setQuad): Make the contract more explicit with assertions.
     30        (WebCore::TransformState::setSecondaryQuad): Ditto when setting the secondary quad.
     31        (WebCore::TransformState::lastPlanarSecondaryQuad):
     32        (WebCore::TransformState::lastPlanarQuad): Deleted.
     33
    1342015-04-24  Myles C. Maxfield  <mmaxfield@apple.com>
    235
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r183241 r183274  
    12091209    if (masksToBounds()) {
    12101210        ASSERT(accumulation == TransformState::FlattenTransform);
    1211         // Replace the quad in the TransformState with one that is clipped to this layer's bounds
     1211        // Flatten, and replace the quad in the TransformState with one that is clipped to this layer's bounds.
     1212        state.flatten();
    12121213        state.setQuad(clipRectForSelf);
    12131214    }
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r183242 r183274  
    3535#include <wtf/RetainPtr.h>
    3636#include <wtf/text/StringHash.h>
    37 
    38 #if PLATFORM(COCOA)
    39 #include "TileController.h"
    40 #endif
    4137
    4238// Enable this to add a light red wash over the visible portion of Tiled Layers, as computed
  • trunk/Source/WebCore/platform/graphics/transforms/TransformState.cpp

    r166889 r183274  
    3636    if (m_mapPoint)
    3737        m_lastPlanarPoint = other.m_lastPlanarPoint;
    38     if (m_mapQuad)
     38    if (m_mapQuad) {
    3939        m_lastPlanarQuad = other.m_lastPlanarQuad;
     40        if (other.m_lastPlanarSecondaryQuad)
     41            m_lastPlanarSecondaryQuad = std::make_unique<FloatQuad>(*other.m_lastPlanarSecondaryQuad);
     42        else
     43            m_lastPlanarSecondaryQuad = nullptr;
     44       
     45    }
    4046    m_accumulatingTransform = other.m_accumulatingTransform;
    4147    m_direction = other.m_direction;
     
    6268    if (m_mapPoint)
    6369        m_lastPlanarPoint.move(adjustedOffset);
    64     if (m_mapQuad)
     70    if (m_mapQuad) {
    6571        m_lastPlanarQuad.move(adjustedOffset);
     72        if (m_lastPlanarSecondaryQuad)
     73            m_lastPlanarSecondaryQuad->move(adjustedOffset);
     74    }
    6675}
    6776
     
    172181
    173182    FloatQuad quad = m_lastPlanarQuad;
     183    mapQuad(quad, wasClamped);
     184    return quad;
     185}
     186
     187std::unique_ptr<FloatQuad> TransformState::mappedSecondaryQuad(bool* wasClamped) const
     188{
     189    if (wasClamped)
     190        *wasClamped = false;
     191
     192    if (!m_lastPlanarSecondaryQuad)
     193        return nullptr;
     194
     195    FloatQuad quad = *m_lastPlanarSecondaryQuad;
     196    mapQuad(quad, wasClamped);
     197    return std::make_unique<FloatQuad>(quad);
     198}
     199
     200void TransformState::mapQuad(FloatQuad& quad, bool* wasClamped) const
     201{
    174202    quad.move((m_direction == ApplyTransformDirection) ? m_accumulatedOffset : -m_accumulatedOffset);
    175203    if (!m_accumulatedTransform)
    176         return quad;
     204        return;
    177205
    178206    if (m_direction == ApplyTransformDirection)
    179         return m_accumulatedTransform->mapQuad(quad);
    180 
    181     return m_accumulatedTransform->inverse().projectQuad(quad, wasClamped);
     207        quad = m_accumulatedTransform->mapQuad(quad);
     208
     209    quad = m_accumulatedTransform->inverse().projectQuad(quad, wasClamped);
    182210}
    183211
  • trunk/Source/WebCore/platform/graphics/transforms/TransformState.h

    r166889 r183274  
    7575    void setQuad(const FloatQuad& quad)
    7676    {
    77         // FIXME: this assumes that the quad being added is in the coordinate system of the current state.
    78         // This breaks if we're simultaneously mapping a point. https://bugs.webkit.org/show_bug.cgi?id=106680
    79         ASSERT(!m_mapPoint);
    80         m_accumulatedOffset = LayoutSize();
     77        // We must be in a flattened state (no accumulated offset) when setting this quad.
     78        ASSERT(m_accumulatedOffset == LayoutSize());
    8179        m_lastPlanarQuad = quad;
     80    }
     81
     82    void setSecondaryQuad(const FloatQuad* quad)
     83    {
     84        // We must be in a flattened state (no accumulated offset) when setting this secondary quad.
     85        ASSERT(m_accumulatedOffset == LayoutSize());
     86        if (quad)
     87            m_lastPlanarSecondaryQuad = std::make_unique<FloatQuad>(*quad);
     88        else
     89            m_lastPlanarSecondaryQuad = nullptr;
    8290    }
    8391
     
    8896
    8997    void move(const LayoutSize&, TransformAccumulation = FlattenTransform);
    90     void applyTransform(const AffineTransform& transformFromContainer, TransformAccumulation = FlattenTransform, bool* wasClamped = 0);
    91     void applyTransform(const TransformationMatrix& transformFromContainer, TransformAccumulation = FlattenTransform, bool* wasClamped = 0);
    92     void flatten(bool* wasClamped = 0);
     98    void applyTransform(const AffineTransform& transformFromContainer, TransformAccumulation = FlattenTransform, bool* wasClamped = nullptr);
     99    void applyTransform(const TransformationMatrix& transformFromContainer, TransformAccumulation = FlattenTransform, bool* wasClamped = nullptr);
     100    void flatten(bool* wasClamped = nullptr);
    93101
    94102    // Return the coords of the point or quad in the last flattened layer
    95103    FloatPoint lastPlanarPoint() const { return m_lastPlanarPoint; }
    96104    FloatQuad lastPlanarQuad() const { return m_lastPlanarQuad; }
     105    FloatQuad* lastPlanarSecondaryQuad() const { return m_lastPlanarSecondaryQuad.get(); }
    97106
    98107    // Return the point or quad mapped through the current transform
    99     FloatPoint mappedPoint(bool* wasClamped = 0) const;
    100     FloatQuad mappedQuad(bool* wasClamped = 0) const;
     108    FloatPoint mappedPoint(bool* wasClamped = nullptr) const;
     109    FloatQuad mappedQuad(bool* wasClamped = nullptr) const;
     110    std::unique_ptr<FloatQuad> mappedSecondaryQuad(bool* wasClamped = nullptr) const;
    101111
    102112private:
     
    106116    void applyAccumulatedOffset();
    107117   
     118    void mapQuad(FloatQuad&, bool* clamped) const;
     119   
    108120    FloatPoint m_lastPlanarPoint;
    109121    FloatQuad m_lastPlanarQuad;
     122    std::unique_ptr<FloatQuad> m_lastPlanarSecondaryQuad; // Optional second quad to map.
    110123
    111124    // We only allocate the transform if we need to
     
    113126    LayoutSize m_accumulatedOffset;
    114127    bool m_accumulatingTransform;
    115     bool m_mapPoint, m_mapQuad;
     128    bool m_mapPoint;
     129    bool m_mapQuad;
    116130    TransformDirection m_direction;
    117131};
Note: See TracChangeset for help on using the changeset viewer.