OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 | 113 |
114 FloatSize intrinsicTileSize = size(); | 114 FloatSize intrinsicTileSize = size(); |
115 if (hasRelativeWidth()) | 115 if (hasRelativeWidth()) |
116 intrinsicTileSize.setWidth(scaledTileSize.width()); | 116 intrinsicTileSize.setWidth(scaledTileSize.width()); |
117 if (hasRelativeHeight()) | 117 if (hasRelativeHeight()) |
118 intrinsicTileSize.setHeight(scaledTileSize.height()); | 118 intrinsicTileSize.setHeight(scaledTileSize.height()); |
119 | 119 |
120 FloatSize scale(scaledTileSize.width() / intrinsicTileSize.width(), | 120 FloatSize scale(scaledTileSize.width() / intrinsicTileSize.width(), |
121 scaledTileSize.height() / intrinsicTileSize.height()); | 121 scaledTileSize.height() / intrinsicTileSize.height()); |
122 TransformationMatrix patternTransform = TransformationMatrix().scale(scale.w
idth(), scale.height()); | 122 TransformationMatrix patternTransform = TransformationMatrix().scaleNonUnifo
rm(scale.width(), scale.height()); |
123 | 123 |
124 FloatRect oneTileRect; | 124 FloatRect oneTileRect; |
125 oneTileRect.setX(destRect.x() + fmodf(fmodf(-srcPoint.x(), scaledTileSize.wi
dth()) - scaledTileSize.width(), scaledTileSize.width())); | 125 oneTileRect.setX(destRect.x() + fmodf(fmodf(-srcPoint.x(), scaledTileSize.wi
dth()) - scaledTileSize.width(), scaledTileSize.width())); |
126 oneTileRect.setY(destRect.y() + fmodf(fmodf(-srcPoint.y(), scaledTileSize.he
ight()) - scaledTileSize.height(), scaledTileSize.height())); | 126 oneTileRect.setY(destRect.y() + fmodf(fmodf(-srcPoint.y(), scaledTileSize.he
ight()) - scaledTileSize.height(), scaledTileSize.height())); |
127 oneTileRect.setSize(scaledTileSize); | 127 oneTileRect.setSize(scaledTileSize); |
128 | 128 |
129 // Check and see if a single draw of the image can cover the entire area we
are supposed to tile. | 129 // Check and see if a single draw of the image can cover the entire area we
are supposed to tile. |
130 if (oneTileRect.contains(destRect)) { | 130 if (oneTileRect.contains(destRect)) { |
131 FloatRect visibleSrcRect; | 131 FloatRect visibleSrcRect; |
132 visibleSrcRect.setX((destRect.x() - oneTileRect.x()) / scale.width()); | 132 visibleSrcRect.setX((destRect.x() - oneTileRect.x()) / scale.width()); |
(...skipping 18 matching lines...) Expand all Loading... |
151 return; | 151 return; |
152 } | 152 } |
153 | 153 |
154 // FIXME: We do not support 'round' yet. For now just map it to 'repeat'. | 154 // FIXME: We do not support 'round' yet. For now just map it to 'repeat'. |
155 if (hRule == RoundTile) | 155 if (hRule == RoundTile) |
156 hRule = RepeatTile; | 156 hRule = RepeatTile; |
157 if (vRule == RoundTile) | 157 if (vRule == RoundTile) |
158 vRule = RepeatTile; | 158 vRule = RepeatTile; |
159 | 159 |
160 FloatSize scale = calculatePatternScale(dstRect, srcRect, hRule, vRule); | 160 FloatSize scale = calculatePatternScale(dstRect, srcRect, hRule, vRule); |
161 TransformationMatrix patternTransform = TransformationMatrix().scale(scale.w
idth(), scale.height()); | 161 TransformationMatrix patternTransform = TransformationMatrix().scaleNonUnifo
rm(scale.width(), scale.height()); |
162 | 162 |
163 // We want to construct the phase such that the pattern is centered (when st
retch is not | 163 // We want to construct the phase such that the pattern is centered (when st
retch is not |
164 // set for a particular rule). | 164 // set for a particular rule). |
165 float hPhase = scale.width() * srcRect.x(); | 165 float hPhase = scale.width() * srcRect.x(); |
166 float vPhase = scale.height() * srcRect.y(); | 166 float vPhase = scale.height() * srcRect.y(); |
167 if (hRule == Image::RepeatTile) | 167 if (hRule == Image::RepeatTile) |
168 hPhase -= fmodf(dstRect.width(), scale.width() * srcRect.width()) / 2.0f
; | 168 hPhase -= fmodf(dstRect.width(), scale.width() * srcRect.width()) / 2.0f
; |
169 if (vRule == Image::RepeatTile) | 169 if (vRule == Image::RepeatTile) |
170 vPhase -= fmodf(dstRect.height(), scale.height() * srcRect.height()) / 2
.0f; | 170 vPhase -= fmodf(dstRect.height(), scale.height() * srcRect.height()) / 2
.0f; |
171 FloatPoint patternPhase(dstRect.x() - hPhase, dstRect.y() - vPhase); | 171 FloatPoint patternPhase(dstRect.x() - hPhase, dstRect.y() - vPhase); |
172 | 172 |
173 drawPattern(ctxt, srcRect, patternTransform, patternPhase, op, dstRect); | 173 drawPattern(ctxt, srcRect, patternTransform, patternPhase, op, dstRect); |
174 | 174 |
175 startAnimation(); | 175 startAnimation(); |
176 } | 176 } |
177 | 177 |
178 | 178 |
179 } | 179 } |
180 | 180 |
OLD | NEW |