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

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

Issue 1305123002: Scanline decoding for gifs (Closed) Base URL: https://skia.googlesource.com/skia.git@real-bmp-scan
Patch Set: First round of fixes Created 5 years, 3 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 kStartingInterlaceYValues[] = { 0, 4, 2, 1 };
11 static const uint8_t kDeltaInterlaceYValues[] = { 8, 8, 4, 2 };
12
13 SkGifInterlaceIter::SkGifInterlaceIter(int height) : fHeight(height) {
14 fStartYPtr = kStartingInterlaceYValues;
15 fDeltaYPtr = kDeltaInterlaceYValues;
16
17 fCurrY = *fStartYPtr++;
18 fDeltaY = *fDeltaYPtr++;
19 }
20
21 void SkGifInterlaceIter::prepareY() {
22 int32_t y = fCurrY + fDeltaY;
23
24 // Iterate through fStartYPtr until a valid row is found.
25 // This ensures that we do not move past the height of the small images.
26 while (y >= fHeight) {
27 if (kStartingInterlaceYValues +
28 SK_ARRAY_COUNT(kStartingInterlaceYValues) == fStartYPtr) {
29 // Now we have iterated over the entire image. Forbid any
30 // subsequent calls to nextY().
31 SkDEBUGCODE(fStartYPtr = NULL;)
32 SkDEBUGCODE(fDeltaYPtr = NULL;)
33 y = 0;
34 } else {
35 y = *fStartYPtr++;
36 fDeltaY = *fDeltaYPtr++;
37 }
38 }
39 fCurrY = y;
40 }
41
42 int32_t SkGifInterlaceIter::nextY() {
43 SkASSERT(fStartYPtr);
44 SkASSERT(fDeltaYPtr);
45 int32_t y = fCurrY;
46 prepareY();
47 return y;
48 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698