<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[191000] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/191000">191000</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2015-10-13 12:03:37 -0700 (Tue, 13 Oct 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move Image::drawPattern for CG into GraphicsContext
https://bugs.webkit.org/show_bug.cgi?id=150077

Reviewed by Myles C. Maxfield.

In order to consolidate code that calls into Core Graphics inside
GraphicsContext, move the body of Image::drawPattern() into
GraphicsContextCG.cpp, and do the same for Cairo.

* platform/graphics/GraphicsContext.h:
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::drawPattern):
* platform/graphics/cairo/ImageCairo.cpp:
(WebCore::Image::drawPattern):
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::drawPatternCallback):
(WebCore::patternReleaseCallback):
(WebCore::GraphicsContext::drawPattern):
* platform/graphics/cg/ImageCG.cpp:
(WebCore::Image::drawPattern):
(WebCore::drawPatternCallback): Deleted.
(WebCore::patternReleaseCallback): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContexth">trunk/Source/WebCore/platform/graphics/GraphicsContext.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoGraphicsContextCairocpp">trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoImageCairocpp">trunk/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgGraphicsContextCGcpp">trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgImageCGcpp">trunk/Source/WebCore/platform/graphics/cg/ImageCG.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (190999 => 191000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-10-13 18:49:58 UTC (rev 190999)
+++ trunk/Source/WebCore/ChangeLog        2015-10-13 19:03:37 UTC (rev 191000)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2015-10-13  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Move Image::drawPattern for CG into GraphicsContext
+        https://bugs.webkit.org/show_bug.cgi?id=150077
+
+        Reviewed by Myles C. Maxfield.
+
+        In order to consolidate code that calls into Core Graphics inside
+        GraphicsContext, move the body of Image::drawPattern() into
+        GraphicsContextCG.cpp, and do the same for Cairo.
+
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::drawPattern):
+        * platform/graphics/cairo/ImageCairo.cpp:
+        (WebCore::Image::drawPattern):
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::drawPatternCallback):
+        (WebCore::patternReleaseCallback):
+        (WebCore::GraphicsContext::drawPattern):
+        * platform/graphics/cg/ImageCG.cpp:
+        (WebCore::Image::drawPattern):
+        (WebCore::drawPatternCallback): Deleted.
+        (WebCore::patternReleaseCallback): Deleted.
+
</ins><span class="cx"> 2015-10-13  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unprefix font-kerning
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (190999 => 191000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2015-10-13 18:49:58 UTC (rev 190999)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2015-10-13 19:03:37 UTC (rev 191000)
</span><span class="lines">@@ -320,6 +320,8 @@
</span><span class="cx">         void drawImageBuffer(ImageBuffer*, ColorSpace, const FloatRect&amp; destination, const ImagePaintingOptions&amp; = ImagePaintingOptions());
</span><span class="cx">         void drawImageBuffer(ImageBuffer*, ColorSpace, const FloatRect&amp; destination, const FloatRect&amp; source, const ImagePaintingOptions&amp; = ImagePaintingOptions());
</span><span class="cx"> 
</span><ins>+        void drawPattern(Image&amp;, const FloatRect&amp; srcRect, const AffineTransform&amp;, const FloatPoint&amp; phase, const FloatSize&amp; spacing, ColorSpace, CompositeOperator, const FloatRect&amp; destRect, BlendMode = BlendModeNormal);
+
</ins><span class="cx">         WEBCORE_EXPORT void setImageInterpolationQuality(InterpolationQuality);
</span><span class="cx">         InterpolationQuality imageInterpolationQuality() const;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoGraphicsContextCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (190999 => 191000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp        2015-10-13 18:49:58 UTC (rev 190999)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp        2015-10-13 19:03:37 UTC (rev 191000)
</span><span class="lines">@@ -1077,6 +1077,16 @@
</span><span class="cx">     cairo_restore(cr);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void GraphicsContext::drawPattern(Image&amp; image, const FloatRect&amp; tileRect, const AffineTransform&amp; patternTransform, const FloatPoint&amp; phase, const FloatSize&amp;, ColorSpace, CompositeOperator op, const FloatRect&amp; destRect, BlendMode)
+{
+    RefPtr&lt;cairo_surface_t&gt; surface = image.nativeImageForCurrentFrame();
+    if (!surface) // If it's too early we won't have an image yet.
+        return;
+
+    cairo_t* cr = platformContext()-&gt;cr();
+    drawPatternToCairoContext(cr, surface.get(), IntSize(image.size()), tileRect, patternTransform, phase, toCairoOperator(op), destRect);
+}
+
</ins><span class="cx"> void GraphicsContext::setPlatformShouldAntialias(bool enable)
</span><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoImageCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp (190999 => 191000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp        2015-10-13 18:49:58 UTC (rev 190999)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp        2015-10-13 19:03:37 UTC (rev 191000)
</span><span class="lines">@@ -42,15 +42,10 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> void Image::drawPattern(GraphicsContext&amp; context, const FloatRect&amp; tileRect, const AffineTransform&amp; patternTransform,
</span><del>-    const FloatPoint&amp; phase, const FloatSize&amp;, ColorSpace, CompositeOperator op, const FloatRect&amp; destRect, BlendMode)
</del><ins>+    const FloatPoint&amp; phase, const FloatSize&amp; spacing, ColorSpace colorSpace, CompositeOperator op, const FloatRect&amp; destRect, BlendMode blendMode)
</ins><span class="cx"> {
</span><del>-    RefPtr&lt;cairo_surface_t&gt; surface = nativeImageForCurrentFrame();
-    if (!surface) // If it's too early we won't have an image yet.
-        return;
</del><ins>+    context.drawPattern(*this, tileRect, patternTransform, phase, spacing, colorSpace, op, destRect, blendMode);
</ins><span class="cx"> 
</span><del>-    cairo_t* cr = context.platformContext()-&gt;cr();
-    drawPatternToCairoContext(cr, surface.get(), IntSize(size()), tileRect, patternTransform, phase, toCairoOperator(op), destRect);
-
</del><span class="cx">     if (imageObserver())
</span><span class="cx">         imageObserver()-&gt;didDraw(this);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgGraphicsContextCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (190999 => 191000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp        2015-10-13 18:49:58 UTC (rev 190999)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp        2015-10-13 19:03:37 UTC (rev 191000)
</span><span class="lines">@@ -243,6 +243,108 @@
</span><span class="cx">     CGContextDrawImage(context, adjustedDestRect, image.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void drawPatternCallback(void* info, CGContextRef context)
+{
+    CGImageRef image = (CGImageRef)info;
+    CGFloat height = CGImageGetHeight(image);
+#if PLATFORM(IOS)
+    CGContextScaleCTM(context, 1, -1);
+    CGContextTranslateCTM(context, 0, -height);
+#endif
+    CGContextDrawImage(context, GraphicsContext(context).roundToDevicePixels(FloatRect(0, 0, CGImageGetWidth(image), height)), image);
+}
+
+static void patternReleaseCallback(void* info)
+{
+    auto image = static_cast&lt;CGImageRef&gt;(info);
+    callOnMainThread([image] {
+        CGImageRelease(image);
+    });
+}
+
+void GraphicsContext::drawPattern(Image&amp; image, const FloatRect&amp; tileRect, const AffineTransform&amp; patternTransform, const FloatPoint&amp; phase, const FloatSize&amp; spacing, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect&amp; destRect, BlendMode blendMode)
+{
+    if (!patternTransform.isInvertible())
+        return;
+
+    CGContextRef context = platformContext();
+    CGContextStateSaver stateSaver(context);
+    CGContextClipToRect(context, destRect);
+
+    setPlatformCompositeOperation(op, blendMode);
+
+    CGContextTranslateCTM(context, destRect.x(), destRect.y() + destRect.height());
+    CGContextScaleCTM(context, 1, -1);
+    
+    // Compute the scaled tile size.
+    float scaledTileHeight = tileRect.height() * narrowPrecisionToFloat(patternTransform.d());
+    
+    // We have to adjust the phase to deal with the fact we're in Cartesian space now (with the bottom left corner of destRect being
+    // the origin).
+    float adjustedX = phase.x() - destRect.x() + tileRect.x() * narrowPrecisionToFloat(patternTransform.a()); // We translated the context so that destRect.x() is the origin, so subtract it out.
+    float adjustedY = destRect.height() - (phase.y() - destRect.y() + tileRect.y() * narrowPrecisionToFloat(patternTransform.d()) + scaledTileHeight);
+
+    CGImageRef tileImage = image.nativeImageForCurrentFrame();
+    float h = CGImageGetHeight(tileImage);
+
+    RetainPtr&lt;CGImageRef&gt; subImage;
+#if PLATFORM(IOS)
+    FloatSize imageSize = image.originalSize();
+#else
+    FloatSize imageSize = image.size();
+#endif
+    if (tileRect.size() == imageSize)
+        subImage = tileImage;
+    else {
+        // Copying a sub-image out of a partially-decoded image stops the decoding of the original image. It should never happen
+        // because sub-images are only used for border-image, which only renders when the image is fully decoded.
+        ASSERT(h == image.height());
+        subImage = adoptCF(CGImageCreateWithImageInRect(tileImage, tileRect));
+    }
+
+    // Adjust the color space.
+    subImage = Image::imageWithColorSpace(subImage.get(), styleColorSpace);
+
+    // If we need to paint gaps between tiles because we have a partially loaded image or non-zero spacing,
+    // fall back to the less efficient CGPattern-based mechanism.
+    float scaledTileWidth = tileRect.width() * narrowPrecisionToFloat(patternTransform.a());
+    float w = CGImageGetWidth(tileImage);
+    if (w == image.size().width() &amp;&amp; h == image.size().height() &amp;&amp; !spacing.width() &amp;&amp; !spacing.height())
+        CGContextDrawTiledImage(context, FloatRect(adjustedX, adjustedY, scaledTileWidth, scaledTileHeight), subImage.get());
+    else {
+        static const CGPatternCallbacks patternCallbacks = { 0, drawPatternCallback, patternReleaseCallback };
+        CGAffineTransform matrix = CGAffineTransformMake(narrowPrecisionToCGFloat(patternTransform.a()), 0, 0, narrowPrecisionToCGFloat(patternTransform.d()), adjustedX, adjustedY);
+        matrix = CGAffineTransformConcat(matrix, CGContextGetCTM(context));
+        // The top of a partially-decoded image is drawn at the bottom of the tile. Map it to the top.
+        matrix = CGAffineTransformTranslate(matrix, 0, image.size().height() - h);
+#if PLATFORM(IOS)
+        matrix = CGAffineTransformScale(matrix, 1, -1);
+        matrix = CGAffineTransformTranslate(matrix, 0, -h);
+#endif
+        CGImageRef platformImage = CGImageRetain(subImage.get());
+        RetainPtr&lt;CGPatternRef&gt; pattern = adoptCF(CGPatternCreate(platformImage, CGRectMake(0, 0, tileRect.width(), tileRect.height()), matrix,
+            tileRect.width() + spacing.width() * (1 / narrowPrecisionToFloat(patternTransform.a())),
+            tileRect.height() + spacing.height() * (1 / narrowPrecisionToFloat(patternTransform.d())),
+            kCGPatternTilingConstantSpacing, true, &amp;patternCallbacks));
+        
+        if (!pattern)
+            return;
+
+        RetainPtr&lt;CGColorSpaceRef&gt; patternSpace = adoptCF(CGColorSpaceCreatePattern(0));
+
+        CGFloat alpha = 1;
+        RetainPtr&lt;CGColorRef&gt; color = adoptCF(CGColorCreateWithPattern(patternSpace.get(), pattern.get(), &amp;alpha));
+        CGContextSetFillColorSpace(context, patternSpace.get());
+
+        // FIXME: Really want a public API for this. It is just CGContextSetBaseCTM(context, CGAffineTransformIdentiy).
+        wkSetBaseCTM(context, CGAffineTransformIdentity);
+        CGContextSetPatternPhase(context, CGSizeZero);
+
+        CGContextSetFillColorWithColor(context, color.get());
+        CGContextFillRect(context, CGContextGetClipBoundingBox(context));
+    }
+}
+
</ins><span class="cx"> // Draws a filled rectangle with a stroked border.
</span><span class="cx"> void GraphicsContext::drawRect(const FloatRect&amp; rect, float borderThickness)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgImageCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/ImageCG.cpp (190999 => 191000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/ImageCG.cpp        2015-10-13 18:49:58 UTC (rev 190999)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageCG.cpp        2015-10-13 19:03:37 UTC (rev 191000)
</span><span class="lines">@@ -67,111 +67,14 @@
</span><span class="cx">     return originalImage;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void drawPatternCallback(void* info, CGContextRef context)
-{
-    CGImageRef image = (CGImageRef)info;
-    CGFloat height = CGImageGetHeight(image);
-#if PLATFORM(IOS)
-    CGContextScaleCTM(context, 1, -1);
-    CGContextTranslateCTM(context, 0, -height);
-#endif
-    CGContextDrawImage(context, GraphicsContext(context).roundToDevicePixels(FloatRect(0, 0, CGImageGetWidth(image), height)), image);
-}
-
-static void patternReleaseCallback(void* info)
-{
-    auto image = static_cast&lt;CGImageRef&gt;(info);
-    callOnMainThread([image] {
-        CGImageRelease(image);
-    });
-}
-
</del><span class="cx"> void Image::drawPattern(GraphicsContext&amp; ctxt, const FloatRect&amp; tileRect, const AffineTransform&amp; patternTransform,
</span><span class="cx">     const FloatPoint&amp; phase, const FloatSize&amp; spacing, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect&amp; destRect, BlendMode blendMode)
</span><span class="cx"> {
</span><span class="cx">     if (!nativeImageForCurrentFrame())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (!patternTransform.isInvertible())
-        return;
</del><ins>+    ctxt.drawPattern(*this, tileRect, patternTransform, phase, spacing, styleColorSpace, op, destRect, blendMode);
</ins><span class="cx"> 
</span><del>-    CGContextRef context = ctxt.platformContext();
-    GraphicsContextStateSaver stateSaver(ctxt);
-    CGContextClipToRect(context, destRect);
-    ctxt.setCompositeOperation(op, blendMode);
-    CGContextTranslateCTM(context, destRect.x(), destRect.y() + destRect.height());
-    CGContextScaleCTM(context, 1, -1);
-    
-    // Compute the scaled tile size.
-    float scaledTileHeight = tileRect.height() * narrowPrecisionToFloat(patternTransform.d());
-    
-    // We have to adjust the phase to deal with the fact we're in Cartesian space now (with the bottom left corner of destRect being
-    // the origin).
-    float adjustedX = phase.x() - destRect.x() + tileRect.x() * narrowPrecisionToFloat(patternTransform.a()); // We translated the context so that destRect.x() is the origin, so subtract it out.
-    float adjustedY = destRect.height() - (phase.y() - destRect.y() + tileRect.y() * narrowPrecisionToFloat(patternTransform.d()) + scaledTileHeight);
-
-    CGImageRef tileImage = nativeImageForCurrentFrame();
-    float h = CGImageGetHeight(tileImage);
-
-    RetainPtr&lt;CGImageRef&gt; subImage;
-#if PLATFORM(IOS)
-    FloatSize imageSize = originalSize();
-#else
-    FloatSize imageSize = size();
-#endif
-    if (tileRect.size() == imageSize)
-        subImage = tileImage;
-    else {
-        // Copying a sub-image out of a partially-decoded image stops the decoding of the original image. It should never happen
-        // because sub-images are only used for border-image, which only renders when the image is fully decoded.
-        ASSERT(h == height());
-        subImage = adoptCF(CGImageCreateWithImageInRect(tileImage, tileRect));
-    }
-
-    // Adjust the color space.
-    subImage = Image::imageWithColorSpace(subImage.get(), styleColorSpace);
-
-    // If we need to paint gaps between tiles because we have a partially loaded image or non-zero spacing,
-    // fall back to the less efficient CGPattern-based mechanism.
-    float scaledTileWidth = tileRect.width() * narrowPrecisionToFloat(patternTransform.a());
-    float w = CGImageGetWidth(tileImage);
-    if (w == size().width() &amp;&amp; h == size().height() &amp;&amp; !spacing.width() &amp;&amp; !spacing.height())
-        CGContextDrawTiledImage(context, FloatRect(adjustedX, adjustedY, scaledTileWidth, scaledTileHeight), subImage.get());
-    else {
-        static const CGPatternCallbacks patternCallbacks = { 0, drawPatternCallback, patternReleaseCallback };
-        CGAffineTransform matrix = CGAffineTransformMake(narrowPrecisionToCGFloat(patternTransform.a()), 0, 0, narrowPrecisionToCGFloat(patternTransform.d()), adjustedX, adjustedY);
-        matrix = CGAffineTransformConcat(matrix, CGContextGetCTM(context));
-        // The top of a partially-decoded image is drawn at the bottom of the tile. Map it to the top.
-        matrix = CGAffineTransformTranslate(matrix, 0, size().height() - h);
-#if PLATFORM(IOS)
-        matrix = CGAffineTransformScale(matrix, 1, -1);
-        matrix = CGAffineTransformTranslate(matrix, 0, -h);
-#endif
-        CGImageRef platformImage = CGImageRetain(subImage.get());
-        RetainPtr&lt;CGPatternRef&gt; pattern = adoptCF(CGPatternCreate(platformImage, CGRectMake(0, 0, tileRect.width(), tileRect.height()), matrix,
-            tileRect.width() + spacing.width() * (1 / narrowPrecisionToFloat(patternTransform.a())),
-            tileRect.height() + spacing.height() * (1 / narrowPrecisionToFloat(patternTransform.d())),
-            kCGPatternTilingConstantSpacing, true, &amp;patternCallbacks));
-        
-        if (!pattern)
-            return;
-
-        RetainPtr&lt;CGColorSpaceRef&gt; patternSpace = adoptCF(CGColorSpaceCreatePattern(0));
-
-        CGFloat alpha = 1;
-        RetainPtr&lt;CGColorRef&gt; color = adoptCF(CGColorCreateWithPattern(patternSpace.get(), pattern.get(), &amp;alpha));
-        CGContextSetFillColorSpace(context, patternSpace.get());
-
-        // FIXME: Really want a public API for this. It is just CGContextSetBaseCTM(context, CGAffineTransformIdentiy).
-        wkSetBaseCTM(context, CGAffineTransformIdentity);
-        CGContextSetPatternPhase(context, CGSizeZero);
-
-        CGContextSetFillColorWithColor(context, color.get());
-        CGContextFillRect(context, CGContextGetClipBoundingBox(context));
-    }
-
-    stateSaver.restore();
-
</del><span class="cx">     if (imageObserver())
</span><span class="cx">         imageObserver()-&gt;didDraw(this);
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>