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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/UnacceleratedStaticBitmapImage.h" 5 #include "platform/graphics/UnacceleratedStaticBitmapImage.h"
6 6
7 #include "third_party/skia/include/core/SkImage.h" 7 #include "third_party/skia/include/core/SkImage.h"
8 #include "v8/include/v8.h"
8 9
9 namespace blink { 10 namespace blink {
10 11
11 PassRefPtr<UnacceleratedStaticBitmapImage> 12 PassRefPtr<UnacceleratedStaticBitmapImage>
12 UnacceleratedStaticBitmapImage::create(sk_sp<SkImage> image) { 13 UnacceleratedStaticBitmapImage::create(sk_sp<SkImage> image) {
13 return adoptRef(new UnacceleratedStaticBitmapImage(std::move(image))); 14 return adoptRef(new UnacceleratedStaticBitmapImage(std::move(image)));
14 } 15 }
15 16
16 UnacceleratedStaticBitmapImage::UnacceleratedStaticBitmapImage( 17 UnacceleratedStaticBitmapImage::UnacceleratedStaticBitmapImage(
17 sk_sp<SkImage> image) 18 sk_sp<SkImage> image)
(...skipping 18 matching lines...) Expand all
36 RespectImageOrientationEnum, 37 RespectImageOrientationEnum,
37 ImageClampingMode clampMode) { 38 ImageClampingMode clampMode) {
38 StaticBitmapImage::drawHelper(canvas, flags, dstRect, srcRect, clampMode, 39 StaticBitmapImage::drawHelper(canvas, flags, dstRect, srcRect, clampMode,
39 m_image); 40 m_image);
40 } 41 }
41 42
42 sk_sp<SkImage> UnacceleratedStaticBitmapImage::imageForCurrentFrame() { 43 sk_sp<SkImage> UnacceleratedStaticBitmapImage::imageForCurrentFrame() {
43 return m_image; 44 return m_image;
44 } 45 }
45 46
47 void UnacceleratedStaticBitmapImage::
48 registerExternalAllocationWithCurrentContext() {
49 if (!m_image)
50 return;
51 int externallyAllocatedMemory = m_image->width() * m_image->height() * 4;
jbroman 2017/04/04 15:44:56 probably not your problem, but beware overflow in
52 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(
53 static_cast<int64_t>(externallyAllocatedMemory));
54 }
55
56 void UnacceleratedStaticBitmapImage::
57 unregisterExternalAllocationWithCurrentContext() {
58 if (!m_image)
59 return;
60 int externallyAllocatedMemory = m_image->width() * m_image->height() * 4;
61 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(
62 -static_cast<int64_t>(externallyAllocatedMemory));
63 }
64
46 } // namespace blink 65 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698