| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkMovie.h" | 10 #include "SkMovie.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 int transparent, int width) | 116 int transparent, int width) |
| 117 { | 117 { |
| 118 for (; width > 0; width--, src++, dst++) { | 118 for (; width > 0; width--, src++, dst++) { |
| 119 if (*src != transparent) { | 119 if (*src != transparent) { |
| 120 const GifColorType& col = cmap->Colors[*src]; | 120 const GifColorType& col = cmap->Colors[*src]; |
| 121 *dst = SkPackARGB32(0xFF, col.Red, col.Green, col.Blue); | 121 *dst = SkPackARGB32(0xFF, col.Red, col.Green, col.Blue); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 #if GIFLIB_MAJOR < 5 |
| 126 static void copyInterlaceGroup(SkBitmap* bm, const unsigned char*& src, | 127 static void copyInterlaceGroup(SkBitmap* bm, const unsigned char*& src, |
| 127 const ColorMapObject* cmap, int transparent, int
copyWidth, | 128 const ColorMapObject* cmap, int transparent, int
copyWidth, |
| 128 int copyHeight, const GifImageDesc& imageDesc, in
t rowStep, | 129 int copyHeight, const GifImageDesc& imageDesc, in
t rowStep, |
| 129 int startRow) | 130 int startRow) |
| 130 { | 131 { |
| 131 int row; | 132 int row; |
| 132 // every 'rowStep'th row, starting with row 'startRow' | 133 // every 'rowStep'th row, starting with row 'startRow' |
| 133 for (row = startRow; row < copyHeight; row += rowStep) { | 134 for (row = startRow; row < copyHeight; row += rowStep) { |
| 134 uint32_t* dst = bm->getAddr32(imageDesc.Left, imageDesc.Top + row); | 135 uint32_t* dst = bm->getAddr32(imageDesc.Left, imageDesc.Top + row); |
| 135 copyLine(dst, src, cmap, transparent, copyWidth); | 136 copyLine(dst, src, cmap, transparent, copyWidth); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 162 copyInterlaceGroup(bm, src, cmap, transparent, copyWidth, copyHeight, frame-
>ImageDesc, 8, 0); | 163 copyInterlaceGroup(bm, src, cmap, transparent, copyWidth, copyHeight, frame-
>ImageDesc, 8, 0); |
| 163 | 164 |
| 164 // group 2 - every 8th row, starting with row 4 | 165 // group 2 - every 8th row, starting with row 4 |
| 165 copyInterlaceGroup(bm, src, cmap, transparent, copyWidth, copyHeight, frame-
>ImageDesc, 8, 4); | 166 copyInterlaceGroup(bm, src, cmap, transparent, copyWidth, copyHeight, frame-
>ImageDesc, 8, 4); |
| 166 | 167 |
| 167 // group 3 - every 4th row, starting with row 2 | 168 // group 3 - every 4th row, starting with row 2 |
| 168 copyInterlaceGroup(bm, src, cmap, transparent, copyWidth, copyHeight, frame-
>ImageDesc, 4, 2); | 169 copyInterlaceGroup(bm, src, cmap, transparent, copyWidth, copyHeight, frame-
>ImageDesc, 4, 2); |
| 169 | 170 |
| 170 copyInterlaceGroup(bm, src, cmap, transparent, copyWidth, copyHeight, frame-
>ImageDesc, 2, 1); | 171 copyInterlaceGroup(bm, src, cmap, transparent, copyWidth, copyHeight, frame-
>ImageDesc, 2, 1); |
| 171 } | 172 } |
| 173 #endif |
| 172 | 174 |
| 173 static void blitNormal(SkBitmap* bm, const SavedImage* frame, const ColorMapObje
ct* cmap, | 175 static void blitNormal(SkBitmap* bm, const SavedImage* frame, const ColorMapObje
ct* cmap, |
| 174 int transparent) | 176 int transparent) |
| 175 { | 177 { |
| 176 int width = bm->width(); | 178 int width = bm->width(); |
| 177 int height = bm->height(); | 179 int height = bm->height(); |
| 178 const unsigned char* src = (unsigned char*)frame->RasterBits; | 180 const unsigned char* src = (unsigned char*)frame->RasterBits; |
| 179 uint32_t* dst = bm->getAddr32(frame->ImageDesc.Left, frame->ImageDesc.Top); | 181 uint32_t* dst = bm->getAddr32(frame->ImageDesc.Left, frame->ImageDesc.Top); |
| 180 GifWord copyWidth = frame->ImageDesc.Width; | 182 GifWord copyWidth = frame->ImageDesc.Width; |
| 181 if (frame->ImageDesc.Left + copyWidth > width) { | 183 if (frame->ImageDesc.Left + copyWidth > width) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 if (frame->ImageDesc.ColorMap != NULL) { | 236 if (frame->ImageDesc.ColorMap != NULL) { |
| 235 // use local color table | 237 // use local color table |
| 236 cmap = frame->ImageDesc.ColorMap; | 238 cmap = frame->ImageDesc.ColorMap; |
| 237 } | 239 } |
| 238 | 240 |
| 239 if (cmap == NULL || cmap->ColorCount != (1 << cmap->BitsPerPixel)) { | 241 if (cmap == NULL || cmap->ColorCount != (1 << cmap->BitsPerPixel)) { |
| 240 SkDEBUGFAIL("bad colortable setup"); | 242 SkDEBUGFAIL("bad colortable setup"); |
| 241 return; | 243 return; |
| 242 } | 244 } |
| 243 | 245 |
| 246 #if GIFLIB_MAJOR < 5 |
| 247 // before GIFLIB 5, de-interlacing wasn't done by library at load time |
| 244 if (frame->ImageDesc.Interlace) { | 248 if (frame->ImageDesc.Interlace) { |
| 245 blitInterlace(bm, frame, cmap, transparent); | 249 blitInterlace(bm, frame, cmap, transparent); |
| 246 } else { | 250 return; |
| 247 blitNormal(bm, frame, cmap, transparent); | |
| 248 } | 251 } |
| 252 #endif |
| 253 |
| 254 blitNormal(bm, frame, cmap, transparent); |
| 249 } | 255 } |
| 250 | 256 |
| 251 static bool checkIfWillBeCleared(const SavedImage* frame) | 257 static bool checkIfWillBeCleared(const SavedImage* frame) |
| 252 { | 258 { |
| 253 for (int i = 0; i < frame->ExtensionBlockCount; ++i) { | 259 for (int i = 0; i < frame->ExtensionBlockCount; ++i) { |
| 254 ExtensionBlock* eb = frame->ExtensionBlocks + i; | 260 ExtensionBlock* eb = frame->ExtensionBlocks + i; |
| 255 if (eb->Function == GRAPHICS_EXT_FUNC_CODE && | 261 if (eb->Function == GRAPHICS_EXT_FUNC_CODE && |
| 256 eb->ByteCount == 4) { | 262 eb->ByteCount == 4) { |
| 257 // check disposal method | 263 // check disposal method |
| 258 int disposal = ((eb->Bytes[0] >> 2) & 7); | 264 int disposal = ((eb->Bytes[0] >> 2) & 7); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) { | 440 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) { |
| 435 // must rewind here, since our construct wants to re-read the data | 441 // must rewind here, since our construct wants to re-read the data |
| 436 stream->rewind(); | 442 stream->rewind(); |
| 437 return SkNEW_ARGS(SkGIFMovie, (stream)); | 443 return SkNEW_ARGS(SkGIFMovie, (stream)); |
| 438 } | 444 } |
| 439 } | 445 } |
| 440 return NULL; | 446 return NULL; |
| 441 } | 447 } |
| 442 | 448 |
| 443 static SkTRegistry<SkMovie*, SkStream*> gReg(Factory); | 449 static SkTRegistry<SkMovie*, SkStream*> gReg(Factory); |
| OLD | NEW |