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

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: cleanup. tableChanged was wrong - do proper check. Created 5 years, 1 month 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 m_frameGenerator->setDecoderCanDecodeToIndex8(m_actualDecoder->canDecodeTo(0 , ImageFrame::Index8));
216 } 217 }
217 218
218 void DeferredImageDecoder::prepareLazyDecodedFrames() 219 void DeferredImageDecoder::prepareLazyDecodedFrames()
219 { 220 {
220 if (!s_enabled 221 if (!s_enabled
221 || !m_actualDecoder 222 || !m_actualDecoder
222 || !m_actualDecoder->isSizeAvailable() 223 || !m_actualDecoder->isSizeAvailable()
223 || m_actualDecoder->filenameExtension() == "ico") 224 || m_actualDecoder->filenameExtension() == "ico")
224 return; 225 return;
225 226
(...skipping 27 matching lines...) Expand all
253 } 254 }
254 } 255 }
255 256
256 // Creates an SkImage that is backed by SkDiscardablePixelRef. 257 // Creates an SkImage that is backed by SkDiscardablePixelRef.
257 PassRefPtr<SkImage> DeferredImageDecoder::createImage(size_t index, bool knownTo BeOpaque) const 258 PassRefPtr<SkImage> DeferredImageDecoder::createImage(size_t index, bool knownTo BeOpaque) const
258 { 259 {
259 SkISize decodedSize = m_frameGenerator->getFullSize(); 260 SkISize decodedSize = m_frameGenerator->getFullSize();
260 ASSERT(decodedSize.width() > 0); 261 ASSERT(decodedSize.width() > 0);
261 ASSERT(decodedSize.height() > 0); 262 ASSERT(decodedSize.height() > 0);
262 263
263 const SkImageInfo info = SkImageInfo::MakeN32(decodedSize.width(), decodedSi ze.height(), 264 const SkImageInfo info = m_frameGenerator->canDecodeTo(index, kIndex_8_SkCol orType)
264 knownToBeOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); 265 ? SkImageInfo::Make(decodedSize.width(), decodedSize.height(), kIndex_8_ SkColorType,
266 knownToBeOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType)
267 : SkImageInfo::MakeN32(decodedSize.width(), decodedSize.height(),
268 knownToBeOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
265 269
266 DecodingImageGenerator* generator = new DecodingImageGenerator(m_frameGenera tor, info, index); 270 DecodingImageGenerator* generator = new DecodingImageGenerator(m_frameGenera tor, info, index);
267 RefPtr<SkImage> image = adoptRef(SkImage::NewFromGenerator(generator)); 271 RefPtr<SkImage> image = adoptRef(SkImage::NewFromGenerator(generator));
268 if (!image) 272 if (!image)
269 return nullptr; 273 return nullptr;
270 274
271 generator->setGenerationId(image->uniqueID()); 275 generator->setGenerationId(image->uniqueID());
272 return image.release(); 276 return image.release();
273 } 277 }
274 278
275 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const 279 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const
276 { 280 {
277 // TODO: Implement. 281 // TODO: Implement.
278 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; 282 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false;
279 } 283 }
280 284
281 } // namespace blink 285 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698