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

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

Issue 2257513002: Refactor ImageDecoder factories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 years, 4 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 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 RefPtr<SkImage> skiaImage = m_image->imageForCurrentFrame(); 2135 RefPtr<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 ImageDecoder::determineImageType(*(m_image->data())), 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) 2147 if (!decoder || !decoder->frameCount())
2148 return;
2149 decoder->setData(m_image->data(), true);
2150 if (!decoder->frameCount())
2151 return; 2148 return;
2152 ImageFrame* frame = decoder->frameBufferAtIndex(0); 2149 ImageFrame* frame = decoder->frameBufferAtIndex(0);
2153 if (!frame || frame->getStatus() != ImageFrame::FrameComplete) 2150 if (!frame || frame->getStatus() != ImageFrame::FrameComplete)
2154 return; 2151 return;
2155 hasAlpha = frame->hasAlpha(); 2152 hasAlpha = frame->hasAlpha();
2156 SkBitmap bitmap = frame->bitmap(); 2153 SkBitmap bitmap = frame->bitmap();
2157 if (!frameIsValid(bitmap)) 2154 if (!frameIsValid(bitmap))
2158 return; 2155 return;
2159 2156
2160 // 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
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 } 2402 }
2406 2403
2407 FormatConverter converter(width, height, sourceData, destinationData, srcStr ide, dstStride); 2404 FormatConverter converter(width, height, sourceData, destinationData, srcStr ide, dstStride);
2408 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); 2405 converter.convert(sourceDataFormat, dstDataFormat, alphaOp);
2409 if (!converter.Success()) 2406 if (!converter.Success())
2410 return false; 2407 return false;
2411 return true; 2408 return true;
2412 } 2409 }
2413 2410
2414 } // namespace blink 2411 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698