<!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>[45676] trunk/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/45676">45676</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2009-07-09 14:57:16 -0700 (Thu, 09 Jul 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>2009-07-09  Simon Fraser  &lt;simon.fraser@apple.com&gt;

        Reviewed by Dave Hyatt

        Improve the appearance of text in compositing layers when -[CALayer geometryFlipped]
        is not available.
        &lt;rdar://problem/6120614&gt;

        * platform/graphics/GraphicsLayer.h:
        (WebCore::GraphicsLayer::setContentsOrientation):
        (WebCore::GraphicsLayer::contentsOrientation):
        * platform/graphics/GraphicsLayer.cpp:
        (WebCore::GraphicsLayer::GraphicsLayer):
        Add a m_contentsOrientation member and getter/setter to control whether
        the contents of this layer have a transform applied to them before display.

        * platform/graphics/mac/GraphicsLayerCA.h:
        New method to return the default contents orientation.

        * platform/graphics/mac/GraphicsLayerCA.mm:
        (WebCore::flipTransform):
        Convenience method to return a transform with a Y flip.

        (WebCore::GraphicsLayerCA::GraphicsLayerCA):
        (WebCore::GraphicsLayerCA::setSize):
        After the size changes we have to update the contentsTransform.

        (WebCore::GraphicsLayerCA::setGeometryOrientation):
        (WebCore::GraphicsLayerCA::geometryOrientation):
        If -setGeometryFlipped: is not available, use a children transform.

        (WebCore::GraphicsLayerCA::swapFromOrToTiledLayer):
        Tiled layers have issues with flipped contentsTransform, so just use
        top-down drawing for them. Call updateContentsTransform() to set the
        new contents transform after swapping layers.

        (WebCore::GraphicsLayerCA::defaultContentsOrientation):
        Use bottom-up when -geometryFlipped is not available, otherwise top-down.

        (WebCore::GraphicsLayerCA::updateContentsTransform):
        Set the layer contents transform based on contentsOrientation().

        (WebCore::GraphicsLayerCA::setContentsLayer):
        We have to manually flip contents layers if we're not using -geometryFlipped.

        * platform/graphics/mac/WebLayer.h:
        * platform/graphics/mac/WebLayer.mm:
        Do early return if layerContents is nil. Flip the CTM if the layer has
        bottom-up coordinates, so that CG sees a CTM with no flip.
        Do the CGContextRestoreGState() after drawing the debug indicator.

        (-[WebLayer setNeedsDisplayInRect:]):
        * platform/graphics/mac/WebTiledLayer.mm:
        (-[WebTiledLayer setNeedsDisplayInRect:]):
        Need to map the dirty rect through the contentsTransform.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreplatformgraphicsGraphicsLayercpp">trunk/WebCore/platform/graphics/GraphicsLayer.cpp</a></li>
<li><a href="#trunkWebCoreplatformgraphicsGraphicsLayerh">trunk/WebCore/platform/graphics/GraphicsLayer.h</a></li>
<li><a href="#trunkWebCoreplatformgraphicsmacGraphicsLayerCAh">trunk/WebCore/platform/graphics/mac/GraphicsLayerCA.h</a></li>
<li><a href="#trunkWebCoreplatformgraphicsmacGraphicsLayerCAmm">trunk/WebCore/platform/graphics/mac/GraphicsLayerCA.mm</a></li>
<li><a href="#trunkWebCoreplatformgraphicsmacWebLayerh">trunk/WebCore/platform/graphics/mac/WebLayer.h</a></li>
<li><a href="#trunkWebCoreplatformgraphicsmacWebLayermm">trunk/WebCore/platform/graphics/mac/WebLayer.mm</a></li>
<li><a href="#trunkWebCoreplatformgraphicsmacWebTiledLayermm">trunk/WebCore/platform/graphics/mac/WebTiledLayer.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (45675 => 45676)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2009-07-09 21:53:13 UTC (rev 45675)
+++ trunk/WebCore/ChangeLog        2009-07-09 21:57:16 UTC (rev 45676)
</span><span class="lines">@@ -1,3 +1,59 @@
</span><ins>+2009-07-09  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Reviewed by Dave Hyatt
+
+        Improve the appearance of text in compositing layers when -[CALayer geometryFlipped]
+        is not available.
+        &lt;rdar://problem/6120614&gt;
+
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::setContentsOrientation):
+        (WebCore::GraphicsLayer::contentsOrientation):
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::GraphicsLayer):
+        Add a m_contentsOrientation member and getter/setter to control whether
+        the contents of this layer have a transform applied to them before display.
+
+        * platform/graphics/mac/GraphicsLayerCA.h:
+        New method to return the default contents orientation.
+
+        * platform/graphics/mac/GraphicsLayerCA.mm:
+        (WebCore::flipTransform):
+        Convenience method to return a transform with a Y flip.
+
+        (WebCore::GraphicsLayerCA::GraphicsLayerCA):
+        (WebCore::GraphicsLayerCA::setSize):
+        After the size changes we have to update the contentsTransform.
+
+        (WebCore::GraphicsLayerCA::setGeometryOrientation):
+        (WebCore::GraphicsLayerCA::geometryOrientation):
+        If -setGeometryFlipped: is not available, use a children transform.
+        
+        (WebCore::GraphicsLayerCA::swapFromOrToTiledLayer):
+        Tiled layers have issues with flipped contentsTransform, so just use
+        top-down drawing for them. Call updateContentsTransform() to set the
+        new contents transform after swapping layers.
+        
+        (WebCore::GraphicsLayerCA::defaultContentsOrientation):
+        Use bottom-up when -geometryFlipped is not available, otherwise top-down.
+        
+        (WebCore::GraphicsLayerCA::updateContentsTransform):
+        Set the layer contents transform based on contentsOrientation().
+
+        (WebCore::GraphicsLayerCA::setContentsLayer):
+        We have to manually flip contents layers if we're not using -geometryFlipped.
+        
+        * platform/graphics/mac/WebLayer.h:
+        * platform/graphics/mac/WebLayer.mm:
+        Do early return if layerContents is nil. Flip the CTM if the layer has
+        bottom-up coordinates, so that CG sees a CTM with no flip.
+        Do the CGContextRestoreGState() after drawing the debug indicator.
+        
+        (-[WebLayer setNeedsDisplayInRect:]):
+        * platform/graphics/mac/WebTiledLayer.mm:
+        (-[WebTiledLayer setNeedsDisplayInRect:]):
+        Need to map the dirty rect through the contentsTransform.
+
</ins><span class="cx"> 2009-07-09  Alexey Proskuryakov  &lt;ap@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Geoff Garen.
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsGraphicsLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/GraphicsLayer.cpp (45675 => 45676)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/GraphicsLayer.cpp        2009-07-09 21:53:13 UTC (rev 45675)
+++ trunk/WebCore/platform/graphics/GraphicsLayer.cpp        2009-07-09 21:57:16 UTC (rev 45676)
</span><span class="lines">@@ -193,6 +193,7 @@
</span><span class="cx">     , m_masksToBounds(false)
</span><span class="cx">     , m_drawsContent(false)
</span><span class="cx">     , m_paintingPhase(GraphicsLayerPaintAllMask)
</span><ins>+    , m_contentsOrientation(CompositingCoordinatesTopDown)
</ins><span class="cx">     , m_parent(0)
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     , m_repaintCount(0)
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsGraphicsLayerh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/GraphicsLayer.h (45675 => 45676)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/GraphicsLayer.h        2009-07-09 21:53:13 UTC (rev 45675)
+++ trunk/WebCore/platform/graphics/GraphicsLayer.h        2009-07-09 21:57:16 UTC (rev 45676)
</span><span class="lines">@@ -297,6 +297,10 @@
</span><span class="cx">     virtual void setGeometryOrientation(CompositingCoordinatesOrientation) { }
</span><span class="cx">     virtual CompositingCoordinatesOrientation geometryOrientation() const { return CompositingCoordinatesTopDown; }
</span><span class="cx"> 
</span><ins>+    // Flippedness of the contents of this layer. Does not affect sublayer geometry.
+    virtual void setContentsOrientation(CompositingCoordinatesOrientation orientation) { m_contentsOrientation = orientation; }
+    virtual CompositingCoordinatesOrientation contentsOrientation() const { return m_contentsOrientation; }
+
</ins><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     static bool showDebugBorders();
</span><span class="cx">     static bool showRepaintCounter();
</span><span class="lines">@@ -352,6 +356,7 @@
</span><span class="cx">     bool m_drawsContent : 1;
</span><span class="cx"> 
</span><span class="cx">     GraphicsLayerPaintingPhase m_paintingPhase;
</span><ins>+    CompositingCoordinatesOrientation m_contentsOrientation;
</ins><span class="cx"> 
</span><span class="cx">     Vector&lt;GraphicsLayer*&gt; m_children;
</span><span class="cx">     GraphicsLayer* m_parent;
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsmacGraphicsLayerCAh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/mac/GraphicsLayerCA.h (45675 => 45676)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/mac/GraphicsLayerCA.h        2009-07-09 21:53:13 UTC (rev 45675)
+++ trunk/WebCore/platform/graphics/mac/GraphicsLayerCA.h        2009-07-09 21:57:16 UTC (rev 45676)
</span><span class="lines">@@ -120,6 +120,9 @@
</span><span class="cx">     bool requiresTiledLayer(const FloatSize&amp;) const;
</span><span class="cx">     void swapFromOrToTiledLayer(bool useTiledLayer);
</span><span class="cx"> 
</span><ins>+    CompositingCoordinatesOrientation defaultContentsOrientation() const;
+    void updateContentsTransform();
+    
</ins><span class="cx">     void setContentsLayer(WebLayer*);
</span><span class="cx">     WebLayer* contentsLayer() const { return m_contentsLayer.get(); }
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsmacGraphicsLayerCAmm"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/mac/GraphicsLayerCA.mm (45675 => 45676)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/mac/GraphicsLayerCA.mm        2009-07-09 21:53:13 UTC (rev 45675)
+++ trunk/WebCore/platform/graphics/mac/GraphicsLayerCA.mm        2009-07-09 21:57:16 UTC (rev 45676)
</span><span class="lines">@@ -213,6 +213,15 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if !HAVE_MODERN_QUARTZCORE
+static TransformationMatrix flipTransform()
+{
+    TransformationMatrix flipper;
+    flipper.flipY();
+    return flipper;
+}
+#endif
+
</ins><span class="cx"> static CAMediaTimingFunction* getCAMediaTimingFunction(const TimingFunction&amp; timingFunction)
</span><span class="cx"> {
</span><span class="cx">     switch (timingFunction.type()) {
</span><span class="lines">@@ -325,6 +334,10 @@
</span><span class="cx">     m_layer.adoptNS([[WebLayer alloc] init]);
</span><span class="cx">     [m_layer.get() setLayerOwner:this];
</span><span class="cx"> 
</span><ins>+#if !HAVE_MODERN_QUARTZCORE
+    setContentsOrientation(defaultContentsOrientation());
+#endif
+
</ins><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     updateDebugIndicators();
</span><span class="cx"> #endif
</span><span class="lines">@@ -543,9 +556,8 @@
</span><span class="cx"> 
</span><span class="cx">     if (m_transformLayer) {
</span><span class="cx">         [m_transformLayer.get() setBounds:rect];
</span><del>-    
-        // the anchor of the contents layer is always at 0.5, 0.5, so the position
-        // is center-relative
</del><ins>+        // The anchor of the contents layer is always at 0.5, 0.5, so the position
+        // is center-relative.
</ins><span class="cx">         [m_layer.get() setPosition:centerPoint];
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="lines">@@ -554,6 +566,7 @@
</span><span class="cx">         swapFromOrToTiledLayer(needTiledLayer);
</span><span class="cx">     
</span><span class="cx">     [m_layer.get() setBounds:rect];
</span><ins>+    updateContentsTransform();
</ins><span class="cx"> 
</span><span class="cx">     // Note that we don't resize m_contentsLayer. It's up the caller to do that.
</span><span class="cx"> 
</span><span class="lines">@@ -1163,11 +1176,19 @@
</span><span class="cx"> {
</span><span class="cx">     switch (orientation) {
</span><span class="cx">     case CompositingCoordinatesTopDown:
</span><ins>+#if HAVE_MODERN_QUARTZCORE
</ins><span class="cx">         [m_layer.get() setGeometryFlipped:NO];
</span><ins>+#else
+        setChildrenTransform(TransformationMatrix());
+#endif
</ins><span class="cx">         break;
</span><span class="cx">         
</span><span class="cx">     case CompositingCoordinatesBottomUp:
</span><ins>+#if HAVE_MODERN_QUARTZCORE
</ins><span class="cx">         [m_layer.get() setGeometryFlipped:YES];
</span><ins>+#else
+        setChildrenTransform(flipTransform());
+#endif
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -1175,7 +1196,13 @@
</span><span class="cx"> GraphicsLayerCA::CompositingCoordinatesOrientation GraphicsLayerCA::geometryOrientation() const
</span><span class="cx"> {
</span><span class="cx">     // CoreAnimation defaults to bottom-up
</span><del>-    return [m_layer.get() isGeometryFlipped] ? CompositingCoordinatesBottomUp : CompositingCoordinatesTopDown;
</del><ins>+    bool layerFlipped;
+#if HAVE_MODERN_QUARTZCORE
+    layerFlipped = [m_layer.get() isGeometryFlipped];
+#else
+    layerFlipped = childrenTransform().m22() == -1;
+#endif
+    return layerFlipped ? CompositingCoordinatesBottomUp : CompositingCoordinatesTopDown;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayerCA::setBasicAnimation(AnimatedPropertyID property, TransformOperation::OperationType operationType, short index, void* fromVal, void* toVal, bool isTransition, const Animation* transition, double beginTime)
</span><span class="lines">@@ -1465,6 +1492,15 @@
</span><span class="cx">             [tiledLayer setContentsGravity:@&quot;bottomLeft&quot;];
</span><span class="cx">         else
</span><span class="cx">             [tiledLayer setContentsGravity:@&quot;topLeft&quot;];
</span><ins>+
+#if !HAVE_MODERN_QUARTZCORE
+        // Tiled layer has issues with flipped coordinates.
+        setContentsOrientation(CompositingCoordinatesTopDown);
+#endif
+    } else {
+#if !HAVE_MODERN_QUARTZCORE
+        setContentsOrientation(defaultContentsOrientation());
+#endif
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     [m_layer.get() setLayerOwner:this];
</span><span class="lines">@@ -1483,6 +1519,7 @@
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     [m_layer.get() setZPosition:[oldLayer.get() zPosition]];
</span><span class="cx"> #endif
</span><ins>+    updateContentsTransform();
</ins><span class="cx">     
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     String name = String::format(&quot;CALayer(%p) GraphicsLayer(%p) &quot;, m_layer.get(), this) + m_name;
</span><span class="lines">@@ -1506,6 +1543,27 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GraphicsLayer::CompositingCoordinatesOrientation GraphicsLayerCA::defaultContentsOrientation() const
+{
+#if !HAVE_MODERN_QUARTZCORE
+    // Older QuartzCore does not support -geometryFlipped, so we manually flip the root
+    // layer geometry, and then flip the contents of each layer back so that the CTM for CG
+    // is unflipped, allowing it to do the correct font auto-hinting.
+    return CompositingCoordinatesBottomUp;
+#else
+    return CompositingCoordinatesTopDown;
+#endif
+}
+
+void GraphicsLayerCA::updateContentsTransform()
+{
+    if (contentsOrientation() == CompositingCoordinatesBottomUp) {
+        CGAffineTransform contentsTransform = CGAffineTransformMakeScale(1, -1);
+        contentsTransform = CGAffineTransformTranslate(contentsTransform, 0, -[m_layer.get() bounds].size.height);
+        [m_layer.get() setContentsTransform:contentsTransform];
+    }
+}
+
</ins><span class="cx"> void GraphicsLayerCA::setContentsLayer(WebLayer* contentsLayer)
</span><span class="cx"> {
</span><span class="cx">     if (contentsLayer == m_contentsLayer)
</span><span class="lines">@@ -1523,7 +1581,16 @@
</span><span class="cx">         [contentsLayer setStyle:[NSDictionary dictionaryWithObject:nullActionsDictionary() forKey:@&quot;actions&quot;]];
</span><span class="cx">         m_contentsLayer.adoptNS([contentsLayer retain]);
</span><span class="cx"> 
</span><del>-        [m_contentsLayer.get() setAnchorPoint:CGPointZero];
</del><ins>+        if (defaultContentsOrientation() == CompositingCoordinatesBottomUp) {
+            CATransform3D flipper = {
+                1.0f, 0.0f, 0.0f, 0.0f,
+                0.0f, -1.0f, 0.0f, 0.0f,
+                0.0f, 0.0f, 1.0f, 0.0f,
+                0.0f, 0.0f, 0.0f, 1.0f};
+            [m_contentsLayer.get() setTransform:flipper];
+            [m_contentsLayer.get() setAnchorPoint:CGPointMake(0.0f, 1.0f)];
+        } else
+            [m_contentsLayer.get() setAnchorPoint:CGPointZero];
</ins><span class="cx"> 
</span><span class="cx">         // Insert the content layer first. Video elements require this, because they have
</span><span class="cx">         // shadow content that must display in front of the video.
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsmacWebLayerh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/mac/WebLayer.h (45675 => 45676)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/mac/WebLayer.h        2009-07-09 21:53:13 UTC (rev 45675)
+++ trunk/WebCore/platform/graphics/mac/WebLayer.h        2009-07-09 21:57:16 UTC (rev 45676)
</span><span class="lines">@@ -42,6 +42,13 @@
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+#if defined(BUILDING_ON_LEOPARD)
+@interface CALayer(WebLayerInternal)
+- (CGAffineTransform)contentsTransform;
+- (void)setContentsTransform:(CGAffineTransform)t;
+@end
+#endif
+
</ins><span class="cx"> @interface WebLayer : CALayer 
</span><span class="cx"> {
</span><span class="cx">     WebCore::GraphicsLayer* m_layerOwner;
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsmacWebLayermm"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/mac/WebLayer.mm (45675 => 45676)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/mac/WebLayer.mm        2009-07-09 21:53:13 UTC (rev 45675)
+++ trunk/WebCore/platform/graphics/mac/WebLayer.mm        2009-07-09 21:57:16 UTC (rev 45676)
</span><span class="lines">@@ -40,10 +40,18 @@
</span><span class="cx"> 
</span><span class="cx"> + (void)drawContents:(WebCore::GraphicsLayer*)layerContents ofLayer:(CALayer*)layer intoContext:(CGContextRef)context
</span><span class="cx"> {
</span><del>-    UNUSED_PARAM(layer);
</del><ins>+    if (!layerContents)
+        return;
+
</ins><span class="cx">     CGContextSaveGState(context);
</span><del>-    
-    if (layerContents &amp;&amp; layerContents-&gt;client()) {
</del><ins>+
+    CGRect layerBounds = [layer bounds];
+    if (layerContents-&gt;contentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp) {
+        CGContextScaleCTM(context, 1, -1);
+        CGContextTranslateCTM(context, 0, -layerBounds.size.height);
+    }
+
+    if (layerContents-&gt;client()) {
</ins><span class="cx">         [NSGraphicsContext saveGraphicsState];
</span><span class="cx"> 
</span><span class="cx">         // Set up an NSGraphicsContext for the context, so that parts of AppKit that rely on
</span><span class="lines">@@ -68,29 +76,24 @@
</span><span class="cx">         // FIXME: ideally we'd avoid calling -setNeedsDisplay on a layer that is a plain color,
</span><span class="cx">         // so CA never makes backing store for it (which is what -setNeedsDisplay will do above).
</span><span class="cx">         CGContextSetRGBFillColor(context, 0.0f, 1.0f, 0.0f, 1.0f);
</span><del>-        CGRect aBounds = [layer bounds];
-        CGContextFillRect(context, aBounds);
</del><ins>+        CGContextFillRect(context, layerBounds);
</ins><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    CGContextRestoreGState(context);
-
</del><span class="cx"> #ifndef NDEBUG
</span><del>-    if (layerContents &amp;&amp; layerContents-&gt;showRepaintCounter()) {
</del><ins>+    if (layerContents-&gt;showRepaintCounter()) {
</ins><span class="cx">         bool isTiledLayer = [layer isKindOfClass:[CATiledLayer class]];
</span><span class="cx"> 
</span><span class="cx">         char text[16]; // that's a lot of repaints
</span><span class="cx">         snprintf(text, sizeof(text), &quot;%d&quot;, layerContents-&gt;incrementRepaintCount());
</span><span class="cx"> 
</span><del>-        CGAffineTransform a = CGContextGetCTM(context);
-        
</del><span class="cx">         CGContextSaveGState(context);
</span><span class="cx">         if (isTiledLayer)
</span><span class="cx">             CGContextSetRGBFillColor(context, 0.0f, 1.0f, 0.0f, 0.8f);
</span><span class="cx">         else
</span><span class="cx">             CGContextSetRGBFillColor(context, 1.0f, 0.0f, 0.0f, 0.8f);
</span><span class="cx">         
</span><del>-        CGRect aBounds = [layer bounds];
</del><ins>+        CGRect aBounds = layerBounds;
</ins><span class="cx"> 
</span><span class="cx">         aBounds.size.width = 10 + 12 * strlen(text);
</span><span class="cx">         aBounds.size.height = 25;
</span><span class="lines">@@ -105,6 +108,8 @@
</span><span class="cx">         CGContextRestoreGState(context);        
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><ins>+
+    CGContextRestoreGState(context);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Disable default animations
</span><span class="lines">@@ -132,12 +137,13 @@
</span><span class="cx"> - (void)setNeedsDisplayInRect:(CGRect)dirtyRect
</span><span class="cx"> {
</span><span class="cx">     if (m_layerOwner &amp;&amp; m_layerOwner-&gt;client() &amp;&amp; m_layerOwner-&gt;drawsContent()) {
</span><del>-        [super setNeedsDisplayInRect:dirtyRect];
</del><ins>+        [super setNeedsDisplayInRect:CGRectApplyAffineTransform(dirtyRect, [self contentsTransform])];
</ins><span class="cx"> 
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">         if (m_layerOwner-&gt;showRepaintCounter()) {
</span><span class="cx">             CGRect bounds = [self bounds];
</span><del>-            [super setNeedsDisplayInRect:CGRectMake(bounds.origin.x, bounds.origin.y, 46, 25)];
</del><ins>+            CGRect indicatorRect = CGRectMake(bounds.origin.x, bounds.origin.y, 46, 25);
+            [super setNeedsDisplayInRect:CGRectApplyAffineTransform(indicatorRect, [self contentsTransform])];
</ins><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsmacWebTiledLayermm"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/mac/WebTiledLayer.mm (45675 => 45676)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/mac/WebTiledLayer.mm        2009-07-09 21:53:13 UTC (rev 45675)
+++ trunk/WebCore/platform/graphics/mac/WebTiledLayer.mm        2009-07-09 21:57:16 UTC (rev 45676)
</span><span class="lines">@@ -74,12 +74,13 @@
</span><span class="cx"> - (void)setNeedsDisplayInRect:(CGRect)dirtyRect
</span><span class="cx"> {
</span><span class="cx">     if (m_layerOwner &amp;&amp; m_layerOwner-&gt;client() &amp;&amp; m_layerOwner-&gt;drawsContent()) {
</span><del>-        [super setNeedsDisplayInRect:dirtyRect];
</del><ins>+        [super setNeedsDisplayInRect:CGRectApplyAffineTransform(dirtyRect, [self contentsTransform])];
</ins><span class="cx"> 
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">         if (m_layerOwner-&gt;showRepaintCounter()) {
</span><span class="cx">             CGRect bounds = [self bounds];
</span><del>-            [super setNeedsDisplayInRect:CGRectMake(bounds.origin.x, bounds.origin.y, 46, 25)];
</del><ins>+            CGRect indicatorRect = CGRectMake(bounds.origin.x, bounds.origin.y, 46, 25);
+            [super setNeedsDisplayInRect:CGRectApplyAffineTransform(indicatorRect, [self contentsTransform])];
</ins><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="cx">     }
</span></span></pre>
</div>
</div>

</body>
</html>