Title: [198599] trunk/Source/WebCore
Revision
198599
Author
[email protected]
Date
2016-03-23 15:27:42 -0700 (Wed, 23 Mar 2016)

Log Message

Change the paint count indicator to indicate whether a layer is opaque
https://bugs.webkit.org/show_bug.cgi?id=155810

Reviewed by Tim Horton.

In non-opaque layers, give the paint count indicator a diagonal top left corner. Being
able to see layer opaqueness helps diagnose bugs.

Also use CGContextStateSaver, and move the indicator in by a pixel to overlap less
with the layer border.

* platform/graphics/ca/PlatformCALayer.cpp:
(WebCore::PlatformCALayer::drawRepaintIndicator):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (198598 => 198599)


--- trunk/Source/WebCore/ChangeLog	2016-03-23 21:55:55 UTC (rev 198598)
+++ trunk/Source/WebCore/ChangeLog	2016-03-23 22:27:42 UTC (rev 198599)
@@ -1,3 +1,19 @@
+2016-03-23  Simon Fraser  <[email protected]>
+
+        Change the paint count indicator to indicate whether a layer is opaque
+        https://bugs.webkit.org/show_bug.cgi?id=155810
+
+        Reviewed by Tim Horton.
+
+        In non-opaque layers, give the paint count indicator a diagonal top left corner. Being
+        able to see layer opaqueness helps diagnose bugs.
+        
+        Also use CGContextStateSaver, and move the indicator in by a pixel to overlap less
+        with the layer border.
+
+        * platform/graphics/ca/PlatformCALayer.cpp:
+        (WebCore::PlatformCALayer::drawRepaintIndicator):
+
 2016-03-23  Zalan Bujtas  <[email protected]>
 
         ASSERTION FAILED: y2 >= y1 in WebCore::RenderElement::drawLineForBoxSide

Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp (198598 => 198599)


--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp	2016-03-23 21:55:55 UTC (rev 198598)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp	2016-03-23 22:27:42 UTC (rev 198599)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "PlatformCALayer.h"
 
+#include "GraphicsContextCG.h"
 #include "LayerPool.h"
 #include "PlatformCALayerClient.h"
 #include "TextStream.h"
@@ -64,12 +65,11 @@
     char text[16]; // that's a lot of repaints
     snprintf(text, sizeof(text), "%d", repaintCount);
     
-    CGRect indicatorBox = platformCALayer->bounds();
+    FloatRect indicatorBox = platformCALayer->bounds();\
+    indicatorBox.setLocation( { 1, 1 } );
+    indicatorBox.setSize(FloatSize(12 + 10 * strlen(text), 27));
 
-    CGContextSaveGState(context);
-
-    indicatorBox.size.width = 12 + 10 * strlen(text);
-    indicatorBox.size.height = 27;
+    CGContextStateSaver stateSaver(context);
     
     CGContextSetAlpha(context, 0.5f);
     CGContextBeginTransparencyLayerWithRect(context, indicatorBox, 0);
@@ -79,23 +79,37 @@
     else
         CGContextSetRGBFillColor(context, 0, 0.5f, 0.25f, 1);
     
-    CGContextFillRect(context, indicatorBox);
-    
-    if (platformCALayer->acceleratesDrawing())
-        CGContextSetRGBFillColor(context, 1, 0, 0, 1);
-    else
-        CGContextSetRGBFillColor(context, 1, 1, 1, 1);
+    if (platformCALayer->isOpaque())
+        CGContextFillRect(context, indicatorBox);
+    else {
+        Path boundsPath;
+        boundsPath.moveTo(indicatorBox.maxXMinYCorner());
+        boundsPath.addLineTo(indicatorBox.maxXMaxYCorner());
+        boundsPath.addLineTo(indicatorBox.minXMaxYCorner());
 
+        const float cornerChunk = 8;
+        boundsPath.addLineTo(FloatPoint(indicatorBox.x(), indicatorBox.y() + cornerChunk));
+        boundsPath.addLineTo(FloatPoint(indicatorBox.x() + cornerChunk, indicatorBox.y()));
+        boundsPath.closeSubpath();
+
+        CGContextAddPath(context, boundsPath.platformPath());
+        CGContextFillPath(context);
+    }
+
     if (platformCALayer->owner()->isUsingDisplayListDrawing(platformCALayer)) {
         CGContextSetRGBStrokeColor(context, 0, 0, 0, 0.65);
         CGContextSetLineWidth(context, 2);
         CGContextStrokeRect(context, indicatorBox);
     }
+
+    if (platformCALayer->acceleratesDrawing())
+        CGContextSetRGBFillColor(context, 1, 0, 0, 1);
+    else
+        CGContextSetRGBFillColor(context, 1, 1, 1, 1);
     
-    platformCALayer->drawTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, CGSizeMake(1, -1), 22, text, strlen(text));
+    platformCALayer->drawTextAtPoint(context, indicatorBox.x() + 5, indicatorBox.y() + 22, CGSizeMake(1, -1), 22, text, strlen(text));
     
     CGContextEndTransparencyLayer(context);
-    CGContextRestoreGState(context);
 }
 
 void PlatformCALayer::flipContext(CGContextRef context, CGFloat height)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to