| 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 | 547 |
| 548 if (parsed_options.premultiply_alpha) { | 548 if (parsed_options.premultiply_alpha) { |
| 549 if (image_format == kDontPremultiplyAlpha) | 549 if (image_format == kDontPremultiplyAlpha) |
| 550 return StaticBitmapImage::Create( | 550 return StaticBitmapImage::Create( |
| 551 UnPremulSkImageToPremul(skia_image.get())); | 551 UnPremulSkImageToPremul(skia_image.get())); |
| 552 return StaticBitmapImage::Create(std::move(skia_image)); | 552 return StaticBitmapImage::Create(std::move(skia_image)); |
| 553 } | 553 } |
| 554 return StaticBitmapImage::Create(PremulSkImageToUnPremul(skia_image.get())); | 554 return StaticBitmapImage::Create(PremulSkImageToUnPremul(skia_image.get())); |
| 555 } | 555 } |
| 556 | 556 |
| 557 ImageBitmap::ImageBitmap(HTMLImageElement* image, | 557 ImageBitmap::ImageBitmap(ImageElementBase* image, |
| 558 Optional<IntRect> crop_rect, | 558 Optional<IntRect> crop_rect, |
| 559 Document* document, | 559 Document* document, |
| 560 const ImageBitmapOptions& options) { | 560 const ImageBitmapOptions& options) { |
| 561 RefPtr<Image> input = image->CachedImage()->GetImage(); | 561 RefPtr<Image> input = image->CachedImage()->GetImage(); |
| 562 ParsedOptions parsed_options = | 562 ParsedOptions parsed_options = |
| 563 ParseOptions(options, crop_rect, image->BitmapSourceSize()); | 563 ParseOptions(options, crop_rect, image->BitmapSourceSize()); |
| 564 if (DstBufferSizeHasOverflow(parsed_options)) | 564 if (DstBufferSizeHasOverflow(parsed_options)) |
| 565 return; | 565 return; |
| 566 | 566 |
| 567 if (options.colorSpaceConversion() == kImageBitmapOptionNone) { | 567 if (options.colorSpaceConversion() == kImageBitmapOptionNone) { |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 | 989 |
| 990 PassRefPtr<StaticBitmapImage> ImageBitmap::Transfer() { | 990 PassRefPtr<StaticBitmapImage> ImageBitmap::Transfer() { |
| 991 ASSERT(!IsNeutered()); | 991 ASSERT(!IsNeutered()); |
| 992 is_neutered_ = true; | 992 is_neutered_ = true; |
| 993 image_->Transfer(); | 993 image_->Transfer(); |
| 994 return std::move(image_); | 994 return std::move(image_); |
| 995 } | 995 } |
| 996 | 996 |
| 997 ImageBitmap::~ImageBitmap() {} | 997 ImageBitmap::~ImageBitmap() {} |
| 998 | 998 |
| 999 ImageBitmap* ImageBitmap::Create(HTMLImageElement* image, | 999 ImageBitmap* ImageBitmap::Create(ImageElementBase* image, |
| 1000 Optional<IntRect> crop_rect, | 1000 Optional<IntRect> crop_rect, |
| 1001 Document* document, | 1001 Document* document, |
| 1002 const ImageBitmapOptions& options) { | 1002 const ImageBitmapOptions& options) { |
| 1003 return new ImageBitmap(image, crop_rect, document, options); | 1003 return new ImageBitmap(image, crop_rect, document, options); |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 ImageBitmap* ImageBitmap::Create(HTMLVideoElement* video, | 1006 ImageBitmap* ImageBitmap::Create(HTMLVideoElement* video, |
| 1007 Optional<IntRect> crop_rect, | 1007 Optional<IntRect> crop_rect, |
| 1008 Document* document, | 1008 Document* document, |
| 1009 const ImageBitmapOptions& options) { | 1009 const ImageBitmapOptions& options) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 void ImageBitmap::AdjustDrawRects(FloatRect* src_rect, | 1138 void ImageBitmap::AdjustDrawRects(FloatRect* src_rect, |
| 1139 FloatRect* dst_rect) const {} | 1139 FloatRect* dst_rect) const {} |
| 1140 | 1140 |
| 1141 FloatSize ImageBitmap::ElementSize(const FloatSize&) const { | 1141 FloatSize ImageBitmap::ElementSize(const FloatSize&) const { |
| 1142 return FloatSize(width(), height()); | 1142 return FloatSize(width(), height()); |
| 1143 } | 1143 } |
| 1144 | 1144 |
| 1145 DEFINE_TRACE(ImageBitmap) {} | 1145 DEFINE_TRACE(ImageBitmap) {} |
| 1146 | 1146 |
| 1147 } // namespace blink | 1147 } // namespace blink |
| OLD | NEW |