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" |
(...skipping 2115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2126 | 2126 |
2127 void WebGLImageConversion::ImageExtractor::extractImage(bool premultiplyAlpha, b
ool ignoreGammaAndColorProfile) | 2127 void WebGLImageConversion::ImageExtractor::extractImage(bool premultiplyAlpha, b
ool ignoreGammaAndColorProfile) |
2128 { | 2128 { |
2129 ASSERT(!m_imagePixelLocker); | 2129 ASSERT(!m_imagePixelLocker); |
2130 | 2130 |
2131 if (!m_image) | 2131 if (!m_image) |
2132 return; | 2132 return; |
2133 | 2133 |
2134 RefPtr<SkImage> skiaImage = m_image->imageForCurrentFrame(); | 2134 RefPtr<SkImage> skiaImage = m_image->imageForCurrentFrame(); |
2135 SkImageInfo info = skiaImage | 2135 SkImageInfo info = skiaImage |
2136 ? SkImageInfo::MakeN32Premul(m_image->width(), m_image->height()) | 2136 ? SkImageInfo::MakeN32Premul(m_image->defaultConcreteObjectSizeWidth(),
m_image->defaultConcreteObjectSizeHeight()) |
2137 : SkImageInfo::MakeUnknown(); | 2137 : SkImageInfo::MakeUnknown(); |
2138 m_alphaOp = AlphaDoNothing; | 2138 m_alphaOp = AlphaDoNothing; |
2139 bool hasAlpha = skiaImage ? !skiaImage->isOpaque() : true; | 2139 bool hasAlpha = skiaImage ? !skiaImage->isOpaque() : true; |
2140 | 2140 |
2141 if ((!skiaImage || ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAl
pha)) && m_image->data()) { | 2141 if ((!skiaImage || ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAl
pha)) && m_image->data()) { |
2142 // Attempt to get raw unpremultiplied image data. | 2142 // Attempt to get raw unpremultiplied image data. |
2143 OwnPtr<ImageDecoder> decoder(ImageDecoder::create( | 2143 OwnPtr<ImageDecoder> decoder(ImageDecoder::create( |
2144 *(m_image->data()), ImageDecoder::AlphaNotPremultiplied, | 2144 *(m_image->data()), ImageDecoder::AlphaNotPremultiplied, |
2145 ignoreGammaAndColorProfile ? ImageDecoder::GammaAndColorProfileIgnor
ed : ImageDecoder::GammaAndColorProfileApplied)); | 2145 ignoreGammaAndColorProfile ? ImageDecoder::GammaAndColorProfileIgnor
ed : ImageDecoder::GammaAndColorProfileApplied)); |
2146 if (!decoder) | 2146 if (!decoder) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 return; | 2178 return; |
2179 | 2179 |
2180 m_imageSourceFormat = SK_B32_SHIFT ? DataFormatRGBA8 : DataFormatBGRA8; | 2180 m_imageSourceFormat = SK_B32_SHIFT ? DataFormatRGBA8 : DataFormatBGRA8; |
2181 m_imageSourceUnpackAlignment = 0; // FIXME: this seems to always be zero - w
hy use at all? | 2181 m_imageSourceUnpackAlignment = 0; // FIXME: this seems to always be zero - w
hy use at all? |
2182 | 2182 |
2183 ASSERT(skiaImage->width() && skiaImage->height()); | 2183 ASSERT(skiaImage->width() && skiaImage->height()); |
2184 m_imageWidth = skiaImage->width(); | 2184 m_imageWidth = skiaImage->width(); |
2185 m_imageHeight = skiaImage->height(); | 2185 m_imageHeight = skiaImage->height(); |
2186 | 2186 |
2187 // Fail if the image was downsampled because of memory limits. | 2187 // Fail if the image was downsampled because of memory limits. |
2188 if (m_imageWidth != (unsigned)m_image->width() || m_imageHeight != (unsigned
)m_image->height()) | 2188 if (m_imageWidth != (unsigned)m_image->defaultConcreteObjectSizeWidth() || m
_imageHeight != (unsigned)m_image->defaultConcreteObjectSizeHeight()) |
2189 return; | 2189 return; |
2190 | 2190 |
2191 m_imagePixelLocker.emplace(skiaImage, info.alphaType()); | 2191 m_imagePixelLocker.emplace(skiaImage, info.alphaType()); |
2192 } | 2192 } |
2193 | 2193 |
2194 unsigned WebGLImageConversion::getChannelBitsByFormat(GLenum format) | 2194 unsigned WebGLImageConversion::getChannelBitsByFormat(GLenum format) |
2195 { | 2195 { |
2196 switch (format) { | 2196 switch (format) { |
2197 case GL_ALPHA: | 2197 case GL_ALPHA: |
2198 return ChannelAlpha; | 2198 return ChannelAlpha; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2403 } | 2403 } |
2404 | 2404 |
2405 FormatConverter converter(width, height, sourceData, destinationData, srcStr
ide, dstStride); | 2405 FormatConverter converter(width, height, sourceData, destinationData, srcStr
ide, dstStride); |
2406 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); | 2406 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); |
2407 if (!converter.Success()) | 2407 if (!converter.Success()) |
2408 return false; | 2408 return false; |
2409 return true; | 2409 return true; |
2410 } | 2410 } |
2411 | 2411 |
2412 } // namespace blink | 2412 } // namespace blink |
OLD | NEW |