Skip to content

Commit

Permalink
Bug 1453795 - Image - Initialize member fields in classes/ structures…
Browse files Browse the repository at this point in the history
…. r=tnikkel
  • Loading branch information
abpostelnicu committed Jun 14, 2018
1 parent 51c35a0 commit 7f8217a
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 27 deletions.
35 changes: 30 additions & 5 deletions image/CopyOnWrite.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,36 @@ class CopyOnWriteValue final
public:
NS_INLINE_DECL_REFCOUNTING(CopyOnWriteValue)

explicit CopyOnWriteValue(T* aValue) : mValue(aValue) { }
explicit CopyOnWriteValue(already_AddRefed<T>& aValue) : mValue(aValue) { }
explicit CopyOnWriteValue(already_AddRefed<T>&& aValue) : mValue(aValue) { }
explicit CopyOnWriteValue(const RefPtr<T>& aValue) : mValue(aValue) { }
explicit CopyOnWriteValue(RefPtr<T>&& aValue) : mValue(aValue) { }
explicit CopyOnWriteValue(T* aValue)
: mValue(aValue)
, mReaders(0)
, mWriter(false)
{
}
explicit CopyOnWriteValue(already_AddRefed<T>& aValue)
: mValue(aValue)
, mReaders(0)
, mWriter(false)
{
}
explicit CopyOnWriteValue(already_AddRefed<T>&& aValue)
: mValue(aValue)
, mReaders(0)
, mWriter(false)
{
}
explicit CopyOnWriteValue(const RefPtr<T>& aValue)
: mValue(aValue)
, mReaders(0)
, mWriter(false)
{
}
explicit CopyOnWriteValue(RefPtr<T>&& aValue)
: mValue(aValue)
, mReaders(0)
, mWriter(false)
{
}

T* get() { return mValue.get(); }
const T* get() const { return mValue.get(); }
Expand Down
4 changes: 4 additions & 0 deletions image/Downscaler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Downscaler::Downscaler(const nsIntSize& aTargetSize)
: mTargetSize(aTargetSize)
, mOutputBuffer(nullptr)
, mWindowCapacity(0)
, mLinesInBuffer(0)
, mPrevInvalidatedLine(0)
, mCurrentOutLine(0)
, mCurrentInLine(0)
, mHasAlpha(true)
, mFlipVertically(false)
{
Expand Down
1 change: 1 addition & 0 deletions image/RasterImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ RasterImage::RasterImage(nsIURI* aURI /* = nullptr */) :
ImageResource(aURI), // invoke superclass's constructor
mSize(0,0),
mLockCount(0),
mDecoderType(DecoderType::UNKNOWN),
mDecodeCount(0),
#ifdef DEBUG
mFramesNotified(0),
Expand Down
1 change: 1 addition & 0 deletions image/VectorImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ VectorImage::VectorImage(nsIURI* aURI /* = nullptr */) :
ImageResource(aURI), // invoke superclass's constructor
mLockCount(0),
mIsInitialized(false),
mDiscardable(false),
mIsFullyLoaded(false),
mIsDrawing(false),
mHaveAnimations(false),
Expand Down
1 change: 1 addition & 0 deletions image/decoders/nsGIFDecoder2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ nsGIFDecoder2::nsGIFDecoder2(RasterImage* aImage)
, mOldColor(0)
, mCurrentFrameIndex(-1)
, mColorTablePos(0)
, mColorMask('\0')
, mGIFOpen(false)
, mSawTransparency(false)
{
Expand Down
27 changes: 21 additions & 6 deletions image/decoders/nsJPEGDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,28 @@ METHODDEF(void) my_error_exit (j_common_ptr cinfo);

nsJPEGDecoder::nsJPEGDecoder(RasterImage* aImage,
Decoder::DecodeStyle aDecodeStyle)
: Decoder(aImage)
, mLexer(Transition::ToUnbuffered(State::FINISHED_JPEG_DATA,
State::JPEG_DATA,
SIZE_MAX),
Transition::TerminateSuccess())
, mDecodeStyle(aDecodeStyle)
: Decoder(aImage)
, mLexer(Transition::ToUnbuffered(State::FINISHED_JPEG_DATA,
State::JPEG_DATA,
SIZE_MAX),
Transition::TerminateSuccess())
, mProfile(nullptr)
, mProfileLength(0)
, mDecodeStyle(aDecodeStyle)
{
this->mErr.pub.error_exit = nullptr;
this->mErr.pub.emit_message = nullptr;
this->mErr.pub.output_message = nullptr;
this->mErr.pub.format_message = nullptr;
this->mErr.pub.reset_error_mgr = nullptr;
this->mErr.pub.msg_code = 0;
this->mErr.pub.trace_level = 0;
this->mErr.pub.num_warnings = 0;
this->mErr.pub.jpeg_message_table = nullptr;
this->mErr.pub.last_jpeg_message = 0;
this->mErr.pub.addon_message_table = nullptr;
this->mErr.pub.first_addon_message = 0;
this->mErr.pub.last_addon_message = 0;
mState = JPEG_HEADER;
mReading = true;
mImageData = nullptr;
Expand Down
21 changes: 13 additions & 8 deletions image/encoders/bmp/nsBMPEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@ using namespace mozilla::image::bmp;
NS_IMPL_ISUPPORTS(nsBMPEncoder, imgIEncoder, nsIInputStream,
nsIAsyncInputStream)

nsBMPEncoder::nsBMPEncoder() : mImageBufferStart(nullptr),
mImageBufferCurr(0),
mImageBufferSize(0),
mImageBufferReadPoint(0),
mFinished(false),
mCallback(nullptr),
mCallbackTarget(nullptr),
mNotifyThreshold(0)
nsBMPEncoder::nsBMPEncoder()
: mBMPInfoHeader{}
, mImageBufferStart(nullptr)
, mImageBufferCurr(0)
, mImageBufferSize(0)
, mImageBufferReadPoint(0)
, mFinished(false)
, mCallback(nullptr)
, mCallbackTarget(nullptr)
, mNotifyThreshold(0)
{
this->mBMPFileHeader.filesize = 0;
this->mBMPFileHeader.reserved = 0;
this->mBMPFileHeader.dataoffset = 0;
}

nsBMPEncoder::~nsBMPEncoder()
Expand Down
17 changes: 10 additions & 7 deletions image/encoders/ico/nsICOEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ using namespace mozilla::image;
NS_IMPL_ISUPPORTS(nsICOEncoder, imgIEncoder, nsIInputStream,
nsIAsyncInputStream)

nsICOEncoder::nsICOEncoder() : mImageBufferStart(nullptr),
mImageBufferCurr(0),
mImageBufferSize(0),
mImageBufferReadPoint(0),
mFinished(false),
mUsePNG(true),
mNotifyThreshold(0)
nsICOEncoder::nsICOEncoder()
: mICOFileHeader{}
, mICODirEntry{}
, mImageBufferStart(nullptr)
, mImageBufferCurr(0)
, mImageBufferSize(0)
, mImageBufferReadPoint(0)
, mFinished(false)
, mUsePNG(true)
, mNotifyThreshold(0)
{
}

Expand Down
1 change: 1 addition & 0 deletions image/imgFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ imgFrame::imgFrame()
, mTimeout(FrameTimeout::FromRawMilliseconds(100))
, mDisposalMethod(DisposalMethod::NOT_SPECIFIED)
, mBlendMethod(BlendMethod::OVER)
, mFormat(SurfaceFormat::UNKNOWN)
, mPalettedImageData(nullptr)
, mPaletteDepth(0)
, mNonPremult(false)
Expand Down
5 changes: 4 additions & 1 deletion image/imgFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ class imgFrame
struct SurfaceWithFormat {
RefPtr<gfxDrawable> mDrawable;
SurfaceFormat mFormat;
SurfaceWithFormat() { }
SurfaceWithFormat()
: mFormat(SurfaceFormat::UNKNOWN)
{
}
SurfaceWithFormat(gfxDrawable* aDrawable, SurfaceFormat aFormat)
: mDrawable(aDrawable), mFormat(aFormat)
{ }
Expand Down

0 comments on commit 7f8217a

Please sign in to comment.