Changeset 284772 in webkit
- Timestamp:
- Oct 24, 2021, 11:47:50 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
html/ImageBitmap.cpp (modified) (3 diffs)
-
html/ImageBitmap.h (modified) (3 diffs)
-
html/ImageBitmap.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r284771 r284772 1 2021-10-24 Kimmo Kinnunen <kkinnunen@apple.com> 2 3 ImageBitmap should report its memory cost 4 https://bugs.webkit.org/show_bug.cgi?id=187964 5 6 Reviewed by Simon Fraser. 7 8 Add memory cost reporting for ImageBitmap. In order to avoid storing a lock, computing the 9 memory cost many times and querying the thread-unsafe image buffer, compute it only when the 10 image buffer updates and cache the value. 11 12 It is unclear how to test this with current infrastructure. 13 14 * html/ImageBitmap.cpp: 15 (WebCore::ImageBitmap::ImageBitmap): 16 (WebCore::ImageBitmap::takeImageBitmapBacking): 17 (WebCore::ImageBitmap::updateMemoryCost): 18 (WebCore::ImageBitmap::memoryCost const): 19 * html/ImageBitmap.h: 20 * html/ImageBitmap.idl: 21 1 22 2021-10-24 Lauro Moura <lmoura@igalia.com> 2 23 -
trunk/Source/WebCore/html/ImageBitmap.cpp
r284522 r284772 847 847 { 848 848 ASSERT_IMPLIES(m_backingStore, m_backingStore->buffer()); 849 updateMemoryCost(); 849 850 } 850 851 … … 859 860 std::optional<ImageBitmapBacking> ImageBitmap::takeImageBitmapBacking() 860 861 { 861 return std::exchange(m_backingStore, std::nullopt); 862 auto result = std::exchange(m_backingStore, std::nullopt); 863 if (result) 864 updateMemoryCost(); 865 return result; 862 866 } 863 867 … … 870 874 } 871 875 876 void ImageBitmap::updateMemoryCost() 877 { 878 if (m_backingStore) { 879 if (auto imageBuffer = m_backingStore->buffer()) { 880 m_memoryCost = imageBuffer->memoryCost(); 881 return; 882 } 883 } 884 m_memoryCost = 0; 885 } 886 887 size_t ImageBitmap::memoryCost() const 888 { 889 return m_memoryCost; 890 } 891 872 892 } // namespace WebCore -
trunk/Source/WebCore/html/ImageBitmap.h
r284075 r284772 29 29 #include "ImageBitmapBacking.h" 30 30 #include "ScriptWrappable.h" 31 #include <atomic> 31 32 #include <wtf/RefCounted.h> 32 33 … … 109 110 static Vector<std::optional<ImageBitmapBacking>> detachBitmaps(Vector<RefPtr<ImageBitmap>>&&); 110 111 112 size_t memoryCost() const; 111 113 private: 112 114 friend class ImageBitmapImageObserver; … … 131 133 static void createPromise(ScriptExecutionContext&, RefPtr<CSSStyleImageValue>&, ImageBitmapOptions&&, std::optional<IntRect>, Promise&&); 132 134 static void createFromBuffer(ScriptExecutionContext&, Ref<ArrayBuffer>&&, String mimeType, long long expectedContentLength, const URL&, ImageBitmapOptions&&, std::optional<IntRect>, Promise&&); 135 void updateMemoryCost(); 133 136 134 137 std::optional<ImageBitmapBacking> m_backingStore; 138 std::atomic<size_t> m_memoryCost { 0 }; 135 139 }; 136 140 -
trunk/Source/WebCore/html/ImageBitmap.idl
r283463 r284772 27 27 EnabledAtRuntime=ImageBitmapEnabled, 28 28 Exposed=(Window,Worker), 29 ImplementationLacksVTable 29 ImplementationLacksVTable, 30 ReportExtraMemoryCost 30 31 ] interface ImageBitmap { 31 32 readonly attribute unsigned long width;
Note:
See TracChangeset
for help on using the changeset viewer.