OLD | NEW |
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 17 matching lines...) Expand all Loading... |
28 #include "platform/graphics/BitmapImage.h" | 28 #include "platform/graphics/BitmapImage.h" |
29 | 29 |
30 #include "platform/PlatformInstrumentation.h" | 30 #include "platform/PlatformInstrumentation.h" |
31 #include "platform/Timer.h" | 31 #include "platform/Timer.h" |
32 #include "platform/TraceEvent.h" | 32 #include "platform/TraceEvent.h" |
33 #include "platform/geometry/FloatRect.h" | 33 #include "platform/geometry/FloatRect.h" |
34 #include "platform/graphics/DeferredImageDecoder.h" | 34 #include "platform/graphics/DeferredImageDecoder.h" |
35 #include "platform/graphics/ImageObserver.h" | 35 #include "platform/graphics/ImageObserver.h" |
36 #include "platform/graphics/StaticBitmapImage.h" | 36 #include "platform/graphics/StaticBitmapImage.h" |
37 #include "platform/graphics/skia/SkiaUtils.h" | 37 #include "platform/graphics/skia/SkiaUtils.h" |
| 38 #include "public/platform/WebProcessMemoryDump.h" |
38 #include "third_party/skia/include/core/SkCanvas.h" | 39 #include "third_party/skia/include/core/SkCanvas.h" |
39 #include "wtf/PassRefPtr.h" | 40 #include "wtf/PassRefPtr.h" |
40 #include "wtf/text/WTFString.h" | 41 #include "wtf/text/WTFString.h" |
41 | 42 |
42 namespace blink { | 43 namespace blink { |
43 | 44 |
44 PassRefPtr<BitmapImage> BitmapImage::createWithOrientationForTesting(const SkBit
map& bitmap, ImageOrientation orientation) | 45 PassRefPtr<BitmapImage> BitmapImage::createWithOrientationForTesting(const SkBit
map& bitmap, ImageOrientation orientation) |
45 { | 46 { |
46 if (bitmap.isNull()) { | 47 if (bitmap.isNull()) { |
47 return BitmapImage::create(); | 48 return BitmapImage::create(); |
(...skipping 15 matching lines...) Expand all Loading... |
63 , m_desiredFrameStartTime(0) | 64 , m_desiredFrameStartTime(0) |
64 , m_frameCount(0) | 65 , m_frameCount(0) |
65 , m_animationPolicy(ImageAnimationPolicyAllowed) | 66 , m_animationPolicy(ImageAnimationPolicyAllowed) |
66 , m_animationFinished(false) | 67 , m_animationFinished(false) |
67 , m_allDataReceived(false) | 68 , m_allDataReceived(false) |
68 , m_haveSize(false) | 69 , m_haveSize(false) |
69 , m_sizeAvailable(false) | 70 , m_sizeAvailable(false) |
70 , m_hasUniformFrameSize(true) | 71 , m_hasUniformFrameSize(true) |
71 , m_haveFrameCount(false) | 72 , m_haveFrameCount(false) |
72 { | 73 { |
| 74 Platform::current()->registerMemoryDumpProvider(this); |
73 } | 75 } |
74 | 76 |
75 BitmapImage::BitmapImage(const SkBitmap& bitmap, ImageObserver* observer) | 77 BitmapImage::BitmapImage(const SkBitmap& bitmap, ImageObserver* observer) |
76 : Image(observer) | 78 : Image(observer) |
77 , m_size(bitmap.width(), bitmap.height()) | 79 , m_size(bitmap.width(), bitmap.height()) |
78 , m_currentFrame(0) | 80 , m_currentFrame(0) |
79 , m_repetitionCount(cAnimationNone) | 81 , m_repetitionCount(cAnimationNone) |
80 , m_repetitionCountStatus(Unknown) | 82 , m_repetitionCountStatus(Unknown) |
81 , m_repetitionsComplete(0) | 83 , m_repetitionsComplete(0) |
82 , m_frameCount(1) | 84 , m_frameCount(1) |
83 , m_animationPolicy(ImageAnimationPolicyAllowed) | 85 , m_animationPolicy(ImageAnimationPolicyAllowed) |
84 , m_animationFinished(true) | 86 , m_animationFinished(true) |
85 , m_allDataReceived(true) | 87 , m_allDataReceived(true) |
86 , m_haveSize(true) | 88 , m_haveSize(true) |
87 , m_sizeAvailable(true) | 89 , m_sizeAvailable(true) |
88 , m_haveFrameCount(true) | 90 , m_haveFrameCount(true) |
89 { | 91 { |
90 // Since we don't have a decoder, we can't figure out the image orientation. | 92 // Since we don't have a decoder, we can't figure out the image orientation. |
91 // Set m_sizeRespectingOrientation to be the same as m_size so it's not 0x0. | 93 // Set m_sizeRespectingOrientation to be the same as m_size so it's not 0x0. |
92 m_sizeRespectingOrientation = m_size; | 94 m_sizeRespectingOrientation = m_size; |
93 | 95 |
94 m_frames.grow(1); | 96 m_frames.grow(1); |
95 m_frames[0].m_hasAlpha = !bitmap.isOpaque(); | 97 m_frames[0].m_hasAlpha = !bitmap.isOpaque(); |
96 m_frames[0].m_frame = adoptRef(SkImage::NewFromBitmap(bitmap)); | 98 m_frames[0].m_frame = adoptRef(SkImage::NewFromBitmap(bitmap)); |
97 m_frames[0].m_haveMetadata = true; | 99 m_frames[0].m_haveMetadata = true; |
| 100 Platform::current()->registerMemoryDumpProvider(this); |
98 } | 101 } |
99 | 102 |
100 BitmapImage::~BitmapImage() | 103 BitmapImage::~BitmapImage() |
101 { | 104 { |
| 105 Platform::current()->unregisterMemoryDumpProvider(this); |
102 stopAnimation(); | 106 stopAnimation(); |
103 } | 107 } |
104 | 108 |
105 bool BitmapImage::isBitmapImage() const | 109 bool BitmapImage::isBitmapImage() const |
106 { | 110 { |
107 return true; | 111 return true; |
108 } | 112 } |
109 | 113 |
110 bool BitmapImage::currentFrameHasSingleSecurityOrigin() const | 114 bool BitmapImage::currentFrameHasSingleSecurityOrigin() const |
111 { | 115 { |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 { | 453 { |
450 RefPtr<SkImage> image = frameAtIndex(currentFrame()); | 454 RefPtr<SkImage> image = frameAtIndex(currentFrame()); |
451 return image && image->isLazyGenerated(); | 455 return image && image->isLazyGenerated(); |
452 } | 456 } |
453 | 457 |
454 ImageOrientation BitmapImage::currentFrameOrientation() | 458 ImageOrientation BitmapImage::currentFrameOrientation() |
455 { | 459 { |
456 return frameOrientationAtIndex(currentFrame()); | 460 return frameOrientationAtIndex(currentFrame()); |
457 } | 461 } |
458 | 462 |
| 463 bool BitmapImage::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProc
essMemoryDump* memoryDump) |
| 464 { |
| 465 String prefix("web_cache/images/decoded/"); |
| 466 SkTraceMemoryDump* dump = memoryDump->CreateSkiaTraceMemoryDump(prefix); |
| 467 ASSERT(dump); |
| 468 for (size_t i = 0; i < m_frames.size(); ++i) { |
| 469 if (m_frames[i].m_frame) |
| 470 m_frames[i].m_frame->dumpMemoryStatistics(dump); |
| 471 } |
| 472 return true; |
| 473 } |
| 474 |
459 ImageOrientation BitmapImage::frameOrientationAtIndex(size_t index) | 475 ImageOrientation BitmapImage::frameOrientationAtIndex(size_t index) |
460 { | 476 { |
461 if (m_frames.size() <= index) | 477 if (m_frames.size() <= index) |
462 return DefaultImageOrientation; | 478 return DefaultImageOrientation; |
463 | 479 |
464 if (m_frames[index].m_haveMetadata) | 480 if (m_frames[index].m_haveMetadata) |
465 return m_frames[index].m_orientation; | 481 return m_frames[index].m_orientation; |
466 | 482 |
467 return m_source.orientationAtIndex(index); | 483 return m_source.orientationAtIndex(index); |
468 } | 484 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 destroyDecodedDataIfNecessary(); | 679 destroyDecodedDataIfNecessary(); |
664 | 680 |
665 // 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 |
666 // 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. |
667 if (skippingFrames != advancedAnimation) | 683 if (skippingFrames != advancedAnimation) |
668 imageObserver()->animationAdvanced(this); | 684 imageObserver()->animationAdvanced(this); |
669 return advancedAnimation; | 685 return advancedAnimation; |
670 } | 686 } |
671 | 687 |
672 } // namespace blink | 688 } // namespace blink |
OLD | NEW |