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

Unified Diff: third_party/WebKit/Source/platform/graphics/UnacceleratedStaticBitmapImage.cpp

Issue 2796103002: WIP: Adjust externally allocated memory when ImageBitmap is transferred (Closed)
Patch Set: Created 3 years, 8 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/platform/graphics/UnacceleratedStaticBitmapImage.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/UnacceleratedStaticBitmapImage.cpp b/third_party/WebKit/Source/platform/graphics/UnacceleratedStaticBitmapImage.cpp
index 33f21dd746d6fd8fb04bb5f3f128aea162d5c979..15afe73821c5ad8053fc9ff163cd0afd2a560e7f 100644
--- a/third_party/WebKit/Source/platform/graphics/UnacceleratedStaticBitmapImage.cpp
+++ b/third_party/WebKit/Source/platform/graphics/UnacceleratedStaticBitmapImage.cpp
@@ -5,6 +5,7 @@
#include "platform/graphics/UnacceleratedStaticBitmapImage.h"
#include "third_party/skia/include/core/SkImage.h"
+#include "v8/include/v8.h"
namespace blink {
@@ -43,4 +44,22 @@ sk_sp<SkImage> UnacceleratedStaticBitmapImage::imageForCurrentFrame() {
return m_image;
}
+void UnacceleratedStaticBitmapImage::
+ registerExternalAllocationWithCurrentContext() {
+ if (!m_image)
+ return;
+ int externallyAllocatedMemory = m_image->width() * m_image->height() * 4;
jbroman 2017/04/04 15:44:56 probably not your problem, but beware overflow in
+ v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(
+ static_cast<int64_t>(externallyAllocatedMemory));
+}
+
+void UnacceleratedStaticBitmapImage::
+ unregisterExternalAllocationWithCurrentContext() {
+ if (!m_image)
+ return;
+ int externallyAllocatedMemory = m_image->width() * m_image->height() * 4;
+ v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(
+ -static_cast<int64_t>(externallyAllocatedMemory));
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698