| 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 <memory> | 7 #include <memory> |
| 8 #include "core/html/HTMLCanvasElement.h" | 8 #include "core/html/HTMLCanvasElement.h" |
| 9 #include "core/html/HTMLVideoElement.h" | 9 #include "core/html/HTMLVideoElement.h" |
| 10 #include "core/html/ImageData.h" | 10 #include "core/html/ImageData.h" |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 data->GetSkColorSpace())); | 889 data->GetSkColorSpace())); |
| 890 } else { | 890 } else { |
| 891 image_ = StaticBitmapImage::Create(sk_image); | 891 image_ = StaticBitmapImage::Create(sk_image); |
| 892 } | 892 } |
| 893 if (!image_) | 893 if (!image_) |
| 894 return; | 894 return; |
| 895 image_->SetPremultiplied(parsed_options.premultiply_alpha); | 895 image_->SetPremultiplied(parsed_options.premultiply_alpha); |
| 896 return; | 896 return; |
| 897 } | 897 } |
| 898 | 898 |
| 899 CanvasColorParams canvas_color_params; |
| 900 if (RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() && |
| 901 RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) { |
| 902 ImageDataColorSettings color_settings; |
| 903 data->getColorSettings(color_settings); |
| 904 CanvasColorSpace canvas_color_space = |
| 905 ImageData::GetCanvasColorSpace(color_settings.colorSpace()); |
| 906 CanvasPixelFormat canvas_pixel_format = kRGBA8CanvasPixelFormat; |
| 907 if (ImageData::GetImageDataStorageFormat(color_settings.storageFormat()) != |
| 908 kUint8ClampedArrayStorageFormat) { |
| 909 canvas_pixel_format = kF16CanvasPixelFormat; |
| 910 } |
| 911 canvas_color_params = |
| 912 CanvasColorParams(canvas_color_space, canvas_pixel_format); |
| 913 } |
| 899 std::unique_ptr<ImageBuffer> buffer = | 914 std::unique_ptr<ImageBuffer> buffer = |
| 900 ImageBuffer::Create(parsed_options.crop_rect.Size(), kNonOpaque, | 915 ImageBuffer::Create(parsed_options.crop_rect.Size(), kNonOpaque, |
| 901 kDoNotInitializeImagePixels, data->GetSkColorSpace()); | 916 kDoNotInitializeImagePixels, canvas_color_params); |
| 902 if (!buffer) | 917 if (!buffer) |
| 903 return; | 918 return; |
| 904 | 919 |
| 905 if (src_rect.IsEmpty()) { | 920 if (src_rect.IsEmpty()) { |
| 906 image_ = StaticBitmapImage::Create(buffer->NewSkImageSnapshot( | 921 image_ = StaticBitmapImage::Create(buffer->NewSkImageSnapshot( |
| 907 kPreferNoAcceleration, kSnapshotReasonUnknown)); | 922 kPreferNoAcceleration, kSnapshotReasonUnknown)); |
| 908 return; | 923 return; |
| 909 } | 924 } |
| 910 | 925 |
| 911 IntPoint dst_point = IntPoint(std::min(0, -parsed_options.crop_rect.X()), | 926 IntPoint dst_point = IntPoint(std::min(0, -parsed_options.crop_rect.X()), |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 void ImageBitmap::AdjustDrawRects(FloatRect* src_rect, | 1153 void ImageBitmap::AdjustDrawRects(FloatRect* src_rect, |
| 1139 FloatRect* dst_rect) const {} | 1154 FloatRect* dst_rect) const {} |
| 1140 | 1155 |
| 1141 FloatSize ImageBitmap::ElementSize(const FloatSize&) const { | 1156 FloatSize ImageBitmap::ElementSize(const FloatSize&) const { |
| 1142 return FloatSize(width(), height()); | 1157 return FloatSize(width(), height()); |
| 1143 } | 1158 } |
| 1144 | 1159 |
| 1145 DEFINE_TRACE(ImageBitmap) {} | 1160 DEFINE_TRACE(ImageBitmap) {} |
| 1146 | 1161 |
| 1147 } // namespace blink | 1162 } // namespace blink |
| OLD | NEW |