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/HTMLCanvasElement.h" | 7 #include "core/html/HTMLCanvasElement.h" |
8 #include "core/html/HTMLVideoElement.h" | 8 #include "core/html/HTMLVideoElement.h" |
9 #include "core/html/ImageData.h" | 9 #include "core/html/ImageData.h" |
10 #include "core/offscreencanvas/OffscreenCanvas.h" | 10 #include "core/offscreencanvas/OffscreenCanvas.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(HTMLAndSVGImageElementSource* 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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 | 990 |
991 PassRefPtr<StaticBitmapImage> ImageBitmap::Transfer() { | 991 PassRefPtr<StaticBitmapImage> ImageBitmap::Transfer() { |
992 ASSERT(!IsNeutered()); | 992 ASSERT(!IsNeutered()); |
993 is_neutered_ = true; | 993 is_neutered_ = true; |
994 image_->Transfer(); | 994 image_->Transfer(); |
995 return std::move(image_); | 995 return std::move(image_); |
996 } | 996 } |
997 | 997 |
998 ImageBitmap::~ImageBitmap() {} | 998 ImageBitmap::~ImageBitmap() {} |
999 | 999 |
1000 ImageBitmap* ImageBitmap::Create(HTMLImageElement* image, | 1000 ImageBitmap* ImageBitmap::Create(HTMLAndSVGImageElementSource* image, |
1001 Optional<IntRect> crop_rect, | 1001 Optional<IntRect> crop_rect, |
1002 Document* document, | 1002 Document* document, |
1003 const ImageBitmapOptions& options) { | 1003 const ImageBitmapOptions& options) { |
1004 return new ImageBitmap(image, crop_rect, document, options); | 1004 return new ImageBitmap(image, crop_rect, document, options); |
1005 } | 1005 } |
1006 | 1006 |
1007 ImageBitmap* ImageBitmap::Create(HTMLVideoElement* video, | 1007 ImageBitmap* ImageBitmap::Create(HTMLVideoElement* video, |
1008 Optional<IntRect> crop_rect, | 1008 Optional<IntRect> crop_rect, |
1009 Document* document, | 1009 Document* document, |
1010 const ImageBitmapOptions& options) { | 1010 const ImageBitmapOptions& options) { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 void ImageBitmap::AdjustDrawRects(FloatRect* src_rect, | 1139 void ImageBitmap::AdjustDrawRects(FloatRect* src_rect, |
1140 FloatRect* dst_rect) const {} | 1140 FloatRect* dst_rect) const {} |
1141 | 1141 |
1142 FloatSize ImageBitmap::ElementSize(const FloatSize&) const { | 1142 FloatSize ImageBitmap::ElementSize(const FloatSize&) const { |
1143 return FloatSize(width(), height()); | 1143 return FloatSize(width(), height()); |
1144 } | 1144 } |
1145 | 1145 |
1146 DEFINE_TRACE(ImageBitmap) {} | 1146 DEFINE_TRACE(ImageBitmap) {} |
1147 | 1147 |
1148 } // namespace blink | 1148 } // namespace blink |
OLD | NEW |