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

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

Issue 1315583003: Interlaced gifs without the iterator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase 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
« no previous file with comments | « src/codec/SkGifInterlaceIter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 = nullptr;)
32 SkDEBUGCODE(fDeltaYPtr = nullptr;)
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
« no previous file with comments | « src/codec/SkGifInterlaceIter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698