Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/WebGLImageConversion.cpp

Issue 2290903002: Change (Pass)RefPtr<SkXxx> into sk_sp<SkXxx>. (Closed)
Patch Set: Self-review. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 extractImage(premultiplyAlpha, ignoreGammaAndColorProfile); 2125 extractImage(premultiplyAlpha, ignoreGammaAndColorProfile);
2126 } 2126 }
2127 2127
2128 void WebGLImageConversion::ImageExtractor::extractImage(bool premultiplyAlpha, b ool ignoreGammaAndColorProfile) 2128 void WebGLImageConversion::ImageExtractor::extractImage(bool premultiplyAlpha, b ool ignoreGammaAndColorProfile)
2129 { 2129 {
2130 ASSERT(!m_imagePixelLocker); 2130 ASSERT(!m_imagePixelLocker);
2131 2131
2132 if (!m_image) 2132 if (!m_image)
2133 return; 2133 return;
2134 2134
2135 RefPtr<SkImage> skiaImage = m_image->imageForCurrentFrame(); 2135 sk_sp<SkImage> skiaImage = m_image->imageForCurrentFrame();
2136 SkImageInfo info = skiaImage 2136 SkImageInfo info = skiaImage
2137 ? SkImageInfo::MakeN32Premul(m_image->width(), m_image->height()) 2137 ? SkImageInfo::MakeN32Premul(m_image->width(), m_image->height())
2138 : SkImageInfo::MakeUnknown(); 2138 : SkImageInfo::MakeUnknown();
2139 m_alphaOp = AlphaDoNothing; 2139 m_alphaOp = AlphaDoNothing;
2140 bool hasAlpha = skiaImage ? !skiaImage->isOpaque() : true; 2140 bool hasAlpha = skiaImage ? !skiaImage->isOpaque() : true;
2141 2141
2142 if ((!skiaImage || ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAl pha)) && m_image->data()) { 2142 if ((!skiaImage || ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAl pha)) && m_image->data()) {
2143 // Attempt to get raw unpremultiplied image data. 2143 // Attempt to get raw unpremultiplied image data.
2144 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create( 2144 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create(
2145 m_image->data(), true, ImageDecoder::AlphaNotPremultiplied, 2145 m_image->data(), true, ImageDecoder::AlphaNotPremultiplied,
2146 ignoreGammaAndColorProfile ? ImageDecoder::GammaAndColorProfileIgnor ed : ImageDecoder::GammaAndColorProfileApplied)); 2146 ignoreGammaAndColorProfile ? ImageDecoder::GammaAndColorProfileIgnor ed : ImageDecoder::GammaAndColorProfileApplied));
2147 if (!decoder || !decoder->frameCount()) 2147 if (!decoder || !decoder->frameCount())
2148 return; 2148 return;
2149 ImageFrame* frame = decoder->frameBufferAtIndex(0); 2149 ImageFrame* frame = decoder->frameBufferAtIndex(0);
2150 if (!frame || frame->getStatus() != ImageFrame::FrameComplete) 2150 if (!frame || frame->getStatus() != ImageFrame::FrameComplete)
2151 return; 2151 return;
2152 hasAlpha = frame->hasAlpha(); 2152 hasAlpha = frame->hasAlpha();
2153 SkBitmap bitmap = frame->bitmap(); 2153 SkBitmap bitmap = frame->bitmap();
2154 if (!frameIsValid(bitmap)) 2154 if (!frameIsValid(bitmap))
2155 return; 2155 return;
2156 2156
2157 // TODO(fmalita): Partial frames are not supported currently: frameIsVal id ensures that 2157 // TODO(fmalita): Partial frames are not supported currently: frameIsVal id ensures that
2158 // only immutable/fully decoded frames make it through. We could potent ially relax this 2158 // only immutable/fully decoded frames make it through. We could potent ially relax this
2159 // and allow SkImage::NewFromBitmap to make a copy. 2159 // and allow SkImage::NewFromBitmap to make a copy.
2160 ASSERT(bitmap.isImmutable()); 2160 ASSERT(bitmap.isImmutable());
2161 skiaImage = fromSkSp(SkImage::MakeFromBitmap(bitmap)); 2161 skiaImage = SkImage::MakeFromBitmap(bitmap);
2162 info = bitmap.info(); 2162 info = bitmap.info();
2163 2163
2164 if (hasAlpha && premultiplyAlpha) 2164 if (hasAlpha && premultiplyAlpha)
2165 m_alphaOp = AlphaDoPremultiply; 2165 m_alphaOp = AlphaDoPremultiply;
2166 } else if (!premultiplyAlpha && hasAlpha) { 2166 } else if (!premultiplyAlpha && hasAlpha) {
2167 // 1. For texImage2D with HTMLVideoElment input, assume no PremultiplyAl pha had been applied and the alpha value for each pixel is 0xFF 2167 // 1. For texImage2D with HTMLVideoElment input, assume no PremultiplyAl pha had been applied and the alpha value for each pixel is 0xFF
2168 // which is true at present and may be changed in the future and needs a djustment accordingly. 2168 // which is true at present and may be changed in the future and needs a djustment accordingly.
2169 // 2. For texImage2D with HTMLCanvasElement input in which Alpha is alre ady Premultiplied in this port, 2169 // 2. For texImage2D with HTMLCanvasElement input in which Alpha is alre ady Premultiplied in this port,
2170 // do AlphaDoUnmultiply if UNPACK_PREMULTIPLY_ALPHA_WEBGL is set to fals e. 2170 // do AlphaDoUnmultiply if UNPACK_PREMULTIPLY_ALPHA_WEBGL is set to fals e.
2171 if (m_imageHtmlDomSource != HtmlDomVideo) 2171 if (m_imageHtmlDomSource != HtmlDomVideo)
2172 m_alphaOp = AlphaDoUnmultiply; 2172 m_alphaOp = AlphaDoUnmultiply;
2173 } 2173 }
2174 2174
2175 if (!skiaImage) 2175 if (!skiaImage)
2176 return; 2176 return;
2177 2177
2178 m_imageSourceFormat = SK_B32_SHIFT ? DataFormatRGBA8 : DataFormatBGRA8; 2178 m_imageSourceFormat = SK_B32_SHIFT ? DataFormatRGBA8 : DataFormatBGRA8;
2179 m_imageSourceUnpackAlignment = 0; // FIXME: this seems to always be zero - w hy use at all? 2179 m_imageSourceUnpackAlignment = 0; // FIXME: this seems to always be zero - w hy use at all?
2180 2180
2181 ASSERT(skiaImage->width() && skiaImage->height()); 2181 ASSERT(skiaImage->width() && skiaImage->height());
2182 m_imageWidth = skiaImage->width(); 2182 m_imageWidth = skiaImage->width();
2183 m_imageHeight = skiaImage->height(); 2183 m_imageHeight = skiaImage->height();
2184 2184
2185 // Fail if the image was downsampled because of memory limits. 2185 // Fail if the image was downsampled because of memory limits.
2186 if (m_imageWidth != (unsigned)m_image->width() || m_imageHeight != (unsigned )m_image->height()) 2186 if (m_imageWidth != (unsigned)m_image->width() || m_imageHeight != (unsigned )m_image->height())
2187 return; 2187 return;
2188 2188
2189 m_imagePixelLocker.emplace(skiaImage, info.alphaType(), kN32_SkColorType); 2189 m_imagePixelLocker.emplace(skiaImage, info.alphaType(), kN32_SkColorType);
f(malita) 2016/09/01 03:55:38 std::move(skiaImage)
Łukasz Anforowicz 2016/09/01 20:50:58 Done.
2190 } 2190 }
2191 2191
2192 unsigned WebGLImageConversion::getChannelBitsByFormat(GLenum format) 2192 unsigned WebGLImageConversion::getChannelBitsByFormat(GLenum format)
2193 { 2193 {
2194 switch (format) { 2194 switch (format) {
2195 case GL_ALPHA: 2195 case GL_ALPHA:
2196 return ChannelAlpha; 2196 return ChannelAlpha;
2197 case GL_RED: 2197 case GL_RED:
2198 case GL_RED_INTEGER: 2198 case GL_RED_INTEGER:
2199 case GL_R8: 2199 case GL_R8:
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2402 } 2402 }
2403 2403
2404 FormatConverter converter(width, height, sourceData, destinationData, srcStr ide, dstStride); 2404 FormatConverter converter(width, height, sourceData, destinationData, srcStr ide, dstStride);
2405 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); 2405 converter.convert(sourceDataFormat, dstDataFormat, alphaOp);
2406 if (!converter.Success()) 2406 if (!converter.Success())
2407 return false; 2407 return false;
2408 return true; 2408 return true;
2409 } 2409 }
2410 2410
2411 } // namespace blink 2411 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698