- Revision
- 183274
- Author
- [email protected]
- Date
- 2015-04-24 12:01:48 -0700 (Fri, 24 Apr 2015)
Log 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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (183273 => 183274)
--- trunk/Source/WebCore/ChangeLog 2015-04-24 18:57:25 UTC (rev 183273)
+++ trunk/Source/WebCore/ChangeLog 2015-04-24 19:01:48 UTC (rev 183274)
@@ -1,3 +1,36 @@
+2015-04-24 Simon Fraser <[email protected]>
+
+ 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.
+
2015-04-24 Myles C. Maxfield <[email protected]>
[iOS] Reimplement r182512 and r183153 in a cleaner way
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (183273 => 183274)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2015-04-24 18:57:25 UTC (rev 183273)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2015-04-24 19:01:48 UTC (rev 183274)
@@ -1208,7 +1208,8 @@
if (masksToBounds()) {
ASSERT(accumulation == TransformState::FlattenTransform);
- // Replace the quad in the TransformState with one that is clipped to this layer's bounds
+ // Flatten, and replace the quad in the TransformState with one that is clipped to this layer's bounds.
+ state.flatten();
state.setQuad(clipRectForSelf);
}
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (183273 => 183274)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h 2015-04-24 18:57:25 UTC (rev 183273)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h 2015-04-24 19:01:48 UTC (rev 183274)
@@ -35,10 +35,6 @@
#include <wtf/RetainPtr.h>
#include <wtf/text/StringHash.h>
-#if PLATFORM(COCOA)
-#include "TileController.h"
-#endif
-
// Enable this to add a light red wash over the visible portion of Tiled Layers, as computed
// by flushCompositingState().
// #define VISIBLE_TILE_WASH
Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformState.cpp (183273 => 183274)
--- trunk/Source/WebCore/platform/graphics/transforms/TransformState.cpp 2015-04-24 18:57:25 UTC (rev 183273)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformState.cpp 2015-04-24 19:01:48 UTC (rev 183274)
@@ -35,8 +35,14 @@
m_mapQuad = other.m_mapQuad;
if (m_mapPoint)
m_lastPlanarPoint = other.m_lastPlanarPoint;
- if (m_mapQuad)
+ if (m_mapQuad) {
m_lastPlanarQuad = other.m_lastPlanarQuad;
+ if (other.m_lastPlanarSecondaryQuad)
+ m_lastPlanarSecondaryQuad = std::make_unique<FloatQuad>(*other.m_lastPlanarSecondaryQuad);
+ else
+ m_lastPlanarSecondaryQuad = nullptr;
+
+ }
m_accumulatingTransform = other.m_accumulatingTransform;
m_direction = other.m_direction;
@@ -61,8 +67,11 @@
LayoutSize adjustedOffset = (m_direction == ApplyTransformDirection) ? offset : -offset;
if (m_mapPoint)
m_lastPlanarPoint.move(adjustedOffset);
- if (m_mapQuad)
+ if (m_mapQuad) {
m_lastPlanarQuad.move(adjustedOffset);
+ if (m_lastPlanarSecondaryQuad)
+ m_lastPlanarSecondaryQuad->move(adjustedOffset);
+ }
}
void TransformState::move(const LayoutSize& offset, TransformAccumulation accumulate)
@@ -171,14 +180,33 @@
*wasClamped = false;
FloatQuad quad = m_lastPlanarQuad;
+ mapQuad(quad, wasClamped);
+ return quad;
+}
+
+std::unique_ptr<FloatQuad> TransformState::mappedSecondaryQuad(bool* wasClamped) const
+{
+ if (wasClamped)
+ *wasClamped = false;
+
+ if (!m_lastPlanarSecondaryQuad)
+ return nullptr;
+
+ FloatQuad quad = *m_lastPlanarSecondaryQuad;
+ mapQuad(quad, wasClamped);
+ return std::make_unique<FloatQuad>(quad);
+}
+
+void TransformState::mapQuad(FloatQuad& quad, bool* wasClamped) const
+{
quad.move((m_direction == ApplyTransformDirection) ? m_accumulatedOffset : -m_accumulatedOffset);
if (!m_accumulatedTransform)
- return quad;
+ return;
if (m_direction == ApplyTransformDirection)
- return m_accumulatedTransform->mapQuad(quad);
+ quad = m_accumulatedTransform->mapQuad(quad);
- return m_accumulatedTransform->inverse().projectQuad(quad, wasClamped);
+ quad = m_accumulatedTransform->inverse().projectQuad(quad, wasClamped);
}
void TransformState::flattenWithTransform(const TransformationMatrix& t, bool* wasClamped)
Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformState.h (183273 => 183274)
--- trunk/Source/WebCore/platform/graphics/transforms/TransformState.h 2015-04-24 18:57:25 UTC (rev 183273)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformState.h 2015-04-24 19:01:48 UTC (rev 183274)
@@ -74,30 +74,40 @@
void setQuad(const FloatQuad& quad)
{
- // FIXME: this assumes that the quad being added is in the coordinate system of the current state.
- // This breaks if we're simultaneously mapping a point. https://bugs.webkit.org/show_bug.cgi?id=106680
- ASSERT(!m_mapPoint);
- m_accumulatedOffset = LayoutSize();
+ // We must be in a flattened state (no accumulated offset) when setting this quad.
+ ASSERT(m_accumulatedOffset == LayoutSize());
m_lastPlanarQuad = quad;
}
+ void setSecondaryQuad(const FloatQuad* quad)
+ {
+ // We must be in a flattened state (no accumulated offset) when setting this secondary quad.
+ ASSERT(m_accumulatedOffset == LayoutSize());
+ if (quad)
+ m_lastPlanarSecondaryQuad = std::make_unique<FloatQuad>(*quad);
+ else
+ m_lastPlanarSecondaryQuad = nullptr;
+ }
+
void move(LayoutUnit x, LayoutUnit y, TransformAccumulation accumulate = FlattenTransform)
{
move(LayoutSize(x, y), accumulate);
}
void move(const LayoutSize&, TransformAccumulation = FlattenTransform);
- void applyTransform(const AffineTransform& transformFromContainer, TransformAccumulation = FlattenTransform, bool* wasClamped = 0);
- void applyTransform(const TransformationMatrix& transformFromContainer, TransformAccumulation = FlattenTransform, bool* wasClamped = 0);
- void flatten(bool* wasClamped = 0);
+ void applyTransform(const AffineTransform& transformFromContainer, TransformAccumulation = FlattenTransform, bool* wasClamped = nullptr);
+ void applyTransform(const TransformationMatrix& transformFromContainer, TransformAccumulation = FlattenTransform, bool* wasClamped = nullptr);
+ void flatten(bool* wasClamped = nullptr);
// Return the coords of the point or quad in the last flattened layer
FloatPoint lastPlanarPoint() const { return m_lastPlanarPoint; }
FloatQuad lastPlanarQuad() const { return m_lastPlanarQuad; }
+ FloatQuad* lastPlanarSecondaryQuad() const { return m_lastPlanarSecondaryQuad.get(); }
// Return the point or quad mapped through the current transform
- FloatPoint mappedPoint(bool* wasClamped = 0) const;
- FloatQuad mappedQuad(bool* wasClamped = 0) const;
+ FloatPoint mappedPoint(bool* wasClamped = nullptr) const;
+ FloatQuad mappedQuad(bool* wasClamped = nullptr) const;
+ std::unique_ptr<FloatQuad> mappedSecondaryQuad(bool* wasClamped = nullptr) const;
private:
void translateTransform(const LayoutSize&);
@@ -105,14 +115,18 @@
void flattenWithTransform(const TransformationMatrix&, bool* wasClamped);
void applyAccumulatedOffset();
+ void mapQuad(FloatQuad&, bool* clamped) const;
+
FloatPoint m_lastPlanarPoint;
FloatQuad m_lastPlanarQuad;
+ std::unique_ptr<FloatQuad> m_lastPlanarSecondaryQuad; // Optional second quad to map.
// We only allocate the transform if we need to
std::unique_ptr<TransformationMatrix> m_accumulatedTransform;
LayoutSize m_accumulatedOffset;
bool m_accumulatingTransform;
- bool m_mapPoint, m_mapQuad;
+ bool m_mapPoint;
+ bool m_mapQuad;
TransformDirection m_direction;
};