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

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

Issue 1800153003: Force image-decoding before resolving createImageBitmap promise (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 "platform/image-decoders/ImageDecoder.h" 10 #include "platform/image-decoders/ImageDecoder.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return nullptr; 128 return nullptr;
129 decoder->setData(image->data(), true); 129 decoder->setData(image->data(), true);
130 skiaImage = ImageBitmap::getSkImageFromDecoder(decoder.release()); 130 skiaImage = ImageBitmap::getSkImageFromDecoder(decoder.release());
131 if (!skiaImage) 131 if (!skiaImage)
132 return nullptr; 132 return nullptr;
133 } 133 }
134 134
135 if (cropRect == srcRect) { 135 if (cropRect == srcRect) {
136 if (flipY) 136 if (flipY)
137 return StaticBitmapImage::create(flipSkImageVertically(skiaImage->ne wSubset(srcRect), premultiplyAlpha ? PremultiplyAlpha : DontPremultiplyAlpha)); 137 return StaticBitmapImage::create(flipSkImageVertically(skiaImage->ne wSubset(srcRect), premultiplyAlpha ? PremultiplyAlpha : DontPremultiplyAlpha));
138 return StaticBitmapImage::create(adoptRef(skiaImage->newSubset(srcRect)) ); 138 SkImage* croppedSkImage = skiaImage->newSubset(srcRect);
139 if (cropRect == imgRect) {
140 SkImageInfo info = SkImageInfo::MakeN32(image->width(), image->heigh t(), premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType);
141 OwnPtr<uint8_t[]> imagePixels = copySkImageData(croppedSkImage, info );
Justin Novosad 2016/03/17 21:27:21 Making a full copy, only to discard it after is wa
142
143 }
144 return StaticBitmapImage::create(adoptRef(croppedSkImage));
139 } 145 }
140 146
141 RefPtr<SkSurface> surface = adoptRef(SkSurface::NewRasterN32Premul(cropRect. width(), cropRect.height())); 147 RefPtr<SkSurface> surface = adoptRef(SkSurface::NewRasterN32Premul(cropRect. width(), cropRect.height()));
142 if (!surface) 148 if (!surface)
143 return nullptr; 149 return nullptr;
144 if (srcRect.isEmpty()) 150 if (srcRect.isEmpty())
145 return StaticBitmapImage::create(adoptRef(surface->newImageSnapshot())); 151 return StaticBitmapImage::create(adoptRef(surface->newImageSnapshot()));
146 152
147 SkScalar dstLeft = std::min(0, -cropRect.x()); 153 SkScalar dstLeft = std::min(0, -cropRect.x());
148 SkScalar dstTop = std::min(0, -cropRect.y()); 154 SkScalar dstTop = std::min(0, -cropRect.y());
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 FloatSize ImageBitmap::elementSize(const FloatSize&) const 452 FloatSize ImageBitmap::elementSize(const FloatSize&) const
447 { 453 {
448 return FloatSize(width(), height()); 454 return FloatSize(width(), height());
449 } 455 }
450 456
451 DEFINE_TRACE(ImageBitmap) 457 DEFINE_TRACE(ImageBitmap)
452 { 458 {
453 } 459 }
454 460
455 } // namespace blink 461 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698