Bug 1255106 - Part 1. Move color transform state to image decoder base class. r=tnikkel

Differential Revision: https://phabricator.services.mozilla.com/D26369
This commit is contained in:
Andrew Osmond 2019-04-04 11:44:12 -04:00
parent ae73865393
commit a445258270
8 changed files with 19 additions and 40 deletions

View File

@ -44,7 +44,9 @@ class MOZ_STACK_CLASS AutoRecordDecoderTelemetry final {
};
Decoder::Decoder(RasterImage* aImage)
: mImageData(nullptr),
: mInProfile(nullptr),
mTransform(nullptr),
mImageData(nullptr),
mImageDataLength(0),
mImage(aImage),
mFrameRecycler(nullptr),
@ -72,6 +74,14 @@ Decoder::~Decoder() {
"Destroying Decoder without taking all its invalidations");
mInitialized = false;
if (mInProfile) {
// mTransform belongs to us only if mInProfile is non-null
if (mTransform) {
qcms_transform_release(mTransform);
}
qcms_profile_release(mInProfile);
}
if (mImage && !NS_IsMainThread()) {
// Dispatch mImage to main thread to prevent it from being destructed by the
// decode thread.

View File

@ -19,6 +19,7 @@
#include "SourceBuffer.h"
#include "StreamingLexer.h"
#include "SurfaceFlags.h"
#include "qcms.h"
namespace mozilla {
@ -559,6 +560,12 @@ class Decoder {
protected:
Maybe<Downscaler> mDownscaler;
/// Color management profile from the ICCP chunk in the image.
qcms_profile* mInProfile;
/// Color management transform to apply to image data.
qcms_transform* mTransform;
uint8_t* mImageData; // Pointer to image data in BGRA/X
uint32_t mImageDataLength;

View File

@ -124,12 +124,6 @@ nsJPEGDecoder::~nsJPEGDecoder() {
free(mBackBuffer);
mBackBuffer = nullptr;
if (mTransform) {
qcms_transform_release(mTransform);
}
if (mInProfile) {
qcms_profile_release(mInProfile);
}
MOZ_LOG(sJPEGDecoderAccountingLog, LogLevel::Debug,
("nsJPEGDecoder::~nsJPEGDecoder: Destroying JPEG decoder %p", this));

View File

@ -17,7 +17,6 @@
#include "nsIInputStream.h"
#include "nsIPipe.h"
#include "qcms.h"
extern "C" {
#include "jpeglib.h"
@ -100,9 +99,6 @@ class nsJPEGDecoder : public Decoder {
JOCTET* mProfile;
uint32_t mProfileLength;
qcms_profile* mInProfile;
qcms_transform* mTransform;
bool mReading;
const Decoder::DecodeStyle mDecodeStyle;

View File

@ -109,8 +109,6 @@ nsPNGDecoder::nsPNGDecoder(RasterImage* aImage)
mInfo(nullptr),
mCMSLine(nullptr),
interlacebuf(nullptr),
mInProfile(nullptr),
mTransform(nullptr),
mFormat(SurfaceFormat::UNKNOWN),
mCMSMode(0),
mChannels(0),
@ -130,14 +128,6 @@ nsPNGDecoder::~nsPNGDecoder() {
if (interlacebuf) {
free(interlacebuf);
}
if (mInProfile) {
qcms_profile_release(mInProfile);
// mTransform belongs to us only if mInProfile is non-null
if (mTransform) {
qcms_transform_release(mTransform);
}
}
}
nsPNGDecoder::TransparencyType nsPNGDecoder::GetTransparencyType(

View File

@ -9,7 +9,6 @@
#include "Decoder.h"
#include "png.h"
#include "qcms.h"
#include "StreamingLexer.h"
#include "SurfacePipe.h"
@ -92,8 +91,6 @@ class nsPNGDecoder : public Decoder {
nsIntRect mFrameRect;
uint8_t* mCMSLine;
uint8_t* interlacebuf;
qcms_profile* mInProfile;
qcms_transform* mTransform;
gfx::SurfaceFormat mFormat;
// whether CMS or premultiplied alpha are forced off

View File

@ -30,9 +30,7 @@ nsWebPDecoder::nsWebPDecoder(RasterImage* aImage)
mLength(0),
mIteratorComplete(false),
mNeedDemuxer(true),
mGotColorProfile(false),
mInProfile(nullptr),
mTransform(nullptr) {
mGotColorProfile(false) {
MOZ_LOG(sWebPLog, LogLevel::Debug,
("[this=%p] nsWebPDecoder::nsWebPDecoder", this));
}
@ -44,13 +42,6 @@ nsWebPDecoder::~nsWebPDecoder() {
WebPIDelete(mDecoder);
WebPFreeDecBuffer(&mBuffer);
}
if (mInProfile) {
// mTransform belongs to us only if mInProfile is non-null
if (mTransform) {
qcms_transform_release(mTransform);
}
qcms_profile_release(mInProfile);
}
}
LexerResult nsWebPDecoder::ReadData() {

View File

@ -97,12 +97,6 @@ class nsWebPDecoder final : public Decoder {
/// True if we have setup the color profile for the image.
bool mGotColorProfile;
/// Color management profile from the ICCP chunk in the image.
qcms_profile* mInProfile;
/// Color management transform to apply to image data.
qcms_transform* mTransform;
};
} // namespace image