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

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

Issue 985583002: Don't cache any SkBitmaps in DeferredImageDecoder (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: done now Created 5 years, 9 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 | Annotate | Revision Log
OLDNEW
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 23 matching lines...) Expand all
34 34
35 namespace blink { 35 namespace blink {
36 36
37 class DeferredImageDecoder; 37 class DeferredImageDecoder;
38 class ImageOrientation; 38 class ImageOrientation;
39 class IntPoint; 39 class IntPoint;
40 class IntSize; 40 class IntSize;
41 class NativeImageSkia; 41 class NativeImageSkia;
42 class SharedBuffer; 42 class SharedBuffer;
43 43
44 // GIF and WebP support animation. The explanation below is in terms of GIF, 44 // This is a helper class used by BitmapImage only. If you need an image
45 // but the same constants are used for WebP, too. 45 // decoder then you should look into
46 // GIFs have an optional 16-bit unsigned loop count that describes how an 46 // Source/platform/image-decoders/ImageDecoder.h.
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 PLATFORM_EXPORT ImageSource { 47 class PLATFORM_EXPORT ImageSource {
63 WTF_MAKE_NONCOPYABLE(ImageSource); 48 WTF_MAKE_NONCOPYABLE(ImageSource);
64 public: 49 public:
65 enum AlphaOption { 50 enum AlphaOption {
66 AlphaPremultiplied, 51 AlphaPremultiplied,
67 AlphaNotPremultiplied 52 AlphaNotPremultiplied
68 }; 53 };
69 54
70 enum GammaAndColorProfileOption { 55 enum GammaAndColorProfileOption {
71 GammaAndColorProfileApplied, 56 GammaAndColorProfileApplied,
(...skipping 16 matching lines...) Expand all
88 // earlier frame may require more work to be done, e.g. redecoding the image 73 // earlier frame may require more work to be done, e.g. redecoding the image
89 // from the beginning. 74 // from the beginning.
90 // 75 //
91 // Implementations may elect to preserve more frames than the one requested 76 // 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 77 // here if doing so is likely to save CPU time in the future, but will pay
93 // an increased memory cost to do so. 78 // an increased memory cost to do so.
94 // 79 //
95 // Returns the number of bytes of frame data actually cleared. 80 // Returns the number of bytes of frame data actually cleared.
96 size_t clearCacheExceptFrame(size_t); 81 size_t clearCacheExceptFrame(size_t);
97 82
98 bool initialized() const;
99 void resetDecoder();
100
101 void setData(SharedBuffer& data, bool allDataReceived); 83 void setData(SharedBuffer& data, bool allDataReceived);
102 String filenameExtension() const; 84 String filenameExtension() const;
103 85
104 bool isSizeAvailable(); 86 bool isSizeAvailable();
105 bool hasColorProfile() const; 87 bool hasColorProfile() const;
106 IntSize size(RespectImageOrientationEnum = DoNotRespectImageOrientation) con st; 88 IntSize size(RespectImageOrientationEnum = DoNotRespectImageOrientation) con st;
107 IntSize frameSizeAtIndex(size_t, RespectImageOrientationEnum = DoNotRespectI mageOrientation) const; 89 IntSize frameSizeAtIndex(size_t, RespectImageOrientationEnum = DoNotRespectI mageOrientation) const;
108 90
109 bool getHotSpot(IntPoint&) const; 91 bool getHotSpot(IntPoint&) const;
110
111 // Returns one of the cAnimationXXX constants at the top of the file, or
112 // a loop count. In the latter case, the actual number of times the animatio n
113 // cycles is one more than the loop count. See comment atop the file.
114 int repetitionCount(); 92 int repetitionCount();
115 93
116 size_t frameCount() const; 94 size_t frameCount() const;
117 95
118 PassRefPtr<NativeImageSkia> createFrameAtIndex(size_t); 96 PassRefPtr<NativeImageSkia> createFrameAtIndex(size_t);
119 97
120 float frameDurationAtIndex(size_t) const; 98 float frameDurationAtIndex(size_t) const;
121 bool frameHasAlphaAtIndex(size_t) const; // Whether or not the frame actuall y used any alpha. 99 bool frameHasAlphaAtIndex(size_t) const; // Whether or not the frame actuall y used any alpha.
122 bool frameIsCompleteAtIndex(size_t) const; // Whether or not the frame is fu lly received. 100 bool frameIsCompleteAtIndex(size_t) const; // Whether or not the frame is fu lly received.
123 ImageOrientation orientationAtIndex(size_t) const; // EXIF image orientation 101 ImageOrientation orientationAtIndex(size_t) const; // EXIF image orientation
124 102
125 // Return the number of bytes in the decoded frame. If the frame is not yet 103 // Return the number of bytes in the decoded frame. If the frame is not yet
126 // decoded then return 0. 104 // decoded then return 0.
127 unsigned frameBytesAtIndex(size_t) const; 105 unsigned frameBytesAtIndex(size_t) const;
128 106
129 private: 107 private:
130 OwnPtr<DeferredImageDecoder> m_decoder; 108 OwnPtr<DeferredImageDecoder> m_decoder;
131 109
132 AlphaOption m_alphaOption; 110 AlphaOption m_alphaOption;
133 GammaAndColorProfileOption m_gammaAndColorProfileOption; 111 GammaAndColorProfileOption m_gammaAndColorProfileOption;
134 }; 112 };
135 113
136 } // namespace blink 114 } // namespace blink
137 115
138 #endif 116 #endif
OLDNEW
« no previous file with comments | « Source/platform/graphics/DeferredImageDecoderTest.cpp ('k') | Source/platform/graphics/ImageSource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698