OLD | NEW |
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* ***** BEGIN LICENSE BLOCK ***** | 2 /* ***** BEGIN LICENSE BLOCK ***** |
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
4 * | 4 * |
5 * The contents of this file are subject to the Mozilla Public License Version | 5 * The contents of this file are subject to the Mozilla Public License Version |
6 * 1.1 (the "License"); you may not use this file except in compliance with | 6 * 1.1 (the "License"); you may not use this file except in compliance with |
7 * the License. You may obtain a copy of the License at | 7 * the License. You may obtain a copy of the License at |
8 * http://www.mozilla.org/MPL/ | 8 * http://www.mozilla.org/MPL/ |
9 * | 9 * |
10 * Software distributed under the License is distributed on an "AS IS" basis, | 10 * Software distributed under the License is distributed on an "AS IS" basis, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 , codemask(0) | 95 , codemask(0) |
96 , clearCode(0) | 96 , clearCode(0) |
97 , avail(0) | 97 , avail(0) |
98 , oldcode(0) | 98 , oldcode(0) |
99 , firstchar(0) | 99 , firstchar(0) |
100 , bits(0) | 100 , bits(0) |
101 , datum(0) | 101 , datum(0) |
102 , ipass(0) | 102 , ipass(0) |
103 , irow(0) | 103 , irow(0) |
104 , rowsRemaining(0) | 104 , rowsRemaining(0) |
| 105 , alwaysWriteTransparentPixels(false) |
105 , rowIter(0) | 106 , rowIter(0) |
106 , m_client(client) | 107 , m_client(client) |
107 , m_frameContext(frameContext) | 108 , m_frameContext(frameContext) |
108 { } | 109 { } |
109 | 110 |
110 bool prepareToDecode(); | 111 bool prepareToDecode(); |
111 bool outputRow(const unsigned char* rowBegin); | 112 bool outputRow(const unsigned char* rowBegin); |
112 bool doLZW(const unsigned char* block, size_t bytesInBlock); | 113 bool doLZW(const unsigned char* block, size_t bytesInBlock); |
113 bool hasRemainingRows() { return SkToBool(rowsRemaining); } | 114 bool hasRemainingRows() { return SkToBool(rowsRemaining); } |
114 | 115 |
115 private: | 116 private: |
116 // LZW decoding states and output states. | 117 // LZW decoding states and output states. |
117 int codesize; | 118 int codesize; |
118 int codemask; | 119 int codemask; |
119 int clearCode; // Codeword used to trigger dictionary reset. | 120 int clearCode; // Codeword used to trigger dictionary reset. |
120 int avail; // Index of next available slot in dictionary. | 121 int avail; // Index of next available slot in dictionary. |
121 int oldcode; | 122 int oldcode; |
122 unsigned char firstchar; | 123 unsigned char firstchar; |
123 int bits; // Number of unread bits in "datum". | 124 int bits; // Number of unread bits in "datum". |
124 int datum; // 32-bit input buffer. | 125 int datum; // 32-bit input buffer. |
125 int ipass; // Interlace pass; Ranges 1-4 if interlaced. | 126 int ipass; // Interlace pass; Ranges 1-4 if interlaced. |
126 size_t irow; // Current output row, starting at zero. | 127 size_t irow; // Current output row, starting at zero. |
127 size_t rowsRemaining; // Rows remaining to be output. | 128 size_t rowsRemaining; // Rows remaining to be output. |
| 129 // This depends on the GIFFrameContext. If the frame is not |
| 130 // interlaced and it is independent, it is always safe to |
| 131 // write transparent pixels. |
| 132 bool alwaysWriteTransparentPixels; |
128 | 133 |
129 unsigned short prefix[SK_MAX_DICTIONARY_ENTRIES]; | 134 unsigned short prefix[SK_MAX_DICTIONARY_ENTRIES]; |
130 unsigned char suffix[SK_MAX_DICTIONARY_ENTRIES]; | 135 unsigned char suffix[SK_MAX_DICTIONARY_ENTRIES]; |
131 unsigned short suffixLength[SK_MAX_DICTIONARY_ENTRIES]; | 136 unsigned short suffixLength[SK_MAX_DICTIONARY_ENTRIES]; |
132 SkGIFRow rowBuffer; // Single scanline temporary buffer. | 137 SkGIFRow rowBuffer; // Single scanline temporary buffer. |
133 unsigned char* rowIter; | 138 unsigned char* rowIter; |
134 | 139 |
135 SkGifCodec* const m_client; | 140 SkGifCodec* const m_client; |
136 const SkGIFFrameContext* m_frameContext; | 141 const SkGIFFrameContext* m_frameContext; |
137 }; | 142 }; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 SkStreamBuffer m_streamBuffer; | 395 SkStreamBuffer m_streamBuffer; |
391 bool m_parseCompleted; | 396 bool m_parseCompleted; |
392 | 397 |
393 // These values can be computed before we create a SkGIFFrameContext, so we | 398 // These values can be computed before we create a SkGIFFrameContext, so we |
394 // store them here instead of on m_frames[0]. | 399 // store them here instead of on m_frames[0]. |
395 bool m_firstFrameHasAlpha; | 400 bool m_firstFrameHasAlpha; |
396 bool m_firstFrameSupportsIndex8; | 401 bool m_firstFrameSupportsIndex8; |
397 }; | 402 }; |
398 | 403 |
399 #endif | 404 #endif |
OLD | NEW |