OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 enum GammaAndColorProfileOption { | 74 enum GammaAndColorProfileOption { |
75 GammaAndColorProfileApplied, | 75 GammaAndColorProfileApplied, |
76 GammaAndColorProfileIgnored | 76 GammaAndColorProfileIgnored |
77 }; | 77 }; |
78 | 78 |
79 ImageSource(AlphaOption alphaOption = AlphaPremultiplied, GammaAndColorProfi
leOption gammaAndColorProfileOption = GammaAndColorProfileApplied); | 79 ImageSource(AlphaOption alphaOption = AlphaPremultiplied, GammaAndColorProfi
leOption gammaAndColorProfileOption = GammaAndColorProfileApplied); |
80 ~ImageSource(); | 80 ~ImageSource(); |
81 | 81 |
82 // Tells the ImageSource that the Image no longer cares about decoded frame | 82 // Tells the ImageSource that the Image no longer cares about decoded frame |
83 // data -- at all (if |destroyAll| is true), or before frame | 83 // data except for the specified frame. Callers may pass WTF::notFound to |
84 // |clearBeforeFrame| (if |destroyAll| is false). The ImageSource should | 84 // clear all frames. |
85 // delete cached decoded data for these frames where possible to keep memory | |
86 // usage low. When |destroyAll| is true, the ImageSource should also reset | |
87 // any local state so that decoding can begin again. | |
88 // | 85 // |
89 // Implementations that delete less than what's specified above waste | 86 // In response, the ImageSource should delete cached decoded data for other |
90 // memory. Implementations that delete more may burn CPU re-decoding frames | 87 // frames where possible to keep memory use low. The expectation is that in |
91 // that could otherwise have been cached, or encounter errors if they're | 88 // the future, the caller may call createFrameAtIndex() with an index larger |
92 // asked to decode frames they can't decode due to the loss of previous | 89 // than the one passed to this function, and the implementation may then |
93 // decoded frames. | 90 // make use of the preserved frame data here in decoding that frame. |
| 91 // By contrast, callers who call this function and then later ask for an |
| 92 // earlier frame may require more work to be done, e.g. redecoding the image |
| 93 // from the beginning. |
94 // | 94 // |
95 // Callers should not call clear(false, n) and subsequently call | 95 // Implementations may elect to preserve more frames than the one requested |
96 // createFrameAtIndex(m) with m < n, unless they first call clear(true). | 96 // here if doing so is likely to save CPU time in the future, but will pay |
97 // This ensures that stateful ImageSources/decoders will work properly. | 97 // an increased memory cost to do so. |
98 // | 98 // |
99 // The |data| and |allDataReceived| parameters should be supplied by callers | 99 // Returns the number of bytes of frame data actually cleared. |
100 // who set |destroyAll| to true if they wish to be able to continue using | 100 size_t clearCacheExceptFrame(size_t); |
101 // the ImageSource. This way implementations which choose to destroy their | |
102 // decoders in some cases can reconstruct them correctly. | |
103 void clear(bool destroyAll, | |
104 size_t clearBeforeFrame = 0, | |
105 SharedBuffer* data = NULL, | |
106 bool allDataReceived = false); | |
107 | 101 |
108 bool initialized() const; | 102 bool initialized() const; |
109 | 103 |
110 void setData(SharedBuffer* data, bool allDataReceived); | 104 void setData(SharedBuffer* data, bool allDataReceived); |
111 String filenameExtension() const; | 105 String filenameExtension() const; |
112 | 106 |
113 bool isSizeAvailable(); | 107 bool isSizeAvailable(); |
114 IntSize size(RespectImageOrientationEnum = DoNotRespectImageOrientation) con
st; | 108 IntSize size(RespectImageOrientationEnum = DoNotRespectImageOrientation) con
st; |
115 IntSize frameSizeAtIndex(size_t, RespectImageOrientationEnum = DoNotRespectI
mageOrientation) const; | 109 IntSize frameSizeAtIndex(size_t, RespectImageOrientationEnum = DoNotRespectI
mageOrientation) const; |
116 | 110 |
117 bool getHotSpot(IntPoint&) const; | 111 bool getHotSpot(IntPoint&) const; |
118 | 112 |
119 size_t bytesDecodedToDetermineProperties() const; | 113 size_t bytesDecodedToDetermineProperties() const; |
120 | 114 |
121 int repetitionCount(); | 115 int repetitionCount(); |
122 | 116 |
123 size_t frameCount() const; | 117 size_t frameCount() const; |
124 | 118 |
125 // Callers should not call this after calling clear() with a higher index; | |
126 // see comments on clear() above. | |
127 PassNativeImagePtr createFrameAtIndex(size_t); | 119 PassNativeImagePtr createFrameAtIndex(size_t); |
128 | 120 |
129 float frameDurationAtIndex(size_t) const; | 121 float frameDurationAtIndex(size_t) const; |
130 bool frameHasAlphaAtIndex(size_t) const; // Whether or not the frame actuall
y used any alpha. | 122 bool frameHasAlphaAtIndex(size_t) const; // Whether or not the frame actuall
y used any alpha. |
131 bool frameIsCompleteAtIndex(size_t) const; // Whether or not the frame is fu
lly received. | 123 bool frameIsCompleteAtIndex(size_t) const; // Whether or not the frame is fu
lly received. |
132 ImageOrientation orientationAtIndex(size_t) const; // EXIF image orientation | 124 ImageOrientation orientationAtIndex(size_t) const; // EXIF image orientation |
133 | 125 |
134 // Return the number of bytes in the decoded frame. If the frame is not yet | 126 // Return the number of bytes in the decoded frame. If the frame is not yet |
135 // decoded then return 0. | 127 // decoded then return 0. |
136 unsigned frameBytesAtIndex(size_t) const; | 128 unsigned frameBytesAtIndex(size_t) const; |
137 | 129 |
138 void reportMemoryUsage(MemoryObjectInfo*) const; | 130 void reportMemoryUsage(MemoryObjectInfo*) const; |
139 | 131 |
140 private: | 132 private: |
141 OwnPtr<NativeImageDecoderPtr> m_decoder; | 133 OwnPtr<NativeImageDecoderPtr> m_decoder; |
142 | 134 |
143 AlphaOption m_alphaOption; | 135 AlphaOption m_alphaOption; |
144 GammaAndColorProfileOption m_gammaAndColorProfileOption; | 136 GammaAndColorProfileOption m_gammaAndColorProfileOption; |
145 }; | 137 }; |
146 | 138 |
147 } | 139 } |
148 | 140 |
149 #endif | 141 #endif |
OLD | NEW |