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

Unified Diff: src/codec/SkCodec_libgif.cpp

Issue 1315583003: Interlaced gifs without the iterator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/codec.gyp ('k') | src/codec/SkGifInterlaceIter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkCodec_libgif.cpp
diff --git a/src/codec/SkCodec_libgif.cpp b/src/codec/SkCodec_libgif.cpp
index 120044193481200edd79aeb05b59c61f36ba1b8d..5ccd040f2bab951e20aac99ba25c77251a092eb5 100644
--- a/src/codec/SkCodec_libgif.cpp
+++ b/src/codec/SkCodec_libgif.cpp
@@ -9,7 +9,6 @@
#include "SkCodecPriv.h"
#include "SkColorPriv.h"
#include "SkColorTable.h"
-#include "SkGifInterlaceIter.h"
#include "SkStream.h"
#include "SkSwizzler.h"
#include "SkUtils.h"
@@ -122,6 +121,30 @@ static uint32_t find_trans_index(const SavedImage& image) {
return SK_MaxU32;
}
+static inline uint32_t ceil_div(uint32_t a, uint32_t b) {
+ return (a + b - 1) / b;
+}
+
+/*
+ * Gets the output row corresponding to the encoded row for interlaced gifs
+ */
+static uint32_t get_output_row_interlaced(uint32_t encodedRow, uint32_t height) {
+ SkASSERT(encodedRow < height);
+ // First pass
+ if (encodedRow * 8 < height) {
+ return encodedRow * 8;
+ // Second pass
+ } else if (encodedRow * 4 < height) {
scroggo 2015/08/28 13:42:32 nit: These do not need to be else statements, sinc
msarett 2015/08/28 14:30:36 Fixing.
+ return 4 + 8 * (encodedRow - ceil_div(height, 8));
+ // Third pass
+ } else if (encodedRow * 2 < height) {
+ return 2 + 4 * (encodedRow - ceil_div(height, 4));
+ // Fourth pass
+ } else {
+ return 1 + 2 * (encodedRow - ceil_div(height, 2));
+ }
+}
+
/*
* Read enough of the stream to initialize the SkGifCodec.
* Returns a bool representing success or failure.
@@ -424,10 +447,6 @@ SkCodec::Result SkGifCodec::onGetPixels(const SkImageInfo& dstInfo,
// Check the interlace flag and iterate over rows of the input
if (fGif->Image.Interlace) {
- // In interlace mode, the rows of input are rearranged in
- // the output image. We use an iterator to take care of
- // the rearranging.
- SkGifInterlaceIter iter(innerHeight);
for (int32_t y = 0; y < innerHeight; y++) {
if (GIF_ERROR == DGifGetLine(fGif, buffer.get(),
innerWidth)) {
@@ -436,7 +455,8 @@ SkCodec::Result SkGifCodec::onGetPixels(const SkImageInfo& dstInfo,
memset(buffer.get(), fillIndex, innerWidth);
for (; y < innerHeight; y++) {
void* dstRow = SkTAddOffset<void>(dst,
- dstRowBytes * iter.nextY());
+ dstRowBytes *
+ get_output_row_interlaced(y, innerHeight));
swizzler->swizzle(dstRow, buffer.get());
}
}
@@ -445,7 +465,8 @@ SkCodec::Result SkGifCodec::onGetPixels(const SkImageInfo& dstInfo,
y, height - 1).c_str(), kIncompleteInput);
}
void* dstRow = SkTAddOffset<void>(
- dst, dstRowBytes * iter.nextY());
+ dst, dstRowBytes *
+ get_output_row_interlaced(y, innerHeight));
swizzler->swizzle(dstRow, buffer.get());
}
} else {
« no previous file with comments | « gyp/codec.gyp ('k') | src/codec/SkGifInterlaceIter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698