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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 void DeferredImageDecoder::activateLazyDecoding() 207 void DeferredImageDecoder::activateLazyDecoding()
208 { 208 {
209 if (m_frameGenerator) 209 if (m_frameGenerator)
210 return; 210 return;
211 m_size = m_actualDecoder->size(); 211 m_size = m_actualDecoder->size();
212 m_filenameExtension = m_actualDecoder->filenameExtension(); 212 m_filenameExtension = m_actualDecoder->filenameExtension();
213 m_hasColorProfile = m_actualDecoder->hasColorProfile(); 213 m_hasColorProfile = m_actualDecoder->hasColorProfile();
214 const bool isSingleFrame = m_actualDecoder->repetitionCount() == cAnimationN one || (m_allDataReceived && m_actualDecoder->frameCount() == 1u); 214 const bool isSingleFrame = m_actualDecoder->repetitionCount() == cAnimationN one || (m_allDataReceived && m_actualDecoder->frameCount() == 1u);
215 m_frameGenerator = ImageFrameGenerator::create(SkISize::Make(m_actualDecoder ->decodedSize().width(), m_actualDecoder->decodedSize().height()), m_data, m_all DataReceived, !isSingleFrame); 215 m_frameGenerator = ImageFrameGenerator::create(SkISize::Make(m_actualDecoder ->decodedSize().width(), m_actualDecoder->decodedSize().height()), m_data, m_all DataReceived, !isSingleFrame);
216 // GIF images support Index8 decoding: other decoders do not.
217 m_frameGenerator->setDecoderCanDecodeToIndex8(m_filenameExtension == "gif");
216 } 218 }
217 219
218 void DeferredImageDecoder::prepareLazyDecodedFrames() 220 void DeferredImageDecoder::prepareLazyDecodedFrames()
219 { 221 {
220 if (!s_enabled 222 if (!s_enabled
221 || !m_actualDecoder 223 || !m_actualDecoder
222 || !m_actualDecoder->isSizeAvailable() 224 || !m_actualDecoder->isSizeAvailable()
223 || m_actualDecoder->filenameExtension() == "ico") 225 || m_actualDecoder->filenameExtension() == "ico")
224 return; 226 return;
225 227
(...skipping 27 matching lines...) Expand all
253 } 255 }
254 } 256 }
255 257
256 // Creates an SkImage that is backed by SkDiscardablePixelRef. 258 // Creates an SkImage that is backed by SkDiscardablePixelRef.
257 PassRefPtr<SkImage> DeferredImageDecoder::createImage(size_t index, bool knownTo BeOpaque) const 259 PassRefPtr<SkImage> DeferredImageDecoder::createImage(size_t index, bool knownTo BeOpaque) const
258 { 260 {
259 SkISize decodedSize = m_frameGenerator->getFullSize(); 261 SkISize decodedSize = m_frameGenerator->getFullSize();
260 ASSERT(decodedSize.width() > 0); 262 ASSERT(decodedSize.width() > 0);
261 ASSERT(decodedSize.height() > 0); 263 ASSERT(decodedSize.height() > 0);
262 264
263 const SkImageInfo info = SkImageInfo::MakeN32(decodedSize.width(), decodedSi ze.height(), 265 const SkImageInfo info = m_frameGenerator->canDecodeTo(index, kIndex_8_SkCol orType)
264 knownToBeOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); 266 ? SkImageInfo::Make(decodedSize.width(), decodedSize.height(), kIndex_8_ SkColorType,
267 knownToBeOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType)
268 : SkImageInfo::MakeN32(decodedSize.width(), decodedSize.height(),
269 knownToBeOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
265 270
266 DecodingImageGenerator* generator = new DecodingImageGenerator(m_frameGenera tor, info, index); 271 DecodingImageGenerator* generator = new DecodingImageGenerator(m_frameGenera tor, info, index);
267 RefPtr<SkImage> image = adoptRef(SkImage::NewFromGenerator(generator)); 272 RefPtr<SkImage> image = adoptRef(SkImage::NewFromGenerator(generator));
268 if (!image) 273 if (!image)
269 return nullptr; 274 return nullptr;
270 275
271 generator->setGenerationId(image->uniqueID()); 276 generator->setGenerationId(image->uniqueID());
272 return image.release(); 277 return image.release();
273 } 278 }
274 279
275 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const 280 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const
276 { 281 {
277 // TODO: Implement. 282 // TODO: Implement.
278 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; 283 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false;
279 } 284 }
280 285
281 } // namespace blink 286 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698