<!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>[206742] 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/206742">206742</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2016-10-03 13:22:57 -0700 (Mon, 03 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Win][Direct2D] Add D2D Bitmap Image handling code
https://bugs.webkit.org/show_bug.cgi?id=162761

Reviewed by Dean Jackson.

This patch lands a set of new files that implement
Image and BitmapImage features on Windows using
Direct2D.

The desired ID2D1RenderTarget handle is needed by the
image decoder so that it can load the resulting bitmap
into the GPU.

No new tests until complete backend lands.

* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::draw): Tell the Direct2D image decoder
which render target to use.
* platform/graphics/BitmapImage.h:
* platform/graphics/ImageBuffer.cpp:
* platform/graphics/ImageBuffer.h:
* platform/graphics/ImageBufferData.h:
* platform/graphics/ImageFrameCache.cpp:
(WebCore::ImageFrameCache::setRenderTarget): Added.
* platform/graphics/ImageFrameCache.h:
(WebCore::ImageFrameCache::decoder): Added.
* platform/graphics/ImageSource.cpp:
* platform/graphics/ImageSource.h:
(WebCore::ImageSource::setRenderTarget):
* platform/graphics/win/ImageBufferDataDirect2D.cpp: Added.
* platform/graphics/win/ImageBufferDataDirect2D.h: Added.
* platform/graphics/win/ImageBufferDirect2D.cpp: Added.
* platform/graphics/win/ImageCGWin.cpp:
* platform/graphics/win/ImageDecoderDirect2D.cpp: Added.
* platform/graphics/win/ImageDecoderDirect2D.h: Added.
* platform/graphics/win/ImageDirect2D.cpp: Added.
* platform/graphics/win/NativeImageDirect2D.cpp: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsBitmapImagecpp">trunk/Source/WebCore/platform/graphics/BitmapImage.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsBitmapImageh">trunk/Source/WebCore/platform/graphics/BitmapImage.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageBuffercpp">trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageBufferh">trunk/Source/WebCore/platform/graphics/ImageBuffer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageBufferDatah">trunk/Source/WebCore/platform/graphics/ImageBufferData.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageFrameCachecpp">trunk/Source/WebCore/platform/graphics/ImageFrameCache.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageFrameCacheh">trunk/Source/WebCore/platform/graphics/ImageFrameCache.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageSourcecpp">trunk/Source/WebCore/platform/graphics/ImageSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageSourceh">trunk/Source/WebCore/platform/graphics/ImageSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsNativeImageh">trunk/Source/WebCore/platform/graphics/NativeImage.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinImageCGWincpp">trunk/Source/WebCore/platform/graphics/win/ImageCGWin.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicswinImageBufferDataDirect2Dcpp">trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinImageBufferDataDirect2Dh">trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinImageBufferDirect2Dcpp">trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinImageDecoderDirect2Dcpp">trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinImageDecoderDirect2Dh">trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinImageDirect2Dcpp">trunk/Source/WebCore/platform/graphics/win/ImageDirect2D.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinNativeImageDirect2Dcpp">trunk/Source/WebCore/platform/graphics/win/NativeImageDirect2D.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206741 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-03 19:26:03 UTC (rev 206741)
+++ trunk/Source/WebCore/ChangeLog        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2016-10-03  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        [Win][Direct2D] Add D2D Bitmap Image handling code
+        https://bugs.webkit.org/show_bug.cgi?id=162761
+
+        Reviewed by Dean Jackson.
+
+        This patch lands a set of new files that implement
+        Image and BitmapImage features on Windows using
+        Direct2D.
+
+        The desired ID2D1RenderTarget handle is needed by the
+        image decoder so that it can load the resulting bitmap
+        into the GPU.
+
+        No new tests until complete backend lands.
+
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::draw): Tell the Direct2D image decoder
+        which render target to use.
+        * platform/graphics/BitmapImage.h:
+        * platform/graphics/ImageBuffer.cpp:
+        * platform/graphics/ImageBuffer.h:
+        * platform/graphics/ImageBufferData.h:
+        * platform/graphics/ImageFrameCache.cpp:
+        (WebCore::ImageFrameCache::setRenderTarget): Added.
+        * platform/graphics/ImageFrameCache.h:
+        (WebCore::ImageFrameCache::decoder): Added.
+        * platform/graphics/ImageSource.cpp:
+        * platform/graphics/ImageSource.h:
+        (WebCore::ImageSource::setRenderTarget):
+        * platform/graphics/win/ImageBufferDataDirect2D.cpp: Added.
+        * platform/graphics/win/ImageBufferDataDirect2D.h: Added.
+        * platform/graphics/win/ImageBufferDirect2D.cpp: Added.
+        * platform/graphics/win/ImageCGWin.cpp:
+        * platform/graphics/win/ImageDecoderDirect2D.cpp: Added.
+        * platform/graphics/win/ImageDecoderDirect2D.h: Added.
+        * platform/graphics/win/ImageDirect2D.cpp: Added.
+        * platform/graphics/win/NativeImageDirect2D.cpp: Added.
+
</ins><span class="cx"> 2016-10-03  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [SOUP] Remove unused methods toSoupMessage from ResourceRequest/Response
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsBitmapImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (206741 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp        2016-10-03 19:26:03 UTC (rev 206741)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -141,6 +141,10 @@
</span><span class="cx">     if (destRect.isEmpty() || srcRect.isEmpty())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+#if USE(DIRECT2D)
+    setRenderTarget(context);
+#endif
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     startAnimation(DoNotCatchUp);
</span><span class="cx"> #else
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsBitmapImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.h (206741 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/BitmapImage.h        2016-10-03 19:26:03 UTC (rev 206741)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.h        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -122,6 +122,9 @@
</span><span class="cx">     NativeImagePtr nativeImageOfSize(const IntSize&amp;) override;
</span><span class="cx">     Vector&lt;NativeImagePtr&gt; framesNativeImages() override;
</span><span class="cx"> #endif
</span><ins>+#if USE(DIRECT2D)
+    void setRenderTarget(GraphicsContext&amp;);
+#endif
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     WEBCORE_EXPORT BitmapImage(NativeImagePtr&amp;&amp;, ImageObserver* = nullptr);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp (206741 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp        2016-10-03 19:26:03 UTC (rev 206741)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -81,7 +81,7 @@
</span><span class="cx">     return FloatRect(rect.location(), clampedSize(rect.size()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if !USE(CG)
</del><ins>+#if !(USE(CG) || USE(DIRECT2D))
</ins><span class="cx"> FloatSize ImageBuffer::sizeForDestinationSize(FloatSize size) const
</span><span class="cx"> {
</span><span class="cx">     return size;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (206741 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h        2016-10-03 19:26:03 UTC (rev 206741)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -40,6 +40,10 @@
</span><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(WIN)
+interface ID2D1RenderTarget;
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class FloatRect;
</span><span class="lines">@@ -149,6 +153,8 @@
</span><span class="cx">     RetainPtr&lt;CGImageRef&gt; copyNativeImage(BackingStoreCopy = CopyBackingStore) const;
</span><span class="cx">     static RetainPtr&lt;CGImageRef&gt; sinkIntoNativeImage(std::unique_ptr&lt;ImageBuffer&gt;);
</span><span class="cx">     void flushContext() const;
</span><ins>+#elif USE(DIRECT2D)
+    void flushContext() const;
</ins><span class="cx"> #endif
</span><span class="cx">     
</span><span class="cx">     void draw(GraphicsContext&amp;, const FloatRect&amp; destRect, const FloatRect&amp; srcRect = FloatRect(0, 0, -1, -1), CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal);
</span><span class="lines">@@ -175,6 +181,8 @@
</span><span class="cx">     WEBCORE_EXPORT ImageBuffer(const FloatSize&amp;, float resolutionScale, ColorSpace, RenderingMode, bool&amp; success);
</span><span class="cx"> #if USE(CG)
</span><span class="cx">     ImageBuffer(const FloatSize&amp;, float resolutionScale, CGColorSpaceRef, RenderingMode, bool&amp; success);
</span><ins>+#elif USE(DIRECT2D)
+    ImageBuffer(const FloatSize&amp;, float resolutionScale, ColorSpace, RenderingMode, ID2D1RenderTarget*, bool&amp; success);
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageBufferDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageBufferData.h (206741 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageBufferData.h        2016-10-03 19:26:03 UTC (rev 206741)
+++ trunk/Source/WebCore/platform/graphics/ImageBufferData.h        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -25,6 +25,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(CG)
</span><span class="cx"> #include &quot;ImageBufferDataCG.h&quot;
</span><ins>+#elif USE(DIRECT2D)
+#include &quot;ImageBufferDataDirect2D.h&quot;
</ins><span class="cx"> #elif USE(CAIRO)
</span><span class="cx"> #include &quot;ImageBufferDataCairo.h&quot;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageFrameCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageFrameCache.cpp (206741 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageFrameCache.cpp        2016-10-03 19:26:03 UTC (rev 206741)
+++ trunk/Source/WebCore/platform/graphics/ImageFrameCache.cpp        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -31,6 +31,10 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(CG)
</span><span class="cx"> #include &quot;ImageDecoderCG.h&quot;
</span><ins>+#elif USE(DIRECT2D)
+#include &quot;GraphicsContext.h&quot;
+#include &quot;ImageDecoderDirect2D.h&quot;
+#include &lt;WinCodec.h&gt;
</ins><span class="cx"> #else
</span><span class="cx"> #include &quot;ImageDecoder.h&quot;
</span><span class="cx"> #endif
</span><span class="lines">@@ -374,4 +378,12 @@
</span><span class="cx">     return frameMetadataAtIndex&lt;NativeImagePtr, (&amp;ImageFrame::nativeImage)&gt;(index, subsamplingLevel, ImageFrame::Caching::MetadataAndImage);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if USE(DIRECT2D)
+void ImageFrameCache::setRenderTarget(GraphicsContext&amp; context)
+{
+    if (m_decoder)
+        m_decoder-&gt;setRenderTarget(context.platformContext());
</ins><span class="cx"> }
</span><ins>+#endif
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageFrameCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageFrameCache.h (206741 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageFrameCache.h        2016-10-03 19:26:03 UTC (rev 206741)
+++ trunk/Source/WebCore/platform/graphics/ImageFrameCache.h        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class GraphicsContext;
</ins><span class="cx"> class Image;
</span><span class="cx"> class ImageDecoder;
</span><span class="cx"> 
</span><span class="lines">@@ -43,6 +44,8 @@
</span><span class="cx">     ImageFrameCache(NativeImagePtr&amp;&amp;);
</span><span class="cx"> 
</span><span class="cx">     void setDecoder(ImageDecoder* decoder) { m_decoder = decoder; }
</span><ins>+    ImageDecoder* decoder() const { return m_decoder; }
+
</ins><span class="cx">     unsigned decodedSize() const { return m_decodedSize; }
</span><span class="cx">     void destroyDecodedData(bool destroyAll = true, size_t count = 0);
</span><span class="cx">     bool destroyDecodedDataIfNecessary(bool destroyAll = true, size_t count = 0);
</span><span class="lines">@@ -79,6 +82,10 @@
</span><span class="cx">     ImageOrientation frameOrientationAtIndex(size_t);
</span><span class="cx">     NativeImagePtr frameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default);
</span><span class="cx"> 
</span><ins>+#if USE(DIRECT2D)
+    void setRenderTarget(GraphicsContext&amp;);
+#endif
+
</ins><span class="cx"> private:
</span><span class="cx">     template&lt;typename T, T (ImageDecoder::*functor)() const&gt;
</span><span class="cx">     T metadata(const T&amp; defaultValue, Optional&lt;T&gt;* cachedValue = nullptr);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageSource.cpp (206741 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageSource.cpp        2016-10-03 19:26:03 UTC (rev 206741)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.cpp        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -31,6 +31,9 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(CG)
</span><span class="cx"> #include &quot;ImageDecoderCG.h&quot;
</span><ins>+#elif USE(DIRECT2D)
+#include &quot;ImageDecoderDirect2D.h&quot;
+#include &lt;WinCodec.h&gt;
</ins><span class="cx"> #else
</span><span class="cx"> #include &quot;ImageDecoder.h&quot;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageSource.h (206741 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageSource.h        2016-10-03 19:26:03 UTC (rev 206741)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.h        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class GraphicsContext;
</ins><span class="cx"> class ImageDecoder;
</span><span class="cx"> class ImageOrientation;
</span><span class="cx"> class IntPoint;
</span><span class="lines">@@ -95,6 +96,10 @@
</span><span class="cx">     void setAllowSubsampling(bool allowSubsampling) { m_allowSubsampling = allowSubsampling; }
</span><span class="cx">     NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default);
</span><span class="cx"> 
</span><ins>+#if USE(DIRECT2D)
+    void setRenderTarget(GraphicsContext&amp; context) { m_frameCache.setRenderTarget(context); }
+#endif
+
</ins><span class="cx"> private:
</span><span class="cx">     void clearFrameBufferCache(size_t);
</span><span class="cx">     void clear(bool destroyAll, size_t count, SharedBuffer* data);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsNativeImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/NativeImage.h (206741 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/NativeImage.h        2016-10-03 19:26:03 UTC (rev 206741)
+++ trunk/Source/WebCore/platform/graphics/NativeImage.h        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -39,6 +39,11 @@
</span><span class="cx"> #include &quot;SharedBitmap.h&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if USE(DIRECT2D)
+#include &quot;COMPtr.h&quot;
+#include &lt;d2d1.h&gt;
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class Color;
</span><span class="lines">@@ -48,6 +53,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(CG)
</span><span class="cx"> typedef RetainPtr&lt;CGImageRef&gt; NativeImagePtr;
</span><ins>+#elif USE(DIRECT2D)
+typedef COMPtr&lt;ID2D1Bitmap&gt; NativeImagePtr;
</ins><span class="cx"> #elif USE(CAIRO)
</span><span class="cx"> typedef RefPtr&lt;cairo_surface_t&gt; NativeImagePtr;
</span><span class="cx"> #elif USE(WINGDI)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinImageBufferDataDirect2Dcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp (0 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -0,0 +1,55 @@
</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;ImageBufferData.h&quot;
+
+#if USE(DIRECT2D)
+
+#include &quot;GraphicsContext.h&quot;
+#include &quot;IntRect.h&quot;
+#include &quot;NotImplemented.h&quot;
+#include &lt;d2d1.h&gt;
+#include &lt;runtime/JSCInlines.h&gt;
+#include &lt;runtime/TypedArrayInlines.h&gt;
+#include &lt;runtime/Uint8ClampedArray.h&gt;
+#include &lt;wtf/Assertions.h&gt;
+
+namespace WebCore {
+
+RefPtr&lt;Uint8ClampedArray&gt; ImageBufferData::getData(const IntRect&amp;, const IntSize&amp;, bool /* accelerateRendering */, bool /* unmultiplied */, float /* resolutionScale */) const
+{
+    notImplemented();
+    return nullptr;
+}
+
+void ImageBufferData::putData(Uint8ClampedArray*&amp; /* source */, const IntSize&amp; /* sourceSize */, const IntRect&amp; /* sourceRect */, const IntPoint&amp; /* destPoint */, const IntSize&amp; /* size */, bool /* accelerateRendering */, bool /* unmultiplied */, float /* resolutionScale */)
+{
+    notImplemented();
+}
+
+} // namespace WebCore
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinImageBufferDataDirect2Dh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.h (0 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.h        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -0,0 +1,50 @@
</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;Image.h&quot;
+#include &quot;IntSize.h&quot;
+#include &lt;runtime/Uint8ClampedArray.h&gt;
+#include &lt;wtf/CheckedArithmetic.h&gt;
+#include &lt;wtf/RefPtr.h&gt;
+#include &lt;wtf/RetainPtr.h&gt;
+
+interface ID2D1RenderTarget;
+
+namespace WebCore {
+
+struct ImageBufferData {
+    IntSize backingStoreSize;
+    Checked&lt;unsigned, RecordOverflow&gt; bytesPerRow;
+
+    // Only for software ImageBuffers.
+    void* data { nullptr };
+    std::unique_ptr&lt;GraphicsContext&gt; context;
+    ID2D1RenderTarget* m_compatibleTarget { nullptr };
+
+    RefPtr&lt;Uint8ClampedArray&gt; getData(const IntRect&amp;, const IntSize&amp;, bool accelerateRendering, bool unmultiplied, float resolutionScale) const;
+    void putData(Uint8ClampedArray*&amp; source, const IntSize&amp; sourceSize, const IntRect&amp; sourceRect, const IntPoint&amp; destPoint, const IntSize&amp;, bool accelerateRendering, bool unmultiplied, float resolutionScale);
+};
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinImageBufferDirect2Dcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp (0 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -0,0 +1,279 @@
</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;ImageBuffer.h&quot;
+
+#if USE(DIRECT2D)
+
+#include &quot;BitmapImage.h&quot;
+#include &quot;COMPtr.h&quot;
+#include &quot;GraphicsContext.h&quot;
+#include &quot;ImageData.h&quot;
+#include &quot;IntRect.h&quot;
+#include &quot;MIMETypeRegistry.h&quot;
+#include &quot;NotImplemented.h&quot;
+#include &lt;d2d1.h&gt;
+#include &lt;math.h&gt;
+#include &lt;wtf/Assertions.h&gt;
+#include &lt;wtf/CheckedArithmetic.h&gt;
+#include &lt;wtf/MainThread.h&gt;
+#include &lt;wtf/RetainPtr.h&gt;
+#include &lt;wtf/text/Base64.h&gt;
+#include &lt;wtf/text/WTFString.h&gt;
+
+#if PLATFORM(COCOA)
+#include &quot;WebCoreSystemInterface.h&quot;
+#endif
+
+
+namespace WebCore {
+
+static FloatSize scaleSizeToUserSpace(const FloatSize&amp; logicalSize, const IntSize&amp; backingStoreSize, const IntSize&amp; internalSize)
+{
+    float xMagnification = static_cast&lt;float&gt;(backingStoreSize.width()) / internalSize.width();
+    float yMagnification = static_cast&lt;float&gt;(backingStoreSize.height()) / internalSize.height();
+    return FloatSize(logicalSize.width() * xMagnification, logicalSize.height() * yMagnification);
+}
+
+std::unique_ptr&lt;ImageBuffer&gt; ImageBuffer::createCompatibleBuffer(const FloatSize&amp; size, const GraphicsContext&amp; context)
+{
+    if (size.isEmpty())
+        return nullptr;
+
+    RenderingMode renderingMode = context.renderingMode();
+    IntSize scaledSize = ImageBuffer::compatibleBufferSize(size, context);
+    bool success = false;
+    std::unique_ptr&lt;ImageBuffer&gt; buffer(new ImageBuffer(scaledSize, 1, ColorSpaceSRGB, renderingMode, context.platformContext(), success));
+
+    if (!success)
+        return nullptr;
+
+    // Set up a corresponding scale factor on the graphics context.
+    buffer-&gt;context().scale(FloatSize(scaledSize.width() / size.width(), scaledSize.height() / size.height()));
+    return buffer;
+}
+
+ImageBuffer::ImageBuffer(const FloatSize&amp; size, float resolutionScale, ColorSpace /*colorSpace*/, RenderingMode renderingMode, ID2D1RenderTarget* renderTarget, bool&amp; success)
+    : m_logicalSize(size)
+    , m_resolutionScale(resolutionScale)
+{
+    success = false; // Make early return mean failure.
+    float scaledWidth = std::ceil(resolutionScale * size.width());
+    float scaledHeight = std::ceil(resolutionScale * size.height());
+
+    // FIXME: Should we automatically use a lower resolution?
+    if (!FloatSize(scaledWidth, scaledHeight).isExpressibleAsIntSize())
+        return;
+
+    m_size = IntSize(scaledWidth, scaledHeight);
+    m_data.backingStoreSize = m_size;
+
+    bool accelerateRendering = renderingMode == Accelerated;
+    if (m_size.width() &lt;= 0 || m_size.height() &lt;= 0)
+        return;
+
+    // Prevent integer overflows
+    m_data.bytesPerRow = 4 * Checked&lt;unsigned, RecordOverflow&gt;(m_data.backingStoreSize.width());
+    Checked&lt;size_t, RecordOverflow&gt; numBytes = Checked&lt;unsigned, RecordOverflow&gt;(m_data.backingStoreSize.height()) * m_data.bytesPerRow;
+    if (numBytes.hasOverflowed())
+        return;
+
+    if (!renderTarget)
+        renderTarget = GraphicsContext::defaultRenderTarget();
+    RELEASE_ASSERT(renderTarget);
+
+    COMPtr&lt;ID2D1BitmapRenderTarget&gt; bitmapContext;
+    HRESULT hr = renderTarget-&gt;CreateCompatibleRenderTarget(FloatSize(m_logicalSize), &amp;bitmapContext);
+    if (!bitmapContext || !SUCCEEDED(hr))
+        return;
+
+    m_data.context = std::make_unique&lt;GraphicsContext&gt;(bitmapContext.get());
+    m_data.m_compatibleTarget = renderTarget;
+
+    success = true;
+}
+
+ImageBuffer::ImageBuffer(const FloatSize&amp; size, float resolutionScale, ColorSpace imageColorSpace, RenderingMode renderingMode, bool&amp; success)
+    : ImageBuffer(size, resolutionScale, imageColorSpace, renderingMode, nullptr, success)
+{
+}
+
+ImageBuffer::~ImageBuffer()
+{
+}
+
+FloatSize ImageBuffer::sizeForDestinationSize(FloatSize destinationSize) const
+{
+    return scaleSizeToUserSpace(destinationSize, m_data.backingStoreSize, internalSize());
+}
+
+GraphicsContext&amp; ImageBuffer::context() const
+{
+    return *m_data.context;
+}
+
+void ImageBuffer::flushContext() const
+{
+    if (!context().didBeginDraw())
+        return;
+
+    HRESULT hr = context().platformContext()-&gt;Flush();
+    ASSERT(SUCCEEDED(hr));
+}
+
+RefPtr&lt;Image&gt; ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavior scaleBehavior) const
+{
+    notImplemented();
+    return nullptr;
+}
+
+RefPtr&lt;Image&gt; ImageBuffer::sinkIntoImage(std::unique_ptr&lt;ImageBuffer&gt; imageBuffer, ScaleBehavior scaleBehavior)
+{
+    IntSize internalSize = imageBuffer-&gt;internalSize();
+    IntSize logicalSize = imageBuffer-&gt;logicalSize();
+    IntSize backingStoreSize = imageBuffer-&gt;m_data.backingStoreSize;
+    float resolutionScale = imageBuffer-&gt;m_resolutionScale;
+
+    notImplemented();
+    return nullptr;
+}
+
+BackingStoreCopy ImageBuffer::fastCopyImageMode()
+{
+    return DontCopyBackingStore;
+}
+
+void ImageBuffer::drawConsuming(std::unique_ptr&lt;ImageBuffer&gt; imageBuffer, GraphicsContext&amp; destContext, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, CompositeOperator op, BlendMode blendMode)
+{
+    imageBuffer-&gt;draw(destContext, destRect, srcRect, op, blendMode);
+}
+
+void ImageBuffer::draw(GraphicsContext&amp; destContext, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, CompositeOperator op, BlendMode blendMode)
+{
+    auto bitmapTarget = reinterpret_cast&lt;ID2D1BitmapRenderTarget*&gt;(context().platformContext());
+    auto outputTarget = destContext.platformContext();
+
+    COMPtr&lt;ID2D1Bitmap&gt; image;
+    HRESULT hr = bitmapTarget-&gt;GetBitmap(&amp;image);
+    if (!SUCCEEDED(hr))
+        return;
+
+    // If the render targets for the source and destination contexts do not match, move the image over.
+    if (destContext.platformContext() != m_data.m_compatibleTarget) {
+        COMPtr&lt;ID2D1Bitmap&gt; sourceImage = image;
+        image = nullptr;
+
+        auto bitmapProperties = D2D1::BitmapProperties();
+        GraphicsContext::systemFactory()-&gt;GetDesktopDpi(&amp;bitmapProperties.dpiX, &amp;bitmapProperties.dpiY);
+        hr = outputTarget-&gt;CreateSharedBitmap(__uuidof(ID2D1Bitmap), sourceImage.get(), &amp;bitmapProperties, &amp;image);
+        if (!SUCCEEDED(hr))
+            return;
+    }
+
+    FloatRect adjustedSrcRect = srcRect;
+    adjustedSrcRect.scale(m_resolutionScale, m_resolutionScale);
+
+    destContext.drawNativeImage(image, image-&gt;GetSize(), destRect, adjustedSrcRect, op, blendMode);
+}
+
+void ImageBuffer::drawPattern(GraphicsContext&amp; destContext, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, const AffineTransform&amp; patternTransform, const FloatPoint&amp; phase, const FloatSize&amp; spacing, CompositeOperator op, BlendMode blendMode)
+{
+    FloatRect adjustedSrcRect = srcRect;
+    adjustedSrcRect.scale(m_resolutionScale, m_resolutionScale);
+
+    if (!context().isAcceleratedContext()) {
+        if (&amp;destContext == &amp;context() || destContext.isAcceleratedContext()) {
+            if (RefPtr&lt;Image&gt; copy = copyImage(CopyBackingStore)) // Drawing into our own buffer, need to deep copy.
+                copy-&gt;drawPattern(destContext, destRect, adjustedSrcRect, patternTransform, phase, spacing, op, blendMode);
+        } else {
+            if (RefPtr&lt;Image&gt; imageForRendering = copyImage(DontCopyBackingStore))
+                imageForRendering-&gt;drawPattern(destContext, destRect, adjustedSrcRect, patternTransform, phase, spacing, op, blendMode);
+        }
+    } else {
+        if (RefPtr&lt;Image&gt; copy = copyImage(CopyBackingStore))
+            copy-&gt;drawPattern(destContext, destRect, adjustedSrcRect, patternTransform, phase, spacing, op, blendMode);
+    }
+}
+
+RefPtr&lt;Uint8ClampedArray&gt; ImageBuffer::getUnmultipliedImageData(const IntRect&amp; rect, CoordinateSystem coordinateSystem) const
+{
+    if (context().isAcceleratedContext())
+        flushContext();
+
+    IntRect srcRect = rect;
+    if (coordinateSystem == LogicalCoordinateSystem)
+        srcRect.scale(m_resolutionScale);
+
+    return m_data.getData(srcRect, internalSize(), context().isAcceleratedContext(), true, 1);
+}
+
+RefPtr&lt;Uint8ClampedArray&gt; ImageBuffer::getPremultipliedImageData(const IntRect&amp; rect, CoordinateSystem coordinateSystem) const
+{
+    if (context().isAcceleratedContext())
+        flushContext();
+
+    IntRect srcRect = rect;
+    if (coordinateSystem == LogicalCoordinateSystem)
+        srcRect.scale(m_resolutionScale);
+
+    return m_data.getData(srcRect, internalSize(), context().isAcceleratedContext(), false, 1);
+}
+
+void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, const IntSize&amp; sourceSize, const IntRect&amp; sourceRect, const IntPoint&amp; destPoint, CoordinateSystem coordinateSystem)
+{
+    if (context().isAcceleratedContext())
+        flushContext();
+
+    IntRect scaledSourceRect = sourceRect;
+    IntSize scaledSourceSize = sourceSize;
+    if (coordinateSystem == LogicalCoordinateSystem) {
+        scaledSourceRect.scale(m_resolutionScale);
+        scaledSourceSize.scale(m_resolutionScale);
+    }
+
+    m_data.putData(source, scaledSourceSize, scaledSourceRect, destPoint, internalSize(), context().isAcceleratedContext(), multiplied == Unmultiplied, 1);
+}
+
+String ImageBuffer::toDataURL(const String&amp; mimeType, const double* quality, CoordinateSystem) const
+{
+    notImplemented();
+    return ASCIILiteral(&quot;data:,&quot;);
+}
+
+String ImageDataToDataURL(const ImageData&amp; source, const String&amp; mimeType, const double* quality)
+{
+    notImplemented();
+    return ASCIILiteral(&quot;data:,&quot;);
+}
+
+void ImageBuffer::transformColorSpace(ColorSpace, ColorSpace)
+{
+    notImplemented();
+}
+
+} // namespace WebCore
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinImageCGWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/ImageCGWin.cpp (206741 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/ImageCGWin.cpp        2016-10-03 19:26:03 UTC (rev 206741)
+++ trunk/Source/WebCore/platform/graphics/win/ImageCGWin.cpp        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -26,6 +26,8 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;Image.h&quot;
</span><span class="cx"> 
</span><ins>+#if USE(CG)
+
</ins><span class="cx"> #include &quot;BitmapImage.h&quot;
</span><span class="cx"> #include &quot;BitmapInfo.h&quot;
</span><span class="cx"> #include &quot;GraphicsContextCG.h&quot;
</span><span class="lines">@@ -106,3 +108,5 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span><ins>+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinImageDecoderDirect2Dcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.cpp (0 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.cpp        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -0,0 +1,249 @@
</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;ImageDecoderDirect2D.h&quot;
+
+#if USE(DIRECT2D)
+
+#include &quot;GraphicsContext.h&quot;
+#include &quot;ImageOrientation.h&quot;
+#include &quot;IntPoint.h&quot;
+#include &quot;IntSize.h&quot;
+#include &quot;Logging.h&quot;
+#include &quot;NotImplemented.h&quot;
+#include &quot;SharedBuffer.h&quot;
+#include &lt;WinCodec.h&gt;
+#include &lt;d2d1.h&gt;
+#include &lt;wtf/NeverDestroyed.h&gt;
+
+namespace WebCore {
+
+ImageDecoder::ImageDecoder()
+{
+}
+
+IWICImagingFactory* ImageDecoder::systemImagingFactory()
+{
+    static IWICImagingFactory* wicImagingFactory = nullptr;
+    if (!wicImagingFactory) {
+        HRESULT hr = CoCreateInstance(CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (LPVOID*)&amp;wicImagingFactory);
+        RELEASE_ASSERT(SUCCEEDED(hr));
+    }
+
+    return wicImagingFactory;
+}
+
+size_t ImageDecoder::bytesDecodedToDetermineProperties()
+{
+    // Set to match value used for CoreGraphics.
+    return 13088;
+}
+
+String ImageDecoder::filenameExtension() const
+{
+    notImplemented();
+    return String();
+}
+
+bool ImageDecoder::isSizeAvailable() const
+{
+    return m_nativeDecoder ? true : false;
+}
+
+IntSize ImageDecoder::size() const
+{
+    if (!m_nativeDecoder)
+        return IntSize();
+
+    COMPtr&lt;IWICBitmapFrameDecode&gt; frame;
+    HRESULT hr = m_nativeDecoder-&gt;GetFrame(0, &amp;frame);
+    if (!SUCCEEDED(hr))
+        return IntSize();
+
+    UINT width, height;
+    hr = frame-&gt;GetSize(&amp;width, &amp;height);
+    if (!SUCCEEDED(hr))
+        return IntSize();
+
+    return IntSize(width, height);
+}
+
+size_t ImageDecoder::frameCount() const
+{
+    if (!m_nativeDecoder)
+        return 0;
+
+    UINT count;
+    HRESULT hr = m_nativeDecoder-&gt;GetFrameCount(&amp;count);
+    if (!SUCCEEDED(hr))
+        return 0;
+
+    return count;
+}
+
+RepetitionCount ImageDecoder::repetitionCount() const
+{
+    return RepetitionCountNone;
+}
+
+Optional&lt;IntPoint&gt; ImageDecoder::hotSpot() const
+{
+    return IntPoint();
+}
+
+IntSize ImageDecoder::frameSizeAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const
+{
+    if (!m_nativeDecoder)
+        return IntSize();
+
+    COMPtr&lt;IWICBitmapFrameDecode&gt; frame;
+    HRESULT hr = m_nativeDecoder-&gt;GetFrame(index, &amp;frame);
+    if (!SUCCEEDED(hr))
+        return IntSize();
+
+    UINT width, height;
+    hr = frame-&gt;GetSize(&amp;width, &amp;height);
+    if (!SUCCEEDED(hr))
+        return IntSize();
+
+    return IntSize(width, height);
+}
+
+bool ImageDecoder::frameIsCompleteAtIndex(size_t index) const
+{
+    if (!m_nativeDecoder)
+        return false;
+
+    COMPtr&lt;IWICBitmapFrameDecode&gt; frame;
+    HRESULT hr = m_nativeDecoder-&gt;GetFrame(index, &amp;frame);
+    if (!SUCCEEDED(hr))
+        return false;
+
+    return true;
+}
+
+ImageOrientation ImageDecoder::frameOrientationAtIndex(size_t index) const
+{
+    notImplemented();
+    return ImageOrientation();
+}
+
+float ImageDecoder::frameDurationAtIndex(size_t index) const
+{
+    notImplemented();
+    return 0;
+}
+
+bool ImageDecoder::frameAllowSubsamplingAtIndex(size_t) const
+{
+    notImplemented();
+    return true;
+}
+
+bool ImageDecoder::frameHasAlphaAtIndex(size_t index) const
+{
+    notImplemented();
+    return true;
+}
+
+unsigned ImageDecoder::frameBytesAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const
+{
+    if (!m_nativeDecoder)
+        return 0;
+
+    COMPtr&lt;IWICBitmapFrameDecode&gt; frame;
+    HRESULT hr = m_nativeDecoder-&gt;GetFrame(index, &amp;frame);
+    if (!SUCCEEDED(hr))
+        return 0;
+
+    UINT width, height;
+    hr = frame-&gt;GetSize(&amp;width, &amp;height);
+    if (!SUCCEEDED(hr))
+        return 0;
+
+    return width * height * 4;
+}
+
+void ImageDecoder::setRenderTarget(ID2D1RenderTarget* renderTarget)
+{
+    m_renderTarget = renderTarget;
+}
+
+NativeImagePtr ImageDecoder::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const
+{
+    if (!m_nativeDecoder)
+        return nullptr;
+
+    COMPtr&lt;IWICBitmapFrameDecode&gt; frame;
+    HRESULT hr = m_nativeDecoder-&gt;GetFrame(0, &amp;frame);
+    if (!SUCCEEDED(hr))
+        return nullptr;
+
+    COMPtr&lt;IWICFormatConverter&gt; converter;
+    hr = systemImagingFactory()-&gt;CreateFormatConverter(&amp;converter);
+    if (!SUCCEEDED(hr))
+        return nullptr;
+
+    hr = converter-&gt;Initialize(frame.get(), GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, nullptr, 0.f, WICBitmapPaletteTypeCustom);
+    if (!SUCCEEDED(hr))
+        return nullptr;
+
+    ASSERT(m_renderTarget);
+    if (!m_renderTarget)
+        return nullptr;
+
+    COMPtr&lt;ID2D1Bitmap&gt; bitmap;
+    hr = m_renderTarget-&gt;CreateBitmapFromWicBitmap(converter.get(), nullptr, &amp;bitmap);
+    if (!SUCCEEDED(hr))
+        return nullptr;
+
+    return bitmap;
+}
+
+void ImageDecoder::setData(SharedBuffer&amp; data, bool allDataReceived)
+{
+    if (allDataReceived)
+        return;
+
+    COMPtr&lt;IWICStream&gt; stream;
+    HRESULT hr = systemImagingFactory()-&gt;CreateStream(&amp;stream);
+    if (!SUCCEEDED(hr))
+        return;
+
+    char* dataPtr = const_cast&lt;char*&gt;(data.data());
+    hr = stream-&gt;InitializeFromMemory(reinterpret_cast&lt;BYTE*&gt;(dataPtr), data.size());
+    if (!SUCCEEDED(hr))
+        return;
+
+    m_nativeDecoder = nullptr;
+
+    hr = systemImagingFactory()-&gt;CreateDecoderFromStream(stream.get(), nullptr, WICDecodeMetadataCacheOnDemand, &amp;m_nativeDecoder);
+    ASSERT(SUCCEEDED(hr));
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinImageDecoderDirect2Dh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h (0 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -0,0 +1,87 @@
</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.
+ */
+
+#pragma once
+
+#include &quot;COMPtr.h&quot;
+#include &quot;ImageSource.h&quot;
+#include &quot;IntSize.h&quot;
+#include &lt;wtf/Optional.h&gt;
+
+interface ID2D1RenderTarget;
+interface IWICBitmapDecoder;
+interface IWICImagingFactory;
+
+namespace WebCore {
+
+class ImageDecoder {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    ImageDecoder();
+    
+    static std::unique_ptr&lt;ImageDecoder&gt; create(const SharedBuffer&amp;, AlphaOption, GammaAndColorProfileOption)
+    {
+        return std::make_unique&lt;ImageDecoder&gt;();
+    }
+    
+    static size_t bytesDecodedToDetermineProperties();
+    
+    String filenameExtension() const;
+    bool isSizeAvailable() const;
+    
+    // Always original size, without subsampling.
+    IntSize size() const;
+    size_t frameCount() const;
+
+    RepetitionCount repetitionCount() const;
+    Optional&lt;IntPoint&gt; hotSpot() const;
+    
+    IntSize frameSizeAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const;
+    bool frameIsCompleteAtIndex(size_t) const;
+    ImageOrientation frameOrientationAtIndex(size_t) const;
+    
+    float frameDurationAtIndex(size_t) const;
+    bool frameHasAlphaAtIndex(size_t) const;
+    bool frameAllowSubsamplingAtIndex(size_t) const;
+    unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const;
+    
+    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const;
+    
+    void setData(SharedBuffer&amp;, bool allDataReceived);
+    bool isAllDataReceived() const { return m_isAllDataReceived; }
+    void clearFrameBufferCache(size_t) { }
+
+    void setRenderTarget(ID2D1RenderTarget*);
+
+    static IWICImagingFactory* systemImagingFactory();
+
+protected:
+    bool m_isAllDataReceived { false };
+    mutable IntSize m_size;
+    COMPtr&lt;IWICBitmapDecoder&gt; m_nativeDecoder;
+    COMPtr&lt;ID2D1RenderTarget&gt; m_renderTarget;
+};
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinImageDirect2Dcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/win/ImageDirect2D.cpp (0 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/ImageDirect2D.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/win/ImageDirect2D.cpp        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -0,0 +1,112 @@
</span><ins>+/*
+ * Copyright (C) 2006-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;Image.h&quot;
+
+#include &quot;BitmapImage.h&quot;
+#include &quot;BitmapInfo.h&quot;
+#include &quot;GraphicsContext.h&quot;
+#include &quot;ImageObserver.h&quot;
+#include &quot;NotImplemented.h&quot;
+#include &lt;d2d1.h&gt;
+#include &lt;windows.h&gt;
+#include &lt;wtf/RetainPtr.h&gt;
+#include &lt;wtf/text/WTFString.h&gt;
+
+namespace WebCore {
+
+RefPtr&lt;BitmapImage&gt; BitmapImage::create(HBITMAP hBitmap)
+{
+    DIBSECTION dibSection;
+    if (!GetObject(hBitmap, sizeof(DIBSECTION), &amp;dibSection))
+        return nullptr;
+
+    ASSERT(dibSection.dsBm.bmBitsPixel == 32);
+    if (dibSection.dsBm.bmBitsPixel != 32)
+        return nullptr;
+
+    ASSERT(dibSection.dsBm.bmBits);
+    if (!dibSection.dsBm.bmBits)
+        return nullptr;
+
+    notImplemented();
+
+    return nullptr;
+}
+
+bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, const IntSize* size)
+{
+    ASSERT(bmp);
+
+    BITMAP bmpInfo;
+    GetObject(bmp, sizeof(BITMAP), &amp;bmpInfo);
+
+    ASSERT(bmpInfo.bmBitsPixel == 32);
+    int bufferSize = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
+    
+    notImplemented();
+
+    return true;
+}
+
+void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext&amp; ctxt, const FloatRect&amp; dstRect, const IntSize&amp; srcSize, CompositeOperator compositeOp)
+{
+    size_t frames = frameCount();
+    for (size_t i = 0; i &lt; frames; ++i) {
+        auto image = frameImageAtIndex(i).get();
+        auto imageSize = image-&gt;GetSize();
+        if (image &amp;&amp; clampTo&lt;size_t&gt;(imageSize.height) == static_cast&lt;size_t&gt;(srcSize.height()) &amp;&amp; clampTo&lt;size_t&gt;(imageSize.width) == static_cast&lt;size_t&gt;(srcSize.width())) {
+            size_t currentFrame = m_currentFrame;
+            m_currentFrame = i;
+            draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), compositeOp, BlendModeNormal, ImageOrientationDescription());
+            m_currentFrame = currentFrame;
+            return;
+        }
+    }
+
+    // No image of the correct size was found, fallback to drawing the current frame
+    FloatSize imageSize = BitmapImage::size();
+    draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), compositeOp, BlendModeNormal, ImageOrientationDescription());
+}
+
+void BitmapImage::setRenderTarget(GraphicsContext&amp; context)
+{
+    m_source.setRenderTarget(context);
+}
+
+void Image::drawPattern(GraphicsContext&amp; ctxt, const FloatRect&amp; destRect, const FloatRect&amp; tileRect, const AffineTransform&amp; patternTransform,
+    const FloatPoint&amp; phase, const FloatSize&amp; spacing, CompositeOperator op, BlendMode blendMode)
+{
+    if (!nativeImageForCurrentFrame())
+        return;
+
+    ctxt.drawPattern(*this, destRect, tileRect, patternTransform, phase, spacing, op, blendMode);
+
+    if (imageObserver())
+        imageObserver()-&gt;didDraw(this);
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinNativeImageDirect2Dcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/win/NativeImageDirect2D.cpp (0 => 206742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/NativeImageDirect2D.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/win/NativeImageDirect2D.cpp        2016-10-03 20:22:57 UTC (rev 206742)
</span><span class="lines">@@ -0,0 +1,112 @@
</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;NativeImage.h&quot;
+
+#include &quot;Color.h&quot;
+#include &quot;FloatRect.h&quot;
+#include &quot;GeometryUtilities.h&quot;
+#include &quot;GraphicsContext.h&quot;
+#include &quot;IntSize.h&quot;
+#include &quot;NotImplemented.h&quot;
+
+namespace WebCore {
+
+IntSize nativeImageSize(const NativeImagePtr&amp; image)
+{
+    return image ? IntSize(image-&gt;GetSize()) : IntSize();
+}
+
+bool nativeImageHasAlpha(const NativeImagePtr&amp; image)
+{
+    if (!image)
+        return false;
+
+    auto alphaMode = image-&gt;GetPixelFormat().alphaMode;
+    return (alphaMode &gt;= D2D1_ALPHA_MODE_PREMULTIPLIED) &amp;&amp; (alphaMode &lt;= D2D1_ALPHA_MODE_STRAIGHT);
+}
+
+Color nativeImageSinglePixelSolidColor(const NativeImagePtr&amp; image)
+{
+    if (!image || nativeImageSize(image) != IntSize(1, 1))
+        return Color();
+
+    notImplemented();
+
+    return Color();
+}
+
+float subsamplingScale(GraphicsContext&amp; context, const FloatRect&amp; destRect, const FloatRect&amp; srcRect)
+{
+    D2D1_MATRIX_3X2_F ctm;
+    context.platformContext()-&gt;GetTransform(&amp;ctm);
+
+    AffineTransform transform(ctm);
+
+    auto transformedDestinationRect = transform.mapRect(destRect);
+    return std::min&lt;float&gt;(1, std::max(transformedDestinationRect.width() / srcRect.width(), transformedDestinationRect.height() / srcRect.height()));
+}
+
+void drawNativeImage(const NativeImagePtr&amp; image, GraphicsContext&amp; context, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, const IntSize&amp; srcSize, CompositeOperator compositeOp, BlendMode blendMode, const ImageOrientation&amp; orientation)
+{
+    auto platformContext = context.platformContext();
+
+    // Subsampling may have given us an image that is smaller than size().
+    IntSize subsampledImageSize = nativeImageSize(image);
+
+    // srcRect is in the coordinates of the unsubsampled image, so we have to map it to the subsampled image.
+    FloatRect adjustedSrcRect = srcRect;
+    if (subsampledImageSize != srcSize)
+        adjustedSrcRect = mapRect(srcRect, FloatRect({ }, srcSize), FloatRect({ }, subsampledImageSize));
+
+    float opacity = 1.0f;
+
+    if (!context.didBeginDraw())
+        platformContext-&gt;BeginDraw();
+
+    platformContext-&gt;DrawBitmap(image.get(), destRect, opacity, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, adjustedSrcRect);
+
+    HRESULT hr = S_OK;
+    if (!context.didBeginDraw())
+        hr = platformContext-&gt;EndDraw();
+    else
+        hr = platformContext-&gt;Flush();
+
+    ASSERT(SUCCEEDED(hr));
+}
+
+void clearNativeImageSubimages(const NativeImagePtr&amp; image)
+{
+    notImplemented();
+
+#if CACHE_SUBIMAGES
+    if (image)
+        subimageCache().clearImage(image.get());
+#endif
+}
+
+
+}
</ins></span></pre>
</div>
</div>

</body>
</html>