OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 DOMArrayBufferBase* ImageData::BufferBase() const { | 626 DOMArrayBufferBase* ImageData::BufferBase() const { |
627 if (data_) | 627 if (data_) |
628 return data_->BufferBase(); | 628 return data_->BufferBase(); |
629 if (data_u16_) | 629 if (data_u16_) |
630 return data_u16_->BufferBase(); | 630 return data_u16_->BufferBase(); |
631 if (data_f32_) | 631 if (data_f32_) |
632 return data_f32_->BufferBase(); | 632 return data_f32_->BufferBase(); |
633 return nullptr; | 633 return nullptr; |
634 } | 634 } |
635 | 635 |
636 // For ImageData, the color space is only specified by color settings. | 636 CanvasColorParams ImageData::GetCanvasColorParams() { |
637 // It cannot have a SkColorSpace. This doesn't mean anything. Fix this. | 637 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() || |
638 sk_sp<SkColorSpace> ImageData::GetSkColorSpace() { | 638 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) |
639 if (!RuntimeEnabledFeatures::colorCanvasExtensionsEnabled()) | 639 return CanvasColorParams(); |
640 return nullptr; | |
641 | 640 |
642 return SkColorSpace::MakeSRGB(); | 641 CanvasColorSpace color_space = |
| 642 ImageData::GetCanvasColorSpace(color_settings_.colorSpace()); |
| 643 CanvasPixelFormat pixel_format = kRGBA8CanvasPixelFormat; |
| 644 if (color_settings_.storageFormat() != kUint8ClampedArrayStorageFormatName) |
| 645 pixel_format = kF16CanvasPixelFormat; |
| 646 return CanvasColorParams(color_space, pixel_format); |
643 } | 647 } |
644 | 648 |
645 bool ImageData::ImageDataInCanvasColorSettings( | 649 bool ImageData::ImageDataInCanvasColorSettings( |
646 const CanvasColorSpace& canvas_color_space, | 650 const CanvasColorSpace& canvas_color_space, |
647 const CanvasPixelFormat& canvas_pixel_format, | 651 const CanvasPixelFormat& canvas_pixel_format, |
648 std::unique_ptr<uint8_t[]>& converted_pixels) { | 652 std::unique_ptr<uint8_t[]>& converted_pixels) { |
649 if (!data_ && !data_u16_ && !data_f32_) | 653 if (!data_ && !data_u16_ && !data_f32_) |
650 return false; | 654 return false; |
651 | 655 |
652 // If canvas and image data are both in the same color space and pixel format | 656 // If canvas and image data are both in the same color space and pixel format |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 | 727 |
724 std::unique_ptr<SkColorSpaceXform> xform = | 728 std::unique_ptr<SkColorSpaceXform> xform = |
725 SkColorSpaceXform::New(src_color_space.get(), dst_color_space.get()); | 729 SkColorSpaceXform::New(src_color_space.get(), dst_color_space.get()); |
726 | 730 |
727 if (!xform->apply(dst_color_format, converted_pixels.get(), src_color_format, | 731 if (!xform->apply(dst_color_format, converted_pixels.get(), src_color_format, |
728 src_data, num_pixels, SkAlphaType::kUnpremul_SkAlphaType)) | 732 src_data, num_pixels, SkAlphaType::kUnpremul_SkAlphaType)) |
729 return false; | 733 return false; |
730 return true; | 734 return true; |
731 } | 735 } |
732 | 736 |
| 737 bool ImageData::ImageDataInCanvasColorSettings( |
| 738 const CanvasColorParams& canvas_color_params, |
| 739 std::unique_ptr<uint8_t[]>& converted_pixels) { |
| 740 return ImageDataInCanvasColorSettings(canvas_color_params.color_space(), |
| 741 canvas_color_params.pixel_format(), |
| 742 converted_pixels); |
| 743 } |
| 744 |
733 void ImageData::Trace(Visitor* visitor) { | 745 void ImageData::Trace(Visitor* visitor) { |
734 visitor->Trace(data_); | 746 visitor->Trace(data_); |
735 visitor->Trace(data_u16_); | 747 visitor->Trace(data_u16_); |
736 visitor->Trace(data_f32_); | 748 visitor->Trace(data_f32_); |
737 visitor->Trace(data_union_); | 749 visitor->Trace(data_union_); |
738 } | 750 } |
739 | 751 |
740 ImageData::ImageData(const IntSize& size, | 752 ImageData::ImageData(const IntSize& size, |
741 DOMArrayBufferView* data, | 753 DOMArrayBufferView* data, |
742 const ImageDataColorSettings* color_settings) | 754 const ImageDataColorSettings* color_settings) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 SECURITY_CHECK(static_cast<unsigned>(size.Width() * size.Height() * 4) <= | 800 SECURITY_CHECK(static_cast<unsigned>(size.Width() * size.Height() * 4) <= |
789 data_f32_->length()); | 801 data_f32_->length()); |
790 break; | 802 break; |
791 | 803 |
792 default: | 804 default: |
793 NOTREACHED(); | 805 NOTREACHED(); |
794 } | 806 } |
795 } | 807 } |
796 | 808 |
797 } // namespace blink | 809 } // namespace blink |
OLD | NEW |