| 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 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 m_image = cropImage( | 699 m_image = cropImage( |
| 699 input.get(), parsedOptions, | 700 input.get(), parsedOptions, |
| 700 bitmap->isPremultiplied() ? PremultiplyAlpha : DontPremultiplyAlpha, | 701 bitmap->isPremultiplied() ? PremultiplyAlpha : DontPremultiplyAlpha, |
| 701 ColorBehavior::transformToGlobalTarget()); | 702 ColorBehavior::transformToGlobalTarget()); |
| 702 if (!m_image) | 703 if (!m_image) |
| 703 return; | 704 return; |
| 704 m_image->setOriginClean(bitmap->originClean()); | 705 m_image->setOriginClean(bitmap->originClean()); |
| 705 m_image->setPremultiplied(parsedOptions.premultiplyAlpha); | 706 m_image->setPremultiplied(parsedOptions.premultiplyAlpha); |
| 706 } | 707 } |
| 707 | 708 |
| 709 ImageBitmap::ImageBitmap(Float32ImageData* data, |
| 710 Optional<IntRect> cropRect, |
| 711 const ImageBitmapOptions& options) {} |
| 712 |
| 708 ImageBitmap::ImageBitmap(PassRefPtr<StaticBitmapImage> image, | 713 ImageBitmap::ImageBitmap(PassRefPtr<StaticBitmapImage> image, |
| 709 Optional<IntRect> cropRect, | 714 Optional<IntRect> cropRect, |
| 710 const ImageBitmapOptions& options) { | 715 const ImageBitmapOptions& options) { |
| 711 bool originClean = image->originClean(); | 716 bool originClean = image->originClean(); |
| 712 RefPtr<Image> input = image; | 717 RefPtr<Image> input = image; |
| 713 ParsedOptions parsedOptions = parseOptions(options, cropRect, input->size()); | 718 ParsedOptions parsedOptions = parseOptions(options, cropRect, input->size()); |
| 714 if (dstBufferSizeHasOverflow(parsedOptions)) | 719 if (dstBufferSizeHasOverflow(parsedOptions)) |
| 715 return; | 720 return; |
| 716 | 721 |
| 717 m_image = cropImage(input.get(), parsedOptions, PremultiplyAlpha, | 722 m_image = cropImage(input.get(), parsedOptions, PremultiplyAlpha, |
| (...skipping 37 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 |