void CanvasRenderingContext2D::applyFillPattern() { GraphicsContext* c = drawingContext(); if (!c) return; #if PLATFORM(CG) // Check for case where the pattern is already set. CGAffineTransform m = CGContextGetCTM(c->platformContext()); if (state().m_appliedFillPattern && CGAffineTransformEqualToTransform(m, state().m_fillStylePatternTransform)) return; CanvasPattern* pattern = state().m_fillStyle->pattern(); if (!pattern) return; CGPatternRef platformPattern = pattern->createPattern(m); if (!platformPattern) return; CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(0); CGContextSetFillColorSpace(c->platformContext(), patternSpace); CGColorSpaceRelease(patternSpace); const CGFloat patternAlpha = 1; CGContextSetFillPattern(c->platformContext(), platformPattern, &patternAlpha); CGPatternRelease(platformPattern); state().m_fillStylePatternTransform = m; #elif PLATFORM(QT) fprintf(stderr, "FIXME: CanvasRenderingContext2D::applyFillPattern\n"); #endif state().m_appliedFillPattern = true; }
void CanvasRenderingContext2D::applyFillPattern() { GraphicsContext* c = drawingContext(); if (!c) return; #if PLATFORM(CG) // Check for case where the pattern is already set. CGAffineTransform m = CGContextGetCTM(c->platformContext()); if (state().m_appliedFillPattern && CGAffineTransformEqualToTransform(m, state().m_fillStylePatternTransform)) return; CanvasPattern* pattern = state().m_fillStyle->pattern(); if (!pattern) return; CGPatternRef platformPattern = pattern->createPattern(m); if (!platformPattern) return; CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(0); CGContextSetFillColorSpace(c->platformContext(), patternSpace); CGColorSpaceRelease(patternSpace); const CGFloat patternAlpha = 1; CGContextSetFillPattern(c->platformContext(), platformPattern, &patternAlpha); CGPatternRelease(platformPattern); state().m_fillStylePatternTransform = m; #elif PLATFORM(QT) notImplemented(); #elif PLATFORM(CAIRO) && !PLATFORM(BAL) CanvasPattern* pattern = state().m_fillStyle->pattern(); if (!pattern) return; cairo_t* cr = c->platformContext(); cairo_matrix_t m; cairo_get_matrix(cr, &m); cairo_pattern_t* platformPattern = pattern->createPattern(m); if (!platformPattern) return; cairo_set_source(cr, platformPattern); cairo_pattern_destroy(platformPattern); #elif PLATFORM(BAL) notImplemented(); #endif state().m_appliedFillPattern = true; }