Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "core/frame/ImageBitmap.h" | 5 #include "core/frame/ImageBitmap.h" |
| 6 | 6 |
| 7 #include "core/html/HTMLCanvasElement.h" | 7 #include "core/html/HTMLCanvasElement.h" |
| 8 #include "core/html/HTMLVideoElement.h" | 8 #include "core/html/HTMLVideoElement.h" |
| 9 #include "core/html/ImageData.h" | 9 #include "core/html/ImageData.h" |
| 10 #include "core/offscreencanvas/OffscreenCanvas.h" | 10 #include "core/offscreencanvas/OffscreenCanvas.h" |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 974 m_image = std::move(image); | 974 m_image = std::move(image); |
| 975 } | 975 } |
| 976 | 976 |
| 977 PassRefPtr<StaticBitmapImage> ImageBitmap::transfer() { | 977 PassRefPtr<StaticBitmapImage> ImageBitmap::transfer() { |
| 978 ASSERT(!isNeutered()); | 978 ASSERT(!isNeutered()); |
| 979 m_isNeutered = true; | 979 m_isNeutered = true; |
| 980 m_image->transfer(); | 980 m_image->transfer(); |
| 981 return std::move(m_image); | 981 return std::move(m_image); |
| 982 } | 982 } |
| 983 | 983 |
| 984 ImageBitmap::~ImageBitmap() {} | 984 ImageBitmap::~ImageBitmap() { |
| 985 if (m_image) | |
| 986 m_image->unregisterExternalAllocationWithCurrentContext(); | |
|
jbroman
2017/04/04 15:44:56
Is this balanced by a corresponding increase somew
Justin Novosad
2017/04/04 16:15:15
I think It would be cleaner to take care of regist
| |
| 987 } | |
| 985 | 988 |
| 986 ImageBitmap* ImageBitmap::create(HTMLImageElement* image, | 989 ImageBitmap* ImageBitmap::create(HTMLImageElement* image, |
| 987 Optional<IntRect> cropRect, | 990 Optional<IntRect> cropRect, |
| 988 Document* document, | 991 Document* document, |
| 989 const ImageBitmapOptions& options) { | 992 const ImageBitmapOptions& options) { |
| 990 return new ImageBitmap(image, cropRect, document, options); | 993 return new ImageBitmap(image, cropRect, document, options); |
| 991 } | 994 } |
| 992 | 995 |
| 993 ImageBitmap* ImageBitmap::create(HTMLVideoElement* video, | 996 ImageBitmap* ImageBitmap::create(HTMLVideoElement* video, |
| 994 Optional<IntRect> cropRect, | 997 Optional<IntRect> cropRect, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1036 uint32_t height, | 1039 uint32_t height, |
| 1037 bool isImageBitmapPremultiplied, | 1040 bool isImageBitmapPremultiplied, |
| 1038 bool isImageBitmapOriginClean) { | 1041 bool isImageBitmapOriginClean) { |
| 1039 return new ImageBitmap(pixelData, width, height, isImageBitmapPremultiplied, | 1042 return new ImageBitmap(pixelData, width, height, isImageBitmapPremultiplied, |
| 1040 isImageBitmapOriginClean); | 1043 isImageBitmapOriginClean); |
| 1041 } | 1044 } |
| 1042 | 1045 |
| 1043 void ImageBitmap::close() { | 1046 void ImageBitmap::close() { |
| 1044 if (!m_image || m_isNeutered) | 1047 if (!m_image || m_isNeutered) |
| 1045 return; | 1048 return; |
| 1049 if (m_image) | |
| 1050 m_image->unregisterExternalAllocationWithCurrentContext(); | |
| 1046 m_image.clear(); | 1051 m_image.clear(); |
| 1047 m_isNeutered = true; | 1052 m_isNeutered = true; |
| 1048 } | 1053 } |
| 1049 | 1054 |
| 1050 // static | 1055 // static |
| 1051 ImageBitmap* ImageBitmap::take(ScriptPromiseResolver*, sk_sp<SkImage> image) { | 1056 ImageBitmap* ImageBitmap::take(ScriptPromiseResolver*, sk_sp<SkImage> image) { |
| 1052 return ImageBitmap::create(StaticBitmapImage::create(std::move(image))); | 1057 return ImageBitmap::create(StaticBitmapImage::create(std::move(image))); |
| 1053 } | 1058 } |
| 1054 | 1059 |
| 1055 PassRefPtr<Uint8Array> ImageBitmap::copyBitmapData(AlphaDisposition alphaOp, | 1060 PassRefPtr<Uint8Array> ImageBitmap::copyBitmapData(AlphaDisposition alphaOp, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1125 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, | 1130 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, |
| 1126 FloatRect* dstRect) const {} | 1131 FloatRect* dstRect) const {} |
| 1127 | 1132 |
| 1128 FloatSize ImageBitmap::elementSize(const FloatSize&) const { | 1133 FloatSize ImageBitmap::elementSize(const FloatSize&) const { |
| 1129 return FloatSize(width(), height()); | 1134 return FloatSize(width(), height()); |
| 1130 } | 1135 } |
| 1131 | 1136 |
| 1132 DEFINE_TRACE(ImageBitmap) {} | 1137 DEFINE_TRACE(ImageBitmap) {} |
| 1133 | 1138 |
| 1134 } // namespace blink | 1139 } // namespace blink |
| OLD | NEW |