| 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 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1921 } | 1921 } |
| 1922 } | 1922 } |
| 1923 m_success = true; | 1923 m_success = true; |
| 1924 return; | 1924 return; |
| 1925 } | 1925 } |
| 1926 | 1926 |
| 1927 bool frameIsValid(const SkBitmap& frameBitmap) | 1927 bool frameIsValid(const SkBitmap& frameBitmap) |
| 1928 { | 1928 { |
| 1929 return !frameBitmap.isNull() | 1929 return !frameBitmap.isNull() |
| 1930 && !frameBitmap.empty() | 1930 && !frameBitmap.empty() |
| 1931 && frameBitmap.isImmutable() | |
| 1932 && frameBitmap.colorType() == kN32_SkColorType; | 1931 && frameBitmap.colorType() == kN32_SkColorType; |
| 1933 } | 1932 } |
| 1934 | 1933 |
| 1935 } // anonymous namespace | 1934 } // anonymous namespace |
| 1936 | 1935 |
| 1937 WebGLImageConversion::PixelStoreParams::PixelStoreParams() | 1936 WebGLImageConversion::PixelStoreParams::PixelStoreParams() |
| 1938 : alignment(4) | 1937 : alignment(4) |
| 1939 , rowLength(0) | 1938 , rowLength(0) |
| 1940 , imageHeight(0) | 1939 , imageHeight(0) |
| 1941 , skipPixels(0) | 1940 , skipPixels(0) |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2150 if (!decoder->frameCount()) | 2149 if (!decoder->frameCount()) |
| 2151 return; | 2150 return; |
| 2152 ImageFrame* frame = decoder->frameBufferAtIndex(0); | 2151 ImageFrame* frame = decoder->frameBufferAtIndex(0); |
| 2153 if (!frame || frame->getStatus() != ImageFrame::FrameComplete) | 2152 if (!frame || frame->getStatus() != ImageFrame::FrameComplete) |
| 2154 return; | 2153 return; |
| 2155 hasAlpha = frame->hasAlpha(); | 2154 hasAlpha = frame->hasAlpha(); |
| 2156 SkBitmap bitmap = frame->bitmap(); | 2155 SkBitmap bitmap = frame->bitmap(); |
| 2157 if (!frameIsValid(bitmap)) | 2156 if (!frameIsValid(bitmap)) |
| 2158 return; | 2157 return; |
| 2159 | 2158 |
| 2160 // TODO(fmalita): Partial frames are not supported currently: frameIsVal
id ensures that | 2159 // TODO(fmalita): Partial frames are not supported currently: only fully |
| 2161 // only immutable/fully decoded frames make it through. We could potent
ially relax this | 2160 // decoded frames make it through. We could potentially relax this and |
| 2162 // and allow SkImage::NewFromBitmap to make a copy. | 2161 // use SkImage::MakeFromBitmap(bitmap) to make a copy. |
| 2163 ASSERT(bitmap.isImmutable()); | 2162 skiaImage = fromSkSp(frame->finalizePixelsAndGetImage()); |
| 2164 skiaImage = fromSkSp(SkImage::MakeFromBitmap(bitmap)); | |
| 2165 info = bitmap.info(); | 2163 info = bitmap.info(); |
| 2166 | 2164 |
| 2167 if (hasAlpha && premultiplyAlpha) | 2165 if (hasAlpha && premultiplyAlpha) |
| 2168 m_alphaOp = AlphaDoPremultiply; | 2166 m_alphaOp = AlphaDoPremultiply; |
| 2169 } else if (!premultiplyAlpha && hasAlpha) { | 2167 } else if (!premultiplyAlpha && hasAlpha) { |
| 2170 // 1. For texImage2D with HTMLVideoElment input, assume no PremultiplyAl
pha had been applied and the alpha value for each pixel is 0xFF | 2168 // 1. For texImage2D with HTMLVideoElment input, assume no PremultiplyAl
pha had been applied and the alpha value for each pixel is 0xFF |
| 2171 // which is true at present and may be changed in the future and needs a
djustment accordingly. | 2169 // which is true at present and may be changed in the future and needs a
djustment accordingly. |
| 2172 // 2. For texImage2D with HTMLCanvasElement input in which Alpha is alre
ady Premultiplied in this port, | 2170 // 2. For texImage2D with HTMLCanvasElement input in which Alpha is alre
ady Premultiplied in this port, |
| 2173 // do AlphaDoUnmultiply if UNPACK_PREMULTIPLY_ALPHA_WEBGL is set to fals
e. | 2171 // do AlphaDoUnmultiply if UNPACK_PREMULTIPLY_ALPHA_WEBGL is set to fals
e. |
| 2174 if (m_imageHtmlDomSource != HtmlDomVideo) | 2172 if (m_imageHtmlDomSource != HtmlDomVideo) |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2405 } | 2403 } |
| 2406 | 2404 |
| 2407 FormatConverter converter(width, height, sourceData, destinationData, srcStr
ide, dstStride); | 2405 FormatConverter converter(width, height, sourceData, destinationData, srcStr
ide, dstStride); |
| 2408 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); | 2406 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); |
| 2409 if (!converter.Success()) | 2407 if (!converter.Success()) |
| 2410 return false; | 2408 return false; |
| 2411 return true; | 2409 return true; |
| 2412 } | 2410 } |
| 2413 | 2411 |
| 2414 } // namespace blink | 2412 } // namespace blink |
| OLD | NEW |