Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 } | |
| OLD | NEW |