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

Side by Side Diff: src/codec/SkGifInterlaceIter.cpp

Issue 1022673011: Creating a new wrapper for gif decoder (Closed) Base URL: https://skia.googlesource.com/skia.git@ico-real
Patch Set: Adding gif functionality to SkCodec 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkGifInterlaceIter.h"
9
10 static const uint8_t kStartingInterlaceYValue[] = { 0, 4, 2, 1 };
scroggo 2015/03/25 19:44:49 nit: Values, plural.
msarett 2015/03/26 19:15:57 Done.
11 static const uint8_t kDeltaInterlaceYValue[] = { 8, 8, 4, 2 };
12
13 SkGifInterlaceIter::SkGifInterlaceIter(int height) : fHeight(height) {
14 fStartYPtr = kStartingInterlaceYValue;
15 fDeltaYPtr = kDeltaInterlaceYValue;
16
17 fCurrY = *fStartYPtr++;
18 fDeltaY = *fDeltaYPtr++;
19 }
20
21 void SkGifInterlaceIter::prepareY() {
22 uint32_t y = fCurrY + fDeltaY;
23
24 // We went from an if statement to a while loop so that we iterate
scroggo 2015/03/25 19:44:49 Are you saying that the old decoder trashed memory
msarett 2015/03/26 19:15:57 This comment is straight from the old decoder. I
25 // through fStartYPtr until a valid row is found. This is so that
26 // images that are smaller than 5x5 will not trash memory.
27 while (y >= fHeight) {
28 if (kStartingInterlaceYValue +
29 SK_ARRAY_COUNT(kStartingInterlaceYValue) == fStartYPtr) {
30 // Now we have iterated over the entire image. Forbid any
31 // subsequent calls to nextY().
32 SkDEBUGCODE(fStartYPtr = NULL;)
33 SkDEBUGCODE(fDeltaYPtr = NULL;)
34 y = 0;
35 } else {
36 y = *fStartYPtr++;
37 fDeltaY = *fDeltaYPtr++;
38 }
39 }
40 fCurrY = y;
41 }
42
43 uint32_t SkGifInterlaceIter::nextY() {
44 SkASSERT(fStartYPtr);
45 SkASSERT(fDeltaYPtr);
46 uint32_t y = fCurrY;
47 prepareY();
48 return y;
49 }
OLDNEW
« src/codec/SkGifInterlaceIter.h ('K') | « src/codec/SkGifInterlaceIter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698