[Webkit-unassigned] [Bug 197774] New: Make a utility class to detect GraphicsContext mismatched save/restore

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri May 10 08:34:35 PDT 2019


https://bugs.webkit.org/show_bug.cgi?id=197774

            Bug ID: 197774
           Summary: Make a utility class to detect GraphicsContext
                    mismatched save/restore
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Tools / Tests
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: simon.fraser at apple.com
                CC: lforschler at apple.com

This might be useful for debugging:

diff --git a/Source/WebCore/platform/graphics/GraphicsContext.h b/Source/WebCore/platform/graphics/GraphicsContext.h
index 1c366d51cbd74d0bcedec5790df2ed71aacc7a96..964598b4a414ca808bdcac7b019cae8b32a35ee8 100644
--- a/Source/WebCore/platform/graphics/GraphicsContext.h
+++ b/Source/WebCore/platform/graphics/GraphicsContext.h
@@ -348,6 +348,8 @@ public:

     WEBCORE_EXPORT void save();
     WEBCORE_EXPORT void restore();
+    
+    unsigned stackSize() const { return m_stack.size(); }

     // These draw methods will do both stroking and filling.
     // FIXME: ...except drawRect(), which fills properly but always strokes
@@ -686,6 +688,27 @@ private:
     bool m_saveAndRestore;
 };

+
+class GraphicsContextStateStackChecker {
+public:
+    GraphicsContextStateStackChecker(GraphicsContext& context)
+        : m_context(context)
+        , m_stackSize(context.stackSize())
+    { }
+    
+    ~GraphicsContextStateStackChecker()
+    {
+        if (m_context.stackSize() != m_stackSize)
+            WTFLogAlways("GraphicsContext %p stack changed by %d", this, (int)m_context.stackSize() - (int)m_stackSize);
+    }
+
+private:
+    GraphicsContext& m_context;
+    unsigned m_stackSize;
+};
+
+
+
 class InterpolationQualityMaintainer {
 public:
     explicit InterpolationQualityMaintainer(GraphicsContext& graphicsContext, InterpolationQuality interpolationQualityToUse)

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20190510/d930cab6/attachment.html>


More information about the webkit-unassigned mailing list