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/Float32ImageData.h" |
7 #include "core/html/HTMLCanvasElement.h" | 8 #include "core/html/HTMLCanvasElement.h" |
8 #include "core/html/HTMLVideoElement.h" | 9 #include "core/html/HTMLVideoElement.h" |
9 #include "core/html/ImageData.h" | 10 #include "core/html/ImageData.h" |
10 #include "platform/graphics/skia/SkiaUtils.h" | 11 #include "platform/graphics/skia/SkiaUtils.h" |
11 #include "platform/image-decoders/ImageDecoder.h" | 12 #include "platform/image-decoders/ImageDecoder.h" |
12 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
13 #include "third_party/skia/include/core/SkSurface.h" | 14 #include "third_party/skia/include/core/SkSurface.h" |
14 #include "wtf/CheckedNumeric.h" | 15 #include "wtf/CheckedNumeric.h" |
15 #include "wtf/PtrUtil.h" | 16 #include "wtf/PtrUtil.h" |
16 #include "wtf/RefPtr.h" | 17 #include "wtf/RefPtr.h" |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 | 700 |
700 m_image = cropImage(input.get(), parsedOptions, bitmap->isPremultiplied() | 701 m_image = cropImage(input.get(), parsedOptions, bitmap->isPremultiplied() |
701 ? PremultiplyAlpha | 702 ? PremultiplyAlpha |
702 : DontPremultiplyAlpha); | 703 : DontPremultiplyAlpha); |
703 if (!m_image) | 704 if (!m_image) |
704 return; | 705 return; |
705 m_image->setOriginClean(bitmap->originClean()); | 706 m_image->setOriginClean(bitmap->originClean()); |
706 m_image->setPremultiplied(parsedOptions.premultiplyAlpha); | 707 m_image->setPremultiplied(parsedOptions.premultiplyAlpha); |
707 } | 708 } |
708 | 709 |
| 710 ImageBitmap::ImageBitmap(Float32ImageData* data, |
| 711 Optional<IntRect> cropRect, |
| 712 const ImageBitmapOptions& options) {} |
| 713 |
709 ImageBitmap::ImageBitmap(PassRefPtr<StaticBitmapImage> image, | 714 ImageBitmap::ImageBitmap(PassRefPtr<StaticBitmapImage> image, |
710 Optional<IntRect> cropRect, | 715 Optional<IntRect> cropRect, |
711 const ImageBitmapOptions& options) { | 716 const ImageBitmapOptions& options) { |
712 bool originClean = image->originClean(); | 717 bool originClean = image->originClean(); |
713 RefPtr<Image> input = image; | 718 RefPtr<Image> input = image; |
714 ParsedOptions parsedOptions = parseOptions(options, cropRect, input->size()); | 719 ParsedOptions parsedOptions = parseOptions(options, cropRect, input->size()); |
715 if (dstBufferSizeHasOverflow(parsedOptions)) | 720 if (dstBufferSizeHasOverflow(parsedOptions)) |
716 return; | 721 return; |
717 | 722 |
718 m_image = cropImage(input.get(), parsedOptions); | 723 m_image = cropImage(input.get(), parsedOptions); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 const ImageBitmapOptions& options) { | 760 const ImageBitmapOptions& options) { |
756 return new ImageBitmap(canvas, cropRect, options); | 761 return new ImageBitmap(canvas, cropRect, options); |
757 } | 762 } |
758 | 763 |
759 ImageBitmap* ImageBitmap::create(ImageData* data, | 764 ImageBitmap* ImageBitmap::create(ImageData* data, |
760 Optional<IntRect> cropRect, | 765 Optional<IntRect> cropRect, |
761 const ImageBitmapOptions& options) { | 766 const ImageBitmapOptions& options) { |
762 return new ImageBitmap(data, cropRect, options); | 767 return new ImageBitmap(data, cropRect, options); |
763 } | 768 } |
764 | 769 |
| 770 ImageBitmap* ImageBitmap::create(Float32ImageData* data, |
| 771 Optional<IntRect> cropRect, |
| 772 const ImageBitmapOptions& options) { |
| 773 return new ImageBitmap(data, cropRect, options); |
| 774 } |
| 775 |
765 ImageBitmap* ImageBitmap::create(ImageBitmap* bitmap, | 776 ImageBitmap* ImageBitmap::create(ImageBitmap* bitmap, |
766 Optional<IntRect> cropRect, | 777 Optional<IntRect> cropRect, |
767 const ImageBitmapOptions& options) { | 778 const ImageBitmapOptions& options) { |
768 return new ImageBitmap(bitmap, cropRect, options); | 779 return new ImageBitmap(bitmap, cropRect, options); |
769 } | 780 } |
770 | 781 |
771 ImageBitmap* ImageBitmap::create(PassRefPtr<StaticBitmapImage> image, | 782 ImageBitmap* ImageBitmap::create(PassRefPtr<StaticBitmapImage> image, |
772 Optional<IntRect> cropRect, | 783 Optional<IntRect> cropRect, |
773 const ImageBitmapOptions& options) { | 784 const ImageBitmapOptions& options) { |
774 return new ImageBitmap(std::move(image), cropRect, options); | 785 return new ImageBitmap(std::move(image), cropRect, options); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, | 875 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, |
865 FloatRect* dstRect) const {} | 876 FloatRect* dstRect) const {} |
866 | 877 |
867 FloatSize ImageBitmap::elementSize(const FloatSize&) const { | 878 FloatSize ImageBitmap::elementSize(const FloatSize&) const { |
868 return FloatSize(width(), height()); | 879 return FloatSize(width(), height()); |
869 } | 880 } |
870 | 881 |
871 DEFINE_TRACE(ImageBitmap) {} | 882 DEFINE_TRACE(ImageBitmap) {} |
872 | 883 |
873 } // namespace blink | 884 } // namespace blink |
OLD | NEW |