|
Lines 205-212
void drawPatternToCairoContext(cairo_t* cr, cairo_surface_t* image, const IntSiz
a/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp_sec1
|
| 205 |
cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image); |
205 |
cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image); |
| 206 |
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT); |
206 |
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT); |
| 207 |
|
207 |
|
|
|
208 |
// Cairo cannot convert a cairo_matrix to a Pixman's matrix if any of its components is bigger than maximum int size of Pixman. |
| 209 |
// With this condition, Cairo gives up to draw given pattern entirely. To workaround this problem, we reduce the coordinate |
| 210 |
// space by translating CTM and destRect. |
| 211 |
cairo_matrix_t ctm; |
| 212 |
cairo_get_matrix(cr, &ctm); |
| 213 |
double dx = 0, dy = 0; |
| 214 |
cairo_matrix_transform_point(&ctm, &dx, &dy); |
| 215 |
double xScale = 1, yScale = 1; |
| 216 |
cairo_matrix_transform_distance(&ctm, &xScale, &yScale); |
| 217 |
|
| 218 |
dx = std::trunc(-dx / tileRect.width()) * tileRect.width() / xScale; |
| 219 |
dy = std::trunc(-dy / tileRect.height()) * tileRect.height() / yScale; |
| 220 |
cairo_translate(cr, dx, dy); |
| 221 |
|
| 222 |
FloatRect adjustedDestRect(destRect); |
| 223 |
adjustedDestRect.move(-dx, -dy); |
| 224 |
|
| 225 |
// Again, we need to reduce the coordinate of the transformation matrix we are using for the pattern. |
| 208 |
cairo_matrix_t patternMatrix = cairo_matrix_t(patternTransform); |
226 |
cairo_matrix_t patternMatrix = cairo_matrix_t(patternTransform); |
| 209 |
cairo_matrix_t phaseMatrix = {1, 0, 0, 1, phase.x() + tileRect.x() * patternTransform.a(), phase.y() + tileRect.y() * patternTransform.d()}; |
227 |
dx = phase.x() - std::trunc(phase.x() / tileRect.width()) * tileRect.width(); |
|
|
228 |
dy = phase.y() - std::trunc(phase.y() / tileRect.height()) * tileRect.height(); |
| 229 |
cairo_matrix_t phaseMatrix = {1, 0, 0, 1, dx + tileRect.x() * patternTransform.a(), dy + tileRect.y() * patternTransform.d()}; |
| 210 |
cairo_matrix_t combined; |
230 |
cairo_matrix_t combined; |
| 211 |
cairo_matrix_multiply(&combined, &patternMatrix, &phaseMatrix); |
231 |
cairo_matrix_multiply(&combined, &patternMatrix, &phaseMatrix); |
| 212 |
cairo_matrix_invert(&combined); |
232 |
cairo_matrix_invert(&combined); |
|
Lines 215-221
void drawPatternToCairoContext(cairo_t* cr, cairo_surface_t* image, const IntSiz
a/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp_sec2
|
| 215 |
cairo_set_operator(cr, op); |
235 |
cairo_set_operator(cr, op); |
| 216 |
cairo_set_source(cr, pattern); |
236 |
cairo_set_source(cr, pattern); |
| 217 |
cairo_pattern_destroy(pattern); |
237 |
cairo_pattern_destroy(pattern); |
| 218 |
cairo_rectangle(cr, destRect.x(), destRect.y(), destRect.width(), destRect.height()); |
238 |
cairo_rectangle(cr, adjustedDestRect.x(), adjustedDestRect.y(), adjustedDestRect.width(), adjustedDestRect.height()); |
| 219 |
cairo_fill(cr); |
239 |
cairo_fill(cr); |
| 220 |
|
240 |
|
| 221 |
cairo_restore(cr); |
241 |
cairo_restore(cr); |