SkDocument: turn off SK_SUPPORT_LEGACY_DOCUMENT_API
no one seems to be using it. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2299653002 Review-Url: https://codereview.chromium.org/2299653002
This commit is contained in:
parent
02f9ed74ea
commit
e86134fc70
@ -19,8 +19,6 @@
|
||||
class SkCanvas;
|
||||
class SkWStream;
|
||||
|
||||
#define SK_SUPPORT_LEGACY_DOCUMENT_API
|
||||
|
||||
/** SK_ScalarDefaultDPI is 72 DPI.
|
||||
*/
|
||||
#define SK_ScalarDefaultRasterDPI 72.0f
|
||||
@ -157,65 +155,6 @@ public:
|
||||
static sk_sp<SkDocument> MakeXPS(const char path[],
|
||||
SkScalar dpi = SK_ScalarDefaultRasterDPI);
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DOCUMENT_API
|
||||
|
||||
/**
|
||||
* Create a PDF-backed document, writing the results into a SkWStream.
|
||||
*
|
||||
* PDF pages are sized in point units. 1 pt == 1/72 inch == 127/360 mm.
|
||||
*
|
||||
* @param SkWStream* A PDF document will be written to this
|
||||
* stream. The document may write to the stream at
|
||||
* anytime during its lifetime, until either close() is
|
||||
* called or the document is deleted.
|
||||
* @param dpi The DPI (pixels-per-inch) at which features without
|
||||
* native PDF support will be rasterized (e.g. draw image
|
||||
* with perspective, draw text with perspective, ...) A
|
||||
* larger DPI would create a PDF that reflects the
|
||||
* original intent with better fidelity, but it can make
|
||||
* for larger PDF files too, which would use more memory
|
||||
* while rendering, and it would be slower to be processed
|
||||
* or sent online or to printer.
|
||||
* @returns NULL if there is an error, otherwise a newly created
|
||||
* PDF-backed SkDocument.
|
||||
*/
|
||||
static SkDocument* CreatePDF(SkWStream* stream,
|
||||
SkScalar dpi = SK_ScalarDefaultRasterDPI) {
|
||||
return SkDocument::MakePDF(stream, dpi, SkDocument::PDFMetadata(),
|
||||
nullptr, false).release();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jpegEncoder For PDF documents, if a jpegEncoder is set,
|
||||
* use it to encode SkImages and SkBitmaps as [JFIF]JPEGs.
|
||||
* This feature is deprecated and is only supplied for
|
||||
* backwards compatability.
|
||||
*
|
||||
* The prefered method to create PDFs with JPEG images is
|
||||
* to use SkImage::NewFromEncoded() and not jpegEncoder.
|
||||
* Chromium uses NewFromEncoded.
|
||||
*
|
||||
* If the encoder is unset, or if jpegEncoder->onEncode()
|
||||
* returns NULL, fall back on encoding images losslessly
|
||||
* with Deflate.
|
||||
*/
|
||||
static SkDocument* CreatePDF(SkWStream* stream,
|
||||
SkScalar dpi,
|
||||
SkPixelSerializer* jpegEncoder) {
|
||||
return SkDocument::MakePDF(stream, dpi, SkDocument::PDFMetadata(),
|
||||
sk_ref_sp(jpegEncoder), false).release();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a PDF-backed document, writing the results into a file.
|
||||
*/
|
||||
static SkDocument* CreatePDF(const char outputFilePath[],
|
||||
SkScalar dpi = SK_ScalarDefaultRasterDPI) {
|
||||
return SkDocument::MakePDF(outputFilePath, dpi).release();
|
||||
}
|
||||
|
||||
#endif // SK_SUPPORT_LEGACY_DOCUMENT_API
|
||||
|
||||
/**
|
||||
* Begin a new page for the document, returning the canvas that will draw
|
||||
* into the page. The document owns this canvas, and it will go out of
|
||||
@ -246,36 +185,6 @@ public:
|
||||
*/
|
||||
void abort();
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DOCUMENT_API
|
||||
/**
|
||||
* Set the document's metadata, if supported by the document
|
||||
* type. The creationDate and modifiedDate parameters can be
|
||||
* nullptr. For example:
|
||||
*
|
||||
* SkDocument* make_doc(SkWStream* output) {
|
||||
* std::vector<SkDocument::Attribute> info;
|
||||
* info.emplace_back(SkString("Title"), SkString("..."));
|
||||
* info.emplace_back(SkString("Author"), SkString("..."));
|
||||
* info.emplace_back(SkString("Subject"), SkString("..."));
|
||||
* info.emplace_back(SkString("Keywords"), SkString("..."));
|
||||
* info.emplace_back(SkString("Creator"), SkString("..."));
|
||||
* SkTime::DateTime now;
|
||||
* SkTime::GetDateTime(&now);
|
||||
* SkDocument* doc = SkDocument::CreatePDF(output);
|
||||
* doc->setMetadata(&info[0], (int)info.size(), &now, &now);
|
||||
* return doc;
|
||||
* }
|
||||
*/
|
||||
struct Attribute {
|
||||
SkString fKey, fValue;
|
||||
Attribute(const SkString& k, const SkString& v) : fKey(k), fValue(v) {}
|
||||
};
|
||||
virtual void setMetadata(const SkDocument::Attribute[],
|
||||
int /* attributeCount */,
|
||||
const SkTime::DateTime* /* creationDate */,
|
||||
const SkTime::DateTime* /* modifiedDate */) {}
|
||||
#endif // SK_SUPPORT_LEGACY_DOCUMENT_API
|
||||
|
||||
protected:
|
||||
SkDocument(SkWStream*, void (*)(SkWStream*, bool aborted));
|
||||
|
||||
|
@ -256,26 +256,6 @@ void SkPDFDocument::reset() {
|
||||
fFonts.reset();
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DOCUMENT_API
|
||||
void SkPDFDocument::setMetadata(const SkDocument::Attribute info[],
|
||||
int infoCount,
|
||||
const SkTime::DateTime* creationDate,
|
||||
const SkTime::DateTime* modifiedDate) {
|
||||
for (int i = 0; i < infoCount; ++i) {
|
||||
const SkDocument::Attribute& kv = info[i];
|
||||
SkPDFMetadata::SetMetadataByKey(kv.fKey, kv.fValue, &fMetadata);
|
||||
}
|
||||
if (creationDate) {
|
||||
fMetadata.fCreation.fEnabled = true;
|
||||
fMetadata.fCreation.fDateTime = *creationDate;
|
||||
}
|
||||
if (modifiedDate) {
|
||||
fMetadata.fModified.fEnabled = true;
|
||||
fMetadata.fModified.fDateTime = *modifiedDate;
|
||||
}
|
||||
}
|
||||
#endif // SK_SUPPORT_LEGACY_DOCUMENT_API
|
||||
|
||||
static sk_sp<SkData> SkSrgbIcm() {
|
||||
// Source: http://www.argyllcms.com/icclibsrc.html
|
||||
static const char kProfile[] =
|
||||
|
@ -55,12 +55,7 @@ public:
|
||||
void onEndPage() override;
|
||||
bool onClose(SkWStream*) override;
|
||||
void onAbort() override;
|
||||
#ifdef SK_SUPPORT_LEGACY_DOCUMENT_API
|
||||
void setMetadata(const SkDocument::Attribute[],
|
||||
int,
|
||||
const SkTime::DateTime*,
|
||||
const SkTime::DateTime*) override;
|
||||
#endif // SK_SUPPORT_LEGACY_DOCUMENT_API
|
||||
|
||||
/**
|
||||
Serialize the object, as well as any other objects it
|
||||
indirectly refers to. If any any other objects have been added
|
||||
|
@ -43,19 +43,6 @@ static const struct {
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DOCUMENT_API
|
||||
void SkPDFMetadata::SetMetadataByKey(const SkString& key,
|
||||
const SkString& value,
|
||||
SkDocument::PDFMetadata* metadata) {
|
||||
for (const auto keyValuePtr : gMetadataKeys) {
|
||||
if (key.equals(keyValuePtr.key)) {
|
||||
metadata->*(keyValuePtr.valuePtr) = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
sk_sp<SkPDFObject> SkPDFMetadata::MakeDocumentInformationDict(
|
||||
const SkDocument::PDFMetadata& metadata) {
|
||||
auto dict = sk_make_sp<SkPDFDict>();
|
||||
|
@ -26,11 +26,5 @@ sk_sp<SkPDFObject> MakePdfId(const UUID& doc, const UUID& instance);
|
||||
sk_sp<SkPDFObject> MakeXMPObject(const SkDocument::PDFMetadata&,
|
||||
const UUID& doc,
|
||||
const UUID& instance);
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DOCUMENT_API
|
||||
void SetMetadataByKey(const SkString& key,
|
||||
const SkString& value,
|
||||
SkDocument::PDFMetadata*);
|
||||
#endif
|
||||
}
|
||||
#endif // SkPDFMetadata_DEFINED
|
||||
|
Loading…
Reference in New Issue
Block a user