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

Unified Diff: third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp

Issue 1460523002: GIF decoding to Index8, unit tests and misusing unit test as benchmark (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Skia:onGetColorType related implementation. Fix part of Leon's review comments. Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp b/third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp
index a1adcce004f065ad73110d3e77733144419bfd66..de91b558ba91bdc9d57d62dd89d0b17578500fd5 100644
--- a/third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp
+++ b/third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp
@@ -71,14 +71,15 @@ bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels,
if (info.width() != getInfo().width() || info.height() != getInfo().height())
return false;
- if (info.colorType() != getInfo().colorType()) {
+ // if colorType declared in getInfo() fails, Skia would fetch N32 version
+ if (info.colorType() != getInfo().colorType() && info.colorType() != kN32_SkColorType) {
// ImageFrame may have changed the owning SkBitmap to kOpaque_SkAlphaType after sniffing the encoded data, so if we see a request
// for opaque, that is ok even if our initial alphatype was not opaque.
return false;
}
PlatformInstrumentation::willDecodeLazyPixelRef(m_generationId);
- bool decoded = m_frameGenerator->decodeAndScale(getInfo(), m_frameIndex, pixels, rowBytes);
+ bool decoded = m_frameGenerator->decodeAndScale(info, m_frameIndex, pixels, rowBytes, ctable, ctableCount);
PlatformInstrumentation::didDecodeLazyPixelRef();
return decoded;
@@ -116,7 +117,9 @@ SkImageGenerator* DecodingImageGenerator::create(SkData* data)
return 0;
const IntSize size = decoder->size();
- const SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height());
+ const SkImageInfo info = decoder->canDecodeTo(0, ImageFrame::Index8)
+ ? SkImageInfo::Make(size.width(), size.height(), kIndex_8_SkColorType, kPremul_SkAlphaType)
+ : SkImageInfo::MakeN32Premul(size.width(), size.height());
RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Make(size.width(), size.height()), buffer, true, false);
if (!frame)
@@ -125,5 +128,14 @@ SkImageGenerator* DecodingImageGenerator::create(SkData* data)
return new DecodingImageGenerator(frame, info, 0);
}
+SkColorType DecodingImageGenerator::onGetColorType()
+{
+ // GIFDecoder: generator info is Index8 when constructed. but after downloading data this could
+ // change - it could turn out that some frames can be decoded only to N32.
+ if (m_frameGenerator->canDecodeTo(m_frameIndex, kIndex_8_SkColorType))
+ return kIndex_8_SkColorType;
+ return kN32_SkColorType;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698