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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 }; | 72 }; |
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 |
Peter Kasting
2013/05/29 02:02:18
Nit: How about this comment:
Tells the ImageSourc
Xianzhu
2013/05/29 18:37:01
Done.
| |
83 // data -- at all (if |destroyAll| is true), or before frame | 83 // data except the specified frame (|notFound| to clear all frames). |
84 // |clearBeforeFrame| (if |destroyAll| is false). The ImageSource should | 84 // The ImageSource should delete cached decoded data for these frames |
85 // delete cached decoded data for these frames where possible to keep memory | 85 // where possible to keep memory usage low. |
86 // usage low. When |destroyAll| is true, the ImageSource should also reset | |
87 // any local state so that decoding can begin again. | |
88 // | 86 // |
89 // Implementations that delete less than what's specified above waste | 87 // The caller is supposed to request for a frame on/after the provided frame |
88 // index after this call. If the caller violate this by clearing and then | |
89 // requesting a frame before the provided frame number, the decoder may need | |
90 // to redecode the image from the beginning. | |
91 // | |
92 // Implementations that delete less than what's specified above may waste | |
90 // memory. Implementations that delete more may burn CPU re-decoding frames | 93 // memory. Implementations that delete more may burn CPU re-decoding frames |
91 // that could otherwise have been cached, or encounter errors if they're | 94 // that could otherwise have been cached, or encounter errors if they're |
92 // asked to decode frames they can't decode due to the loss of previous | 95 // asked to decode frames they can't decode due to the loss of previous |
93 // decoded frames. | 96 // decoded frames. |
94 // | 97 // |
95 // Callers should not call clear(false, n) and subsequently call | 98 // Returns number of bytes of the cleared frames. |
96 // createFrameAtIndex(m) with m < n, unless they first call clear(true). | 99 size_t clearCacheExceptFrame(size_t); |
97 // This ensures that stateful ImageSources/decoders will work properly. | |
98 // | |
99 // The |data| and |allDataReceived| parameters should be supplied by callers | |
100 // who set |destroyAll| to true if they wish to be able to continue using | |
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 | 100 |
108 bool initialized() const; | 101 bool initialized() const; |
109 | 102 |
110 void setData(SharedBuffer* data, bool allDataReceived); | 103 void setData(SharedBuffer* data, bool allDataReceived); |
111 String filenameExtension() const; | 104 String filenameExtension() const; |
112 | 105 |
113 bool isSizeAvailable(); | 106 bool isSizeAvailable(); |
114 IntSize size(RespectImageOrientationEnum = DoNotRespectImageOrientation) con st; | 107 IntSize size(RespectImageOrientationEnum = DoNotRespectImageOrientation) con st; |
115 IntSize frameSizeAtIndex(size_t, RespectImageOrientationEnum = DoNotRespectI mageOrientation) const; | 108 IntSize frameSizeAtIndex(size_t, RespectImageOrientationEnum = DoNotRespectI mageOrientation) const; |
116 | 109 |
117 bool getHotSpot(IntPoint&) const; | 110 bool getHotSpot(IntPoint&) const; |
118 | 111 |
119 size_t bytesDecodedToDetermineProperties() const; | 112 size_t bytesDecodedToDetermineProperties() const; |
120 | 113 |
121 int repetitionCount(); | 114 int repetitionCount(); |
122 | 115 |
123 size_t frameCount() const; | 116 size_t frameCount() const; |
124 | 117 |
125 // Callers should not call this after calling clear() with a higher index; | 118 // Callers should not call this after calling clear() with a higher index; |
126 // see comments on clear() above. | 119 // see comments on clear() above. |
Peter Kasting
2013/05/29 02:02:18
Nit: This comment should be removed.
Xianzhu
2013/05/29 18:37:01
Done.
| |
127 PassNativeImagePtr createFrameAtIndex(size_t); | 120 PassNativeImagePtr createFrameAtIndex(size_t); |
128 | 121 |
129 float frameDurationAtIndex(size_t) const; | 122 float frameDurationAtIndex(size_t) const; |
130 bool frameHasAlphaAtIndex(size_t) const; // Whether or not the frame actuall y used any alpha. | 123 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. | 124 bool frameIsCompleteAtIndex(size_t) const; // Whether or not the frame is fu lly received. |
132 ImageOrientation orientationAtIndex(size_t) const; // EXIF image orientation | 125 ImageOrientation orientationAtIndex(size_t) const; // EXIF image orientation |
133 | 126 |
134 // Return the number of bytes in the decoded frame. If the frame is not yet | 127 // Return the number of bytes in the decoded frame. If the frame is not yet |
135 // decoded then return 0. | 128 // decoded then return 0. |
136 unsigned frameBytesAtIndex(size_t) const; | 129 unsigned frameBytesAtIndex(size_t) const; |
137 | 130 |
138 void reportMemoryUsage(MemoryObjectInfo*) const; | 131 void reportMemoryUsage(MemoryObjectInfo*) const; |
139 | 132 |
140 private: | 133 private: |
141 OwnPtr<NativeImageDecoderPtr> m_decoder; | 134 OwnPtr<NativeImageDecoderPtr> m_decoder; |
142 | 135 |
143 AlphaOption m_alphaOption; | 136 AlphaOption m_alphaOption; |
144 GammaAndColorProfileOption m_gammaAndColorProfileOption; | 137 GammaAndColorProfileOption m_gammaAndColorProfileOption; |
145 }; | 138 }; |
146 | 139 |
147 } | 140 } |
148 | 141 |
149 #endif | 142 #endif |
OLD | NEW |