<!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>[191324] 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/191324">191324</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2015-10-19 17:36:03 -0700 (Mon, 19 Oct 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Host GraphicsContext's CTM inside GraphicsContextState
https://bugs.webkit.org/show_bug.cgi?id=150146

There are 6 operations which interact with CTMs:
- Get
- Set
- Concatenate
- Scale
- Rotate
- Translate

This patch modifies all these operations so that these operations shadow the
platform's CTM inside GraphicsContextState. This way, we don't have to consult
with the underlying graphics context in order to know the current CTM.

There are currently many places in the Core Graphics ports where we will change
the platform's CTM out from under the GraphicsContext. This patch migrates
those users to going through GraphicsContext, thereby preserving the integrity
of the shadowed state.

No new tests because there is no behavior change.

* platform/graphics/GraphicsContext.cpp: Setters deletate to platform calls.
The getter can just consult with the shadowed state.
(WebCore::GraphicsContext::concatCTM):
(WebCore::GraphicsContext::scale):
(WebCore::GraphicsContext::rotate):
(WebCore::GraphicsContext::translate):
(WebCore::GraphicsContext::setCTM):
(WebCore::GraphicsContext::getCTM):
(WebCore::GraphicsContext::beginTransparencyLayer):
(WebCore::GraphicsContext::applyDeviceScaleFactor):
* platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContext::scale):
(WebCore::GraphicsContext::checkCTMInvariants): Make sure the shadowed state
matches the platform graphics context's state.
* platform/graphics/Image.h:
(WebCore::Image::nativeImageForCurrentFrame):
* platform/graphics/cairo/GraphicsContextCairo.cpp: Renaming functions.
(WebCore::GraphicsContext::resetPlatformCTM):
(WebCore::GraphicsContext::getPlatformCTM):
(WebCore::GraphicsContext::translatePlatformCTM):
(WebCore::GraphicsContext::concatPlatformCTM):
(WebCore::GraphicsContext::setPlatformCTM):
(WebCore::GraphicsContext::rotatePlatformCTM):
(WebCore::GraphicsContext::scalePlatformCTM):
(WebCore::GraphicsContext::getCTM): Deleted.
(WebCore::GraphicsContext::translate): Deleted.
(WebCore::GraphicsContext::concatCTM): Deleted.
(WebCore::GraphicsContext::setCTM): Deleted.
(WebCore::GraphicsContext::rotate): Deleted.
(WebCore::GraphicsContext::scale): Deleted.
* platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
Renaming functions.
(WebCore::GraphicsContextPlatformPrivate::save):
(WebCore::GraphicsContextPlatformPrivate::restore):
(WebCore::GraphicsContextPlatformPrivate::flush):
(WebCore::GraphicsContextPlatformPrivate::clip):
(WebCore::GraphicsContextPlatformPrivate::scalePlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::rotatePlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::translatePlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::concatPlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::setPlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::scale): Deleted.
(WebCore::GraphicsContextPlatformPrivate::rotate): Deleted.
(WebCore::GraphicsContextPlatformPrivate::translate): Deleted.
(WebCore::GraphicsContextPlatformPrivate::concatCTM): Deleted.
(WebCore::GraphicsContextPlatformPrivate::setCTM): Deleted.
* platform/graphics/cg/GraphicsContextCG.cpp: Renaming functions. Also,
migrate CTM setters to go through GraphicsContext.
(WebCore::GraphicsContext::resetPlatformCTM):
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::drawNativeImage):
(WebCore::GraphicsContext::drawPattern):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::scalePlatformCTM):
(WebCore::GraphicsContext::rotatePlatformCTM):
(WebCore::GraphicsContext::translatePlatformCTM):
(WebCore::GraphicsContext::concatPlatformCTM):
(WebCore::GraphicsContext::setPlatformCTM):
(WebCore::GraphicsContext::getPlatformCTM):
(WebCore::GraphicsContext::scale): Deleted.
(WebCore::GraphicsContext::rotate): Deleted.
(WebCore::GraphicsContext::translate): Deleted.
(WebCore::GraphicsContext::concatCTM): Deleted.
(WebCore::GraphicsContext::setCTM): Deleted.
(WebCore::GraphicsContext::getCTM): Deleted.
* platform/graphics/cg/GraphicsContextPlatformPrivateCG.h:
(WebCore::GraphicsContextPlatformPrivate::save):
(WebCore::GraphicsContextPlatformPrivate::restore):
(WebCore::GraphicsContextPlatformPrivate::flush):
(WebCore::GraphicsContextPlatformPrivate::clip):
(WebCore::GraphicsContextPlatformPrivate::scalePlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::rotatePlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::translatePlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::concatPlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::setPlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::scale): Deleted.
(WebCore::GraphicsContextPlatformPrivate::rotate): Deleted.
(WebCore::GraphicsContextPlatformPrivate::translate): Deleted.
(WebCore::GraphicsContextPlatformPrivate::concatCTM): Deleted.
(WebCore::GraphicsContextPlatformPrivate::setCTM): Deleted.
* platform/graphics/transforms/AffineTransform.h:
(WebCore::AffineTransform::isEssentiallyEqualTo): Equality comparison on floats
is not a good idea. Instead, this function is more valuable. (However, note that
it is expected for values in a CTM to hold values close to 0, which means that
this function might erroneously return false (similar to operator=()).
* platform/graphics/win/GraphicsContextWin.cpp:
(WebCore::GraphicsContextPlatformPrivate::scalePlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::rotatePlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::translatePlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::concatPlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::setPlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::scale): Deleted.
(WebCore::GraphicsContextPlatformPrivate::rotate): Deleted.
(WebCore::GraphicsContextPlatformPrivate::translate): Deleted.
(WebCore::GraphicsContextPlatformPrivate::concatCTM): Deleted.
(WebCore::GraphicsContextPlatformPrivate::setCTM): Deleted.
* platform/mac/DragImageMac.mm:
(WebCore::drawAtPoint):
* platform/spi/cg/CoreGraphicsSPI.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContextcpp">trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContexth">trunk/Source/WebCore/platform/graphics/GraphicsContext.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageh">trunk/Source/WebCore/platform/graphics/Image.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoGraphicsContextCairocpp">trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoGraphicsContextPlatformPrivateCairoh">trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgGraphicsContextCGcpp">trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgGraphicsContextPlatformPrivateCGh">trunk/Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstransformsAffineTransformh">trunk/Source/WebCore/platform/graphics/transforms/AffineTransform.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinGraphicsContextWincpp">trunk/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmacDragImageMacmm">trunk/Source/WebCore/platform/mac/DragImageMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformspicgCoreGraphicsSPIh">trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (191323 => 191324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-10-20 00:17:17 UTC (rev 191323)
+++ trunk/Source/WebCore/ChangeLog        2015-10-20 00:36:03 UTC (rev 191324)
</span><span class="lines">@@ -1,3 +1,127 @@
</span><ins>+2015-10-19  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        Host GraphicsContext's CTM inside GraphicsContextState
+        https://bugs.webkit.org/show_bug.cgi?id=150146
+
+        There are 6 operations which interact with CTMs:
+        - Get
+        - Set
+        - Concatenate
+        - Scale
+        - Rotate
+        - Translate
+
+        This patch modifies all these operations so that these operations shadow the
+        platform's CTM inside GraphicsContextState. This way, we don't have to consult
+        with the underlying graphics context in order to know the current CTM.
+
+        There are currently many places in the Core Graphics ports where we will change
+        the platform's CTM out from under the GraphicsContext. This patch migrates
+        those users to going through GraphicsContext, thereby preserving the integrity
+        of the shadowed state.
+
+        No new tests because there is no behavior change.
+
+        * platform/graphics/GraphicsContext.cpp: Setters deletate to platform calls.
+        The getter can just consult with the shadowed state.
+        (WebCore::GraphicsContext::concatCTM):
+        (WebCore::GraphicsContext::scale):
+        (WebCore::GraphicsContext::rotate):
+        (WebCore::GraphicsContext::translate):
+        (WebCore::GraphicsContext::setCTM):
+        (WebCore::GraphicsContext::getCTM):
+        (WebCore::GraphicsContext::beginTransparencyLayer):
+        (WebCore::GraphicsContext::applyDeviceScaleFactor):
+        * platform/graphics/GraphicsContext.h:
+        (WebCore::GraphicsContext::scale):
+        (WebCore::GraphicsContext::checkCTMInvariants): Make sure the shadowed state
+        matches the platform graphics context's state.
+        * platform/graphics/Image.h:
+        (WebCore::Image::nativeImageForCurrentFrame):
+        * platform/graphics/cairo/GraphicsContextCairo.cpp: Renaming functions.
+        (WebCore::GraphicsContext::resetPlatformCTM):
+        (WebCore::GraphicsContext::getPlatformCTM):
+        (WebCore::GraphicsContext::translatePlatformCTM):
+        (WebCore::GraphicsContext::concatPlatformCTM):
+        (WebCore::GraphicsContext::setPlatformCTM):
+        (WebCore::GraphicsContext::rotatePlatformCTM):
+        (WebCore::GraphicsContext::scalePlatformCTM):
+        (WebCore::GraphicsContext::getCTM): Deleted.
+        (WebCore::GraphicsContext::translate): Deleted.
+        (WebCore::GraphicsContext::concatCTM): Deleted.
+        (WebCore::GraphicsContext::setCTM): Deleted.
+        (WebCore::GraphicsContext::rotate): Deleted.
+        (WebCore::GraphicsContext::scale): Deleted.
+        * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
+        Renaming functions.
+        (WebCore::GraphicsContextPlatformPrivate::save):
+        (WebCore::GraphicsContextPlatformPrivate::restore):
+        (WebCore::GraphicsContextPlatformPrivate::flush):
+        (WebCore::GraphicsContextPlatformPrivate::clip):
+        (WebCore::GraphicsContextPlatformPrivate::scalePlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::rotatePlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::translatePlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::concatPlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::setPlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::scale): Deleted.
+        (WebCore::GraphicsContextPlatformPrivate::rotate): Deleted.
+        (WebCore::GraphicsContextPlatformPrivate::translate): Deleted.
+        (WebCore::GraphicsContextPlatformPrivate::concatCTM): Deleted.
+        (WebCore::GraphicsContextPlatformPrivate::setCTM): Deleted.
+        * platform/graphics/cg/GraphicsContextCG.cpp: Renaming functions. Also,
+        migrate CTM setters to go through GraphicsContext.
+        (WebCore::GraphicsContext::resetPlatformCTM):
+        (WebCore::GraphicsContext::platformInit):
+        (WebCore::GraphicsContext::drawNativeImage):
+        (WebCore::GraphicsContext::drawPattern):
+        (WebCore::GraphicsContext::fillPath):
+        (WebCore::GraphicsContext::scalePlatformCTM):
+        (WebCore::GraphicsContext::rotatePlatformCTM):
+        (WebCore::GraphicsContext::translatePlatformCTM):
+        (WebCore::GraphicsContext::concatPlatformCTM):
+        (WebCore::GraphicsContext::setPlatformCTM):
+        (WebCore::GraphicsContext::getPlatformCTM):
+        (WebCore::GraphicsContext::scale): Deleted.
+        (WebCore::GraphicsContext::rotate): Deleted.
+        (WebCore::GraphicsContext::translate): Deleted.
+        (WebCore::GraphicsContext::concatCTM): Deleted.
+        (WebCore::GraphicsContext::setCTM): Deleted.
+        (WebCore::GraphicsContext::getCTM): Deleted.
+        * platform/graphics/cg/GraphicsContextPlatformPrivateCG.h:
+        (WebCore::GraphicsContextPlatformPrivate::save):
+        (WebCore::GraphicsContextPlatformPrivate::restore):
+        (WebCore::GraphicsContextPlatformPrivate::flush):
+        (WebCore::GraphicsContextPlatformPrivate::clip):
+        (WebCore::GraphicsContextPlatformPrivate::scalePlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::rotatePlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::translatePlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::concatPlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::setPlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::scale): Deleted.
+        (WebCore::GraphicsContextPlatformPrivate::rotate): Deleted.
+        (WebCore::GraphicsContextPlatformPrivate::translate): Deleted.
+        (WebCore::GraphicsContextPlatformPrivate::concatCTM): Deleted.
+        (WebCore::GraphicsContextPlatformPrivate::setCTM): Deleted.
+        * platform/graphics/transforms/AffineTransform.h:
+        (WebCore::AffineTransform::isEssentiallyEqualTo): Equality comparison on floats
+        is not a good idea. Instead, this function is more valuable. (However, note that
+        it is expected for values in a CTM to hold values close to 0, which means that
+        this function might erroneously return false (similar to operator=()).
+        * platform/graphics/win/GraphicsContextWin.cpp:
+        (WebCore::GraphicsContextPlatformPrivate::scalePlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::rotatePlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::translatePlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::concatPlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::setPlatformCTM):
+        (WebCore::GraphicsContextPlatformPrivate::scale): Deleted.
+        (WebCore::GraphicsContextPlatformPrivate::rotate): Deleted.
+        (WebCore::GraphicsContextPlatformPrivate::translate): Deleted.
+        (WebCore::GraphicsContextPlatformPrivate::concatCTM): Deleted.
+        (WebCore::GraphicsContextPlatformPrivate::setCTM): Deleted.
+        * platform/mac/DragImageMac.mm:
+        (WebCore::drawAtPoint):
+        * platform/spi/cg/CoreGraphicsSPI.h:
+
</ins><span class="cx"> 2015-10-19  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove unused support for long presses from WebKit
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (191323 => 191324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp        2015-10-20 00:17:17 UTC (rev 191323)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp        2015-10-20 00:36:03 UTC (rev 191324)
</span><span class="lines">@@ -142,6 +142,87 @@
</span><span class="cx">     restorePlatformState();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void GraphicsContext::concatCTM(const AffineTransform&amp; other)
+{
+    if (paintingDisabled())
+        return;
+
+    checkCTMInvariants();
+
+    m_state.ctm *= other;
+    concatPlatformCTM(other);
+
+    checkCTMInvariants();
+}
+
+void GraphicsContext::scale(float x, float y)
+{
+    if (paintingDisabled())
+        return;
+
+    checkCTMInvariants();
+
+    m_state.ctm.scale(x, y);
+    scalePlatformCTM(x, y);
+
+    checkCTMInvariants();
+}
+
+void GraphicsContext::rotate(float angle)
+{
+    if (paintingDisabled())
+        return;
+
+    checkCTMInvariants();
+
+    m_state.ctm.rotate(rad2deg(angle));
+    rotatePlatformCTM(angle);
+
+    checkCTMInvariants();
+}
+
+void GraphicsContext::translate(float x, float y)
+{
+    if (paintingDisabled())
+        return;
+
+    checkCTMInvariants();
+
+    m_state.ctm.translate(x, y);
+    translatePlatformCTM(x, y);
+
+    checkCTMInvariants();
+}
+
+void GraphicsContext::setCTM(const AffineTransform&amp; other)
+{
+    if (paintingDisabled())
+        return;
+
+    checkCTMInvariants();
+
+    m_state.ctm = other;
+    setPlatformCTM(other);
+
+    checkCTMInvariants();
+}
+
+AffineTransform GraphicsContext::getCTM(IncludeDeviceScale includeScale) const
+{
+    if (paintingDisabled())
+        return AffineTransform();
+
+    AffineTransform result;
+    if (includeScale == DefinitelyIncludeDeviceScale)
+        result = m_state.userToDeviceSpaceCTM * m_state.ctm;
+    else
+        result = m_state.ctm;
+
+    ASSERT(result.isEssentiallyEqualTo(getPlatformCTM(includeScale)));
+
+    return result;
+}
+
</ins><span class="cx"> void GraphicsContext::drawRaisedEllipse(const FloatRect&amp; rect, const Color&amp; ellipseColor, ColorSpace ellipseColorSpace, const Color&amp; shadowColor, ColorSpace shadowColorSpace)
</span><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="lines">@@ -295,6 +376,8 @@
</span><span class="cx"> {
</span><span class="cx">     beginPlatformTransparencyLayer(opacity);
</span><span class="cx">     ++m_transparencyCount;
</span><ins>+
+    resetPlatformCTM();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::endTransparencyLayer()
</span><span class="lines">@@ -654,7 +737,8 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::applyDeviceScaleFactor(float deviceScaleFactor)
</span><span class="cx"> {
</span><del>-    scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
</del><ins>+    scale(deviceScaleFactor, deviceScaleFactor);
+
</ins><span class="cx">     platformApplyDeviceScaleFactor(deviceScaleFactor);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (191323 => 191324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2015-10-20 00:17:17 UTC (rev 191323)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2015-10-20 00:36:03 UTC (rev 191324)
</span><span class="lines">@@ -156,6 +156,9 @@
</span><span class="cx">     CompositeOperator compositeOperator { CompositeSourceOver };
</span><span class="cx">     BlendMode blendMode { BlendModeNormal };
</span><span class="cx"> 
</span><ins>+    AffineTransform userToDeviceSpaceCTM;
+    AffineTransform ctm;
+
</ins><span class="cx">     bool shouldAntialias : 1;
</span><span class="cx">     bool shouldSmoothFonts : 1;
</span><span class="cx">     bool antialiasedFontDilationEnabled : 1;
</span><span class="lines">@@ -420,18 +423,25 @@
</span><span class="cx">     void canvasClip(const Path&amp;, WindRule = RULE_EVENODD);
</span><span class="cx">     void clipOut(const Path&amp;);
</span><span class="cx"> 
</span><del>-    WEBCORE_EXPORT void scale(const FloatSize&amp;);
</del><ins>+    WEBCORE_EXPORT void scale(const FloatSize&amp; size) { scale(size.width(), size.height()); }
</ins><span class="cx">     void rotate(float angleInRadians);
</span><span class="cx">     void translate(const FloatSize&amp; size) { translate(size.width(), size.height()); }
</span><ins>+    WEBCORE_EXPORT void scale(float x, float y);
</ins><span class="cx">     WEBCORE_EXPORT void translate(float x, float y);
</span><span class="cx"> 
</span><span class="cx">     void setURLForRect(const URL&amp;, const IntRect&amp;);
</span><span class="cx"> 
</span><ins>+    void checkCTMInvariants() const
+    {
+        ASSERT(getCTM(DefinitelyIncludeDeviceScale).isEssentiallyEqualTo(getPlatformCTM(DefinitelyIncludeDeviceScale)));
+        ASSERT(getCTM(PossiblyIncludeDeviceScale).isEssentiallyEqualTo(getPlatformCTM(PossiblyIncludeDeviceScale)));
+    }
</ins><span class="cx">     void concatCTM(const AffineTransform&amp;);
</span><span class="cx">     void setCTM(const AffineTransform&amp;);
</span><ins>+    void resetPlatformCTM();
</ins><span class="cx"> 
</span><span class="cx">     enum IncludeDeviceScale { DefinitelyIncludeDeviceScale, PossiblyIncludeDeviceScale };
</span><del>-    AffineTransform getCTM(IncludeDeviceScale includeScale = PossiblyIncludeDeviceScale) const;
</del><ins>+    AffineTransform getCTM(IncludeDeviceScale = PossiblyIncludeDeviceScale) const;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(3D_TRANSFORMS) &amp;&amp; USE(TEXTURE_MAPPER)
</span><span class="cx">     // This is needed when using accelerated-compositing in software mode, like in TextureMapper.
</span><span class="lines">@@ -545,6 +555,13 @@
</span><span class="cx">     void setPlatformAlpha(float);
</span><span class="cx">     void setPlatformCompositeOperation(CompositeOperator, BlendMode = BlendModeNormal);
</span><span class="cx"> 
</span><ins>+    void concatPlatformCTM(const AffineTransform&amp;);
+    void scalePlatformCTM(float x, float y);
+    void rotatePlatformCTM(float);
+    void translatePlatformCTM(float, float);
+    void setPlatformCTM(const AffineTransform&amp;);
+    AffineTransform getPlatformCTM(IncludeDeviceScale = PossiblyIncludeDeviceScale) const; // This is only computed to ASSERT() that the GraphicsContextState agrees with the underlying platform.
+
</ins><span class="cx">     void beginPlatformTransparencyLayer(float opacity);
</span><span class="cx">     void endPlatformTransparencyLayer();
</span><span class="cx">     static bool supportsTransparencyLayers();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Image.h (191323 => 191324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Image.h        2015-10-20 00:17:17 UTC (rev 191323)
+++ trunk/Source/WebCore/platform/graphics/Image.h        2015-10-20 00:36:03 UTC (rev 191324)
</span><span class="lines">@@ -133,7 +133,7 @@
</span><span class="cx"> 
</span><span class="cx">     enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile };
</span><span class="cx"> 
</span><del>-    virtual PassNativeImagePtr nativeImageForCurrentFrame() { return 0; }
</del><ins>+    virtual PassNativeImagePtr nativeImageForCurrentFrame() { return nullptr; }
</ins><span class="cx">     virtual ImageOrientation orientationForCurrentFrame() { return ImageOrientation(); }
</span><span class="cx"> 
</span><span class="cx">     // Accessors for native image formats.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoGraphicsContextCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (191323 => 191324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp        2015-10-20 00:17:17 UTC (rev 191323)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp        2015-10-20 00:36:03 UTC (rev 191324)
</span><span class="lines">@@ -194,8 +194,16 @@
</span><span class="cx">     delete m_data;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
</del><ins>+void GraphicsContext::resetPlatformCTM()
</ins><span class="cx"> {
</span><ins>+    if (platformContext())
+        m_state.ctm = getPlatformCTM();
+    else
+        m_state.ctm.makeIdentity();
+}
+
+AffineTransform GraphicsContext::getPlatformCTM(IncludeDeviceScale) const
+{
</ins><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return AffineTransform();
</span><span class="cx"> 
</span><span class="lines">@@ -711,14 +719,14 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::translate(float x, float y)
</del><ins>+void GraphicsContext::translatePlatformCTM(float x, float y)
</ins><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     cairo_t* cr = platformContext()-&gt;cr();
</span><span class="cx">     cairo_translate(cr, x, y);
</span><del>-    m_data-&gt;translate(x, y);
</del><ins>+    m_data-&gt;translatePlatformCTM(x, y);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::setPlatformFillColor(const Color&amp;, ColorSpace)
</span><span class="lines">@@ -773,7 +781,7 @@
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::concatCTM(const AffineTransform&amp; transform)
</del><ins>+void GraphicsContext::concatPlatformCTM(const AffineTransform&amp; transform)
</ins><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><span class="lines">@@ -781,10 +789,10 @@
</span><span class="cx">     cairo_t* cr = platformContext()-&gt;cr();
</span><span class="cx">     const cairo_matrix_t matrix = cairo_matrix_t(transform);
</span><span class="cx">     cairo_transform(cr, &amp;matrix);
</span><del>-    m_data-&gt;concatCTM(transform);
</del><ins>+    m_data-&gt;concatPlatformCTM(transform);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::setCTM(const AffineTransform&amp; transform)
</del><ins>+void GraphicsContext::setPlatformCTM(const AffineTransform&amp; transform)
</ins><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><span class="lines">@@ -792,7 +800,7 @@
</span><span class="cx">     cairo_t* cr = platformContext()-&gt;cr();
</span><span class="cx">     const cairo_matrix_t matrix = cairo_matrix_t(transform);
</span><span class="cx">     cairo_set_matrix(cr, &amp;matrix);
</span><del>-    m_data-&gt;setCTM(transform);
</del><ins>+    m_data-&gt;setPlatformCTM(transform);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::setPlatformShadow(FloatSize const&amp; size, float, Color const&amp;, ColorSpace)
</span><span class="lines">@@ -1003,22 +1011,22 @@
</span><span class="cx">     cairo_set_fill_rule(cr, savedFillRule);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::rotate(float radians)
</del><ins>+void GraphicsContext::rotatePlatformCTM(float radians)
</ins><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     cairo_rotate(platformContext()-&gt;cr(), radians);
</span><del>-    m_data-&gt;rotate(radians);
</del><ins>+    m_data-&gt;rotatePlatformCTM(radians);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::scale(const FloatSize&amp; size)
</del><ins>+void GraphicsContext::scalePlatformCTM(float x, float y)
</ins><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    cairo_scale(platformContext()-&gt;cr(), size.width(), size.height());
-    m_data-&gt;scale(size);
</del><ins>+    cairo_scale(platformContext()-&gt;cr(), x, y);
+    m_data-&gt;scalePlatformCTM(x, y);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::clipOut(const FloatRect&amp; r)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoGraphicsContextPlatformPrivateCairoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h (191323 => 191324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h        2015-10-20 00:17:17 UTC (rev 191323)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h        2015-10-20 00:36:03 UTC (rev 191324)
</span><span class="lines">@@ -67,24 +67,24 @@
</span><span class="cx">     void flush();
</span><span class="cx">     void clip(const FloatRect&amp;);
</span><span class="cx">     void clip(const Path&amp;);
</span><del>-    void scale(const FloatSize&amp;);
-    void rotate(float);
-    void translate(float, float);
-    void concatCTM(const AffineTransform&amp;);
-    void setCTM(const AffineTransform&amp;);
</del><ins>+    void scalePlatformCTM(float, float);
+    void rotatePlatformCTM(float);
+    void translatePlatformCTM(float, float);
+    void concatPlatformCTM(const AffineTransform&amp;);
+    void setPlatformCTM(const AffineTransform&amp;);
</ins><span class="cx">     void syncContext(cairo_t* cr);
</span><span class="cx"> #else
</span><span class="cx">     // On everything else, we do nothing.
</span><del>-    void save() {}
-    void restore() {}
-    void flush() {}
-    void clip(const FloatRect&amp;) {}
-    void clip(const Path&amp;) {}
-    void scale(const FloatSize&amp;) {}
-    void rotate(float) {}
-    void translate(float, float) {}
-    void concatCTM(const AffineTransform&amp;) {}
-    void setCTM(const AffineTransform&amp;) {}
</del><ins>+    void save() { }
+    void restore() { }
+    void flush() { }
+    void clip(const FloatRect&amp;) { }
+    void clip(const Path&amp;) { }
+    void scalePlatformCTM(float, float) { }
+    void rotatePlatformCTM(float) { }
+    void translatePlatformCTM(float, float) { }
+    void concatPlatformCTM(const AffineTransform&amp;) { }
+    void setPlatformCTM(const AffineTransform&amp;) { }
</ins><span class="cx">     void syncContext(cairo_t*) { }
</span><span class="cx"> #endif
</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 (191323 => 191324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp        2015-10-20 00:17:17 UTC (rev 191323)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp        2015-10-20 00:36:03 UTC (rev 191324)
</span><span class="lines">@@ -104,6 +104,16 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+void GraphicsContext::resetPlatformCTM()
+{
+    m_state.ctm = CGContextGetCTM(platformContext());
+#if PLATFORM(WIN) || PLATFORM(IOS)
+    m_state.userToDeviceSpaceCTM = static_cast&lt;AffineTransform&gt;(CGContextGetUserSpaceToDeviceSpaceTransform(platformContext())) * m_state.ctm.inverse();
+#else
+    m_state.userToDeviceSpaceCTM = CGContextGetDefaultUserSpaceToDeviceSpaceTransform(platformContext());
+#endif
+}
+
</ins><span class="cx"> void GraphicsContext::platformInit(CGContextRef cgContext)
</span><span class="cx"> {
</span><span class="cx">     m_data = new GraphicsContextPlatformPrivate(cgContext);
</span><span class="lines">@@ -113,6 +123,7 @@
</span><span class="cx">         setPlatformFillColor(fillColor(), fillColorSpace());
</span><span class="cx">         setPlatformStrokeColor(strokeColor(), strokeColorSpace());
</span><span class="cx">         setPlatformStrokeThickness(strokeThickness());
</span><ins>+        resetPlatformCTM();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -154,7 +165,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     CGContextRef context = platformContext();
</span><del>-    CGContextStateSaver stateSaver(context);
</del><ins>+    GraphicsContextStateSaver stateSaver(*this);
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     // Anti-aliasing is on by default on the iPhone. Need to turn it off when drawing images.
</span><span class="lines">@@ -268,7 +279,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     CGContextRef context = platformContext();
</span><del>-    CGContextStateSaver stateSaver(context);
</del><ins>+    GraphicsContextStateSaver stateSaver(*this);
</ins><span class="cx">     CGContextClipToRect(context, destRect);
</span><span class="cx"> 
</span><span class="cx">     setPlatformCompositeOperation(op, blendMode);
</span><span class="lines">@@ -670,7 +681,7 @@
</span><span class="cx">             FloatRect rect = path.fastBoundingRect();
</span><span class="cx">             FloatSize layerSize = getCTM().mapSize(rect.size());
</span><span class="cx"> 
</span><del>-            CGLayerRef layer = CGLayerCreateWithContext(context, layerSize, 0);
</del><ins>+            CGLayerRef layer = CGLayerCreateWithContext(context, layerSize, nullptr);
</ins><span class="cx">             CGContextRef layerContext = CGLayerGetContext(layer);
</span><span class="cx"> 
</span><span class="cx">             CGContextScaleCTM(layerContext, layerSize.width() / rect.width(), layerSize.height() / rect.height());
</span><span class="lines">@@ -1253,52 +1264,52 @@
</span><span class="cx">     CGContextEOClip(platformContext());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::scale(const FloatSize&amp; size)
</del><ins>+void GraphicsContext::scalePlatformCTM(float x, float y)
</ins><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><del>-    CGContextScaleCTM(platformContext(), size.width(), size.height());
-    m_data-&gt;scale(size);
</del><ins>+    CGContextScaleCTM(platformContext(), x, y);
+    m_data-&gt;scalePlatformCTM(x, y);
</ins><span class="cx">     m_data-&gt;m_userToDeviceTransformKnownToBeIdentity = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::rotate(float angle)
</del><ins>+void GraphicsContext::rotatePlatformCTM(float angle)
</ins><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><span class="cx">     CGContextRotateCTM(platformContext(), angle);
</span><del>-    m_data-&gt;rotate(angle);
</del><ins>+    m_data-&gt;rotatePlatformCTM(angle);
</ins><span class="cx">     m_data-&gt;m_userToDeviceTransformKnownToBeIdentity = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::translate(float x, float y)
</del><ins>+void GraphicsContext::translatePlatformCTM(float x, float y)
</ins><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><span class="cx">     CGContextTranslateCTM(platformContext(), x, y);
</span><del>-    m_data-&gt;translate(x, y);
</del><ins>+    m_data-&gt;translatePlatformCTM(x, y);
</ins><span class="cx">     m_data-&gt;m_userToDeviceTransformKnownToBeIdentity = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::concatCTM(const AffineTransform&amp; transform)
</del><ins>+void GraphicsContext::concatPlatformCTM(const AffineTransform&amp; transform)
</ins><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><span class="cx">     CGContextConcatCTM(platformContext(), transform);
</span><del>-    m_data-&gt;concatCTM(transform);
</del><ins>+    m_data-&gt;concatPlatformCTM(transform);
</ins><span class="cx">     m_data-&gt;m_userToDeviceTransformKnownToBeIdentity = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::setCTM(const AffineTransform&amp; transform)
</del><ins>+void GraphicsContext::setPlatformCTM(const AffineTransform&amp; transform)
</ins><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><span class="cx">     CGContextSetCTM(platformContext(), transform);
</span><del>-    m_data-&gt;setCTM(transform);
</del><ins>+    m_data-&gt;setPlatformCTM(transform);
</ins><span class="cx">     m_data-&gt;m_userToDeviceTransformKnownToBeIdentity = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-AffineTransform GraphicsContext::getCTM(IncludeDeviceScale includeScale) const
</del><ins>+AffineTransform GraphicsContext::getPlatformCTM(IncludeDeviceScale includeScale) const
</ins><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return AffineTransform();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgGraphicsContextPlatformPrivateCGh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h (191323 => 191324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h        2015-10-20 00:17:17 UTC (rev 191323)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h        2015-10-20 00:36:03 UTC (rev 191324)
</span><span class="lines">@@ -53,16 +53,16 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     // These methods do nothing on Mac.
</span><del>-    void save() {}
-    void restore() {}
-    void flush() {}
-    void clip(const FloatRect&amp;) {}
-    void clip(const Path&amp;) {}
-    void scale(const FloatSize&amp;) {}
-    void rotate(float) {}
-    void translate(float, float) {}
-    void concatCTM(const AffineTransform&amp;) {}
-    void setCTM(const AffineTransform&amp;) {}
</del><ins>+    void save() { }
+    void restore() { }
+    void flush() { }
+    void clip(const FloatRect&amp;) { }
+    void clip(const Path&amp;) { }
+    void scalePlatformCTM(float, float) { }
+    void rotatePlatformCTM(float) { }
+    void translatePlatformCTM(float, float) { }
+    void concatPlatformCTM(const AffineTransform&amp;) { }
+    void setPlatformCTM(const AffineTransform&amp;) { }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(WIN)
</span><span class="lines">@@ -72,11 +72,11 @@
</span><span class="cx">     void flush();
</span><span class="cx">     void clip(const FloatRect&amp;);
</span><span class="cx">     void clip(const Path&amp;);
</span><del>-    void scale(const FloatSize&amp;);
-    void rotate(float);
-    void translate(float, float);
-    void concatCTM(const AffineTransform&amp;);
-    void setCTM(const AffineTransform&amp;);
</del><ins>+    void scalePlatformCTM(float x, float y);
+    void rotatePlatformCTM(float);
+    void translatePlatformCTM(float, float);
+    void concatPlatformCTM(const AffineTransform&amp;);
+    void setPlatformCTM(const AffineTransform&amp;);
</ins><span class="cx"> 
</span><span class="cx">     HDC m_hdc;
</span><span class="cx">     bool m_shouldIncludeChildWindows;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstransformsAffineTransformh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/transforms/AffineTransform.h (191323 => 191324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/transforms/AffineTransform.h        2015-10-20 00:17:17 UTC (rev 191323)
+++ trunk/Source/WebCore/platform/graphics/transforms/AffineTransform.h        2015-10-20 00:36:03 UTC (rev 191324)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include &quot;PlatformExportMacros.h&quot;
</span><span class="cx"> #include &lt;array&gt;
</span><span class="cx"> #include &lt;wtf/FastMalloc.h&gt;
</span><ins>+#include &lt;wtf/MathExtras.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> #if USE(CG)
</span><span class="cx"> typedef struct CGAffineTransform CGAffineTransform;
</span><span class="lines">@@ -140,6 +141,7 @@
</span><span class="cx">         return (m_transform[1] == 0 &amp;&amp; m_transform[2] == 0) || (m_transform[0] == 0 &amp;&amp; m_transform[3] == 0);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // FIXME: If you compare floats for equality, you're gonna have a bad time. We should delete this.
</ins><span class="cx">     bool operator== (const AffineTransform&amp; m2) const
</span><span class="cx">     {
</span><span class="cx">         return (m_transform[0] == m2.m_transform[0]
</span><span class="lines">@@ -152,6 +154,21 @@
</span><span class="cx"> 
</span><span class="cx">     bool operator!=(const AffineTransform&amp; other) const { return !(*this == other); }
</span><span class="cx"> 
</span><ins>+    bool isEssentiallyEqualTo(const AffineTransform&amp; m2, double epsilon = 0.001) const
+    {
+        // WTF::areEssentiallyEqual() doesn't work well in this case. That function is designed to allow for error
+        // which scales proportionately to the values. However, AffineTransforms are often rotated by pi/2, which
+        // are not exactly representable. This results in AffineTransform components which are close to, but not
+        // exactly equal to, zero. In this case, the error and the value are approximately equal, which leads to
+        // a false negative return.
+        return std::abs(m_transform[0] - m2.m_transform[0]) &lt; epsilon
+            &amp;&amp; std::abs(m_transform[1] - m2.m_transform[1]) &lt; epsilon
+            &amp;&amp; std::abs(m_transform[2] - m2.m_transform[2]) &lt; epsilon
+            &amp;&amp; std::abs(m_transform[3] - m2.m_transform[3]) &lt; epsilon
+            &amp;&amp; std::abs(m_transform[4] - m2.m_transform[4]) &lt; epsilon
+            &amp;&amp; std::abs(m_transform[5] - m2.m_transform[5]) &lt; epsilon;
+    }
+
</ins><span class="cx">     // *this = *this * t (i.e., a multRight)
</span><span class="cx">     AffineTransform&amp; operator*=(const AffineTransform&amp; t)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinGraphicsContextWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp (191323 => 191324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp        2015-10-20 00:17:17 UTC (rev 191323)
+++ trunk/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp        2015-10-20 00:36:03 UTC (rev 191324)
</span><span class="lines">@@ -171,24 +171,24 @@
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContextPlatformPrivate::scale(const FloatSize&amp; size)
</del><ins>+void GraphicsContextPlatformPrivate::scalePlatformCTM(float x, float y)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_hdc)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    XFORM xform = TransformationMatrix().scaleNonUniform(size.width(), size.height());
</del><ins>+    XFORM xform = TransformationMatrix().scaleNonUniform(x, y);
</ins><span class="cx">     ModifyWorldTransform(m_hdc, &amp;xform, MWT_LEFTMULTIPLY);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static const double deg2rad = 0.017453292519943295769; // pi/180
</span><span class="cx"> 
</span><del>-void GraphicsContextPlatformPrivate::rotate(float degreesAngle)
</del><ins>+void GraphicsContextPlatformPrivate::rotatePlatformCTM(float degreesAngle)
</ins><span class="cx"> {
</span><span class="cx">     XFORM xform = TransformationMatrix().rotate(degreesAngle);
</span><span class="cx">     ModifyWorldTransform(m_hdc, &amp;xform, MWT_LEFTMULTIPLY);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContextPlatformPrivate::translate(float x , float y)
</del><ins>+void GraphicsContextPlatformPrivate::translatePlatformCTM(float x , float y)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_hdc)
</span><span class="cx">         return;
</span><span class="lines">@@ -197,7 +197,7 @@
</span><span class="cx">     ModifyWorldTransform(m_hdc, &amp;xform, MWT_LEFTMULTIPLY);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContextPlatformPrivate::concatCTM(const AffineTransform&amp; transform)
</del><ins>+void GraphicsContextPlatformPrivate::concatPlatformCTM(const AffineTransform&amp; transform)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_hdc)
</span><span class="cx">         return;
</span><span class="lines">@@ -206,7 +206,7 @@
</span><span class="cx">     ModifyWorldTransform(m_hdc, &amp;xform, MWT_LEFTMULTIPLY);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContextPlatformPrivate::setCTM(const AffineTransform&amp; transform)
</del><ins>+void GraphicsContextPlatformPrivate::setPlatformCTM(const AffineTransform&amp; transform)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_hdc)
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacDragImageMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/DragImageMac.mm (191323 => 191324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/DragImageMac.mm        2015-10-20 00:17:17 UTC (rev 191323)
+++ trunk/Source/WebCore/platform/mac/DragImageMac.mm        2015-10-20 00:36:03 UTC (rev 191324)
</span><span class="lines">@@ -216,12 +216,13 @@
</span><span class="cx">         
</span><span class="cx">         NSGraphicsContext *nsContext = [NSGraphicsContext currentContext];
</span><span class="cx">         CGContextRef cgContext = static_cast&lt;CGContextRef&gt;([nsContext graphicsPort]);
</span><del>-        GraphicsContext graphicsContext(cgContext);    
</del><span class="cx">         
</span><span class="cx">         // Safari doesn't flip the NSGraphicsContext before calling WebKit, yet WebCore requires a flipped graphics context.
</span><span class="cx">         BOOL flipped = [nsContext isFlipped];
</span><span class="cx">         if (!flipped)
</span><span class="cx">             CGContextScaleCTM(cgContext, 1, -1);
</span><ins>+
+        GraphicsContext graphicsContext(cgContext);
</ins><span class="cx">             
</span><span class="cx">         FontCascade webCoreFont(FontPlatformData(toCTFont(font), [font pointSize]), Antialiased);
</span><span class="cx">         TextRun run(StringView(buffer.data(), length));
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformspicgCoreGraphicsSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h (191323 => 191324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h        2015-10-20 00:17:17 UTC (rev 191323)
+++ trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h        2015-10-20 00:36:03 UTC (rev 191324)
</span><span class="lines">@@ -143,6 +143,8 @@
</span><span class="cx"> void CGContextSetCompositeOperation(CGContextRef, CGCompositeOperation);
</span><span class="cx"> void CGContextSetShouldAntialiasFonts(CGContextRef, bool shouldAntialiasFonts);
</span><span class="cx"> void CGContextResetClip(CGContextRef);
</span><ins>+CGAffineTransform CGContextGetUserSpaceToDeviceSpaceTransform(CGContextRef);
+CGAffineTransform CGContextGetDefaultUserSpaceToDeviceSpaceTransform(CGContextRef);
</ins><span class="cx"> #if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101100
</span><span class="cx"> void CGContextSetFontDilation(CGContextRef, CGSize);
</span><span class="cx"> void CGContextSetFontRenderingStyle(CGContextRef, CGFontRenderingStyle);
</span></span></pre>
</div>
</div>

</body>
</html>