<!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>[202394] trunk/Source</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/202394">202394</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-06-23 13:05:23 -0700 (Thu, 23 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Memory Timeline sometimes shows impossible value for bmalloc size (underflowed)
https://bugs.webkit.org/show_bug.cgi?id=158110
&lt;rdar://problem/26498584&gt;

Patch by Joseph Pecoraro &lt;pecoraro@apple.com&gt; on 2016-06-23
Reviewed by Andreas Kling.

Source/JavaScriptCore:

* heap/Heap.cpp:
(JSC::Heap::willStartCollection):
(JSC::Heap::didFinishCollection):
* heap/Heap.h:
(JSC::Heap::externalMemorySize):
* heap/HeapInlines.h:
(JSC::Heap::reportExternalMemoryVisited):
Keep count of external memory we visit.

* heap/SlotVisitor.h:
* heap/SlotVisitorInlines.h:
(JSC::SlotVisitor::reportExternalMemoryVisited):
Report external memory visited like we do extra memory, since
it will be some subset of extra memory that is external.

Source/WebCore:

IOSurface memory backing Canvas element buffers should be classified as &quot;GC Owned&quot;,
but should not be considered a part of bmalloc. In fact, the actual memory cost is
external to the Web Content Process. The majority of extra memory reporters tend
to report extra memory that is also allocated in bmalloc. However, some report
non-bmalloc memory, such as the IOSurfaces here.

Continue to report the memory cost without changes to inform the Heap for garbage
collection. However, also keep better accounting of GCOwned memory that is external
to the process for better accounting for the Resource Usage overlay and Web Inspector
Memory timeline.

This is a bit of a game where we want to display the best possible number for
&quot;GCOwned memory&quot; in the tools, but some of that memory shows up in the other
regions (bmalloc, system malloc, etc). Already many sizes are estimates
(ReportExtraMemory, reportExtraMemory ignores small allocations), so we just focus
on getting the largest sources of allocations, such as Canvas IOSurfaces here,
into the right bucket. ResourceUsageThreadCocoa continues to subtract the &quot;extra&quot;
memory from bmalloc. So, we should address other large sources of &quot;extra memory&quot;
not in bmalloc. A likely candidate is HTMLMediaElement which uses the deprecated
reporting right now.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
* bindings/scripts/IDLAttributes.txt:
Add a way to report External memory, dependent on reporting Extra memory.

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::externalMemoryCost):
* html/HTMLCanvasElement.h:
* html/HTMLCanvasElement.idl:
Report external memory cost just like extra memory.

* page/ResourceUsageData.cpp:
(WebCore::ResourceUsageData::ResourceUsageData):
* page/ResourceUsageData.h:
(WebCore::MemoryCategoryInfo::totalSize):
* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::RingBuffer::at):
(WebCore::appendDataToHistory):
(WebCore::ResourceUsageOverlay::platformDraw):
* page/cocoa/ResourceUsageThreadCocoa.mm:
(WebCore::categoryForVMTag):
(WebCore::ResourceUsageThread::platformThreadBody):
Do not count the GCOwned External memory as dirty memory.
Include External memory output in the overlay.

* inspector/InspectorMemoryAgent.cpp:
(WebCore::InspectorMemoryAgent::collectSample):
When sizing the JavaScript portion, include both the GC Owned
category's dirty and external memory. Ultimately we will
want this everywhere in case things change.

* platform/graphics/ImageBuffer.cpp:
(WebCore::memoryCost):
(WebCore::externalMemoryCost):
* platform/graphics/ImageBuffer.h:
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::memoryCost):
(WebCore::ImageBuffer::externalMemoryCost):
Report IOSurface total bytes as extra memory and external memory
so that it can be tracked as GC Owned memory that is separate from
regular (bmalloc/other) in process memory.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapHeapcpp">trunk/Source/JavaScriptCore/heap/Heap.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapHeaph">trunk/Source/JavaScriptCore/heap/Heap.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapHeapInlinesh">trunk/Source/JavaScriptCore/heap/HeapInlines.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapSlotVisitorh">trunk/Source/JavaScriptCore/heap/SlotVisitor.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapSlotVisitorInlinesh">trunk/Source/JavaScriptCore/heap/SlotVisitorInlines.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsIDLAttributestxt">trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLCanvasElementcpp">trunk/Source/WebCore/html/HTMLCanvasElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLCanvasElementh">trunk/Source/WebCore/html/HTMLCanvasElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLCanvasElementidl">trunk/Source/WebCore/html/HTMLCanvasElement.idl</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorMemoryAgentcpp">trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp</a></li>
<li><a href="#trunkSourceWebCorepageResourceUsageDatacpp">trunk/Source/WebCore/page/ResourceUsageData.cpp</a></li>
<li><a href="#trunkSourceWebCorepageResourceUsageDatah">trunk/Source/WebCore/page/ResourceUsageData.h</a></li>
<li><a href="#trunkSourceWebCorepagecocoaResourceUsageOverlayCocoamm">trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm</a></li>
<li><a href="#trunkSourceWebCorepagecocoaResourceUsageThreadCocoamm">trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm</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="#trunkSourceWebCoreplatformgraphicscgImageBufferCGcpp">trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaIOSurfaceh">trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -1,5 +1,28 @@
</span><span class="cx"> 2016-06-23  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Web Inspector: Memory Timeline sometimes shows impossible value for bmalloc size (underflowed)
+        https://bugs.webkit.org/show_bug.cgi?id=158110
+        &lt;rdar://problem/26498584&gt;
+
+        Reviewed by Andreas Kling.
+
+        * heap/Heap.cpp:
+        (JSC::Heap::willStartCollection):
+        (JSC::Heap::didFinishCollection):
+        * heap/Heap.h:
+        (JSC::Heap::externalMemorySize):
+        * heap/HeapInlines.h:
+        (JSC::Heap::reportExternalMemoryVisited):
+        Keep count of external memory we visit.
+
+        * heap/SlotVisitor.h:
+        * heap/SlotVisitorInlines.h:
+        (JSC::SlotVisitor::reportExternalMemoryVisited):
+        Report external memory visited like we do extra memory, since
+        it will be some subset of extra memory that is external.
+
+2016-06-23  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
</ins><span class="cx">         Web Inspector: Snapshots should be cleared at some point
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=157907
</span><span class="cx">         &lt;rdar://problem/26373610&gt;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapHeapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/Heap.cpp (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/Heap.cpp        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/JavaScriptCore/heap/Heap.cpp        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -1240,6 +1240,9 @@
</span><span class="cx">         m_sizeBeforeLastFullCollect = m_sizeAfterLastCollect + m_bytesAllocatedThisCycle;
</span><span class="cx">         m_extraMemorySize = 0;
</span><span class="cx">         m_deprecatedExtraMemorySize = 0;
</span><ins>+#if ENABLE(RESOURCE_USAGE)
+        m_externalMemorySize = 0;
+#endif
</ins><span class="cx"> 
</span><span class="cx">         if (m_fullActivityCallback)
</span><span class="cx">             m_fullActivityCallback-&gt;willCollect();
</span><span class="lines">@@ -1452,6 +1455,10 @@
</span><span class="cx">     else
</span><span class="cx">         m_lastEdenGCLength = gcEndTime - gcStartTime;
</span><span class="cx"> 
</span><ins>+#if ENABLE(RESOURCE_USAGE)
+    ASSERT(externalMemorySize() &lt;= extraMemorySize());
+#endif
+
</ins><span class="cx">     if (Options::recordGCPauseTimes())
</span><span class="cx">         HeapStatistics::recordGCPauseTime(gcStartTime, gcEndTime);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapHeaph"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/Heap.h (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/Heap.h        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/JavaScriptCore/heap/Heap.h        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -179,6 +179,12 @@
</span><span class="cx">     void reportExtraMemoryAllocated(size_t);
</span><span class="cx">     void reportExtraMemoryVisited(CellState cellStateBeforeVisiting, size_t);
</span><span class="cx"> 
</span><ins>+#if ENABLE(RESOURCE_USAGE)
+    // Use this API to report the subset of extra memory that lives outside this process.
+    void reportExternalMemoryVisited(CellState cellStateBeforeVisiting, size_t);
+    size_t externalMemorySize() { return m_extraMemorySize; }
+#endif
+
</ins><span class="cx">     // Use this API to report non-GC memory if you can't use the better API above.
</span><span class="cx">     void deprecatedReportExtraMemory(size_t);
</span><span class="cx"> 
</span><span class="lines">@@ -462,6 +468,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(RESOURCE_USAGE)
</span><span class="cx">     size_t m_blockBytesAllocated { 0 };
</span><ins>+    size_t m_externalMemorySize { 0 };
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapHeapInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/HeapInlines.h (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/HeapInlines.h        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/JavaScriptCore/heap/HeapInlines.h        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -141,6 +141,23 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(RESOURCE_USAGE)
+inline void Heap::reportExternalMemoryVisited(CellState dataBeforeVisiting, size_t size)
+{
+    // We don't want to double-count the external memory that was reported in previous collections.
+    if (operationInProgress() == EdenCollection &amp;&amp; dataBeforeVisiting == CellState::OldGrey)
+        return;
+
+    size_t* counter = &amp;m_externalMemorySize;
+
+    for (;;) {
+        size_t oldSize = *counter;
+        if (WTF::weakCompareAndSwap(counter, oldSize, oldSize + size))
+            return;
+    }
+}
+#endif
+
</ins><span class="cx"> inline void Heap::deprecatedReportExtraMemory(size_t size)
</span><span class="cx"> {
</span><span class="cx">     if (size &gt; minExtraMemory) 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapSlotVisitorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/SlotVisitor.h (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/SlotVisitor.h        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/JavaScriptCore/heap/SlotVisitor.h        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -109,6 +109,9 @@
</span><span class="cx">     void copyLater(JSCell*, CopyToken, void*, size_t);
</span><span class="cx">     
</span><span class="cx">     void reportExtraMemoryVisited(size_t);
</span><ins>+#if ENABLE(RESOURCE_USAGE)
+    void reportExternalMemoryVisited(size_t);
+#endif
</ins><span class="cx">     
</span><span class="cx">     void addWeakReferenceHarvester(WeakReferenceHarvester*);
</span><span class="cx">     void addUnconditionalFinalizer(UnconditionalFinalizer*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapSlotVisitorInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/SlotVisitorInlines.h (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/SlotVisitorInlines.h        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/JavaScriptCore/heap/SlotVisitorInlines.h        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -109,6 +109,13 @@
</span><span class="cx">     heap()-&gt;reportExtraMemoryVisited(m_currentObjectCellStateBeforeVisiting, size);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(RESOURCE_USAGE)
+inline void SlotVisitor::reportExternalMemoryVisited(size_t size)
+{
+    heap()-&gt;reportExternalMemoryVisited(m_currentObjectCellStateBeforeVisiting, size);
+}
+#endif
+
</ins><span class="cx"> inline Heap* SlotVisitor::heap() const
</span><span class="cx"> {
</span><span class="cx">     return &amp;m_heap;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/ChangeLog        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -1,3 +1,74 @@
</span><ins>+2016-06-23  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: Memory Timeline sometimes shows impossible value for bmalloc size (underflowed)
+        https://bugs.webkit.org/show_bug.cgi?id=158110
+        &lt;rdar://problem/26498584&gt;
+
+        Reviewed by Andreas Kling.
+
+        IOSurface memory backing Canvas element buffers should be classified as &quot;GC Owned&quot;,
+        but should not be considered a part of bmalloc. In fact, the actual memory cost is
+        external to the Web Content Process. The majority of extra memory reporters tend
+        to report extra memory that is also allocated in bmalloc. However, some report
+        non-bmalloc memory, such as the IOSurfaces here.
+        
+        Continue to report the memory cost without changes to inform the Heap for garbage
+        collection. However, also keep better accounting of GCOwned memory that is external
+        to the process for better accounting for the Resource Usage overlay and Web Inspector
+        Memory timeline.
+        
+        This is a bit of a game where we want to display the best possible number for
+        &quot;GCOwned memory&quot; in the tools, but some of that memory shows up in the other
+        regions (bmalloc, system malloc, etc). Already many sizes are estimates
+        (ReportExtraMemory, reportExtraMemory ignores small allocations), so we just focus
+        on getting the largest sources of allocations, such as Canvas IOSurfaces here,
+        into the right bucket. ResourceUsageThreadCocoa continues to subtract the &quot;extra&quot;
+        memory from bmalloc. So, we should address other large sources of &quot;extra memory&quot;
+        not in bmalloc. A likely candidate is HTMLMediaElement which uses the deprecated
+        reporting right now.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation):
+        * bindings/scripts/IDLAttributes.txt:
+        Add a way to report External memory, dependent on reporting Extra memory.
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::externalMemoryCost):
+        * html/HTMLCanvasElement.h:
+        * html/HTMLCanvasElement.idl:
+        Report external memory cost just like extra memory.
+
+        * page/ResourceUsageData.cpp:
+        (WebCore::ResourceUsageData::ResourceUsageData):
+        * page/ResourceUsageData.h:
+        (WebCore::MemoryCategoryInfo::totalSize):
+        * page/cocoa/ResourceUsageOverlayCocoa.mm:
+        (WebCore::RingBuffer::at):
+        (WebCore::appendDataToHistory):
+        (WebCore::ResourceUsageOverlay::platformDraw):
+        * page/cocoa/ResourceUsageThreadCocoa.mm:
+        (WebCore::categoryForVMTag):
+        (WebCore::ResourceUsageThread::platformThreadBody):
+        Do not count the GCOwned External memory as dirty memory.
+        Include External memory output in the overlay.
+
+        * inspector/InspectorMemoryAgent.cpp:
+        (WebCore::InspectorMemoryAgent::collectSample):
+        When sizing the JavaScript portion, include both the GC Owned
+        category's dirty and external memory. Ultimately we will
+        want this everywhere in case things change.
+
+        * platform/graphics/ImageBuffer.cpp:
+        (WebCore::memoryCost):
+        (WebCore::externalMemoryCost):
+        * platform/graphics/ImageBuffer.h:
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::ImageBuffer::memoryCost):
+        (WebCore::ImageBuffer::externalMemoryCost):
+        Report IOSurface total bytes as extra memory and external memory
+        so that it can be tracked as GC Owned memory that is separate from
+        regular (bmalloc/other) in process memory.
+
</ins><span class="cx"> 2016-06-23  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Handle (0, 0) ranges from Lookup
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -3245,6 +3245,11 @@
</span><span class="cx">         push(@implContent, &quot;    thisObject-&gt;visitAdditionalChildren(visitor);\n&quot;) if $interface-&gt;extendedAttributes-&gt;{&quot;JSCustomMarkFunction&quot;};
</span><span class="cx">         if ($interface-&gt;extendedAttributes-&gt;{&quot;ReportExtraMemoryCost&quot;}) {
</span><span class="cx">             push(@implContent, &quot;    visitor.reportExtraMemoryVisited(thisObject-&gt;wrapped().memoryCost());\n&quot;);
</span><ins>+            if ($interface-&gt;extendedAttributes-&gt;{&quot;ReportExternalMemoryCost&quot;}) {;
+                push(@implContent, &quot;#if ENABLE(RESOURCE_USAGE)\n&quot;);
+                push(@implContent, &quot;    visitor.reportExternalMemoryVisited(thisObject-&gt;wrapped().externalMemoryCost());\n&quot;);
+                push(@implContent, &quot;#endif\n&quot;);
+            }
</ins><span class="cx">         }
</span><span class="cx">         if ($numCachedAttributes &gt; 0) {
</span><span class="cx">             foreach (@{$interface-&gt;attributes}) {
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsIDLAttributestxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -114,6 +114,7 @@
</span><span class="cx"> Reflect=*
</span><span class="cx"> Replaceable
</span><span class="cx"> ReportExtraMemoryCost
</span><ins>+ReportExternalMemoryCost
</ins><span class="cx"> RequiresExistingAtomicString
</span><span class="cx"> SetterRaisesException
</span><span class="cx"> SetterRaisesExceptionWithMessage
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLCanvasElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -589,6 +589,13 @@
</span><span class="cx">     return 4 * m_imageBuffer-&gt;internalSize().width() * m_imageBuffer-&gt;internalSize().height();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+size_t HTMLCanvasElement::externalMemoryCost() const
+{
+    if (!m_imageBuffer)
+        return 0;
+    return 4 * m_imageBuffer-&gt;internalSize().width() * m_imageBuffer-&gt;internalSize().height();
+}
+
</ins><span class="cx"> void HTMLCanvasElement::setUsesDisplayListDrawing(bool usesDisplayListDrawing)
</span><span class="cx"> {
</span><span class="cx">     if (usesDisplayListDrawing == m_usesDisplayListDrawing)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLCanvasElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLCanvasElement.h (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLCanvasElement.h        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.h        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -136,6 +136,7 @@
</span><span class="cx">     WEBCORE_EXPORT String replayDisplayListAsText(DisplayList::AsTextFlags) const;
</span><span class="cx"> 
</span><span class="cx">     size_t memoryCost() const;
</span><ins>+    size_t externalMemoryCost() const;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     HTMLCanvasElement(const QualifiedName&amp;, Document&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLCanvasElementidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLCanvasElement.idl (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLCanvasElement.idl        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.idl        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -26,7 +26,8 @@
</span><span class="cx"> 
</span><span class="cx"> [
</span><span class="cx">     JSGenerateToNativeObject,
</span><del>-    ReportExtraMemoryCost
</del><ins>+    ReportExtraMemoryCost,
+    ReportExternalMemoryCost,
</ins><span class="cx"> ] interface HTMLCanvasElement : HTMLElement {
</span><span class="cx"> #if defined(LANGUAGE_OBJECTIVE_C) &amp;&amp; LANGUAGE_OBJECTIVE_C || defined(LANGUAGE_GOBJECT) &amp;&amp; LANGUAGE_GOBJECT
</span><span class="cx">     attribute long width;
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorMemoryAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -107,32 +107,32 @@
</span><span class="cx"> {
</span><span class="cx">     auto javascriptCategory = Protocol::Memory::CategoryData::create()
</span><span class="cx">         .setType(Protocol::Memory::CategoryData::Type::Javascript)
</span><del>-        .setSize(data.categories[MemoryCategory::GCHeap].dirtySize + data.categories[MemoryCategory::GCOwned].dirtySize)
</del><ins>+        .setSize(data.categories[MemoryCategory::GCHeap].totalSize() + data.categories[MemoryCategory::GCOwned].totalSize())
</ins><span class="cx">         .release();
</span><span class="cx"> 
</span><span class="cx">     auto jitCategory = Protocol::Memory::CategoryData::create()
</span><span class="cx">         .setType(Protocol::Memory::CategoryData::Type::JIT)
</span><del>-        .setSize(data.categories[MemoryCategory::JSJIT].dirtySize)
</del><ins>+        .setSize(data.categories[MemoryCategory::JSJIT].totalSize())
</ins><span class="cx">         .release();
</span><span class="cx"> 
</span><span class="cx">     auto imagesCategory = Protocol::Memory::CategoryData::create()
</span><span class="cx">         .setType(Protocol::Memory::CategoryData::Type::Images)
</span><del>-        .setSize(data.categories[MemoryCategory::Images].dirtySize)
</del><ins>+        .setSize(data.categories[MemoryCategory::Images].totalSize())
</ins><span class="cx">         .release();
</span><span class="cx"> 
</span><span class="cx">     auto layersCategory = Protocol::Memory::CategoryData::create()
</span><span class="cx">         .setType(Protocol::Memory::CategoryData::Type::Layers)
</span><del>-        .setSize(data.categories[MemoryCategory::Layers].dirtySize)
</del><ins>+        .setSize(data.categories[MemoryCategory::Layers].totalSize())
</ins><span class="cx">         .release();
</span><span class="cx"> 
</span><span class="cx">     auto pageCategory = Protocol::Memory::CategoryData::create()
</span><span class="cx">         .setType(Protocol::Memory::CategoryData::Type::Page)
</span><del>-        .setSize(data.categories[MemoryCategory::bmalloc].dirtySize + data.categories[MemoryCategory::LibcMalloc].dirtySize)
</del><ins>+        .setSize(data.categories[MemoryCategory::bmalloc].totalSize() + data.categories[MemoryCategory::LibcMalloc].totalSize())
</ins><span class="cx">         .release();
</span><span class="cx"> 
</span><span class="cx">     auto otherCategory = Protocol::Memory::CategoryData::create()
</span><span class="cx">         .setType(Protocol::Memory::CategoryData::Type::Other)
</span><del>-        .setSize(data.categories[MemoryCategory::Other].dirtySize)
</del><ins>+        .setSize(data.categories[MemoryCategory::Other].totalSize())
</ins><span class="cx">         .release();
</span><span class="cx"> 
</span><span class="cx">     auto categories = Protocol::Array&lt;Protocol::Memory::CategoryData&gt;::create();
</span></span></pre></div>
<a id="trunkSourceWebCorepageResourceUsageDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ResourceUsageData.cpp (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ResourceUsageData.cpp        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/page/ResourceUsageData.cpp        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx"> ResourceUsageData::ResourceUsageData(const ResourceUsageData&amp; other)
</span><span class="cx">     : cpu(other.cpu)
</span><span class="cx">     , totalDirtySize(other.totalDirtySize)
</span><ins>+    , totalExternalSize(other.totalExternalSize)
</ins><span class="cx">     , timeOfNextEdenCollection(other.timeOfNextEdenCollection)
</span><span class="cx">     , timeOfNextFullCollection(other.timeOfNextFullCollection)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorepageResourceUsageDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ResourceUsageData.h (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ResourceUsageData.h        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/page/ResourceUsageData.h        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -52,8 +52,11 @@
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    size_t totalSize() const { return dirtySize + externalSize; }
+
</ins><span class="cx">     size_t dirtySize { 0 };
</span><span class="cx">     size_t reclaimableSize { 0 };
</span><ins>+    size_t externalSize { 0 };
</ins><span class="cx">     bool isSubcategory { false };
</span><span class="cx">     unsigned type { MemoryCategory::NumberOfCategories };
</span><span class="cx"> };
</span><span class="lines">@@ -64,6 +67,7 @@
</span><span class="cx"> 
</span><span class="cx">     float cpu { 0 };
</span><span class="cx">     size_t totalDirtySize { 0 };
</span><ins>+    size_t totalExternalSize { 0 };
</ins><span class="cx">     std::array&lt;MemoryCategoryInfo, MemoryCategory::NumberOfCategories&gt; categories;
</span><span class="cx">     double timeOfNextEdenCollection { 0 };
</span><span class="cx">     double timeOfNextFullCollection { 0 };
</span></span></pre></div>
<a id="trunkSourceWebCorepagecocoaResourceUsageOverlayCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -138,6 +138,7 @@
</span><span class="cx">     RetainPtr&lt;CGColorRef&gt; color;
</span><span class="cx">     RingBuffer&lt;size_t&gt; dirtySize;
</span><span class="cx">     RingBuffer&lt;size_t&gt; reclaimableSize;
</span><ins>+    RingBuffer&lt;size_t&gt; externalSize;
</ins><span class="cx">     bool isSubcategory { false };
</span><span class="cx">     unsigned type { MemoryCategory::NumberOfCategories };
</span><span class="cx"> };
</span><span class="lines">@@ -147,6 +148,7 @@
</span><span class="cx"> 
</span><span class="cx">     RingBuffer&lt;float&gt; cpu;
</span><span class="cx">     RingBuffer&lt;size_t&gt; totalDirtySize;
</span><ins>+    RingBuffer&lt;size_t&gt; totalExternalSize;
</ins><span class="cx">     RingBuffer&lt;size_t&gt; gcHeapSize;
</span><span class="cx">     std::array&lt;HistoricMemoryCategoryInfo, MemoryCategory::NumberOfCategories&gt; categories;
</span><span class="cx">     double timeOfNextEdenCollection { 0 };
</span><span class="lines">@@ -189,9 +191,11 @@
</span><span class="cx">     auto&amp; historicData = historicUsageData();
</span><span class="cx">     historicData.cpu.append(data.cpu);
</span><span class="cx">     historicData.totalDirtySize.append(data.totalDirtySize);
</span><ins>+    historicData.totalExternalSize.append(data.totalExternalSize);
</ins><span class="cx">     for (auto&amp; category : historicData.categories) {
</span><span class="cx">         category.dirtySize.append(data.categories[category.type].dirtySize);
</span><span class="cx">         category.reclaimableSize.append(data.categories[category.type].reclaimableSize);
</span><ins>+        category.externalSize.append(data.categories[category.type].externalSize);
</ins><span class="cx">     }
</span><span class="cx">     historicData.timeOfNextEdenCollection = data.timeOfNextEdenCollection;
</span><span class="cx">     historicData.timeOfNextFullCollection = data.timeOfNextFullCollection;
</span><span class="lines">@@ -448,11 +452,17 @@
</span><span class="cx">     static CGColorRef colorForLabels = createColor(0.9, 0.9, 0.9, 1);
</span><span class="cx">     showText(context, 10, 20, colorForLabels, String::format(&quot;        CPU: %g&quot;, data.cpu.last()));
</span><span class="cx">     showText(context, 10, 30, colorForLabels, &quot;  Footprint: &quot; + formatByteNumber(data.totalDirtySize.last()));
</span><ins>+    showText(context, 10, 40, colorForLabels, &quot;   External: &quot; + formatByteNumber(data.totalExternalSize.last()));
</ins><span class="cx"> 
</span><del>-    float y = 50;
</del><ins>+    float y = 55;
</ins><span class="cx">     for (auto&amp; category : data.categories) {
</span><del>-        String label = String::format(&quot;% 11s: %s&quot;, category.name.ascii().data(), formatByteNumber(category.dirtySize.last()).ascii().data());
</del><ins>+        size_t dirty = category.dirtySize.last();
</ins><span class="cx">         size_t reclaimable = category.reclaimableSize.last();
</span><ins>+        size_t external = category.externalSize.last();
+        
+        String label = String::format(&quot;% 11s: %s&quot;, category.name.ascii().data(), formatByteNumber(dirty).ascii().data());
+        if (external)
+            label = label + String::format(&quot; + %s&quot;, formatByteNumber(external).ascii().data());
</ins><span class="cx">         if (reclaimable)
</span><span class="cx">             label = label + String::format(&quot; [%s]&quot;, formatByteNumber(reclaimable).ascii().data());
</span><span class="cx"> 
</span><span class="lines">@@ -460,6 +470,7 @@
</span><span class="cx">         showText(context, 10, y, category.color.get(), label);
</span><span class="cx">         y += 10;
</span><span class="cx">     }
</span><ins>+    y -= 5;
</ins><span class="cx"> 
</span><span class="cx">     double now = WTF::currentTime();
</span><span class="cx">     showText(context, 10, y + 10, colorForLabels, String::format(&quot;    Eden GC: %s&quot;, gcTimerString(data.timeOfNextEdenCollection, now).ascii().data()));
</span></span></pre></div>
<a id="trunkSourceWebCorepagecocoaResourceUsageThreadCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -195,7 +195,7 @@
</span><span class="cx">     default:
</span><span class="cx">         return MemoryCategory::Other;
</span><span class="cx">     }
</span><del>-};
</del><ins>+}
</ins><span class="cx"> 
</span><span class="cx"> void ResourceUsageThread::platformThreadBody(JSC::VM* vm, ResourceUsageData&amp; data)
</span><span class="cx"> {
</span><span class="lines">@@ -219,15 +219,22 @@
</span><span class="cx">     data.totalDirtySize = totalDirtyPages * vmPageSize();
</span><span class="cx"> 
</span><span class="cx">     size_t currentGCHeapCapacity = vm-&gt;heap.blockBytesAllocated();
</span><del>-    size_t currentGCOwned = vm-&gt;heap.extraMemorySize();
</del><ins>+    size_t currentGCOwnedExtra = vm-&gt;heap.extraMemorySize();
+    size_t currentGCOwnedExternal = vm-&gt;heap.externalMemorySize();
+    ASSERT(currentGCOwnedExternal &lt;= currentGCOwnedExtra);
</ins><span class="cx"> 
</span><span class="cx">     data.categories[MemoryCategory::GCHeap].dirtySize = currentGCHeapCapacity;
</span><del>-    data.categories[MemoryCategory::GCOwned].dirtySize = currentGCOwned;
</del><ins>+    data.categories[MemoryCategory::GCOwned].dirtySize = currentGCOwnedExtra - currentGCOwnedExternal;
+    data.categories[MemoryCategory::GCOwned].externalSize = currentGCOwnedExternal;
</ins><span class="cx"> 
</span><span class="cx">     // Subtract known subchunks from the bmalloc bucket.
</span><span class="cx">     // FIXME: Handle running with bmalloc disabled.
</span><del>-    data.categories[MemoryCategory::bmalloc].dirtySize -= currentGCHeapCapacity + currentGCOwned;
</del><ins>+    size_t currentGCOwnedGenerallyInBmalloc = currentGCOwnedExtra - currentGCOwnedExternal;
+    ASSERT(currentGCOwnedGenerallyInBmalloc &lt; data.categories[MemoryCategory::bmalloc].dirtySize);
+    data.categories[MemoryCategory::bmalloc].dirtySize -= currentGCHeapCapacity + currentGCOwnedGenerallyInBmalloc;
</ins><span class="cx"> 
</span><ins>+    data.totalExternalSize = currentGCOwnedExternal;
+
</ins><span class="cx">     data.timeOfNextEdenCollection = vm-&gt;heap.edenActivityCallback()-&gt;nextFireTime();
</span><span class="cx">     data.timeOfNextFullCollection = vm-&gt;heap.fullActivityCallback()-&gt;nextFireTime();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -197,4 +197,16 @@
</span><span class="cx">     return areEssentiallyEqual(context.scaleFactor(), this-&gt;context().scaleFactor());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if !USE(IOSURFACE_CANVAS_BACKING_STORE)
+size_t ImageBuffer::memoryCost() const
+{
+    return 4 * internalSize().width() * internalSize().height();
</ins><span class="cx"> }
</span><ins>+
+size_t ImageBuffer::externalMemoryCost() const
+{
+    return 0;
+}
+#endif
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -127,6 +127,9 @@
</span><span class="cx">     NativeImagePtr nativeImage() const;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    size_t memoryCost() const;
+    size_t externalMemoryCost() const;
+
</ins><span class="cx">     // FIXME: current implementations of this method have the restriction that they only work
</span><span class="cx">     // with textures that are RGB or RGBA format, and UNSIGNED_BYTE type.
</span><span class="cx">     bool copyToPlatformTexture(GraphicsContext3D&amp;, GC3Denum, Platform3DObject, GC3Denum, bool, bool);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgImageBufferCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -160,6 +160,22 @@
</span><span class="cx">     return scaleSizeToUserSpace(destinationSize, m_data.backingStoreSize, internalSize());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if USE(IOSURFACE_CANVAS_BACKING_STORE)
+size_t ImageBuffer::memoryCost() const
+{
+    if (m_data.surface)
+        return m_data.surface-&gt;totalBytes();
+    return 4 * internalSize().width() * internalSize().height();
+}
+
+size_t ImageBuffer::externalMemoryCost() const
+{
+    if (m_data.surface)
+        return m_data.surface-&gt;totalBytes();
+    return 0;
+}
+#endif
+
</ins><span class="cx"> GraphicsContext&amp; ImageBuffer::context() const
</span><span class="cx"> {
</span><span class="cx"> #if USE(IOSURFACE_CANVAS_BACKING_STORE)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaIOSurfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h (202393 => 202394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h        2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h        2016-06-23 20:05:23 UTC (rev 202394)
</span><span class="lines">@@ -30,7 +30,6 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;GraphicsContext.h&quot;
</span><span class="cx"> #include &quot;IntSize.h&quot;
</span><del>-#include &lt;wtf/PassRefPtr.h&gt;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>