| 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/CheckedInt.h" | 7 #include "platform/CheckedInt.h" |
| 8 #include "platform/graphics/ImageObserver.h" | 8 #include "platform/graphics/ImageObserver.h" |
| 9 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h" | 9 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h" |
| 10 #include "platform/graphics/cpu/x86/WebGLImageConversionSSE.h" | 10 #include "platform/graphics/cpu/x86/WebGLImageConversionSSE.h" |
| 11 #include "platform/image-decoders/ImageDecoder.h" | 11 #include "platform/image-decoders/ImageDecoder.h" |
| 12 #include "platform/image-decoders/SharedBufferSegmentReader.h" |
| 12 #include "third_party/skia/include/core/SkImage.h" | 13 #include "third_party/skia/include/core/SkImage.h" |
| 13 #include "wtf/OwnPtr.h" | 14 #include "wtf/OwnPtr.h" |
| 14 #include "wtf/PassOwnPtr.h" | 15 #include "wtf/PassOwnPtr.h" |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 const float maxInt8Value = INT8_MAX; | 21 const float maxInt8Value = INT8_MAX; |
| 21 const float maxUInt8Value = UINT8_MAX; | 22 const float maxUInt8Value = UINT8_MAX; |
| (...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2065 | 2066 |
| 2066 RefPtr<SkImage> skiaImage = m_image->imageForCurrentFrame(); | 2067 RefPtr<SkImage> skiaImage = m_image->imageForCurrentFrame(); |
| 2067 SkImageInfo info = skiaImage | 2068 SkImageInfo info = skiaImage |
| 2068 ? SkImageInfo::MakeN32Premul(m_image->width(), m_image->height()) | 2069 ? SkImageInfo::MakeN32Premul(m_image->width(), m_image->height()) |
| 2069 : SkImageInfo::MakeUnknown(); | 2070 : SkImageInfo::MakeUnknown(); |
| 2070 m_alphaOp = AlphaDoNothing; | 2071 m_alphaOp = AlphaDoNothing; |
| 2071 bool hasAlpha = skiaImage ? !skiaImage->isOpaque() : true; | 2072 bool hasAlpha = skiaImage ? !skiaImage->isOpaque() : true; |
| 2072 | 2073 |
| 2073 if ((!skiaImage || ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAl
pha)) && m_image->data()) { | 2074 if ((!skiaImage || ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAl
pha)) && m_image->data()) { |
| 2074 // Attempt to get raw unpremultiplied image data. | 2075 // Attempt to get raw unpremultiplied image data. |
| 2076 RefPtr<SharedBufferSegmentReader> segmentReader = adoptRef(new SharedBuf
ferSegmentReader(m_image->data())); |
| 2075 OwnPtr<ImageDecoder> decoder(ImageDecoder::create( | 2077 OwnPtr<ImageDecoder> decoder(ImageDecoder::create( |
| 2076 *(m_image->data()), ImageDecoder::AlphaNotPremultiplied, | 2078 *segmentReader.get(), ImageDecoder::AlphaNotPremultiplied, |
| 2077 ignoreGammaAndColorProfile ? ImageDecoder::GammaAndColorProfileIgnor
ed : ImageDecoder::GammaAndColorProfileApplied)); | 2079 ignoreGammaAndColorProfile ? ImageDecoder::GammaAndColorProfileIgnor
ed : ImageDecoder::GammaAndColorProfileApplied)); |
| 2078 if (!decoder) | 2080 if (!decoder) |
| 2079 return; | 2081 return; |
| 2080 decoder->setData(m_image->data(), true); | 2082 decoder->setData(segmentReader.get(), true); |
| 2081 if (!decoder->frameCount()) | 2083 if (!decoder->frameCount()) |
| 2082 return; | 2084 return; |
| 2083 ImageFrame* frame = decoder->frameBufferAtIndex(0); | 2085 ImageFrame* frame = decoder->frameBufferAtIndex(0); |
| 2084 if (!frame || frame->status() != ImageFrame::FrameComplete) | 2086 if (!frame || frame->status() != ImageFrame::FrameComplete) |
| 2085 return; | 2087 return; |
| 2086 hasAlpha = frame->hasAlpha(); | 2088 hasAlpha = frame->hasAlpha(); |
| 2087 SkBitmap bitmap = frame->bitmap(); | 2089 SkBitmap bitmap = frame->bitmap(); |
| 2088 if (!frameIsValid(bitmap)) | 2090 if (!frameIsValid(bitmap)) |
| 2089 return; | 2091 return; |
| 2090 | 2092 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2331 } | 2333 } |
| 2332 | 2334 |
| 2333 FormatConverter converter(width, height, sourceData, destinationData, srcStr
ide, dstStride); | 2335 FormatConverter converter(width, height, sourceData, destinationData, srcStr
ide, dstStride); |
| 2334 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); | 2336 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); |
| 2335 if (!converter.Success()) | 2337 if (!converter.Success()) |
| 2336 return false; | 2338 return false; |
| 2337 return true; | 2339 return true; |
| 2338 } | 2340 } |
| 2339 | 2341 |
| 2340 } // namespace blink | 2342 } // namespace blink |
| OLD | NEW |