Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (202393 => 202394)
--- trunk/Source/_javascript_Core/ChangeLog 2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-06-23 20:05:23 UTC (rev 202394)
@@ -1,5 +1,28 @@
2016-06-23 Joseph Pecoraro <[email protected]>
+ Web Inspector: Memory Timeline sometimes shows impossible value for bmalloc size (underflowed)
+ https://bugs.webkit.org/show_bug.cgi?id=158110
+ <rdar://problem/26498584>
+
+ 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 <[email protected]>
+
Web Inspector: Snapshots should be cleared at some point
https://bugs.webkit.org/show_bug.cgi?id=157907
<rdar://problem/26373610>
Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (202393 => 202394)
--- trunk/Source/_javascript_Core/heap/Heap.cpp 2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp 2016-06-23 20:05:23 UTC (rev 202394)
@@ -1240,6 +1240,9 @@
m_sizeBeforeLastFullCollect = m_sizeAfterLastCollect + m_bytesAllocatedThisCycle;
m_extraMemorySize = 0;
m_deprecatedExtraMemorySize = 0;
+#if ENABLE(RESOURCE_USAGE)
+ m_externalMemorySize = 0;
+#endif
if (m_fullActivityCallback)
m_fullActivityCallback->willCollect();
@@ -1452,6 +1455,10 @@
else
m_lastEdenGCLength = gcEndTime - gcStartTime;
+#if ENABLE(RESOURCE_USAGE)
+ ASSERT(externalMemorySize() <= extraMemorySize());
+#endif
+
if (Options::recordGCPauseTimes())
HeapStatistics::recordGCPauseTime(gcStartTime, gcEndTime);
Modified: trunk/Source/_javascript_Core/heap/Heap.h (202393 => 202394)
--- trunk/Source/_javascript_Core/heap/Heap.h 2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/_javascript_Core/heap/Heap.h 2016-06-23 20:05:23 UTC (rev 202394)
@@ -179,6 +179,12 @@
void reportExtraMemoryAllocated(size_t);
void reportExtraMemoryVisited(CellState cellStateBeforeVisiting, size_t);
+#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
+
// Use this API to report non-GC memory if you can't use the better API above.
void deprecatedReportExtraMemory(size_t);
@@ -462,6 +468,7 @@
#if ENABLE(RESOURCE_USAGE)
size_t m_blockBytesAllocated { 0 };
+ size_t m_externalMemorySize { 0 };
#endif
};
Modified: trunk/Source/_javascript_Core/heap/HeapInlines.h (202393 => 202394)
--- trunk/Source/_javascript_Core/heap/HeapInlines.h 2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/_javascript_Core/heap/HeapInlines.h 2016-06-23 20:05:23 UTC (rev 202394)
@@ -141,6 +141,23 @@
}
}
+#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 && dataBeforeVisiting == CellState::OldGrey)
+ return;
+
+ size_t* counter = &m_externalMemorySize;
+
+ for (;;) {
+ size_t oldSize = *counter;
+ if (WTF::weakCompareAndSwap(counter, oldSize, oldSize + size))
+ return;
+ }
+}
+#endif
+
inline void Heap::deprecatedReportExtraMemory(size_t size)
{
if (size > minExtraMemory)
Modified: trunk/Source/_javascript_Core/heap/SlotVisitor.h (202393 => 202394)
--- trunk/Source/_javascript_Core/heap/SlotVisitor.h 2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/_javascript_Core/heap/SlotVisitor.h 2016-06-23 20:05:23 UTC (rev 202394)
@@ -109,6 +109,9 @@
void copyLater(JSCell*, CopyToken, void*, size_t);
void reportExtraMemoryVisited(size_t);
+#if ENABLE(RESOURCE_USAGE)
+ void reportExternalMemoryVisited(size_t);
+#endif
void addWeakReferenceHarvester(WeakReferenceHarvester*);
void addUnconditionalFinalizer(UnconditionalFinalizer*);
Modified: trunk/Source/_javascript_Core/heap/SlotVisitorInlines.h (202393 => 202394)
--- trunk/Source/_javascript_Core/heap/SlotVisitorInlines.h 2016-06-23 19:58:56 UTC (rev 202393)
+++ trunk/Source/_javascript_Core/heap/SlotVisitorInlines.h 2016-06-23 20:05:23 UTC (rev 202394)
@@ -109,6 +109,13 @@
heap()->reportExtraMemoryVisited(m_currentObjectCellStateBeforeVisiting, size);
}
+#if ENABLE(RESOURCE_USAGE)
+inline void SlotVisitor::reportExternalMemoryVisited(size_t size)
+{
+ heap()->reportExternalMemoryVisited(m_currentObjectCellStateBeforeVisiting, size);
+}
+#endif
+
inline Heap* SlotVisitor::heap() const
{
return &m_heap;
Modified: trunk/Source/WebCore/ChangeLog (202393 => 202394)
--- 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)
@@ -1,3 +1,74 @@
+2016-06-23 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Memory Timeline sometimes shows impossible value for bmalloc size (underflowed)
+ https://bugs.webkit.org/show_bug.cgi?id=158110
+ <rdar://problem/26498584>
+
+ Reviewed by Andreas Kling.
+
+ IOSurface memory backing Canvas element buffers should be classified as "GC Owned",
+ 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
+ "GCOwned memory" 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 "extra"
+ memory from bmalloc. So, we should address other large sources of "extra memory"
+ 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.
+
2016-06-23 Alexey Proskuryakov <[email protected]>
Handle (0, 0) ranges from Lookup
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (202393 => 202394)
--- 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)
@@ -3245,6 +3245,11 @@
push(@implContent, " thisObject->visitAdditionalChildren(visitor);\n") if $interface->extendedAttributes->{"JSCustomMarkFunction"};
if ($interface->extendedAttributes->{"ReportExtraMemoryCost"}) {
push(@implContent, " visitor.reportExtraMemoryVisited(thisObject->wrapped().memoryCost());\n");
+ if ($interface->extendedAttributes->{"ReportExternalMemoryCost"}) {;
+ push(@implContent, "#if ENABLE(RESOURCE_USAGE)\n");
+ push(@implContent, " visitor.reportExternalMemoryVisited(thisObject->wrapped().externalMemoryCost());\n");
+ push(@implContent, "#endif\n");
+ }
}
if ($numCachedAttributes > 0) {
foreach (@{$interface->attributes}) {
Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (202393 => 202394)
--- 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)
@@ -114,6 +114,7 @@
Reflect=*
Replaceable
ReportExtraMemoryCost
+ReportExternalMemoryCost
RequiresExistingAtomicString
SetterRaisesException
SetterRaisesExceptionWithMessage
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (202393 => 202394)
--- 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)
@@ -589,6 +589,13 @@
return 4 * m_imageBuffer->internalSize().width() * m_imageBuffer->internalSize().height();
}
+size_t HTMLCanvasElement::externalMemoryCost() const
+{
+ if (!m_imageBuffer)
+ return 0;
+ return 4 * m_imageBuffer->internalSize().width() * m_imageBuffer->internalSize().height();
+}
+
void HTMLCanvasElement::setUsesDisplayListDrawing(bool usesDisplayListDrawing)
{
if (usesDisplayListDrawing == m_usesDisplayListDrawing)
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.h (202393 => 202394)
--- 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)
@@ -136,6 +136,7 @@
WEBCORE_EXPORT String replayDisplayListAsText(DisplayList::AsTextFlags) const;
size_t memoryCost() const;
+ size_t externalMemoryCost() const;
private:
HTMLCanvasElement(const QualifiedName&, Document&);
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.idl (202393 => 202394)
--- 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)
@@ -26,7 +26,8 @@
[
JSGenerateToNativeObject,
- ReportExtraMemoryCost
+ ReportExtraMemoryCost,
+ ReportExternalMemoryCost,
] interface HTMLCanvasElement : HTMLElement {
#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C || defined(LANGUAGE_GOBJECT) && LANGUAGE_GOBJECT
attribute long width;
Modified: trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp (202393 => 202394)
--- 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)
@@ -107,32 +107,32 @@
{
auto _javascript_Category = Protocol::Memory::CategoryData::create()
.setType(Protocol::Memory::CategoryData::Type::_javascript_)
- .setSize(data.categories[MemoryCategory::GCHeap].dirtySize + data.categories[MemoryCategory::GCOwned].dirtySize)
+ .setSize(data.categories[MemoryCategory::GCHeap].totalSize() + data.categories[MemoryCategory::GCOwned].totalSize())
.release();
auto jitCategory = Protocol::Memory::CategoryData::create()
.setType(Protocol::Memory::CategoryData::Type::JIT)
- .setSize(data.categories[MemoryCategory::JSJIT].dirtySize)
+ .setSize(data.categories[MemoryCategory::JSJIT].totalSize())
.release();
auto imagesCategory = Protocol::Memory::CategoryData::create()
.setType(Protocol::Memory::CategoryData::Type::Images)
- .setSize(data.categories[MemoryCategory::Images].dirtySize)
+ .setSize(data.categories[MemoryCategory::Images].totalSize())
.release();
auto layersCategory = Protocol::Memory::CategoryData::create()
.setType(Protocol::Memory::CategoryData::Type::Layers)
- .setSize(data.categories[MemoryCategory::Layers].dirtySize)
+ .setSize(data.categories[MemoryCategory::Layers].totalSize())
.release();
auto pageCategory = Protocol::Memory::CategoryData::create()
.setType(Protocol::Memory::CategoryData::Type::Page)
- .setSize(data.categories[MemoryCategory::bmalloc].dirtySize + data.categories[MemoryCategory::LibcMalloc].dirtySize)
+ .setSize(data.categories[MemoryCategory::bmalloc].totalSize() + data.categories[MemoryCategory::LibcMalloc].totalSize())
.release();
auto otherCategory = Protocol::Memory::CategoryData::create()
.setType(Protocol::Memory::CategoryData::Type::Other)
- .setSize(data.categories[MemoryCategory::Other].dirtySize)
+ .setSize(data.categories[MemoryCategory::Other].totalSize())
.release();
auto categories = Protocol::Array<Protocol::Memory::CategoryData>::create();
Modified: trunk/Source/WebCore/page/ResourceUsageData.cpp (202393 => 202394)
--- 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)
@@ -48,6 +48,7 @@
ResourceUsageData::ResourceUsageData(const ResourceUsageData& other)
: cpu(other.cpu)
, totalDirtySize(other.totalDirtySize)
+ , totalExternalSize(other.totalExternalSize)
, timeOfNextEdenCollection(other.timeOfNextEdenCollection)
, timeOfNextFullCollection(other.timeOfNextFullCollection)
{
Modified: trunk/Source/WebCore/page/ResourceUsageData.h (202393 => 202394)
--- 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)
@@ -52,8 +52,11 @@
{
}
+ size_t totalSize() const { return dirtySize + externalSize; }
+
size_t dirtySize { 0 };
size_t reclaimableSize { 0 };
+ size_t externalSize { 0 };
bool isSubcategory { false };
unsigned type { MemoryCategory::NumberOfCategories };
};
@@ -64,6 +67,7 @@
float cpu { 0 };
size_t totalDirtySize { 0 };
+ size_t totalExternalSize { 0 };
std::array<MemoryCategoryInfo, MemoryCategory::NumberOfCategories> categories;
double timeOfNextEdenCollection { 0 };
double timeOfNextFullCollection { 0 };
Modified: trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm (202393 => 202394)
--- 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)
@@ -138,6 +138,7 @@
RetainPtr<CGColorRef> color;
RingBuffer<size_t> dirtySize;
RingBuffer<size_t> reclaimableSize;
+ RingBuffer<size_t> externalSize;
bool isSubcategory { false };
unsigned type { MemoryCategory::NumberOfCategories };
};
@@ -147,6 +148,7 @@
RingBuffer<float> cpu;
RingBuffer<size_t> totalDirtySize;
+ RingBuffer<size_t> totalExternalSize;
RingBuffer<size_t> gcHeapSize;
std::array<HistoricMemoryCategoryInfo, MemoryCategory::NumberOfCategories> categories;
double timeOfNextEdenCollection { 0 };
@@ -189,9 +191,11 @@
auto& historicData = historicUsageData();
historicData.cpu.append(data.cpu);
historicData.totalDirtySize.append(data.totalDirtySize);
+ historicData.totalExternalSize.append(data.totalExternalSize);
for (auto& category : historicData.categories) {
category.dirtySize.append(data.categories[category.type].dirtySize);
category.reclaimableSize.append(data.categories[category.type].reclaimableSize);
+ category.externalSize.append(data.categories[category.type].externalSize);
}
historicData.timeOfNextEdenCollection = data.timeOfNextEdenCollection;
historicData.timeOfNextFullCollection = data.timeOfNextFullCollection;
@@ -448,11 +452,17 @@
static CGColorRef colorForLabels = createColor(0.9, 0.9, 0.9, 1);
showText(context, 10, 20, colorForLabels, String::format(" CPU: %g", data.cpu.last()));
showText(context, 10, 30, colorForLabels, " Footprint: " + formatByteNumber(data.totalDirtySize.last()));
+ showText(context, 10, 40, colorForLabels, " External: " + formatByteNumber(data.totalExternalSize.last()));
- float y = 50;
+ float y = 55;
for (auto& category : data.categories) {
- String label = String::format("% 11s: %s", category.name.ascii().data(), formatByteNumber(category.dirtySize.last()).ascii().data());
+ size_t dirty = category.dirtySize.last();
size_t reclaimable = category.reclaimableSize.last();
+ size_t external = category.externalSize.last();
+
+ String label = String::format("% 11s: %s", category.name.ascii().data(), formatByteNumber(dirty).ascii().data());
+ if (external)
+ label = label + String::format(" + %s", formatByteNumber(external).ascii().data());
if (reclaimable)
label = label + String::format(" [%s]", formatByteNumber(reclaimable).ascii().data());
@@ -460,6 +470,7 @@
showText(context, 10, y, category.color.get(), label);
y += 10;
}
+ y -= 5;
double now = WTF::currentTime();
showText(context, 10, y + 10, colorForLabels, String::format(" Eden GC: %s", gcTimerString(data.timeOfNextEdenCollection, now).ascii().data()));
Modified: trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm (202393 => 202394)
--- 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)
@@ -195,7 +195,7 @@
default:
return MemoryCategory::Other;
}
-};
+}
void ResourceUsageThread::platformThreadBody(JSC::VM* vm, ResourceUsageData& data)
{
@@ -219,15 +219,22 @@
data.totalDirtySize = totalDirtyPages * vmPageSize();
size_t currentGCHeapCapacity = vm->heap.blockBytesAllocated();
- size_t currentGCOwned = vm->heap.extraMemorySize();
+ size_t currentGCOwnedExtra = vm->heap.extraMemorySize();
+ size_t currentGCOwnedExternal = vm->heap.externalMemorySize();
+ ASSERT(currentGCOwnedExternal <= currentGCOwnedExtra);
data.categories[MemoryCategory::GCHeap].dirtySize = currentGCHeapCapacity;
- data.categories[MemoryCategory::GCOwned].dirtySize = currentGCOwned;
+ data.categories[MemoryCategory::GCOwned].dirtySize = currentGCOwnedExtra - currentGCOwnedExternal;
+ data.categories[MemoryCategory::GCOwned].externalSize = currentGCOwnedExternal;
// Subtract known subchunks from the bmalloc bucket.
// FIXME: Handle running with bmalloc disabled.
- data.categories[MemoryCategory::bmalloc].dirtySize -= currentGCHeapCapacity + currentGCOwned;
+ size_t currentGCOwnedGenerallyInBmalloc = currentGCOwnedExtra - currentGCOwnedExternal;
+ ASSERT(currentGCOwnedGenerallyInBmalloc < data.categories[MemoryCategory::bmalloc].dirtySize);
+ data.categories[MemoryCategory::bmalloc].dirtySize -= currentGCHeapCapacity + currentGCOwnedGenerallyInBmalloc;
+ data.totalExternalSize = currentGCOwnedExternal;
+
data.timeOfNextEdenCollection = vm->heap.edenActivityCallback()->nextFireTime();
data.timeOfNextFullCollection = vm->heap.fullActivityCallback()->nextFireTime();
}
Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp (202393 => 202394)
--- 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)
@@ -197,4 +197,16 @@
return areEssentiallyEqual(context.scaleFactor(), this->context().scaleFactor());
}
+#if !USE(IOSURFACE_CANVAS_BACKING_STORE)
+size_t ImageBuffer::memoryCost() const
+{
+ return 4 * internalSize().width() * internalSize().height();
}
+
+size_t ImageBuffer::externalMemoryCost() const
+{
+ return 0;
+}
+#endif
+
+}
Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (202393 => 202394)
--- 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)
@@ -127,6 +127,9 @@
NativeImagePtr nativeImage() const;
#endif
+ size_t memoryCost() const;
+ size_t externalMemoryCost() const;
+
// FIXME: current implementations of this method have the restriction that they only work
// with textures that are RGB or RGBA format, and UNSIGNED_BYTE type.
bool copyToPlatformTexture(GraphicsContext3D&, GC3Denum, Platform3DObject, GC3Denum, bool, bool);
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (202393 => 202394)
--- 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)
@@ -160,6 +160,22 @@
return scaleSizeToUserSpace(destinationSize, m_data.backingStoreSize, internalSize());
}
+#if USE(IOSURFACE_CANVAS_BACKING_STORE)
+size_t ImageBuffer::memoryCost() const
+{
+ if (m_data.surface)
+ return m_data.surface->totalBytes();
+ return 4 * internalSize().width() * internalSize().height();
+}
+
+size_t ImageBuffer::externalMemoryCost() const
+{
+ if (m_data.surface)
+ return m_data.surface->totalBytes();
+ return 0;
+}
+#endif
+
GraphicsContext& ImageBuffer::context() const
{
#if USE(IOSURFACE_CANVAS_BACKING_STORE)
Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h (202393 => 202394)
--- 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)
@@ -30,7 +30,6 @@
#include "GraphicsContext.h"
#include "IntSize.h"
-#include <wtf/PassRefPtr.h>
namespace WebCore {