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

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

Issue 2630563003: Fix ImageBitmap constructor from ImageData to consider the color space tags (Closed)
Patch Set: Rebaseline Created 3 years, 11 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/frame/ImageBitmapTest.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/Float32ImageData.h" 7 #include "core/html/Float32ImageData.h"
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 DCHECK(options.imageOrientation() == imageBitmapOptionNone); 63 DCHECK(options.imageOrientation() == imageBitmapOptionNone);
64 } 64 }
65 if (options.premultiplyAlpha() == imageBitmapOptionNone) { 65 if (options.premultiplyAlpha() == imageBitmapOptionNone) {
66 parsedOptions.premultiplyAlpha = false; 66 parsedOptions.premultiplyAlpha = false;
67 } else { 67 } else {
68 parsedOptions.premultiplyAlpha = true; 68 parsedOptions.premultiplyAlpha = true;
69 DCHECK(options.premultiplyAlpha() == "default" || 69 DCHECK(options.premultiplyAlpha() == "default" ||
70 options.premultiplyAlpha() == "premultiply"); 70 options.premultiplyAlpha() == "premultiply");
71 } 71 }
72 72
73 if (options.colorSpaceConversion() != "none") { 73 if (options.colorSpaceConversion() != imageBitmapOptionNone) {
74 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() || 74 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() ||
75 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) { 75 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) {
76 DCHECK_EQ(options.colorSpaceConversion(), "default"); 76 DCHECK_EQ(options.colorSpaceConversion(), "default");
77 if (RuntimeEnabledFeatures::colorCorrectRenderingDefaultModeEnabled()) { 77 if (RuntimeEnabledFeatures::colorCorrectRenderingDefaultModeEnabled()) {
78 parsedOptions.dstColorSpace = ColorBehavior::globalTargetColorSpace(); 78 parsedOptions.dstColorSpace = ColorBehavior::globalTargetColorSpace();
79 parsedOptions.dstColorType = SkColorType::kN32_SkColorType; 79 parsedOptions.dstColorType = SkColorType::kN32_SkColorType;
80 } 80 }
81 } else { 81 } else {
82 if (options.colorSpaceConversion() == "default" || 82 if (options.colorSpaceConversion() == "default" ||
83 options.colorSpaceConversion() == "srgb") { 83 options.colorSpaceConversion() == "srgb") {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 } 305 }
306 306
307 static inline void updateLatestColorInformation(ParsedOptions& options) { 307 static inline void updateLatestColorInformation(ParsedOptions& options) {
308 options.latestColorType = options.dstColorType; 308 options.latestColorType = options.dstColorType;
309 options.latestColorSpace = options.dstColorSpace; 309 options.latestColorSpace = options.dstColorSpace;
310 } 310 }
311 311
312 // TODO (zakrinasab). Rewrite this when SkImage::readPixels() respectes the 312 // TODO (zakrinasab). Rewrite this when SkImage::readPixels() respectes the
313 // color space of the passed SkImageInfo (crbug.com/skia/6021) and SkImage 313 // color space of the passed SkImageInfo (crbug.com/skia/6021) and SkImage
314 // exposes SkColorSpace and SkColorType (crbug.com/skia/6022). 314 // exposes SkColorSpace and SkColorType (crbug.com/skia/6022).
315
316 static void applyColorSpaceConversion(sk_sp<SkImage>& image, 315 static void applyColorSpaceConversion(sk_sp<SkImage>& image,
317 ParsedOptions& options) { 316 ParsedOptions& options) {
318 if (!options.dstColorSpace) 317 if (!options.dstColorSpace)
319 return; 318 return;
320 if (SkColorSpace::Equals(options.latestColorSpace.get(), 319 if (SkColorSpace::Equals(options.latestColorSpace.get(),
321 options.dstColorSpace.get())) 320 options.dstColorSpace.get()))
322 return; 321 return;
323 322
324 // If we have the color space information of the source image, we can use 323 // If we have the color space information of the source image, we can use
325 // SkColorSpaceXform. Otherwise, we need to draw the image on a canvas and 324 // SkColorSpaceXform. Otherwise, we need to draw the image on a canvas and
326 // take a snapshot. 325 // take a snapshot.
327 if (options.latestColorSpace) { 326 if (options.latestColorSpace) {
328 SkImageInfo info = SkImageInfo::Make( 327 SkImageInfo info = SkImageInfo::Make(
329 image->width(), image->height(), options.latestColorType, 328 image->width(), image->height(), options.latestColorType,
330 image->alphaType(), options.latestColorSpace); 329 image->alphaType(), options.latestColorSpace);
331 size_t size = image->width() * image->height() * info.bytesPerPixel(); 330 size_t size = image->width() * image->height() * info.bytesPerPixel();
332 std::unique_ptr<uint8_t[]> srcPixels(new uint8_t[size]()); 331 sk_sp<SkData> srcData = SkData::MakeUninitialized(size);
333 if (!image->readPixels(info, &srcPixels, 332 if (srcData->size() != size)
333 return;
334 if (!image->readPixels(info, srcData->writable_data(),
334 image->width() * info.bytesPerPixel(), 0, 0)) { 335 image->width() * info.bytesPerPixel(), 0, 0)) {
335 return; 336 return;
336 } 337 }
337 338 // Proceed with in-place color correction, if possible.
338 // For in-place color correction, bytes per pixel must be equal for source 339 sk_sp<SkData> dstData = srcData;
339 // and destination color spaces.
340 std::unique_ptr<uint8_t[]> dstPixels = nullptr;
341 if (SkColorTypeBytesPerPixel(options.dstColorType) != 340 if (SkColorTypeBytesPerPixel(options.dstColorType) !=
342 SkColorTypeBytesPerPixel(options.latestColorType)) { 341 SkColorTypeBytesPerPixel(options.latestColorType)) {
343 size = image->width() * image->height() * 342 size = image->width() * image->height() *
344 SkColorTypeBytesPerPixel(options.latestColorType); 343 SkColorTypeBytesPerPixel(options.dstColorType);
345 dstPixels = std::unique_ptr<uint8_t[]>(new uint8_t[size]()); 344 dstData = SkData::MakeUninitialized(size);
345 if (dstData->size() != size)
346 return;
346 } 347 }
347
348 std::unique_ptr<SkColorSpaceXform> xform = SkColorSpaceXform::New(
349 options.latestColorSpace.get(), options.dstColorSpace.get());
350 xform->apply(getXformFormat(options.dstColorType),
351 dstPixels ? &dstPixels : &srcPixels,
352 getXformFormat(options.latestColorType), &srcPixels,
353 image->width() * image->height(), kUnpremul_SkAlphaType);
354
355 SkImageInfo dstInfo = 348 SkImageInfo dstInfo =
356 SkImageInfo::Make(image->width(), image->height(), options.dstColorType, 349 SkImageInfo::Make(image->width(), image->height(), options.dstColorType,
357 image->alphaType(), options.dstColorSpace); 350 image->alphaType(), options.dstColorSpace);
358 sk_sp<SkData> data(SkData::MakeWithoutCopy(&dstPixels, size)); 351 std::unique_ptr<SkColorSpaceXform> xform = SkColorSpaceXform::New(
359 sk_sp<SkImage> coloredImage = SkImage::MakeRasterData( 352 options.latestColorSpace.get(), options.dstColorSpace.get());
360 dstInfo, data, image->width() * dstInfo.bytesPerPixel()); 353 if (xform->apply(getXformFormat(options.dstColorType),
361 if (coloredImage) { 354 dstData->writable_data(),
362 updateLatestColorInformation(options); 355 getXformFormat(options.latestColorType), srcData->data(),
363 image = coloredImage; 356 image->width() * image->height(), kUnpremul_SkAlphaType)) {
364 return; 357 sk_sp<SkImage> coloredImage = SkImage::MakeRasterData(
358 dstInfo, dstData, image->width() * dstInfo.bytesPerPixel());
359 if (coloredImage) {
360 updateLatestColorInformation(options);
361 image = coloredImage;
362 return;
363 }
365 } 364 }
366 return; 365 return;
367 } 366 }
368 367
369 // Skia does not support drawing to unpremul surfaces/canvases. 368 // Skia does not support drawing to unpremul surfaces/canvases.
370 sk_sp<SkImage> unPremulImage = nullptr; 369 sk_sp<SkImage> unPremulImage = nullptr;
371 if (image->alphaType() == kUnpremul_SkAlphaType) 370 if (image->alphaType() == kUnpremul_SkAlphaType)
372 unPremulImage = unPremulSkImageToPremul(image.get(), options); 371 unPremulImage = unPremulSkImageToPremul(image.get(), options);
373 372
374 // If the color space of the source SkImage is null, the following code 373 // If the color space of the source SkImage is null, the following code
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 ImageBitmap::ImageBitmap(HTMLImageElement* image, 551 ImageBitmap::ImageBitmap(HTMLImageElement* image,
553 Optional<IntRect> cropRect, 552 Optional<IntRect> cropRect,
554 Document* document, 553 Document* document,
555 const ImageBitmapOptions& options) { 554 const ImageBitmapOptions& options) {
556 RefPtr<Image> input = image->cachedImage()->getImage(); 555 RefPtr<Image> input = image->cachedImage()->getImage();
557 ParsedOptions parsedOptions = 556 ParsedOptions parsedOptions =
558 parseOptions(options, cropRect, image->bitmapSourceSize()); 557 parseOptions(options, cropRect, image->bitmapSourceSize());
559 if (dstBufferSizeHasOverflow(parsedOptions)) 558 if (dstBufferSizeHasOverflow(parsedOptions))
560 return; 559 return;
561 560
562 if (options.colorSpaceConversion() == "none") { 561 if (options.colorSpaceConversion() == imageBitmapOptionNone) {
563 m_image = cropImageAndApplyColorSpaceConversion( 562 m_image = cropImageAndApplyColorSpaceConversion(
564 input.get(), parsedOptions, PremultiplyAlpha, ColorBehavior::ignore()); 563 input.get(), parsedOptions, PremultiplyAlpha, ColorBehavior::ignore());
565 } else { 564 } else {
566 m_image = cropImageAndApplyColorSpaceConversion( 565 m_image = cropImageAndApplyColorSpaceConversion(
567 input.get(), parsedOptions, PremultiplyAlpha, 566 input.get(), parsedOptions, PremultiplyAlpha,
568 ColorBehavior::transformToGlobalTarget()); 567 ColorBehavior::transformToGlobalTarget());
569 } 568 }
570 569
571 if (!m_image) 570 if (!m_image)
572 return; 571 return;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 m_image = StaticBitmapImage::create(SkImage::MakeRasterCopy(pixmap)); 730 m_image = StaticBitmapImage::create(SkImage::MakeRasterCopy(pixmap));
732 if (!m_image) 731 if (!m_image)
733 return; 732 return;
734 m_image->setPremultiplied(isImageBitmapPremultiplied); 733 m_image->setPremultiplied(isImageBitmapPremultiplied);
735 m_image->setOriginClean(isImageBitmapOriginClean); 734 m_image->setOriginClean(isImageBitmapOriginClean);
736 } 735 }
737 736
738 static sk_sp<SkImage> scaleSkImage(sk_sp<SkImage> skImage, 737 static sk_sp<SkImage> scaleSkImage(sk_sp<SkImage> skImage,
739 unsigned resizeWidth, 738 unsigned resizeWidth,
740 unsigned resizeHeight, 739 unsigned resizeHeight,
741 SkFilterQuality resizeQuality) { 740 SkFilterQuality resizeQuality,
741 SkColorType colorType = kN32_SkColorType,
742 sk_sp<SkColorSpace> colorSpace = nullptr) {
742 SkImageInfo resizedInfo = SkImageInfo::Make( 743 SkImageInfo resizedInfo = SkImageInfo::Make(
743 resizeWidth, resizeHeight, kN32_SkColorType, kUnpremul_SkAlphaType); 744 resizeWidth, resizeHeight, colorType, kUnpremul_SkAlphaType, colorSpace);
744 RefPtr<ArrayBuffer> dstBuffer = ArrayBuffer::createOrNull( 745 RefPtr<ArrayBuffer> dstBuffer = ArrayBuffer::createOrNull(
745 resizeWidth * resizeHeight, resizedInfo.bytesPerPixel()); 746 resizeWidth * resizeHeight, resizedInfo.bytesPerPixel());
746 if (!dstBuffer) 747 if (!dstBuffer)
747 return nullptr; 748 return nullptr;
748 RefPtr<Uint8Array> resizedPixels = 749
749 Uint8Array::create(dstBuffer, 0, dstBuffer->byteLength()); 750 if (colorType == kN32_SkColorType) {
751 RefPtr<Uint8Array> resizedPixels =
752 Uint8Array::create(dstBuffer, 0, dstBuffer->byteLength());
753 SkPixmap pixmap(
754 resizedInfo, resizedPixels->data(),
755 static_cast<unsigned>(resizeWidth) * resizedInfo.bytesPerPixel());
756 skImage->scalePixels(pixmap, resizeQuality);
757 return SkImage::MakeFromRaster(pixmap,
758 [](const void*, void* pixels) {
759 static_cast<Uint8Array*>(pixels)->deref();
760 },
761 resizedPixels.release().leakRef());
762 }
763
764 RefPtr<Float32Array> resizedPixels =
765 Float32Array::create(dstBuffer, 0, dstBuffer->byteLength());
750 SkPixmap pixmap( 766 SkPixmap pixmap(
751 resizedInfo, resizedPixels->data(), 767 resizedInfo, resizedPixels->data(),
752 static_cast<unsigned>(resizeWidth) * resizedInfo.bytesPerPixel()); 768 static_cast<unsigned>(resizeWidth) * resizedInfo.bytesPerPixel());
753 skImage->scalePixels(pixmap, resizeQuality); 769 skImage->scalePixels(pixmap, resizeQuality);
754 return SkImage::MakeFromRaster(pixmap, 770 return SkImage::MakeFromRaster(pixmap,
755 [](const void*, void* pixels) { 771 [](const void*, void* pixels) {
756 static_cast<Uint8Array*>(pixels)->deref(); 772 static_cast<Float32Array*>(pixels)->deref();
757 }, 773 },
758 resizedPixels.release().leakRef()); 774 resizedPixels.release().leakRef());
759 } 775 }
760 776
761 // TODO(zakerinasab): Fix this and the constructor from Float32ImageData
762 // when the CL for Float32ImageData landed.
763 ImageBitmap::ImageBitmap(ImageData* data, 777 ImageBitmap::ImageBitmap(ImageData* data,
764 Optional<IntRect> cropRect, 778 Optional<IntRect> cropRect,
765 const ImageBitmapOptions& options) { 779 const ImageBitmapOptions& options) {
766 // TODO(xidachen): implement the resize option 780 // TODO(xidachen): implement the resize option
767 IntRect dataSrcRect = IntRect(IntPoint(), data->size()); 781 IntRect dataSrcRect = IntRect(IntPoint(), data->size());
768 ParsedOptions parsedOptions = 782 ParsedOptions parsedOptions =
769 parseOptions(options, cropRect, data->bitmapSourceSize()); 783 parseOptions(options, cropRect, data->bitmapSourceSize());
770 if (dstBufferSizeHasOverflow(parsedOptions)) 784 if (dstBufferSizeHasOverflow(parsedOptions))
771 return; 785 return;
772 IntRect srcRect = cropRect ? intersection(parsedOptions.cropRect, dataSrcRect) 786 IntRect srcRect = cropRect ? intersection(parsedOptions.cropRect, dataSrcRect)
773 : dataSrcRect; 787 : dataSrcRect;
774 788
775 // treat non-premultiplyAlpha as a special case 789 // treat non-premultiplyAlpha as a special case
776 if (!parsedOptions.premultiplyAlpha) { 790 if (!parsedOptions.premultiplyAlpha) {
777 unsigned char* srcAddr = data->data()->data(); 791 unsigned char* srcAddr = data->data()->data();
778 792
779 // Using kN32 type, swizzle input if necessary. 793 // Using kN32 type, swizzle input if necessary.
780 SkImageInfo info = SkImageInfo::Make( 794 SkImageInfo info = SkImageInfo::Make(
781 parsedOptions.cropRect.width(), parsedOptions.cropRect.height(), 795 parsedOptions.cropRect.width(), parsedOptions.cropRect.height(),
782 kN32_SkColorType, kUnpremul_SkAlphaType); 796 kN32_SkColorType, kUnpremul_SkAlphaType, data->getSkColorSpace());
783 unsigned bytesPerPixel = static_cast<unsigned>(info.bytesPerPixel()); 797 unsigned bytesPerPixel = static_cast<unsigned>(info.bytesPerPixel());
784 unsigned srcPixelBytesPerRow = bytesPerPixel * data->size().width(); 798 unsigned srcPixelBytesPerRow = bytesPerPixel * data->size().width();
785 unsigned dstPixelBytesPerRow = 799 unsigned dstPixelBytesPerRow =
786 bytesPerPixel * parsedOptions.cropRect.width(); 800 bytesPerPixel * parsedOptions.cropRect.width();
787 sk_sp<SkImage> skImage; 801 sk_sp<SkImage> skImage;
788 if (parsedOptions.cropRect == IntRect(IntPoint(), data->size())) { 802 if (parsedOptions.cropRect == IntRect(IntPoint(), data->size())) {
789 swizzleImageData(srcAddr, data->size().height(), srcPixelBytesPerRow, 803 swizzleImageData(srcAddr, data->size().height(), srcPixelBytesPerRow,
790 parsedOptions.flipY); 804 parsedOptions.flipY);
791 skImage = 805 skImage =
792 SkImage::MakeRasterCopy(SkPixmap(info, srcAddr, dstPixelBytesPerRow)); 806 SkImage::MakeRasterCopy(SkPixmap(info, srcAddr, dstPixelBytesPerRow));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 srcAddr[srcStartCopyPosition + j]; 863 srcAddr[srcStartCopyPosition + j];
850 } 864 }
851 } 865 }
852 } 866 }
853 } 867 }
854 skImage = newSkImageFromRaster(info, std::move(copiedDataBuffer), 868 skImage = newSkImageFromRaster(info, std::move(copiedDataBuffer),
855 dstPixelBytesPerRow); 869 dstPixelBytesPerRow);
856 } 870 }
857 if (!skImage) 871 if (!skImage)
858 return; 872 return;
859 if (parsedOptions.shouldScaleInput) 873 if (data->getSkColorSpace()) {
860 m_image = StaticBitmapImage::create(scaleSkImage( 874 parsedOptions.latestColorSpace = data->getSkColorSpace();
861 skImage, parsedOptions.resizeWidth, parsedOptions.resizeHeight, 875 applyColorSpaceConversion(skImage, parsedOptions);
862 parsedOptions.resizeQuality)); 876 }
863 else 877 if (parsedOptions.shouldScaleInput) {
878 m_image = StaticBitmapImage::create(
879 scaleSkImage(skImage, parsedOptions.resizeWidth,
880 parsedOptions.resizeHeight, parsedOptions.resizeQuality,
881 parsedOptions.latestColorType, data->getSkColorSpace()));
882 } else {
864 m_image = StaticBitmapImage::create(skImage); 883 m_image = StaticBitmapImage::create(skImage);
884 }
865 if (!m_image) 885 if (!m_image)
866 return; 886 return;
867 m_image->setPremultiplied(parsedOptions.premultiplyAlpha); 887 m_image->setPremultiplied(parsedOptions.premultiplyAlpha);
868 return; 888 return;
869 } 889 }
870 890
871 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create( 891 std::unique_ptr<ImageBuffer> buffer =
872 parsedOptions.cropRect.size(), NonOpaque, DoNotInitializeImagePixels); 892 ImageBuffer::create(parsedOptions.cropRect.size(), NonOpaque,
893 DoNotInitializeImagePixels, data->getSkColorSpace());
873 if (!buffer) 894 if (!buffer)
874 return; 895 return;
875 896
876 if (srcRect.isEmpty()) { 897 if (srcRect.isEmpty()) {
877 m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot( 898 m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(
878 PreferNoAcceleration, SnapshotReasonUnknown)); 899 PreferNoAcceleration, SnapshotReasonUnknown));
879 return; 900 return;
880 } 901 }
881 902
882 IntPoint dstPoint = IntPoint(std::min(0, -parsedOptions.cropRect.x()), 903 IntPoint dstPoint = IntPoint(std::min(0, -parsedOptions.cropRect.x()),
883 std::min(0, -parsedOptions.cropRect.y())); 904 std::min(0, -parsedOptions.cropRect.y()));
884 if (parsedOptions.cropRect.x() < 0) 905 if (parsedOptions.cropRect.x() < 0)
885 dstPoint.setX(-parsedOptions.cropRect.x()); 906 dstPoint.setX(-parsedOptions.cropRect.x());
886 if (parsedOptions.cropRect.y() < 0) 907 if (parsedOptions.cropRect.y() < 0)
887 dstPoint.setY(-parsedOptions.cropRect.y()); 908 dstPoint.setY(-parsedOptions.cropRect.y());
909
888 buffer->putByteArray(Unmultiplied, data->data()->data(), data->size(), 910 buffer->putByteArray(Unmultiplied, data->data()->data(), data->size(),
889 srcRect, dstPoint); 911 srcRect, dstPoint);
890 sk_sp<SkImage> skImage = 912 sk_sp<SkImage> skImage =
891 buffer->newSkImageSnapshot(PreferNoAcceleration, SnapshotReasonUnknown); 913 buffer->newSkImageSnapshot(PreferNoAcceleration, SnapshotReasonUnknown);
892 if (parsedOptions.flipY) 914 if (parsedOptions.flipY)
893 skImage = flipSkImageVertically(skImage.get(), EnforceAlphaPremultiply); 915 skImage = flipSkImageVertically(skImage.get(), EnforceAlphaPremultiply);
894 if (!skImage) 916 if (!skImage)
895 return; 917 return;
896 if (parsedOptions.shouldScaleInput) { 918 if (parsedOptions.shouldScaleInput) {
897 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul( 919 sk_sp<SkSurface> surface = SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(
898 parsedOptions.resizeWidth, parsedOptions.resizeHeight); 920 parsedOptions.resizeWidth, parsedOptions.resizeHeight,
921 data->getSkColorSpace()));
899 if (!surface) 922 if (!surface)
900 return; 923 return;
901 SkPaint paint; 924 SkPaint paint;
902 paint.setFilterQuality(parsedOptions.resizeQuality); 925 paint.setFilterQuality(parsedOptions.resizeQuality);
903 SkRect dstDrawRect = 926 SkRect dstDrawRect =
904 SkRect::MakeWH(parsedOptions.resizeWidth, parsedOptions.resizeHeight); 927 SkRect::MakeWH(parsedOptions.resizeWidth, parsedOptions.resizeHeight);
905 surface->getCanvas()->drawImageRect(skImage, dstDrawRect, &paint); 928 surface->getCanvas()->drawImageRect(skImage, dstDrawRect, &paint);
906 skImage = surface->makeImageSnapshot(); 929 skImage = surface->makeImageSnapshot();
907 } 930 }
931 if (data->getSkColorSpace()) {
932 parsedOptions.latestColorSpace = data->getSkColorSpace();
933 applyColorSpaceConversion(skImage, parsedOptions);
934 }
908 m_image = StaticBitmapImage::create(std::move(skImage)); 935 m_image = StaticBitmapImage::create(std::move(skImage));
909 } 936 }
910 937
938 // TODO(zakerinasab): Fix the constructor from Float32ImageData.
911 ImageBitmap::ImageBitmap(Float32ImageData* data, 939 ImageBitmap::ImageBitmap(Float32ImageData* data,
912 Optional<IntRect> cropRect, 940 Optional<IntRect> cropRect,
913 const ImageBitmapOptions& options) {} 941 const ImageBitmapOptions& options) {}
914 942
915 ImageBitmap::ImageBitmap(ImageBitmap* bitmap, 943 ImageBitmap::ImageBitmap(ImageBitmap* bitmap,
916 Optional<IntRect> cropRect, 944 Optional<IntRect> cropRect,
917 const ImageBitmapOptions& options) { 945 const ImageBitmapOptions& options) {
918 RefPtr<Image> input = bitmap->bitmapImage(); 946 RefPtr<Image> input = bitmap->bitmapImage();
919 if (!input) 947 if (!input)
920 return; 948 return;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, 1136 void ImageBitmap::adjustDrawRects(FloatRect* srcRect,
1109 FloatRect* dstRect) const {} 1137 FloatRect* dstRect) const {}
1110 1138
1111 FloatSize ImageBitmap::elementSize(const FloatSize&) const { 1139 FloatSize ImageBitmap::elementSize(const FloatSize&) const {
1112 return FloatSize(width(), height()); 1140 return FloatSize(width(), height());
1113 } 1141 }
1114 1142
1115 DEFINE_TRACE(ImageBitmap) {} 1143 DEFINE_TRACE(ImageBitmap) {}
1116 1144
1117 } // namespace blink 1145 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/ImageBitmapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698