OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 29 matching lines...) Expand all Loading... |
40 class PLATFORM_EXPORT TransformState { | 40 class PLATFORM_EXPORT TransformState { |
41 STACK_ALLOCATED(); | 41 STACK_ALLOCATED(); |
42 public: | 42 public: |
43 enum TransformDirection { ApplyTransformDirection, UnapplyInverseTransformDi
rection }; | 43 enum TransformDirection { ApplyTransformDirection, UnapplyInverseTransformDi
rection }; |
44 enum TransformAccumulation { FlattenTransform, AccumulateTransform }; | 44 enum TransformAccumulation { FlattenTransform, AccumulateTransform }; |
45 | 45 |
46 TransformState(TransformDirection mappingDirection, const FloatPoint& p, con
st FloatQuad& quad) | 46 TransformState(TransformDirection mappingDirection, const FloatPoint& p, con
st FloatQuad& quad) |
47 : m_lastPlanarPoint(p) | 47 : m_lastPlanarPoint(p) |
48 , m_lastPlanarQuad(quad) | 48 , m_lastPlanarQuad(quad) |
49 , m_accumulatingTransform(false) | 49 , m_accumulatingTransform(false) |
| 50 , m_forceAccumulatingTransform(false) |
50 , m_mapPoint(true) | 51 , m_mapPoint(true) |
51 , m_mapQuad(true) | 52 , m_mapQuad(true) |
52 , m_direction(mappingDirection) | 53 , m_direction(mappingDirection) |
53 { | 54 { |
54 } | 55 } |
55 | 56 |
56 TransformState(TransformDirection mappingDirection, const FloatPoint& p) | 57 TransformState(TransformDirection mappingDirection, const FloatPoint& p) |
57 : m_lastPlanarPoint(p) | 58 : m_lastPlanarPoint(p) |
58 , m_accumulatingTransform(false) | 59 , m_accumulatingTransform(false) |
| 60 , m_forceAccumulatingTransform(false) |
59 , m_mapPoint(true) | 61 , m_mapPoint(true) |
60 , m_mapQuad(false) | 62 , m_mapQuad(false) |
61 , m_direction(mappingDirection) | 63 , m_direction(mappingDirection) |
62 { | 64 { |
63 } | 65 } |
64 | 66 |
65 TransformState(TransformDirection mappingDirection, const FloatQuad& quad) | 67 TransformState(TransformDirection mappingDirection, const FloatQuad& quad) |
66 : m_lastPlanarQuad(quad) | 68 : m_lastPlanarQuad(quad) |
67 , m_accumulatingTransform(false) | 69 , m_accumulatingTransform(false) |
| 70 , m_forceAccumulatingTransform(false) |
68 , m_mapPoint(false) | 71 , m_mapPoint(false) |
69 , m_mapQuad(true) | 72 , m_mapQuad(true) |
70 , m_direction(mappingDirection) | 73 , m_direction(mappingDirection) |
71 { | 74 { |
72 } | 75 } |
73 | 76 |
| 77 // Accumulate a transform but don't map any points directly. |
| 78 TransformState(TransformDirection mappingDirection) |
| 79 : m_accumulatedTransform(TransformationMatrix::create()) |
| 80 , m_accumulatingTransform(true) |
| 81 , m_forceAccumulatingTransform(true) |
| 82 , m_mapPoint(false) |
| 83 , m_mapQuad(false) |
| 84 , m_direction(mappingDirection) |
| 85 { |
| 86 } |
| 87 |
74 TransformState(const TransformState& other) { *this = other; } | 88 TransformState(const TransformState& other) { *this = other; } |
75 | 89 |
76 TransformState& operator=(const TransformState&); | 90 TransformState& operator=(const TransformState&); |
77 | 91 |
78 void setQuad(const FloatQuad& quad) | 92 void setQuad(const FloatQuad& quad) |
79 { | 93 { |
80 // FIXME: this assumes that the quad being added is in the coordinate sy
stem of the current state. | 94 // FIXME: this assumes that the quad being added is in the coordinate sy
stem of the current state. |
81 // This breaks if we're simultaneously mapping a point. https://bugs.web
kit.org/show_bug.cgi?id=106680 | 95 // This breaks if we're simultaneously mapping a point. https://bugs.web
kit.org/show_bug.cgi?id=106680 |
82 ASSERT(!m_mapPoint); | 96 ASSERT(!m_mapPoint); |
83 m_accumulatedOffset = LayoutSize(); | 97 m_accumulatedOffset = LayoutSize(); |
(...skipping 15 matching lines...) Expand all Loading... |
99 void flatten(bool* wasClamped = 0); | 113 void flatten(bool* wasClamped = 0); |
100 | 114 |
101 // Return the coords of the point or quad in the last flattened layer | 115 // Return the coords of the point or quad in the last flattened layer |
102 FloatPoint lastPlanarPoint() const { return m_lastPlanarPoint; } | 116 FloatPoint lastPlanarPoint() const { return m_lastPlanarPoint; } |
103 FloatQuad lastPlanarQuad() const { return m_lastPlanarQuad; } | 117 FloatQuad lastPlanarQuad() const { return m_lastPlanarQuad; } |
104 | 118 |
105 // Return the point or quad mapped through the current transform | 119 // Return the point or quad mapped through the current transform |
106 FloatPoint mappedPoint(bool* wasClamped = 0) const; | 120 FloatPoint mappedPoint(bool* wasClamped = 0) const; |
107 FloatQuad mappedQuad(bool* wasClamped = 0) const; | 121 FloatQuad mappedQuad(bool* wasClamped = 0) const; |
108 | 122 |
| 123 // Return the accumulated transform. |
| 124 const TransformationMatrix& accumulatedTransform() const; |
| 125 |
109 private: | 126 private: |
110 void translateTransform(const LayoutSize&); | 127 void translateTransform(const LayoutSize&); |
111 void translateMappedCoordinates(const LayoutSize&); | 128 void translateMappedCoordinates(const LayoutSize&); |
112 void flattenWithTransform(const TransformationMatrix&, bool* wasClamped); | 129 void flattenWithTransform(const TransformationMatrix&, bool* wasClamped); |
113 void applyAccumulatedOffset(); | 130 void applyAccumulatedOffset(); |
114 | 131 |
115 FloatPoint m_lastPlanarPoint; | 132 FloatPoint m_lastPlanarPoint; |
116 FloatQuad m_lastPlanarQuad; | 133 FloatQuad m_lastPlanarQuad; |
117 | 134 |
118 // We only allocate the transform if we need to | 135 // We only allocate the transform if we need to |
119 OwnPtr<TransformationMatrix> m_accumulatedTransform; | 136 OwnPtr<TransformationMatrix> m_accumulatedTransform; |
120 LayoutSize m_accumulatedOffset; | 137 LayoutSize m_accumulatedOffset; |
121 bool m_accumulatingTransform; | 138 bool m_accumulatingTransform; |
| 139 bool m_forceAccumulatingTransform; |
122 bool m_mapPoint, m_mapQuad; | 140 bool m_mapPoint, m_mapQuad; |
123 TransformDirection m_direction; | 141 TransformDirection m_direction; |
124 }; | 142 }; |
125 | 143 |
126 } // namespace blink | 144 } // namespace blink |
127 | 145 |
128 #endif // TransformState_h | 146 #endif // TransformState_h |
OLD | NEW |