Index: src/codec/SkCodec_libgif.cpp |
diff --git a/src/codec/SkCodec_libgif.cpp b/src/codec/SkCodec_libgif.cpp |
index 0dfc75fd9c478a4ff659aa3ea56ad49afd164825..91ef75b2f8e839f011e9056001dda3f3e2872321 100644 |
--- a/src/codec/SkCodec_libgif.cpp |
+++ b/src/codec/SkCodec_libgif.cpp |
@@ -101,7 +101,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); |
} |
/* |
@@ -109,7 +109,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); |
} |
} |
@@ -222,8 +222,8 @@ SkGifCodec::SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType |
, fFillIndex(0) |
, fFrameDims(SkIRect::MakeEmpty()) |
, fFrameIsSubset(false) |
- , fColorTable(NULL) |
- , fSwizzler(NULL) |
+ , fColorTable(nullptr) |
+ , fSwizzler(nullptr) |
{} |
bool SkGifCodec::onRewind() { |
@@ -377,7 +377,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. |
@@ -387,12 +387,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))); |
@@ -457,10 +457,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, this->getInfo())); |
+ fSwizzler.reset(SkSwizzler::CreateSwizzler(SkSwizzler::kIndex, colorPtr, dstInfo, zeroInit, |
+ this->getInfo(), subsetLeft, subsetWidth)); |
scroggo
2015/10/02 18:27:03
If we stick these on options, we can update SkSwiz
|
if (nullptr != fSwizzler.get()) { |
return kSuccess; |
} |
@@ -492,7 +492,8 @@ SkCodec::Result SkGifCodec::onGetPixels(const SkImageInfo& dstInfo, |
// Initialize the swizzler |
if (fFrameIsSubset) { |
const SkImageInfo subsetDstInfo = dstInfo.makeWH(fFrameDims.width(), fFrameDims.height()); |
- if (kSuccess != this->initializeSwizzler(subsetDstInfo, opts.fZeroInitialized)) { |
+ if (kSuccess != this->initializeSwizzler(subsetDstInfo, opts.fZeroInitialized, 0, |
+ fFrameDims.width())) { |
return gif_error("Could not initialize swizzler.\n", kUnimplemented); |
} |
@@ -506,7 +507,8 @@ SkCodec::Result SkGifCodec::onGetPixels(const SkImageInfo& dstInfo, |
dst = SkTAddOffset<void*>(dst, dstRowBytes * fFrameDims.top() + |
dstBytesPerPixel * fFrameDims.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); |
} |
} |
@@ -531,7 +533,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) { |
@@ -548,15 +551,18 @@ SkCodec::Result SkGifCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, |
// Initialize the swizzler |
if (fFrameIsSubset) { |
int sampleX; |
- SkScaledCodec::ComputeSampleSize(dstInfo, this->getInfo(), &sampleX, NULL); |
+ SkScaledCodec::ComputeSampleSize(dstInfo.dimensions(), this->getInfo().dimensions(), |
+ &sampleX, NULL); |
const SkImageInfo subsetDstInfo = dstInfo.makeWH( |
get_scaled_dimension(fFrameDims.width(), sampleX), |
fFrameDims.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); |
} |
} |
@@ -569,7 +575,7 @@ int SkGifCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { |
int rowsAfterFrame = 0; |
if (fFrameIsSubset) { |
// Fill the requested rows |
- SkSwizzler::Fill(dst, this->dstInfo().makeWH(this->dstInfo().width(), count), rowBytes, |
+ SkSwizzler::Fill(dst, this->dstInfo().makeWH(this->subsetWidth(), count), rowBytes, |
this->onGetFillValue(this->dstInfo().colorType(), this->dstInfo().alphaType()), |
this->options().fZeroInitialized); |