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

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

Issue 2257513002: Refactor ImageDecoder factories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 years, 3 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 | third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp » ('j') | 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/graphics/AcceleratedStaticBitmapImage.h" 10 #include "platform/graphics/AcceleratedStaticBitmapImage.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 if (srcRect.isEmpty() && !parsedOptions.premultiplyAlpha) { 220 if (srcRect.isEmpty() && !parsedOptions.premultiplyAlpha) {
221 SkImageInfo info = SkImageInfo::Make(parsedOptions.resizeWidth, parsedOp tions.resizeHeight, kN32_SkColorType, kUnpremul_SkAlphaType); 221 SkImageInfo info = SkImageInfo::Make(parsedOptions.resizeWidth, parsedOp tions.resizeHeight, kN32_SkColorType, kUnpremul_SkAlphaType);
222 std::unique_ptr<uint8_t[]> dstPixels = wrapArrayUnique(new uint8_t[info. width() * info.height() * info.bytesPerPixel()]()); 222 std::unique_ptr<uint8_t[]> dstPixels = wrapArrayUnique(new uint8_t[info. width() * info.height() * info.bytesPerPixel()]());
223 return StaticBitmapImage::create(newSkImageFromRaster(info, std::move(ds tPixels), info.width() * info.bytesPerPixel())); 223 return StaticBitmapImage::create(newSkImageFromRaster(info, std::move(ds tPixels), info.width() * info.bytesPerPixel()));
224 } 224 }
225 225
226 RefPtr<SkImage> skiaImage = image->imageForCurrentFrame(); 226 RefPtr<SkImage> skiaImage = image->imageForCurrentFrame();
227 // Attempt to get raw unpremultiplied image data, executed only when skiaIma ge is premultiplied. 227 // Attempt to get raw unpremultiplied image data, executed only when skiaIma ge is premultiplied.
228 if ((((!parsedOptions.premultiplyAlpha && !skiaImage->isOpaque()) || !skiaIm age) && image->data() && imageFormat == PremultiplyAlpha) || colorSpaceOp == Ima geDecoder::GammaAndColorProfileIgnored) { 228 if ((((!parsedOptions.premultiplyAlpha && !skiaImage->isOpaque()) || !skiaIm age) && image->data() && imageFormat == PremultiplyAlpha) || colorSpaceOp == Ima geDecoder::GammaAndColorProfileIgnored) {
229 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create( 229 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create(
230 ImageDecoder::determineImageType(*(image->data())), 230 image->data(), true,
231 parsedOptions.premultiplyAlpha ? ImageDecoder::AlphaPremultiplied : ImageDecoder::AlphaNotPremultiplied, 231 parsedOptions.premultiplyAlpha ? ImageDecoder::AlphaPremultiplied : ImageDecoder::AlphaNotPremultiplied,
232 colorSpaceOp)); 232 colorSpaceOp));
233 if (!decoder) 233 if (!decoder)
234 return nullptr; 234 return nullptr;
235 decoder->setData(image->data(), true);
236 skiaImage = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); 235 skiaImage = ImageBitmap::getSkImageFromDecoder(std::move(decoder));
237 if (!skiaImage) 236 if (!skiaImage)
238 return nullptr; 237 return nullptr;
239 } 238 }
240 239
241 if (parsedOptions.cropRect == srcRect && !parsedOptions.shouldScaleInput) { 240 if (parsedOptions.cropRect == srcRect && !parsedOptions.shouldScaleInput) {
242 RefPtr<SkImage> croppedSkImage = fromSkSp(skiaImage->makeSubset(srcRect) ); 241 RefPtr<SkImage> croppedSkImage = fromSkSp(skiaImage->makeSubset(srcRect) );
243 if (parsedOptions.flipY) 242 if (parsedOptions.flipY)
244 return StaticBitmapImage::create(flipSkImageVertically(croppedSkImag e.get(), parsedOptions.premultiplyAlpha ? PremultiplyAlpha : DontPremultiplyAlph a)); 243 return StaticBitmapImage::create(flipSkImageVertically(croppedSkImag e.get(), parsedOptions.premultiplyAlpha ? PremultiplyAlpha : DontPremultiplyAlph a));
245 // Special case: The first parameter image is unpremul but we need to tu rn it into premul. 244 // Special case: The first parameter image is unpremul but we need to tu rn it into premul.
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 FloatSize ImageBitmap::elementSize(const FloatSize&) const 651 FloatSize ImageBitmap::elementSize(const FloatSize&) const
653 { 652 {
654 return FloatSize(width(), height()); 653 return FloatSize(width(), height());
655 } 654 }
656 655
657 DEFINE_TRACE(ImageBitmap) 656 DEFINE_TRACE(ImageBitmap)
658 { 657 {
659 } 658 }
660 659
661 } // namespace blink 660 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698