Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 1670463002: [Oilpan] Unify memory usage reporters of Oilpan (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
index 63d691d071e28e0340a84d5aae3a19f0c0839ca3..ab9ea846a1fc6e2522bdd89172e0f8a9246f2bd2 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -129,7 +129,6 @@ inline HTMLCanvasElement::HTMLCanvasElement(Document& document)
, DocumentVisibilityObserver(document)
, m_size(DefaultWidth, DefaultHeight)
, m_ignoreReset(false)
- , m_externallyAllocatedMemory(0)
, m_originClean(true)
, m_didFailToCreateImageBuffer(false)
, m_imageBufferIsClear(false)
@@ -142,7 +141,6 @@ DEFINE_NODE_FACTORY(HTMLCanvasElement)
HTMLCanvasElement::~HTMLCanvasElement()
{
- v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_externallyAllocatedMemory);
#if !ENABLE(OILPAN)
// Ensure these go away before the ImageBuffer.
m_context.clear();
@@ -265,7 +263,6 @@ CanvasRenderingContext* HTMLCanvasElement::getCanvasRenderingContext(const Strin
const ComputedStyle* style = ensureComputedStyle();
if (style)
m_context->setFilterQuality(style->imageRendering() == ImageRenderingPixelated ? kNone_SkFilterQuality : kLow_SkFilterQuality);
- updateExternallyAllocatedMemory();
}
setNeedsCompositingUpdate();
@@ -784,8 +781,6 @@ void HTMLCanvasElement::createImageBufferInternal(PassOwnPtr<ImageBufferSurface>
m_didFailToCreateImageBuffer = false;
- updateExternallyAllocatedMemory();
-
if (is3D()) {
// Early out for WebGL canvases
return;
@@ -816,38 +811,6 @@ DEFINE_TRACE(HTMLCanvasElement)
HTMLElement::trace(visitor);
}
-void HTMLCanvasElement::updateExternallyAllocatedMemory() const
-{
- int bufferCount = 0;
- if (m_imageBuffer) {
- bufferCount++;
- if (m_imageBuffer->isAccelerated()) {
- // The number of internal GPU buffers vary between one (stable
- // non-displayed state) and three (triple-buffered animations).
- // Adding 2 is a pessimistic but relevant estimate.
- // Note: These buffers might be allocated in GPU memory.
- bufferCount += 2;
- }
- }
- if (m_copiedImage)
- bufferCount++;
-
- // Four bytes per pixel per buffer.
- Checked<intptr_t, RecordOverflow> checkedExternallyAllocatedMemory = 4 * bufferCount;
- if (is3D())
- checkedExternallyAllocatedMemory += m_context->externallyAllocatedBytesPerPixel();
-
- checkedExternallyAllocatedMemory *= width();
- checkedExternallyAllocatedMemory *= height();
- intptr_t externallyAllocatedMemory;
- if (checkedExternallyAllocatedMemory.safeGet(externallyAllocatedMemory) == CheckedState::DidOverflow)
- externallyAllocatedMemory = std::numeric_limits<intptr_t>::max();
-
- // Subtracting two intptr_t that are known to be positive will never underflow.
- v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(externallyAllocatedMemory - m_externallyAllocatedMemory);
- m_externallyAllocatedMemory = externallyAllocatedMemory;
-}
-
SkCanvas* HTMLCanvasElement::drawingCanvas() const
{
return buffer() ? m_imageBuffer->canvas() : nullptr;
@@ -907,7 +870,6 @@ PassRefPtr<Image> HTMLCanvasElement::copiedImage(SourceDrawingBuffer sourceBuffe
needToUpdate |= m_context->paintRenderingResultsToCanvas(sourceBuffer);
if (needToUpdate && buffer()) {
m_copiedImage = buffer()->newImageSnapshot(hint);
- updateExternallyAllocatedMemory();
}
return m_copiedImage;
}
@@ -916,14 +878,12 @@ void HTMLCanvasElement::discardImageBuffer()
{
m_imageBuffer.clear();
m_dirtyRect = FloatRect();
- updateExternallyAllocatedMemory();
}
void HTMLCanvasElement::clearCopiedImage()
{
if (m_copiedImage) {
m_copiedImage.clear();
- updateExternallyAllocatedMemory();
}
}

Powered by Google App Engine
This is Rietveld 408576698