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

Side by Side Diff: Source/platform/graphics/BitmapImage.cpp

Issue 1242263011: Record UMA stats for Blink decoded image types (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: move enum to source file Created 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 if (!m_haveFrameCount) { 326 if (!m_haveFrameCount) {
327 m_frameCount = m_source.frameCount(); 327 m_frameCount = m_source.frameCount();
328 // If decoder is not initialized yet, m_source.frameCount() returns 0. 328 // If decoder is not initialized yet, m_source.frameCount() returns 0.
329 if (m_frameCount) 329 if (m_frameCount)
330 m_haveFrameCount = true; 330 m_haveFrameCount = true;
331 } 331 }
332 332
333 return m_frameCount; 333 return m_frameCount;
334 } 334 }
335 335
336 enum DecodedImageType {
337 // These values are histogrammed over time; do not change their ordinal
338 // values. When deleting an image type, replace it with a dummy value;
339 // when adding an image type, do so at the bottom (and update LastDecodedIma geType
340 // so that it equals the last real image type).
341 // Also, this enum should be in sync with the 'DecodedImageType' enum in
342 // src/tools/metrics/histograms/histograms.xml
343 ImageUnknown = 0,
344 ImageJPEG,
345 ImagePNG,
346 ImageGIF,
347 ImageWebP,
348 ImageICO,
349 ImageBMP,
350
351 LastDecodedImageType = ImageBMP
352 };
353
354 static inline bool hasVisibleImageSize(IntSize size)
355 {
356 return (size.width() > 1 || size.height() > 1);
357 }
358
336 bool BitmapImage::isSizeAvailable() 359 bool BitmapImage::isSizeAvailable()
337 { 360 {
338 if (m_sizeAvailable) 361 if (m_sizeAvailable)
339 return true; 362 return true;
340 363
341 m_sizeAvailable = m_source.isSizeAvailable(); 364 m_sizeAvailable = m_source.isSizeAvailable();
342 365
366 if (m_sizeAvailable && hasVisibleImageSize(size())) {
367 String fileExtention = m_source.filenameExtension();
368 DecodedImageType type =
369 fileExtention == "jpg" ? ImageJPEG :
370 fileExtention == "png" ? ImagePNG :
371 fileExtention == "gif" ? ImageGIF :
372 fileExtention == "webp" ? ImageWebP :
373 fileExtention == "ico" ? ImageICO :
374 fileExtention == "bmp" ? ImageBMP :
375 ImageUnknown;
376 Platform::current()->histogramEnumeration("Blink.DecodedImageType", type , LastDecodedImageType + 1);
377 }
378
343 return m_sizeAvailable; 379 return m_sizeAvailable;
344 } 380 }
345 381
346 bool BitmapImage::ensureFrameIsCached(size_t index) 382 bool BitmapImage::ensureFrameIsCached(size_t index)
347 { 383 {
348 if (index >= frameCount()) 384 if (index >= frameCount())
349 return false; 385 return false;
350 386
351 if (index >= m_frames.size() || !m_frames[index].m_frame) 387 if (index >= m_frames.size() || !m_frames[index].m_frame)
352 cacheFrame(index); 388 cacheFrame(index);
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 destroyDecodedDataIfNecessary(); 679 destroyDecodedDataIfNecessary();
644 680
645 // We need to draw this frame if we advanced to it while not skipping, or if 681 // We need to draw this frame if we advanced to it while not skipping, or if
646 // while trying to skip frames we hit the last frame and thus had to stop. 682 // while trying to skip frames we hit the last frame and thus had to stop.
647 if (skippingFrames != advancedAnimation) 683 if (skippingFrames != advancedAnimation)
648 imageObserver()->animationAdvanced(this); 684 imageObserver()->animationAdvanced(this);
649 return advancedAnimation; 685 return advancedAnimation;
650 } 686 }
651 687
652 } // namespace blink 688 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698