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

Side by Side Diff: Source/core/platform/graphics/ImageSource.h

Issue 99103006: Moving GraphicsContext and dependencies from core to platform. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final patch - fixes Android Created 7 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
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.
12 *
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.
24 */
25
26 #ifndef ImageSource_h
27 #define ImageSource_h
28
29 #include "platform/graphics/ImageOrientation.h"
30 #include "wtf/Forward.h"
31 #include "wtf/Noncopyable.h"
32 #include "wtf/OwnPtr.h"
33 #include "wtf/Vector.h"
34
35 namespace WebCore {
36
37 class DeferredImageDecoder;
38 class ImageOrientation;
39 class IntPoint;
40 class IntSize;
41 class NativeImageSkia;
42 class SharedBuffer;
43
44 // Right now GIFs are the only recognized image format that supports animation.
45 // The animation system and the constants below are designed with this in mind.
46 // GIFs have an optional 16-bit unsigned loop count that describes how an
47 // animated GIF should be cycled. If the loop count is absent, the animation
48 // cycles once; if it is 0, the animation cycles infinitely; otherwise the
49 // animation plays n + 1 cycles (where n is the specified loop count). If the
50 // GIF decoder defaults to cAnimationLoopOnce in the absence of any loop count
51 // and translates an explicit "0" loop count to cAnimationLoopInfinite, then we
52 // get a couple of nice side effects:
53 // * By making cAnimationLoopOnce be 0, we allow the animation cycling code in
54 // BitmapImage.cpp to avoid special-casing it, and simply treat all
55 // non-negative loop counts identically.
56 // * By making the other two constants negative, we avoid conflicts with any
57 // real loop count values.
58 const int cAnimationLoopOnce = 0;
59 const int cAnimationLoopInfinite = -1;
60 const int cAnimationNone = -2;
61
62 class ImageSource {
63 WTF_MAKE_NONCOPYABLE(ImageSource);
64 public:
65 enum AlphaOption {
66 AlphaPremultiplied,
67 AlphaNotPremultiplied
68 };
69
70 enum GammaAndColorProfileOption {
71 GammaAndColorProfileApplied,
72 GammaAndColorProfileIgnored
73 };
74
75 ImageSource(AlphaOption alphaOption = AlphaPremultiplied, GammaAndColorProfi leOption gammaAndColorProfileOption = GammaAndColorProfileApplied);
76 ~ImageSource();
77
78 // Tells the ImageSource that the Image no longer cares about decoded frame
79 // data except for the specified frame. Callers may pass WTF::kNotFound to
80 // clear all frames.
81 //
82 // In response, the ImageSource should delete cached decoded data for other
83 // frames where possible to keep memory use low. The expectation is that in
84 // the future, the caller may call createFrameAtIndex() with an index larger
85 // than the one passed to this function, and the implementation may then
86 // make use of the preserved frame data here in decoding that frame.
87 // By contrast, callers who call this function and then later ask for an
88 // earlier frame may require more work to be done, e.g. redecoding the image
89 // from the beginning.
90 //
91 // Implementations may elect to preserve more frames than the one requested
92 // here if doing so is likely to save CPU time in the future, but will pay
93 // an increased memory cost to do so.
94 //
95 // Returns the number of bytes of frame data actually cleared.
96 size_t clearCacheExceptFrame(size_t);
97
98 bool initialized() const;
99
100 void setData(SharedBuffer* data, bool allDataReceived);
101 String filenameExtension() const;
102
103 bool isSizeAvailable();
104 IntSize size(RespectImageOrientationEnum = DoNotRespectImageOrientation) con st;
105 IntSize frameSizeAtIndex(size_t, RespectImageOrientationEnum = DoNotRespectI mageOrientation) const;
106
107 bool getHotSpot(IntPoint&) const;
108
109 int repetitionCount();
110
111 size_t frameCount() const;
112
113 PassRefPtr<NativeImageSkia> createFrameAtIndex(size_t);
114
115 float frameDurationAtIndex(size_t) const;
116 bool frameHasAlphaAtIndex(size_t) const; // Whether or not the frame actuall y used any alpha.
117 bool frameIsCompleteAtIndex(size_t) const; // Whether or not the frame is fu lly received.
118 ImageOrientation orientationAtIndex(size_t) const; // EXIF image orientation
119
120 // Return the number of bytes in the decoded frame. If the frame is not yet
121 // decoded then return 0.
122 unsigned frameBytesAtIndex(size_t) const;
123
124 private:
125 OwnPtr<DeferredImageDecoder> m_decoder;
126
127 AlphaOption m_alphaOption;
128 GammaAndColorProfileOption m_gammaAndColorProfileOption;
129 };
130
131 }
132
133 #endif
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/ImageFrameGeneratorTest.cpp ('k') | Source/core/platform/graphics/ImageSource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698