<!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>[207140] 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/207140">207140</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2016-10-11 08:57:39 -0700 (Tue, 11 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Win][Direct2D] Add initial Pattern handling implementation
https://bugs.webkit.org/show_bug.cgi?id=163270

Reviewed by Simon Fraser.

Provide an implemenation of Patterns for Direct2D.

No new tests. Covered by fast/borders/border-image-01.html and others.

* platform/graphics/GraphicsContext.h:
* platform/graphics/Pattern.h: Add D2D definitions.
* platform/graphics/win/GraphicsContextDirect2D.cpp:
(WebCore::GraphicsContext::solidStrokeBrush): Use a more generic return type.
(WebCore::GraphicsContext::solidFillBrush): Ditto.
(WebCore::GraphicsContext::patternStrokeBrush): Added.
(WebCore::GraphicsContext::patternFillBrush): Added.
(WebCore::GraphicsContext::drawPattern): Provide D2D implementation.
(WebCore::GraphicsContext::applyStrokePattern): Ditto.
(WebCore::GraphicsContext::applyFillPattern): Ditto.
(WebCore::GraphicsContext::drawPath): Use stroke pattern if available.
(WebCore::GraphicsContext::fillPath): Use fill pattern if available.
(WebCore::GraphicsContext::strokePath): Use stroke pattern if available.
(WebCore::GraphicsContext::fillRect): Use fill pattern if available.
* platform/graphics/win/GraphicsContextPlatformPrivateDirect2D.h:
* platform/graphics/win/PatternDirect2D.cpp: Added.</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="#trunkSourceWebCoreplatformgraphicsPatternh">trunk/Source/WebCore/platform/graphics/Pattern.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinGraphicsContextDirect2Dcpp">trunk/Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinGraphicsContextPlatformPrivateDirect2Dh">trunk/Source/WebCore/platform/graphics/win/GraphicsContextPlatformPrivateDirect2D.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicswinPatternDirect2Dcpp">trunk/Source/WebCore/platform/graphics/win/PatternDirect2D.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (207139 => 207140)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-11 15:53:58 UTC (rev 207139)
+++ trunk/Source/WebCore/ChangeLog        2016-10-11 15:57:39 UTC (rev 207140)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2016-10-10  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        [Win][Direct2D] Add initial Pattern handling implementation
+        https://bugs.webkit.org/show_bug.cgi?id=163270
+
+        Reviewed by Simon Fraser.
+
+        Provide an implemenation of Patterns for Direct2D.
+
+        No new tests. Covered by fast/borders/border-image-01.html and others.
+
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/Pattern.h: Add D2D definitions.
+        * platform/graphics/win/GraphicsContextDirect2D.cpp:
+        (WebCore::GraphicsContext::solidStrokeBrush): Use a more generic return type.
+        (WebCore::GraphicsContext::solidFillBrush): Ditto.
+        (WebCore::GraphicsContext::patternStrokeBrush): Added.
+        (WebCore::GraphicsContext::patternFillBrush): Added.
+        (WebCore::GraphicsContext::drawPattern): Provide D2D implementation.
+        (WebCore::GraphicsContext::applyStrokePattern): Ditto.
+        (WebCore::GraphicsContext::applyFillPattern): Ditto.
+        (WebCore::GraphicsContext::drawPath): Use stroke pattern if available.
+        (WebCore::GraphicsContext::fillPath): Use fill pattern if available.
+        (WebCore::GraphicsContext::strokePath): Use stroke pattern if available.
+        (WebCore::GraphicsContext::fillRect): Use fill pattern if available.
+        * platform/graphics/win/GraphicsContextPlatformPrivateDirect2D.h:
+        * platform/graphics/win/PatternDirect2D.cpp: Added.
+
</ins><span class="cx"> 2016-10-11  Per Arne Vollan  &lt;pvollan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Win] Compile fix.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (207139 => 207140)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2016-10-11 15:53:58 UTC (rev 207139)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2016-10-11 15:57:39 UTC (rev 207140)
</span><span class="lines">@@ -555,8 +555,10 @@
</span><span class="cx">     WEBCORE_EXPORT bool didBeginDraw() const;
</span><span class="cx">     D2D1_COLOR_F colorWithGlobalAlpha(const Color&amp;) const;
</span><span class="cx"> 
</span><del>-    ID2D1SolidColorBrush* solidStrokeBrush();
-    ID2D1SolidColorBrush* solidFillBrush();
</del><ins>+    ID2D1Brush* solidStrokeBrush() const;
+    ID2D1Brush* solidFillBrush() const;
+    ID2D1Brush* patternStrokeBrush() const;
+    ID2D1Brush* patternFillBrush() const;
</ins><span class="cx"> #endif
</span><span class="cx"> #else // PLATFORM(WIN)
</span><span class="cx">     bool shouldIncludeChildWindows() const { return false; }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsPatternh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Pattern.h (207139 => 207140)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Pattern.h        2016-10-11 15:53:58 UTC (rev 207139)
+++ trunk/Source/WebCore/platform/graphics/Pattern.h        2016-10-11 15:57:39 UTC (rev 207140)
</span><span class="lines">@@ -38,7 +38,9 @@
</span><span class="cx"> typedef struct CGPattern* CGPatternRef;
</span><span class="cx"> typedef CGPatternRef PlatformPatternPtr;
</span><span class="cx"> #elif USE(DIRECT2D)
</span><del>-typedef void* PlatformPatternPtr;
</del><ins>+interface ID2D1BitmapBrush;
+interface ID2D1RenderTarget;
+typedef ID2D1BitmapBrush* PlatformPatternPtr;
</ins><span class="cx"> #elif USE(CAIRO)
</span><span class="cx"> #include &lt;cairo.h&gt;
</span><span class="cx"> typedef cairo_pattern_t* PlatformPatternPtr;
</span><span class="lines">@@ -60,8 +62,12 @@
</span><span class="cx"> 
</span><span class="cx">     void platformDestroy();
</span><span class="cx"> 
</span><del>-    // Pattern space is an abstract space that maps to the default user space by the transformation 'userSpaceTransformation' 
</del><ins>+    // Pattern space is an abstract space that maps to the default user space by the transformation 'userSpaceTransformation'
+#if !USE(DIRECT2D)
</ins><span class="cx">     PlatformPatternPtr createPlatformPattern(const AffineTransform&amp; userSpaceTransformation) const;
</span><ins>+#else
+    PlatformPatternPtr createPlatformPattern(ID2D1RenderTarget*, float alpha, const AffineTransform&amp; userSpaceTransformation) const;
+#endif
</ins><span class="cx">     void setPatternSpaceTransform(const AffineTransform&amp; patternSpaceTransformation);
</span><span class="cx">     const AffineTransform&amp; getPatternSpaceTransform() { return m_patternSpaceTransformation; };
</span><span class="cx">     void setPlatformPatternSpaceTransform();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinGraphicsContextDirect2Dcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp (207139 => 207140)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp        2016-10-11 15:53:58 UTC (rev 207139)
+++ trunk/Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp        2016-10-11 15:57:39 UTC (rev 207140)
</span><span class="lines">@@ -415,16 +415,26 @@
</span><span class="cx">     return D2D1::ColorF(color.rgb(), globalAlpha * colorAlpha);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ID2D1SolidColorBrush* GraphicsContext::solidStrokeBrush()
</del><ins>+ID2D1Brush* GraphicsContext::solidStrokeBrush() const
</ins><span class="cx"> {
</span><span class="cx">     return m_data-&gt;m_solidStrokeBrush.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ID2D1SolidColorBrush* GraphicsContext::solidFillBrush()
</del><ins>+ID2D1Brush* GraphicsContext::solidFillBrush() const
</ins><span class="cx"> {
</span><span class="cx">     return m_data-&gt;m_solidFillBrush.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ID2D1Brush* GraphicsContext::patternStrokeBrush() const
+{
+    return m_data-&gt;m_patternStrokeBrush.get();
+}
+
+ID2D1Brush* GraphicsContext::patternFillBrush() const
+{
+    return m_data-&gt;m_patternFillBrush.get();
+}
+
</ins><span class="cx"> void GraphicsContext::drawPattern(Image&amp; image, const FloatRect&amp; destRect, const FloatRect&amp; tileRect, const AffineTransform&amp; patternTransform, const FloatPoint&amp; phase, const FloatSize&amp; spacing, CompositeOperator op, BlendMode blendMode)
</span><span class="cx"> {
</span><span class="cx">     if (paintingDisabled() || !patternTransform.isInvertible())
</span><span class="lines">@@ -435,7 +445,51 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    notImplemented();
</del><ins>+    auto context = platformContext();
+    D2DContextStateSaver stateSaver(*m_data);
+
+    m_data-&gt;clip(destRect);
+
+    setPlatformCompositeOperation(op, blendMode);
+
+    auto bitmapBrushProperties = D2D1::BitmapBrushProperties();
+    bitmapBrushProperties.extendModeX = D2D1_EXTEND_MODE_WRAP;
+    bitmapBrushProperties.extendModeY = D2D1_EXTEND_MODE_WRAP;
+
+    // Create a brush transformation so we paint using the section of the image we care about.
+    AffineTransform transformation = patternTransform;
+    transformation.translate(destRect.location());
+
+    auto brushProperties = D2D1::BrushProperties();
+    brushProperties.transform = transformation;
+    brushProperties.opacity = 1.0f;
+
+    auto tileImage = image.nativeImageForCurrentFrame();
+
+    // If we only want a subset of the bitmap, we need to create a cropped bitmap image. According to the documentation,
+    // this does not allocate new bitmap memory.
+    if (image.width() &gt; destRect.width() || image.height() &gt; destRect.height()) {
+        float dpiX = 0;
+        float dpiY = 0;
+        tileImage-&gt;GetDpi(&amp;dpiX, &amp;dpiY);
+        auto bitmapProperties = D2D1::BitmapProperties(tileImage-&gt;GetPixelFormat(), dpiX, dpiY);
+        COMPtr&lt;ID2D1Bitmap&gt; subImage;
+        HRESULT hr = context-&gt;CreateBitmap(IntSize(tileRect.size()), bitmapProperties, &amp;subImage);
+        if (SUCCEEDED(hr)) {
+            D2D1_RECT_U finishRect = IntRect(tileRect);
+            hr = subImage-&gt;CopyFromBitmap(nullptr, tileImage.get(), &amp;finishRect);
+            if (SUCCEEDED(hr))
+                tileImage = subImage;
+        }
+    }
+
+    COMPtr&lt;ID2D1BitmapBrush&gt; patternBrush;
+    HRESULT hr = context-&gt;CreateBitmapBrush(tileImage.get(), &amp;bitmapBrushProperties, &amp;brushProperties, &amp;patternBrush);
+
+    drawWithoutShadow(destRect, [this, destRect, patternBrush](ID2D1RenderTarget* renderTarget) {
+        const D2D1_RECT_F d2dRect = destRect;
+        renderTarget-&gt;FillRectangle(&amp;d2dRect, patternBrush.get());
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::clipToImageBuffer(ImageBuffer&amp; buffer, const FloatRect&amp; destRect)
</span><span class="lines">@@ -700,8 +754,11 @@
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    // Note: Because of the way Direct2D draws, we may not need this explicit context 'set stroke pattern' logic.
-    notImplemented();
</del><ins>+    auto context = platformContext();
+    AffineTransform userToBaseCTM; // FIXME: This isn't really needed on Windows
+
+    const float patternAlpha = 1;
+    m_data-&gt;m_patternStrokeBrush = adoptCOM(m_state.strokePattern-&gt;createPlatformPattern(context, patternAlpha, userToBaseCTM));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::applyFillPattern()
</span><span class="lines">@@ -709,8 +766,11 @@
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    // Note: Because of the way Direct2D draws, we may not need this explicit context 'set fill pattern' logic.
-    notImplemented();
</del><ins>+    auto context = platformContext();
+    AffineTransform userToBaseCTM; // FIXME: This isn't really needed on Windows
+
+    const float patternAlpha = 1;
+    m_data-&gt;m_patternFillBrush = adoptCOM(m_state.fillPattern-&gt;createPlatformPattern(context, patternAlpha, userToBaseCTM));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::drawPath(const Path&amp; path)
</span><span class="lines">@@ -747,7 +807,8 @@
</span><span class="cx"> 
</span><span class="cx">     auto rect = path.fastBoundingRect();
</span><span class="cx">     drawWithoutShadow(rect, [this, &amp;path](ID2D1RenderTarget* renderTarget) {
</span><del>-        renderTarget-&gt;DrawGeometry(path.platformPath(), solidStrokeBrush(), strokeThickness(), m_data-&gt;strokeStyle());
</del><ins>+        auto brush = m_state.strokePattern ? patternStrokeBrush() : solidStrokeBrush();
+        renderTarget-&gt;DrawGeometry(path.platformPath(), brush, strokeThickness(), m_data-&gt;strokeStyle());
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -870,7 +931,8 @@
</span><span class="cx"> 
</span><span class="cx">     FloatRect contextRect(FloatPoint(), context-&gt;GetSize());
</span><span class="cx">     drawWithoutShadow(contextRect, [this, &amp;pathToFill](ID2D1RenderTarget* renderTarget) {
</span><del>-        renderTarget-&gt;FillGeometry(pathToFill.get(), solidFillBrush());
</del><ins>+        auto brush = m_state.fillPattern ? patternFillBrush() : solidFillBrush();
+        renderTarget-&gt;FillGeometry(pathToFill.get(), brush);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -912,7 +974,8 @@
</span><span class="cx"> 
</span><span class="cx">     FloatRect contextRect(FloatPoint(), context-&gt;GetSize());
</span><span class="cx">     drawWithoutShadow(contextRect, [this, &amp;path](ID2D1RenderTarget* renderTarget) {
</span><del>-        renderTarget-&gt;DrawGeometry(path.platformPath(), solidStrokeBrush(), strokeThickness(), m_data-&gt;strokeStyle());
</del><ins>+        auto brush = m_state.strokePattern ? patternStrokeBrush() : solidStrokeBrush();
+        renderTarget-&gt;DrawGeometry(path.platformPath(), brush, strokeThickness(), m_data-&gt;strokeStyle());
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -958,7 +1021,8 @@
</span><span class="cx"> 
</span><span class="cx">     drawWithoutShadow(rect, [this, rect](ID2D1RenderTarget* renderTarget) {
</span><span class="cx">         const D2D1_RECT_F d2dRect = rect;
</span><del>-        renderTarget-&gt;FillRectangle(&amp;d2dRect, solidFillBrush());
</del><ins>+        auto brush = m_state.fillPattern ? patternFillBrush() : solidFillBrush();
+        renderTarget-&gt;FillRectangle(&amp;d2dRect, brush);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinGraphicsContextPlatformPrivateDirect2Dh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/GraphicsContextPlatformPrivateDirect2D.h (207139 => 207140)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/GraphicsContextPlatformPrivateDirect2D.h        2016-10-11 15:53:58 UTC (rev 207139)
+++ trunk/Source/WebCore/platform/graphics/win/GraphicsContextPlatformPrivateDirect2D.h        2016-10-11 15:57:39 UTC (rev 207140)
</span><span class="lines">@@ -84,6 +84,8 @@
</span><span class="cx"> 
</span><span class="cx">     COMPtr&lt;ID2D1SolidColorBrush&gt; m_solidStrokeBrush;
</span><span class="cx">     COMPtr&lt;ID2D1SolidColorBrush&gt; m_solidFillBrush;
</span><ins>+    COMPtr&lt;ID2D1BitmapBrush&gt; m_patternStrokeBrush;
+    COMPtr&lt;ID2D1BitmapBrush&gt; m_patternFillBrush;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void recomputeStrokeStyle();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinPatternDirect2Dcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/win/PatternDirect2D.cpp (0 => 207140)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/PatternDirect2D.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/win/PatternDirect2D.cpp        2016-10-11 15:57:39 UTC (rev 207140)
</span><span class="lines">@@ -0,0 +1,63 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;config.h&quot;
+#include &quot;Pattern.h&quot;
+
+#if USE(DIRECT2D)
+
+#include &quot;AffineTransform.h&quot;
+#include &quot;GraphicsContext.h&quot;
+#include &lt;CoreGraphics/CoreGraphics.h&gt;
+#include &lt;d2d1.h&gt;
+#include &lt;wtf/MainThread.h&gt;
+
+
+namespace WebCore {
+
+ID2D1BitmapBrush* Pattern::createPlatformPattern(ID2D1RenderTarget* renderTarget, float alpha, const AffineTransform&amp; userSpaceTransformation) const
+{
+    RELEASE_ASSERT(renderTarget);
+
+    FloatRect tileRect = tileImage()-&gt;rect();
+
+    AffineTransform patternTransform = userSpaceTransformation * m_patternSpaceTransformation;
+    auto bitmapBrushProperties = D2D1::BitmapBrushProperties();
+    bitmapBrushProperties.extendModeX = m_repeatX ? D2D1_EXTEND_MODE_WRAP : D2D1_EXTEND_MODE_CLAMP;
+    bitmapBrushProperties.extendModeY = m_repeatY ? D2D1_EXTEND_MODE_WRAP : D2D1_EXTEND_MODE_CLAMP;
+
+    auto brushProperties = D2D1::BrushProperties();
+    brushProperties.transform = patternTransform;
+    brushProperties.opacity = alpha;
+
+    ID2D1BitmapBrush* patternBrush = nullptr;
+    HRESULT hr = renderTarget-&gt;CreateBitmapBrush(tileImage()-&gt;nativeImage().get(), &amp;bitmapBrushProperties, &amp;brushProperties, &amp;patternBrush);
+    ASSERT(hr);
+    return patternBrush;
+}
+
+}
+
+#endif
</ins></span></pre>
</div>
</div>

</body>
</html>