Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 |
| OLD | NEW |