Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: third_party/WebKit/Source/core/frame/ImageBitmap.cpp

Issue 2858963002: Replace ASSERT with DCHECK in core/ (Closed)
Patch Set: WorkerBackingThread Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 // The parameter imageFormat indicates whether the first parameter "image" is 410 // The parameter imageFormat indicates whether the first parameter "image" is
411 // unpremultiplied or not. imageFormat = PremultiplyAlpha means the image is in 411 // unpremultiplied or not. imageFormat = PremultiplyAlpha means the image is in
412 // premuliplied format For example, if the image is already in unpremultiplied 412 // premuliplied format For example, if the image is already in unpremultiplied
413 // format and we want the created ImageBitmap in the same format, then we don't 413 // format and we want the created ImageBitmap in the same format, then we don't
414 // need to use the ImageDecoder to decode the image. 414 // need to use the ImageDecoder to decode the image.
415 static PassRefPtr<StaticBitmapImage> CropImageAndApplyColorSpaceConversion( 415 static PassRefPtr<StaticBitmapImage> CropImageAndApplyColorSpaceConversion(
416 Image* image, 416 Image* image,
417 ParsedOptions& parsed_options, 417 ParsedOptions& parsed_options,
418 AlphaDisposition image_format, 418 AlphaDisposition image_format,
419 ColorBehavior color_behavior) { 419 ColorBehavior color_behavior) {
420 ASSERT(image); 420 DCHECK(image);
421 IntRect img_rect(IntPoint(), IntSize(image->width(), image->height())); 421 IntRect img_rect(IntPoint(), IntSize(image->width(), image->height()));
422 const IntRect src_rect = Intersection(img_rect, parsed_options.crop_rect); 422 const IntRect src_rect = Intersection(img_rect, parsed_options.crop_rect);
423 423
424 // In the case when cropRect doesn't intersect the source image and it 424 // In the case when cropRect doesn't intersect the source image and it
425 // requires a umpremul image We immediately return a transparent black image 425 // requires a umpremul image We immediately return a transparent black image
426 // with cropRect.size() 426 // with cropRect.size()
427 if (src_rect.IsEmpty() && !parsed_options.premultiply_alpha) { 427 if (src_rect.IsEmpty() && !parsed_options.premultiply_alpha) {
428 SkImageInfo info = SkImageInfo::Make( 428 SkImageInfo info = SkImageInfo::Make(
429 parsed_options.resize_width, parsed_options.resize_height, 429 parsed_options.resize_width, parsed_options.resize_height,
430 kN32_SkColorType, kUnpremul_SkAlphaType); 430 kN32_SkColorType, kUnpremul_SkAlphaType);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 return; 622 return;
623 image_ = StaticBitmapImage::Create(std::move(skia_image)); 623 image_ = StaticBitmapImage::Create(std::move(skia_image));
624 image_->SetOriginClean( 624 image_->SetOriginClean(
625 !video->WouldTaintOrigin(document->GetSecurityOrigin())); 625 !video->WouldTaintOrigin(document->GetSecurityOrigin()));
626 image_->SetPremultiplied(parsed_options.premultiply_alpha); 626 image_->SetPremultiplied(parsed_options.premultiply_alpha);
627 } 627 }
628 628
629 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, 629 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas,
630 Optional<IntRect> crop_rect, 630 Optional<IntRect> crop_rect,
631 const ImageBitmapOptions& options) { 631 const ImageBitmapOptions& options) {
632 ASSERT(canvas->IsPaintable()); 632 DCHECK(canvas->IsPaintable());
633 RefPtr<Image> input; 633 RefPtr<Image> input;
634 if (canvas->PlaceholderFrame()) { 634 if (canvas->PlaceholderFrame()) {
635 input = canvas->PlaceholderFrame(); 635 input = canvas->PlaceholderFrame();
636 } else { 636 } else {
637 input = canvas->CopiedImage(kBackBuffer, kPreferAcceleration, 637 input = canvas->CopiedImage(kBackBuffer, kPreferAcceleration,
638 kSnapshotReasonCreateImageBitmap); 638 kSnapshotReasonCreateImageBitmap);
639 } 639 }
640 ParsedOptions parsed_options = ParseOptions( 640 ParsedOptions parsed_options = ParseOptions(
641 options, crop_rect, IntSize(input->width(), input->height())); 641 options, crop_rect, IntSize(input->width(), input->height()));
642 if (DstBufferSizeHasOverflow(parsed_options)) 642 if (DstBufferSizeHasOverflow(parsed_options))
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 971
972 image_->SetOriginClean(origin_clean); 972 image_->SetOriginClean(origin_clean);
973 image_->SetPremultiplied(parsed_options.premultiply_alpha); 973 image_->SetPremultiplied(parsed_options.premultiply_alpha);
974 } 974 }
975 975
976 ImageBitmap::ImageBitmap(PassRefPtr<StaticBitmapImage> image) { 976 ImageBitmap::ImageBitmap(PassRefPtr<StaticBitmapImage> image) {
977 image_ = std::move(image); 977 image_ = std::move(image);
978 } 978 }
979 979
980 PassRefPtr<StaticBitmapImage> ImageBitmap::Transfer() { 980 PassRefPtr<StaticBitmapImage> ImageBitmap::Transfer() {
981 ASSERT(!IsNeutered()); 981 DCHECK(!IsNeutered());
982 is_neutered_ = true; 982 is_neutered_ = true;
983 image_->Transfer(); 983 image_->Transfer();
984 return std::move(image_); 984 return std::move(image_);
985 } 985 }
986 986
987 ImageBitmap::~ImageBitmap() {} 987 ImageBitmap::~ImageBitmap() {}
988 988
989 ImageBitmap* ImageBitmap::Create(ImageElementBase* image, 989 ImageBitmap* ImageBitmap::Create(ImageElementBase* image,
990 Optional<IntRect> crop_rect, 990 Optional<IntRect> crop_rect,
991 Document* document, 991 Document* document,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 void ImageBitmap::AdjustDrawRects(FloatRect* src_rect, 1128 void ImageBitmap::AdjustDrawRects(FloatRect* src_rect,
1129 FloatRect* dst_rect) const {} 1129 FloatRect* dst_rect) const {}
1130 1130
1131 FloatSize ImageBitmap::ElementSize(const FloatSize&) const { 1131 FloatSize ImageBitmap::ElementSize(const FloatSize&) const {
1132 return FloatSize(width(), height()); 1132 return FloatSize(width(), height());
1133 } 1133 }
1134 1134
1135 DEFINE_TRACE(ImageBitmap) {} 1135 DEFINE_TRACE(ImageBitmap) {}
1136 1136
1137 } // namespace blink 1137 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698