SkPDF s/SkAutoTDelete/std::unique_ptr/

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1837553002

Review URL: https://codereview.chromium.org/1837553002
This commit is contained in:
halcanary 2016-03-28 07:58:30 -07:00 committed by Commit bot
parent e50f3e7539
commit b8fb9934a0
12 changed files with 32 additions and 32 deletions

View File

@ -49,7 +49,7 @@ public:
private:
struct Impl;
SkAutoTDelete<Impl> fImpl;
std::unique_ptr<Impl> fImpl;
};
#endif // SkFlate_DEFINED

View File

@ -346,7 +346,7 @@ static void emit_image_xobject(SkWStream* stream,
bitmap_to_pdf_pixels(bitmap, &deflateWStream);
}
deflateWStream.finalize(); // call before detachAsStream().
SkAutoTDelete<SkStreamAsset> asset(buffer.detachAsStream());
std::unique_ptr<SkStreamAsset> asset(buffer.detachAsStream());
SkPDFDict pdfDict("XObject");
pdfDict.insertName("Subtype", "Image");

View File

@ -232,13 +232,13 @@ private:
SkTDArray<SkPDFFont*> fFontResources;
SkTDArray<SkPDFObject*> fShaderResources;
SkAutoTDelete<ContentEntry> fContentEntries;
std::unique_ptr<ContentEntry> fContentEntries;
ContentEntry* fLastContentEntry;
const SkClipStack* fClipStack;
// Glyph ids used for each font on this device.
SkAutoTDelete<SkPDFGlyphSetMap> fFontGlyphUsage;
std::unique_ptr<SkPDFGlyphSetMap> fFontGlyphUsage;
SkScalar fRasterDpi;

View File

@ -362,7 +362,7 @@ SkDocument* SkDocument::CreatePDF(SkWStream* stream,
SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) {
auto delete_wstream = [](SkWStream* stream, bool) { delete stream; };
SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(path));
std::unique_ptr<SkFILEWStream> stream(new SkFILEWStream(path));
return stream->isValid()
? SkPDFMakeDocument(stream.release(), delete_wstream, dpi, nullptr).release()
: nullptr;

View File

@ -162,7 +162,7 @@ static SkData* handle_type1_stream(SkStream* srcStream, size_t* headerLen,
// if the data was NUL terminated so that we can use strstr() to search it.
// Make as few copies as possible given these constraints.
SkDynamicMemoryWStream dynamicStream;
SkAutoTDelete<SkMemoryStream> staticStream;
std::unique_ptr<SkMemoryStream> staticStream;
SkData* data = nullptr;
const uint8_t* src;
size_t srcLen;
@ -589,7 +589,7 @@ static size_t get_subset_font_stream(const char* fontName,
const SkTDArray<uint32_t>& subset,
SkPDFStream** fontStream) {
int ttcIndex;
SkAutoTDelete<SkStream> fontData(typeface->openStream(&ttcIndex));
std::unique_ptr<SkStream> fontData(typeface->openStream(&ttcIndex));
SkASSERT(fontData.get());
size_t fontSize = fontData->getLength();
@ -1056,7 +1056,7 @@ bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth,
}
#endif
sk_sp<SkPDFSharedStream> fontStream;
SkAutoTDelete<SkStreamAsset> fontData(
std::unique_ptr<SkStreamAsset> fontData(
this->typeface()->openStream(nullptr));
SkASSERT(fontData);
fontSize = fontData->getLength();
@ -1198,7 +1198,7 @@ bool SkPDFType1Font::addFontDescriptor(int16_t defaultWidth) {
size_t header SK_INIT_TO_AVOID_WARNING;
size_t data SK_INIT_TO_AVOID_WARNING;
size_t trailer SK_INIT_TO_AVOID_WARNING;
SkAutoTDelete<SkStream> rawFontData(typeface()->openStream(&ttcIndex));
std::unique_ptr<SkStream> rawFontData(typeface()->openStream(&ttcIndex));
sk_sp<SkData> fontData(handle_type1_stream(rawFontData.get(), &header,
&data, &trailer));
if (fontData.get() == nullptr) {
@ -1357,7 +1357,7 @@ bool SkPDFType3Font::populate(uint16_t glyphID) {
SkPDFUtils::PaintPath(paint.getStyle(), path->getFillType(),
&content);
}
SkAutoTDelete<SkMemoryStream> glyphStream(new SkMemoryStream());
std::unique_ptr<SkMemoryStream> glyphStream(new SkMemoryStream());
glyphStream->setData(content.copyToData())->unref();
charProcs->insertObjRef(

View File

@ -15,8 +15,8 @@ class SkPDFObject;
struct SkPDFMetadata {
SkTArray<SkDocument::Attribute> fInfo;
SkAutoTDelete<const SkTime::DateTime> fCreation;
SkAutoTDelete<const SkTime::DateTime> fModified;
std::unique_ptr<const SkTime::DateTime> fCreation;
std::unique_ptr<const SkTime::DateTime> fModified;
SkPDFObject* createDocumentInformationDict() const;

View File

@ -488,7 +488,7 @@ SkPDFImageShader::~SkPDFImageShader() {}
static SkPDFObject* get_pdf_shader_by_state(
SkPDFDocument* doc,
SkScalar dpi,
SkAutoTDelete<SkPDFShader::State>* autoState) {
std::unique_ptr<SkPDFShader::State>* autoState) {
const SkPDFShader::State& state = **autoState;
SkPDFCanon* canon = doc->canon();
if (state.fType == SkShader::kNone_GradientType && state.fImage.isNull()) {
@ -519,7 +519,7 @@ SkPDFObject* SkPDFShader::GetPDFShader(SkPDFDocument* doc,
const SkMatrix& matrix,
const SkIRect& surfaceBBox,
SkScalar rasterScale) {
SkAutoTDelete<SkPDFShader::State> state(new State(shader, matrix, surfaceBBox, rasterScale));
std::unique_ptr<SkPDFShader::State> state(new State(shader, matrix, surfaceBBox, rasterScale));
return get_pdf_shader_by_state(doc, dpi, &state);
}
@ -585,12 +585,12 @@ static sk_sp<SkPDFObject> create_smask_graphic_state(
SkRect bbox;
bbox.set(state.fBBox);
SkAutoTDelete<SkPDFShader::State> alphaToLuminosityState(
std::unique_ptr<SkPDFShader::State> alphaToLuminosityState(
state.CreateAlphaToLuminosityState());
sk_sp<SkPDFObject> luminosityShader(
get_pdf_shader_by_state(doc, dpi, &alphaToLuminosityState));
SkAutoTDelete<SkStream> alphaStream(create_pattern_fill_content(-1, bbox));
std::unique_ptr<SkStream> alphaStream(create_pattern_fill_content(-1, bbox));
auto resources =
get_gradient_resource_dict(luminosityShader.get(), nullptr);
@ -606,12 +606,12 @@ static sk_sp<SkPDFObject> create_smask_graphic_state(
SkPDFAlphaFunctionShader* SkPDFAlphaFunctionShader::Create(
SkPDFDocument* doc,
SkScalar dpi,
SkAutoTDelete<SkPDFShader::State>* autoState) {
std::unique_ptr<SkPDFShader::State>* autoState) {
const SkPDFShader::State& state = **autoState;
SkRect bbox;
bbox.set(state.fBBox);
SkAutoTDelete<SkPDFShader::State> opaqueState(state.CreateOpaqueState());
std::unique_ptr<SkPDFShader::State> opaqueState(state.CreateOpaqueState());
sk_sp<SkPDFObject> colorShader(
get_pdf_shader_by_state(doc, dpi, &opaqueState));
@ -629,7 +629,7 @@ SkPDFAlphaFunctionShader* SkPDFAlphaFunctionShader::Create(
auto resourceDict =
get_gradient_resource_dict(colorShader.get(), alphaGs.get());
SkAutoTDelete<SkStream> colorStream(
std::unique_ptr<SkStream> colorStream(
create_pattern_fill_content(0, bbox));
alphaFunctionShader->setData(colorStream.get());
@ -701,7 +701,7 @@ static sk_sp<SkPDFStream> make_ps_function(
}
SkPDFFunctionShader* SkPDFFunctionShader::Create(
SkPDFCanon* canon, SkAutoTDelete<SkPDFShader::State>* autoState) {
SkPDFCanon* canon, std::unique_ptr<SkPDFShader::State>* autoState) {
const SkPDFShader::State& state = **autoState;
void (*codeFunction)(const SkShader::GradientInfo& info,
@ -826,7 +826,7 @@ SkPDFFunctionShader* SkPDFFunctionShader::Create(
SkPDFImageShader* SkPDFImageShader::Create(
SkPDFDocument* doc,
SkScalar dpi,
SkAutoTDelete<SkPDFShader::State>* autoState) {
std::unique_ptr<SkPDFShader::State>* autoState) {
const SkPDFShader::State& state = **autoState;
state.fImage.lockPixels();

View File

@ -56,12 +56,12 @@ public:
class SkPDFFunctionShader final : public SkPDFDict {
public:
static SkPDFFunctionShader* Create(SkPDFCanon*,
SkAutoTDelete<SkPDFShader::State>*);
std::unique_ptr<SkPDFShader::State>*);
virtual ~SkPDFFunctionShader();
bool equals(const SkPDFShader::State&) const;
private:
SkAutoTDelete<const SkPDFShader::State> fShaderState;
std::unique_ptr<const SkPDFShader::State> fShaderState;
SkPDFFunctionShader(SkPDFShader::State*);
typedef SkPDFDict INHERITED;
};
@ -75,12 +75,12 @@ class SkPDFAlphaFunctionShader final : public SkPDFStream {
public:
static SkPDFAlphaFunctionShader* Create(SkPDFDocument*,
SkScalar dpi,
SkAutoTDelete<SkPDFShader::State>*);
std::unique_ptr<SkPDFShader::State>*);
virtual ~SkPDFAlphaFunctionShader();
bool equals(const SkPDFShader::State&) const;
private:
SkAutoTDelete<const SkPDFShader::State> fShaderState;
std::unique_ptr<const SkPDFShader::State> fShaderState;
SkPDFAlphaFunctionShader(SkPDFShader::State*);
typedef SkPDFStream INHERITED;
};
@ -89,12 +89,12 @@ class SkPDFImageShader final : public SkPDFStream {
public:
static SkPDFImageShader* Create(SkPDFDocument*,
SkScalar dpi,
SkAutoTDelete<SkPDFShader::State>*);
std::unique_ptr<SkPDFShader::State>*);
virtual ~SkPDFImageShader();
bool equals(const SkPDFShader::State&) const;
private:
SkAutoTDelete<const SkPDFShader::State> fShaderState;
std::unique_ptr<const SkPDFShader::State> fShaderState;
SkPDFImageShader(SkPDFShader::State*);
typedef SkPDFStream INHERITED;
};

View File

@ -26,7 +26,7 @@ void SkPDFStream::emitObject(SkWStream* stream,
SkASSERT(fCompressedData);
this->INHERITED::emitObject(stream, objNumMap, substitutes);
// duplicate (a cheap operation) preserves const on fCompressedData.
SkAutoTDelete<SkStreamRewindable> dup(fCompressedData->duplicate());
std::unique_ptr<SkStreamRewindable> dup(fCompressedData->duplicate());
SkASSERT(dup);
SkASSERT(dup->hasLength());
stream->writeText(" stream\n");
@ -46,7 +46,7 @@ void SkPDFStream::setData(SkStream* stream) {
size_t length = compressedData.bytesWritten();
if (stream->hasLength()) {
SkAutoTDelete<SkStreamRewindable> dup(stream->duplicate());
std::unique_ptr<SkStreamRewindable> dup(stream->duplicate());
if (dup && dup->hasLength() &&
dup->getLength() <= length + strlen("/Filter_/FlateDecode_")) {
this->insertInt("Length", dup->getLength());

View File

@ -59,7 +59,7 @@ protected:
}
private:
SkAutoTDelete<SkStreamRewindable> fCompressedData;
std::unique_ptr<SkStreamRewindable> fCompressedData;
typedef SkPDFDict INHERITED;
};

View File

@ -473,7 +473,7 @@ void SkPDFSharedStream::emitObject(
SkDynamicMemoryWStream buffer;
SkDeflateWStream deflateWStream(&buffer);
// Since emitObject is const, this function doesn't change the dictionary.
SkAutoTDelete<SkStreamAsset> dup(fAsset->duplicate()); // Cheap copy
std::unique_ptr<SkStreamAsset> dup(fAsset->duplicate()); // Cheap copy
SkASSERT(dup);
SkStreamCopy(&deflateWStream, dup.get());
deflateWStream.finalize();

View File

@ -315,7 +315,7 @@ public:
void drop() override;
private:
SkAutoTDelete<SkStreamAsset> fAsset;
std::unique_ptr<SkStreamAsset> fAsset;
sk_sp<SkPDFDict> fDict;
SkDEBUGCODE(bool fDumped;)
typedef SkPDFObject INHERITED;