OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 /* | |
9 * Copyright (C) 2015 Google Inc. All rights reserved. | |
10 * | |
11 * Redistribution and use in source and binary forms, with or without | |
12 * modification, are permitted provided that the following conditions | |
13 * are met: | |
14 * 1. Redistributions of source code must retain the above copyright | |
15 * notice, this list of conditions and the following disclaimer. | |
16 * 2. Redistributions in binary form must reproduce the above copyright | |
17 * notice, this list of conditions and the following disclaimer in the | |
18 * documentation and/or other materials provided with the distribution. | |
19 * | |
20 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
21 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
28 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
31 */ | |
32 | |
33 #ifndef SkCodecAnimation_DEFINED | 8 #ifndef SkCodecAnimation_DEFINED |
34 #define SkCodecAnimation_DEFINED | 9 #define SkCodecAnimation_DEFINED |
35 | 10 |
36 #include "SkCodec.h" | 11 #include "SkCodec.h" |
37 #include "SkRect.h" | 12 #include "SkRect.h" |
38 | 13 |
39 class SkCodecAnimation { | 14 class SkCodecAnimation { |
40 public: | 15 public: |
41 | |
42 // GIF and WebP support animation. The explanation below is in terms of GIF, | |
43 // but the same constants are used for WebP, too. | |
44 // GIFs have an optional 16-bit unsigned loop count that describes how an | |
45 // animated GIF should be cycled. If the loop count is absent, the animatio
n | |
46 // cycles once; if it is 0, the animation cycles infinitely; otherwise the | |
47 // animation plays n + 1 cycles (where n is the specified loop count). If t
he | |
48 // GIF decoder defaults to kAnimationLoopOnce in the absence of any loop cou
nt | |
49 // and translates an explicit "0" loop count to kAnimationLoopInfinite, then
we | |
50 // get a couple of nice side effects: | |
51 // * By making kAnimationLoopOnce be 0, we allow the animation cycling cod
e to | |
52 // avoid special-casing it, and simply treat all non-negative loop count
s | |
53 // identically. | |
54 // * By making the other two constants negative, we avoid conflicts with a
ny | |
55 // real loop count values. | |
56 static const int kAnimationLoopOnce = 0; | |
57 static const int kAnimationLoopInfinite = -1; | |
58 static const int kAnimationNone = -2; | |
59 | |
60 /** | 16 /** |
61 * This specifies how the next frame is based on this frame. | 17 * This specifies how the next frame is based on this frame. |
62 * | 18 * |
63 * Names are based on the GIF 89a spec. | 19 * Names are based on the GIF 89a spec. |
64 * | 20 * |
65 * The numbers correspond to values in a GIF. | 21 * The numbers correspond to values in a GIF. |
66 */ | 22 */ |
67 enum DisposalMethod { | 23 enum DisposalMethod { |
68 /** | 24 /** |
69 * The next frame should be drawn on top of this one. | 25 * The next frame should be drawn on top of this one. |
(...skipping 15 matching lines...) Expand all Loading... |
85 * | 41 * |
86 * In a GIF, a value of 4 is also treated as RestorePrevious. | 42 * In a GIF, a value of 4 is also treated as RestorePrevious. |
87 */ | 43 */ |
88 RestorePrevious_DisposalMethod = 3, | 44 RestorePrevious_DisposalMethod = 3, |
89 }; | 45 }; |
90 | 46 |
91 private: | 47 private: |
92 SkCodecAnimation(); | 48 SkCodecAnimation(); |
93 }; | 49 }; |
94 #endif // SkCodecAnimation_DEFINED | 50 #endif // SkCodecAnimation_DEFINED |
OLD | NEW |