| 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" | |
| 8 #include "core/html/HTMLCanvasElement.h" | 7 #include "core/html/HTMLCanvasElement.h" |
| 9 #include "core/html/HTMLVideoElement.h" | 8 #include "core/html/HTMLVideoElement.h" |
| 10 #include "core/html/ImageData.h" | 9 #include "core/html/ImageData.h" |
| 11 #include "core/offscreencanvas/OffscreenCanvas.h" | 10 #include "core/offscreencanvas/OffscreenCanvas.h" |
| 12 #include "platform/graphics/skia/SkiaUtils.h" | 11 #include "platform/graphics/skia/SkiaUtils.h" |
| 13 #include "platform/image-decoders/ImageDecoder.h" | 12 #include "platform/image-decoders/ImageDecoder.h" |
| 14 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
| 15 #include "third_party/skia/include/core/SkImageInfo.h" | 14 #include "third_party/skia/include/core/SkImageInfo.h" |
| 16 #include "third_party/skia/include/core/SkSurface.h" | 15 #include "third_party/skia/include/core/SkSurface.h" |
| 17 #include "wtf/CheckedNumeric.h" | 16 #include "wtf/CheckedNumeric.h" |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 surface->getCanvas()->drawImageRect(skImage, dstDrawRect, &paint); | 924 surface->getCanvas()->drawImageRect(skImage, dstDrawRect, &paint); |
| 926 skImage = surface->makeImageSnapshot(); | 925 skImage = surface->makeImageSnapshot(); |
| 927 } | 926 } |
| 928 if (data->getSkColorSpace()) { | 927 if (data->getSkColorSpace()) { |
| 929 parsedOptions.latestColorSpace = data->getSkColorSpace(); | 928 parsedOptions.latestColorSpace = data->getSkColorSpace(); |
| 930 applyColorSpaceConversion(skImage, parsedOptions); | 929 applyColorSpaceConversion(skImage, parsedOptions); |
| 931 } | 930 } |
| 932 m_image = StaticBitmapImage::create(std::move(skImage)); | 931 m_image = StaticBitmapImage::create(std::move(skImage)); |
| 933 } | 932 } |
| 934 | 933 |
| 935 // TODO(zakerinasab): Fix the constructor from Float32ImageData. | |
| 936 ImageBitmap::ImageBitmap(Float32ImageData* data, | |
| 937 Optional<IntRect> cropRect, | |
| 938 const ImageBitmapOptions& options) {} | |
| 939 | |
| 940 ImageBitmap::ImageBitmap(ImageBitmap* bitmap, | 934 ImageBitmap::ImageBitmap(ImageBitmap* bitmap, |
| 941 Optional<IntRect> cropRect, | 935 Optional<IntRect> cropRect, |
| 942 const ImageBitmapOptions& options) { | 936 const ImageBitmapOptions& options) { |
| 943 RefPtr<Image> input = bitmap->bitmapImage(); | 937 RefPtr<Image> input = bitmap->bitmapImage(); |
| 944 if (!input) | 938 if (!input) |
| 945 return; | 939 return; |
| 946 ParsedOptions parsedOptions = parseOptions(options, cropRect, input->size()); | 940 ParsedOptions parsedOptions = parseOptions(options, cropRect, input->size()); |
| 947 if (dstBufferSizeHasOverflow(parsedOptions)) | 941 if (dstBufferSizeHasOverflow(parsedOptions)) |
| 948 return; | 942 return; |
| 949 | 943 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 const ImageBitmapOptions& options) { | 1008 const ImageBitmapOptions& options) { |
| 1015 return new ImageBitmap(offscreenCanvas, cropRect, options); | 1009 return new ImageBitmap(offscreenCanvas, cropRect, options); |
| 1016 } | 1010 } |
| 1017 | 1011 |
| 1018 ImageBitmap* ImageBitmap::create(ImageData* data, | 1012 ImageBitmap* ImageBitmap::create(ImageData* data, |
| 1019 Optional<IntRect> cropRect, | 1013 Optional<IntRect> cropRect, |
| 1020 const ImageBitmapOptions& options) { | 1014 const ImageBitmapOptions& options) { |
| 1021 return new ImageBitmap(data, cropRect, options); | 1015 return new ImageBitmap(data, cropRect, options); |
| 1022 } | 1016 } |
| 1023 | 1017 |
| 1024 ImageBitmap* ImageBitmap::create(Float32ImageData* data, | |
| 1025 Optional<IntRect> cropRect, | |
| 1026 const ImageBitmapOptions& options) { | |
| 1027 return new ImageBitmap(data, cropRect, options); | |
| 1028 } | |
| 1029 | |
| 1030 ImageBitmap* ImageBitmap::create(ImageBitmap* bitmap, | 1018 ImageBitmap* ImageBitmap::create(ImageBitmap* bitmap, |
| 1031 Optional<IntRect> cropRect, | 1019 Optional<IntRect> cropRect, |
| 1032 const ImageBitmapOptions& options) { | 1020 const ImageBitmapOptions& options) { |
| 1033 return new ImageBitmap(bitmap, cropRect, options); | 1021 return new ImageBitmap(bitmap, cropRect, options); |
| 1034 } | 1022 } |
| 1035 | 1023 |
| 1036 ImageBitmap* ImageBitmap::create(PassRefPtr<StaticBitmapImage> image, | 1024 ImageBitmap* ImageBitmap::create(PassRefPtr<StaticBitmapImage> image, |
| 1037 Optional<IntRect> cropRect, | 1025 Optional<IntRect> cropRect, |
| 1038 const ImageBitmapOptions& options) { | 1026 const ImageBitmapOptions& options) { |
| 1039 return new ImageBitmap(std::move(image), cropRect, options); | 1027 return new ImageBitmap(std::move(image), cropRect, options); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, | 1125 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, |
| 1138 FloatRect* dstRect) const {} | 1126 FloatRect* dstRect) const {} |
| 1139 | 1127 |
| 1140 FloatSize ImageBitmap::elementSize(const FloatSize&) const { | 1128 FloatSize ImageBitmap::elementSize(const FloatSize&) const { |
| 1141 return FloatSize(width(), height()); | 1129 return FloatSize(width(), height()); |
| 1142 } | 1130 } |
| 1143 | 1131 |
| 1144 DEFINE_TRACE(ImageBitmap) {} | 1132 DEFINE_TRACE(ImageBitmap) {} |
| 1145 | 1133 |
| 1146 } // namespace blink | 1134 } // namespace blink |
| OLD | NEW |