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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/BitmapImage.h

Issue 2054643003: Remove duplication of encoded image data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bug fix Created 4 years, 5 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
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 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
4 * Copyright (C) 2008-2009 Torch Mobile, Inc. 4 * Copyright (C) 2008-2009 Torch Mobile, Inc.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 ~BitmapImage() override; 58 ~BitmapImage() override;
59 59
60 bool isBitmapImage() const override { return true; } 60 bool isBitmapImage() const override { return true; }
61 61
62 bool currentFrameHasSingleSecurityOrigin() const override; 62 bool currentFrameHasSingleSecurityOrigin() const override;
63 63
64 IntSize size() const override; 64 IntSize size() const override;
65 IntSize sizeRespectingOrientation() const; 65 IntSize sizeRespectingOrientation() const;
66 bool getHotSpot(IntPoint&) const override; 66 bool getHotSpot(IntPoint&) const override;
67 String filenameExtension() const override; 67 String filenameExtension() const override;
68 bool setData(PassRefPtr<SharedBuffer> data, bool allDataReceived) override;
68 bool dataChanged(bool allDataReceived) override; 69 bool dataChanged(bool allDataReceived) override;
69 70
70 bool isAllDataReceived() const { return m_allDataReceived; } 71 bool isAllDataReceived() const { return m_allDataReceived; }
71 bool hasColorProfile() const; 72 bool hasColorProfile() const;
72 73
73 void resetAnimation() override; 74 void resetAnimation() override;
74 bool maybeAnimated() override; 75 bool maybeAnimated() override;
75 76
76 void setAnimationPolicy(ImageAnimationPolicy policy) override { m_animationP olicy = policy; } 77 void setAnimationPolicy(ImageAnimationPolicy policy) override { m_animationP olicy = policy; }
77 ImageAnimationPolicy animationPolicy() override { return m_animationPolicy; } 78 ImageAnimationPolicy animationPolicy() override { return m_animationPolicy; }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 119
119 // Returns the total number of bytes allocated for all framebuffers, i.e. 120 // Returns the total number of bytes allocated for all framebuffers, i.e.
120 // the sum of m_source.frameBytesAtIndex(...) for all frames. 121 // the sum of m_source.frameBytesAtIndex(...) for all frames.
121 size_t totalFrameBytes(); 122 size_t totalFrameBytes();
122 123
123 // Called to wipe out the entire frame buffer cache and tell the image 124 // Called to wipe out the entire frame buffer cache and tell the image
124 // source to destroy everything; this is used when e.g. we want to free 125 // source to destroy everything; this is used when e.g. we want to free
125 // some room in the image cache. 126 // some room in the image cache.
126 void destroyDecodedData() override; 127 void destroyDecodedData() override;
127 128
129 PassRefPtr<SharedBuffer> data() override;
130
128 // Notifies observers that the memory footprint has changed. 131 // Notifies observers that the memory footprint has changed.
129 void notifyMemoryChanged(); 132 void notifyMemoryChanged();
130 133
131 // Whether or not size is available yet. 134 // Whether or not size is available yet.
132 bool isSizeAvailable(); 135 bool isSizeAvailable();
133 136
134 // Animation. 137 // Animation.
135 // We start and stop animating lazily. Animation starts when the image is 138 // We start and stop animating lazily. Animation starts when the image is
136 // rendered, and automatically stops once no observer wants to render the 139 // rendered, and automatically stops once no observer wants to render the
137 // image. 140 // image.
138 int repetitionCount(bool imageKnownToBeComplete); // |imageKnownToBeComplet e| should be set if the caller knows the entire image has been decoded. 141 int repetitionCount(bool imageKnownToBeComplete); // |imageKnownToBeComplet e| should be set if the caller knows the entire image has been decoded.
139 bool shouldAnimate(); 142 bool shouldAnimate();
140 void startAnimation(CatchUpAnimation = CatchUp) override; 143 void startAnimation(CatchUpAnimation = CatchUp) override;
141 void stopAnimation(); 144 void stopAnimation();
142 void advanceAnimation(Timer<BitmapImage>*); 145 void advanceAnimation(Timer<BitmapImage>*);
143 // Advance the animation and let the next frame get scheduled without 146 // Advance the animation and let the next frame get scheduled without
144 // catch-up logic. For large images with slow or heavily-loaded systems, 147 // catch-up logic. For large images with slow or heavily-loaded systems,
145 // throwing away data as we go (see destroyDecodedData()) means we can spend 148 // throwing away data as we go (see destroyDecodedData()) means we can spend
146 // so much time re-decoding data that we are always behind. To prevent this, 149 // so much time re-decoding data that we are always behind. To prevent this,
147 // we force the next animation to skip the catch up logic. 150 // we force the next animation to skip the catch up logic.
148 void advanceAnimationWithoutCatchUp(Timer<BitmapImage>*); 151 void advanceAnimationWithoutCatchUp(Timer<BitmapImage>*);
149 152
150 // Function that does the real work of advancing the animation. When 153 // Function that does the real work of advancing the animation. When
151 // skippingFrames is true, we're in the middle of a loop trying to skip over 154 // skippingFrames is true, we're in the middle of a loop trying to skip over
152 // a bunch of animation frames, so we should not do things like decode each 155 // a bunch of animation frames, so we should not do things like decode each
153 // one or notify our observers. 156 // one or notify our observers.
154 // Returns whether the animation was advanced. 157 // Returns whether the animation was advanced.
155 bool internalAdvanceAnimation(bool skippingFrames); 158 bool internalAdvanceAnimation(bool skippingFrames);
156 159
160 RefPtr<SharedBuffer> m_temporaryEncodedImageData;
157 ImageSource m_source; 161 ImageSource m_source;
158 mutable IntSize m_size; // The size to use for the overall image (will just be the size of the first image). 162 mutable IntSize m_size; // The size to use for the overall image (will just be the size of the first image).
159 mutable IntSize m_sizeRespectingOrientation; 163 mutable IntSize m_sizeRespectingOrientation;
160 164
161 size_t m_currentFrame; // The index of the current frame of animation. 165 size_t m_currentFrame; // The index of the current frame of animation.
162 Vector<FrameData, 1> m_frames; // An array of the cached frames of the anima tion. We have to ref frames to pin them in the cache. 166 Vector<FrameData, 1> m_frames; // An array of the cached frames of the anima tion. We have to ref frames to pin them in the cache.
163 167
164 RefPtr<SkImage> m_cachedFrame; // A cached copy of the most recently-accesse d frame. 168 RefPtr<SkImage> m_cachedFrame; // A cached copy of the most recently-accesse d frame.
165 size_t m_cachedFrameIndex; // Index of the frame that is cached. 169 size_t m_cachedFrameIndex; // Index of the frame that is cached.
166 170
(...skipping 13 matching lines...) Expand all
180 mutable bool m_haveSize : 1; // Whether or not our |m_size| member variable has the final overall image size yet. 184 mutable bool m_haveSize : 1; // Whether or not our |m_size| member variable has the final overall image size yet.
181 bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the fi rst image frame yet from ImageIO. 185 bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the fi rst image frame yet from ImageIO.
182 mutable bool m_haveFrameCount : 1; 186 mutable bool m_haveFrameCount : 1;
183 }; 187 };
184 188
185 DEFINE_IMAGE_TYPE_CASTS(BitmapImage); 189 DEFINE_IMAGE_TYPE_CASTS(BitmapImage);
186 190
187 } // namespace blink 191 } // namespace blink
188 192
189 #endif 193 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698