2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include "platform/PlatformExport.h"
30 #include "platform/graphics/ImageOrientation.h"
31 #include "wtf/Forward.h"
32 #include "wtf/Noncopyable.h"
33 #include "wtf/OwnPtr.h"
39 class DeferredImageDecoder
;
40 class ImageOrientation
;
45 class PLATFORM_EXPORT ImageSource
{
46 WTF_MAKE_NONCOPYABLE(ImageSource
);
51 // Tells the ImageSource that the Image no longer cares about decoded frame
52 // data except for the specified frame. Callers may pass WTF::kNotFound to
55 // In response, the ImageSource should delete cached decoded data for other
56 // frames where possible to keep memory use low. The expectation is that in
57 // the future, the caller may call createFrameAtIndex() with an index larger
58 // than the one passed to this function, and the implementation may then
59 // make use of the preserved frame data here in decoding that frame.
60 // By contrast, callers who call this function and then later ask for an
61 // earlier frame may require more work to be done, e.g. redecoding the image
62 // from the beginning.
64 // Implementations may elect to preserve more frames than the one requested
65 // here if doing so is likely to save CPU time in the future, but will pay
66 // an increased memory cost to do so.
68 // Returns the number of bytes of frame data actually cleared.
69 size_t clearCacheExceptFrame(size_t);
71 void setData(SharedBuffer
& data
, bool allDataReceived
);
72 String
filenameExtension() const;
74 bool isSizeAvailable();
75 bool hasColorProfile() const;
76 IntSize
size(RespectImageOrientationEnum
= DoNotRespectImageOrientation
) const;
77 IntSize
frameSizeAtIndex(size_t, RespectImageOrientationEnum
= DoNotRespectImageOrientation
) const;
79 bool getHotSpot(IntPoint
&) const;
80 int repetitionCount();
82 size_t frameCount() const;
84 // Attempts to create the requested frame.
85 PassRefPtr
<SkImage
> createFrameAtIndex(size_t);
87 float frameDurationAtIndex(size_t) const;
88 bool frameHasAlphaAtIndex(size_t) const; // Whether or not the frame actually used any alpha.
89 bool frameIsCompleteAtIndex(size_t) const; // Whether or not the frame is fully received.
90 ImageOrientation
orientationAtIndex(size_t) const; // EXIF image orientation
92 // Returns the number of bytes in the decoded frame. May return 0 if the
93 // frame has not yet begun to decode.
94 size_t frameBytesAtIndex(size_t) const;
97 OwnPtr
<DeferredImageDecoder
> m_decoder
;