Index: src/codec/SkCodec_libgif.cpp |
diff --git a/src/codec/SkCodec_libgif.cpp b/src/codec/SkCodec_libgif.cpp |
index 036285360b47040f49b04db4a8db8e3bceb746fc..e483aa01ad9558e556ef1de3c40edbd2863264fe 100644 |
--- a/src/codec/SkCodec_libgif.cpp |
+++ b/src/codec/SkCodec_libgif.cpp |
@@ -100,7 +100,7 @@ static uint32_t find_trans_index(const SavedImage& image) { |
* It is used in a SkAutoTCallIProc template |
*/ |
void SkGifCodec::CloseGif(GifFileType* gif) { |
- DGifCloseFile(gif, NULL); |
+ DGifCloseFile(gif, nullptr); |
} |
/* |
@@ -108,7 +108,7 @@ void SkGifCodec::CloseGif(GifFileType* gif) { |
* decoder |
*/ |
void SkGifCodec::FreeExtension(SavedImage* image) { |
- if (NULL != image->ExtensionBlocks) { |
+ if (nullptr != image->ExtensionBlocks) { |
GifFreeExtensions(&image->ExtensionBlockCount, &image->ExtensionBlocks); |
} |
} |
@@ -220,9 +220,9 @@ SkGifCodec::SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType |
// there is a valid background color. |
, fFillIndex(0) |
, fFrameRect(frameRect) |
- , fFrameIsSubset(frameIsSubset) |
- , fColorTable(NULL) |
- , fSwizzler(NULL) |
+ , fFrameIsSubset(false) |
+ , fColorTable(nullptr) |
+ , fSwizzler(nullptr) |
{} |
bool SkGifCodec::onRewind() { |
@@ -355,7 +355,7 @@ void SkGifCodec::initializeColorTable(const SkImageInfo& dstInfo, SkPMColor* inp |
// Set up our own color table |
const uint32_t maxColors = 256; |
SkPMColor colorPtr[256]; |
- if (NULL != inputColorCount) { |
+ if (nullptr != inputColorCount) { |
// We set the number of colors to maxColors in order to ensure |
// safe memory accesses. Otherwise, an invalid pixel could |
// access memory outside of our color table array. |
@@ -365,12 +365,12 @@ void SkGifCodec::initializeColorTable(const SkImageInfo& dstInfo, SkPMColor* inp |
// Get local color table |
ColorMapObject* colorMap = fGif->Image.ColorMap; |
// If there is no local color table, use the global color table |
- if (NULL == colorMap) { |
+ if (nullptr == colorMap) { |
colorMap = fGif->SColorMap; |
} |
uint32_t colorCount = 0; |
- if (NULL != colorMap) { |
+ if (nullptr != colorMap) { |
colorCount = colorMap->ColorCount; |
// giflib guarantees these properties |
SkASSERT(colorCount == (unsigned) (1 << (colorMap->BitsPerPixel))); |
@@ -425,10 +425,10 @@ SkCodec::Result SkGifCodec::prepareToDecode(const SkImageInfo& dstInfo, SkPMColo |
} |
SkCodec::Result SkGifCodec::initializeSwizzler(const SkImageInfo& dstInfo, |
- ZeroInitialized zeroInit) { |
+ ZeroInitialized zeroInit, int subsetLeft, int subsetWidth) { |
const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
- fSwizzler.reset(SkSwizzler::CreateSwizzler(SkSwizzler::kIndex, |
- colorPtr, dstInfo, zeroInit)); |
+ fSwizzler.reset(SkSwizzler::CreateSwizzler(SkSwizzler::kIndex, colorPtr, dstInfo, zeroInit, |
+ subsetLeft, subsetWidth)); |
if (nullptr != fSwizzler.get()) { |
return kSuccess; |
} |
@@ -460,7 +460,8 @@ SkCodec::Result SkGifCodec::onGetPixels(const SkImageInfo& dstInfo, |
// Initialize the swizzler |
if (fFrameIsSubset) { |
const SkImageInfo subsetDstInfo = dstInfo.makeWH(fFrameRect.width(), fFrameRect.height()); |
- if (kSuccess != this->initializeSwizzler(subsetDstInfo, opts.fZeroInitialized)) { |
+ if (kSuccess != this->initializeSwizzler(subsetDstInfo, opts.fZeroInitialized, 0, |
+ fFrameRect.width())) { |
return gif_error("Could not initialize swizzler.\n", kUnimplemented); |
} |
@@ -474,7 +475,8 @@ SkCodec::Result SkGifCodec::onGetPixels(const SkImageInfo& dstInfo, |
dst = SkTAddOffset<void*>(dst, dstRowBytes * fFrameRect.top() + |
dstBytesPerPixel * fFrameRect.left()); |
} else { |
- if (kSuccess != this->initializeSwizzler(dstInfo, opts.fZeroInitialized)) { |
+ if (kSuccess != this->initializeSwizzler(dstInfo, opts.fZeroInitialized, 0, |
+ dstInfo.width())) { |
return gif_error("Could not initialize swizzler.\n", kUnimplemented); |
} |
} |
@@ -499,7 +501,8 @@ uint32_t SkGifCodec::onGetFillValue(SkColorType colorType, SkAlphaType alphaType |
} |
SkCodec::Result SkGifCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, |
- const SkCodec::Options& opts, SkPMColor inputColorPtr[], int* inputColorCount) { |
+ const SkCodec::Options& opts, SkPMColor inputColorPtr[], int* inputColorCount, |
+ int subsetLeft, int subsetWidth) { |
Result result = this->prepareToDecode(dstInfo, inputColorPtr, inputColorCount, this->options()); |
if (kSuccess != result) { |
@@ -509,11 +512,13 @@ SkCodec::Result SkGifCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, |
// Initialize the swizzler |
if (fFrameIsSubset) { |
const SkImageInfo subsetDstInfo = dstInfo.makeWH(fFrameRect.width(), fFrameRect.height()); |
- if (kSuccess != this->initializeSwizzler(subsetDstInfo, opts.fZeroInitialized)) { |
+ if (kSuccess != this->initializeSwizzler(subsetDstInfo, opts.fZeroInitialized, subsetLeft, |
+ subsetWidth)) { |
return gif_error("Could not initialize swizzler.\n", kUnimplemented); |
} |
} else { |
- if (kSuccess != this->initializeSwizzler(dstInfo, opts.fZeroInitialized)) { |
+ if (kSuccess != this->initializeSwizzler(dstInfo, opts.fZeroInitialized, subsetLeft, |
+ subsetWidth)) { |
return gif_error("Could not initialize swizzler.\n", kUnimplemented); |
} |
} |