From d5de49efd5111472d96158db47676b5abbd8dac0 Mon Sep 17 00:00:00 2001 From: Seth Fowler Date: Fri, 31 Jul 2015 07:29:00 -0700 Subject: [PATCH] Bug 1187386 (Part 1) - Make most decoder state private. r=tn --- image/Decoder.cpp | 24 ++++++++-------- image/Decoder.h | 47 +++++++++++++++----------------- image/decoders/nsJPEGDecoder.cpp | 2 +- image/decoders/nsPNGDecoder.cpp | 2 +- 4 files changed, 37 insertions(+), 38 deletions(-) diff --git a/image/Decoder.cpp b/image/Decoder.cpp index 0e6f3f1c6db..6f883bf4507 100644 --- a/image/Decoder.cpp +++ b/image/Decoder.cpp @@ -24,27 +24,29 @@ namespace mozilla { namespace image { Decoder::Decoder(RasterImage* aImage) - : mImage(aImage) - , mProgress(NoProgress) - , mImageData(nullptr) + : mImageData(nullptr) + , mImageDataLength(0) , mColormap(nullptr) + , mColormapSize(0) + , mImage(aImage) + , mProgress(NoProgress) + , mFrameCount(0) + , mFailCode(NS_OK) , mChunkCount(0) , mFlags(0) , mBytesDecoded(0) + , mInitialized(false) + , mMetadataDecode(false) , mSendPartialInvalidations(false) + , mImageIsTransient(false) + , mImageIsLocked(false) + , mInFrame(false) + , mIsAnimated(false) , mDataDone(false) , mDecodeDone(false) , mDataError(false) , mDecodeAborted(false) , mShouldReportError(false) - , mImageIsTransient(false) - , mImageIsLocked(false) - , mFrameCount(0) - , mFailCode(NS_OK) - , mInitialized(false) - , mMetadataDecode(false) - , mInFrame(false) - , mIsAnimated(false) { } Decoder::~Decoder() diff --git a/image/Decoder.h b/image/Decoder.h index 020a784ca5c..9458f111cc1 100644 --- a/image/Decoder.h +++ b/image/Decoder.h @@ -389,10 +389,13 @@ protected: uint8_t aPaletteDepth, imgFrame* aPreviousFrame); - /* - * Member variables. - * - */ +protected: + uint8_t* mImageData; // Pointer to image data in either Cairo or 8bit format + uint32_t mImageDataLength; + uint32_t* mColormap; // Current colormap to be used in Cairo format + uint32_t mColormapSize; + +private: nsRefPtr mImage; Maybe mIterator; RawAccessFrameRef mCurrentFrame; @@ -400,10 +403,9 @@ protected: nsIntRect mInvalidRect; // Tracks an invalidation region in the current frame. Progress mProgress; - uint8_t* mImageData; // Pointer to image data in either Cairo or 8bit format - uint32_t mImageDataLength; - uint32_t* mColormap; // Current colormap to be used in Cairo format - uint32_t mColormapSize; + uint32_t mFrameCount; // Number of frames, including anything in-progress + + nsresult mFailCode; // Telemetry data for this decoder. TimeDuration mDecodeTime; @@ -411,24 +413,19 @@ protected: uint32_t mFlags; size_t mBytesDecoded; - bool mSendPartialInvalidations; - bool mDataDone; - bool mDecodeDone; - bool mDataError; - bool mDecodeAborted; - bool mShouldReportError; - bool mImageIsTransient; - bool mImageIsLocked; -private: - uint32_t mFrameCount; // Number of frames, including anything in-progress - - nsresult mFailCode; - - bool mInitialized; - bool mMetadataDecode; - bool mInFrame; - bool mIsAnimated; + bool mInitialized : 1; + bool mMetadataDecode : 1; + bool mSendPartialInvalidations : 1; + bool mImageIsTransient : 1; + bool mImageIsLocked : 1; + bool mInFrame : 1; + bool mIsAnimated : 1; + bool mDataDone : 1; + bool mDecodeDone : 1; + bool mDataError : 1; + bool mDecodeAborted : 1; + bool mShouldReportError : 1; }; } // namespace image diff --git a/image/decoders/nsJPEGDecoder.cpp b/image/decoders/nsJPEGDecoder.cpp index e1556d02bb8..57e7f0496bc 100644 --- a/image/decoders/nsJPEGDecoder.cpp +++ b/image/decoders/nsJPEGDecoder.cpp @@ -248,7 +248,7 @@ nsJPEGDecoder::WriteInternal(const char* aBuffer, uint32_t aCount) return; // I/O suspension } - int sampleSize = mImage->GetRequestedSampleSize(); + int sampleSize = GetImage()->GetRequestedSampleSize(); if (sampleSize > 0) { mInfo.scale_num = 1; mInfo.scale_denom = sampleSize; diff --git a/image/decoders/nsPNGDecoder.cpp b/image/decoders/nsPNGDecoder.cpp index 0e0bd738884..2c7b14ba093 100644 --- a/image/decoders/nsPNGDecoder.cpp +++ b/image/decoders/nsPNGDecoder.cpp @@ -178,7 +178,7 @@ nsPNGDecoder::CreateFrame(png_uint_32 aXOffset, png_uint_32 aYOffset, ("PNGDecoderAccounting: nsPNGDecoder::CreateFrame -- created " "image frame with %dx%d pixels in container %p", aWidth, aHeight, - &mImage)); + GetImage())); #ifdef PNG_APNG_SUPPORTED if (png_get_valid(mPNG, mInfo, PNG_INFO_acTL)) {