| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "platform/graphics/gpu/WebGLImageConversion.h" | 5 #include "platform/graphics/gpu/WebGLImageConversion.h" |
| 6 | 6 |
| 7 #include "platform/graphics/ImageObserver.h" | 7 #include "platform/graphics/ImageObserver.h" |
| 8 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h" | 8 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h" |
| 9 #include "platform/graphics/cpu/mips/WebGLImageConversionMSA.h" | 9 #include "platform/graphics/cpu/mips/WebGLImageConversionMSA.h" |
| 10 #include "platform/graphics/cpu/x86/WebGLImageConversionSSE.h" | 10 #include "platform/graphics/cpu/x86/WebGLImageConversionSSE.h" |
| (...skipping 2671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2682 checkedValue += skipSize.ValueOrDie(); | 2682 checkedValue += skipSize.ValueOrDie(); |
| 2683 if (!checkedValue.IsValid()) | 2683 if (!checkedValue.IsValid()) |
| 2684 return GL_INVALID_VALUE; | 2684 return GL_INVALID_VALUE; |
| 2685 return GL_NO_ERROR; | 2685 return GL_NO_ERROR; |
| 2686 } | 2686 } |
| 2687 | 2687 |
| 2688 WebGLImageConversion::ImageExtractor::ImageExtractor( | 2688 WebGLImageConversion::ImageExtractor::ImageExtractor( |
| 2689 Image* image, | 2689 Image* image, |
| 2690 ImageHtmlDomSource imageHtmlDomSource, | 2690 ImageHtmlDomSource imageHtmlDomSource, |
| 2691 bool premultiplyAlpha, | 2691 bool premultiplyAlpha, |
| 2692 bool ignoreGammaAndColorProfile) { | 2692 bool ignoreColorSpace) { |
| 2693 m_image = image; | 2693 m_image = image; |
| 2694 m_imageHtmlDomSource = imageHtmlDomSource; | 2694 m_imageHtmlDomSource = imageHtmlDomSource; |
| 2695 extractImage(premultiplyAlpha, ignoreGammaAndColorProfile); | 2695 extractImage(premultiplyAlpha, ignoreColorSpace); |
| 2696 } | 2696 } |
| 2697 | 2697 |
| 2698 void WebGLImageConversion::ImageExtractor::extractImage( | 2698 void WebGLImageConversion::ImageExtractor::extractImage(bool premultiplyAlpha, |
| 2699 bool premultiplyAlpha, | 2699 bool ignoreColorSpace) { |
| 2700 bool ignoreGammaAndColorProfile) { | |
| 2701 ASSERT(!m_imagePixelLocker); | 2700 ASSERT(!m_imagePixelLocker); |
| 2702 | 2701 |
| 2703 if (!m_image) | 2702 if (!m_image) |
| 2704 return; | 2703 return; |
| 2705 | 2704 |
| 2706 sk_sp<SkImage> skiaImage = m_image->imageForCurrentFrame(); | 2705 sk_sp<SkImage> skiaImage = m_image->imageForCurrentFrame(); |
| 2707 SkImageInfo info = skiaImage ? SkImageInfo::MakeN32Premul(m_image->width(), | 2706 SkImageInfo info = skiaImage ? SkImageInfo::MakeN32Premul(m_image->width(), |
| 2708 m_image->height()) | 2707 m_image->height()) |
| 2709 : SkImageInfo::MakeUnknown(); | 2708 : SkImageInfo::MakeUnknown(); |
| 2710 m_alphaOp = AlphaDoNothing; | 2709 m_alphaOp = AlphaDoNothing; |
| 2711 bool hasAlpha = skiaImage ? !skiaImage->isOpaque() : true; | 2710 bool hasAlpha = skiaImage ? !skiaImage->isOpaque() : true; |
| 2712 | 2711 |
| 2713 if ((!skiaImage || ignoreGammaAndColorProfile || | 2712 if ((!skiaImage || ignoreColorSpace || (hasAlpha && !premultiplyAlpha)) && |
| 2714 (hasAlpha && !premultiplyAlpha)) && | |
| 2715 m_image->data()) { | 2713 m_image->data()) { |
| 2716 // Attempt to get raw unpremultiplied image data. | 2714 // Attempt to get raw unpremultiplied image data. |
| 2717 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create( | 2715 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create( |
| 2718 m_image->data(), true, ImageDecoder::AlphaNotPremultiplied, | 2716 m_image->data(), true, ImageDecoder::AlphaNotPremultiplied, |
| 2719 ignoreGammaAndColorProfile | 2717 ignoreColorSpace ? ImageDecoder::ColorSpaceIgnored |
| 2720 ? ImageDecoder::GammaAndColorProfileIgnored | 2718 : ImageDecoder::ColorSpaceApplied)); |
| 2721 : ImageDecoder::GammaAndColorProfileApplied)); | |
| 2722 if (!decoder || !decoder->frameCount()) | 2719 if (!decoder || !decoder->frameCount()) |
| 2723 return; | 2720 return; |
| 2724 ImageFrame* frame = decoder->frameBufferAtIndex(0); | 2721 ImageFrame* frame = decoder->frameBufferAtIndex(0); |
| 2725 if (!frame || frame->getStatus() != ImageFrame::FrameComplete) | 2722 if (!frame || frame->getStatus() != ImageFrame::FrameComplete) |
| 2726 return; | 2723 return; |
| 2727 hasAlpha = frame->hasAlpha(); | 2724 hasAlpha = frame->hasAlpha(); |
| 2728 SkBitmap bitmap = frame->bitmap(); | 2725 SkBitmap bitmap = frame->bitmap(); |
| 2729 if (!frameIsValid(bitmap)) | 2726 if (!frameIsValid(bitmap)) |
| 2730 return; | 2727 return; |
| 2731 | 2728 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3092 pack<WebGLImageConversion::DataFormatRGB565, | 3089 pack<WebGLImageConversion::DataFormatRGB565, |
| 3093 WebGLImageConversion::AlphaDoNothing>(srcRowStart, dstRowStart, | 3090 WebGLImageConversion::AlphaDoNothing>(srcRowStart, dstRowStart, |
| 3094 pixelsPerRow); | 3091 pixelsPerRow); |
| 3095 } break; | 3092 } break; |
| 3096 default: | 3093 default: |
| 3097 break; | 3094 break; |
| 3098 } | 3095 } |
| 3099 } | 3096 } |
| 3100 | 3097 |
| 3101 } // namespace blink | 3098 } // namespace blink |
| OLD | NEW |