const SkTDArray<uint32_t>& subset,
SkPDFStream** fontStream) {
int ttcIndex;
- std::unique_ptr<SkStream> fontData(typeface->openStream(&ttcIndex));
+ std::unique_ptr<SkStreamAsset> fontData(typeface->openStream(&ttcIndex));
SkASSERT(fontData);
if (!fontData) {
return 0;
/**
* Creates a FormXObject from a content stream and associated resources.
*/
-SkPDFFormXObject::SkPDFFormXObject(SkStream* content, SkRect bbox,
+SkPDFFormXObject::SkPDFFormXObject(SkStreamAsset* content, SkRect bbox,
SkPDFDict* resourceDict) {
setData(content);
* Create a PDF form XObject from a raw content stream and associated
* resources.
*/
- explicit SkPDFFormXObject(SkStream* content,
+ explicit SkPDFFormXObject(SkStreamAsset* content,
SkRect bbox,
SkPDFDict* resourceDict);
virtual ~SkPDFFormXObject();
* @param gsIndex A graphics state resource index to apply, or <0 if no
* graphics state to apply.
*/
-static SkStream* create_pattern_fill_content(int gsIndex, SkRect& bounds) {
+static SkStreamAsset* create_pattern_fill_content(int gsIndex, SkRect& bounds) {
SkDynamicMemoryWStream content;
if (gsIndex >= 0) {
SkPDFUtils::ApplyGraphicState(gsIndex, &content);
sk_sp<SkPDFObject> luminosityShader(
get_pdf_shader_by_state(doc, dpi, &alphaToLuminosityState));
- std::unique_ptr<SkStream> alphaStream(create_pattern_fill_content(-1, bbox));
+ std::unique_ptr<SkStreamAsset> alphaStream(create_pattern_fill_content(-1, bbox));
auto resources =
get_gradient_resource_dict(luminosityShader.get(), nullptr);
auto resourceDict =
get_gradient_resource_dict(colorShader.get(), alphaGs.get());
- std::unique_ptr<SkStream> colorStream(
+ std::unique_ptr<SkStreamAsset> colorStream(
create_pattern_fill_content(0, bbox));
alphaFunctionShader->setData(colorStream.get());
SkASSERT(fCompressedData);
this->INHERITED::emitObject(stream, objNumMap, substitutes);
// duplicate (a cheap operation) preserves const on fCompressedData.
- std::unique_ptr<SkStreamRewindable> dup(fCompressedData->duplicate());
+ std::unique_ptr<SkStreamAsset> dup(fCompressedData->duplicate());
SkASSERT(dup);
SkASSERT(dup->hasLength());
stream->writeText(" stream\n");
}
-void SkPDFStream::setData(SkStream* stream) {
+void SkPDFStream::setData(SkStreamAsset* stream) {
SkASSERT(!fCompressedData); // Only call this function once.
SkASSERT(stream);
// Code assumes that the stream starts at the beginning.
#ifdef SK_PDF_LESS_COMPRESSION
- std::unique_ptr<SkStreamRewindable> duplicate(stream->duplicate());
+ std::unique_ptr<SkStreamAsset> duplicate(stream->duplicate());
+ SkASSERT(duplicate && duplicate->hasLength());
if (duplicate && duplicate->hasLength()) {
this->insertInt("Length", duplicate->getLength());
fCompressedData.reset(duplicate.release());
deflateWStream.finalize();
size_t length = compressedData.bytesWritten();
+ SkASSERT(stream->hasLength());
if (stream->hasLength()) {
- std::unique_ptr<SkStreamRewindable> dup(stream->duplicate());
+ std::unique_ptr<SkStreamAsset> dup(stream->duplicate());
+ SkASSERT(stream->hasLength());
+ SkASSERT(stream->getLength() == dup->getLength());
+ SkASSERT(dup && dup->hasLength());
if (dup && dup->hasLength() &&
dup->getLength() <= length + strlen("/Filter_/FlateDecode_")) {
this->insertInt("Length", dup->getLength());
* stream dictionary.
* @param stream The data part of the stream. Will not take ownership.
*/
- explicit SkPDFStream(SkStream* stream) { this->setData(stream); }
+ explicit SkPDFStream(SkStreamAsset* stream) { this->setData(stream); }
virtual ~SkPDFStream();
SkPDFStream() {}
/** Only call this function once. */
- void setData(SkStream* stream);
+ void setData(SkStreamAsset* stream);
void setData(SkData* data) {
SkMemoryStream memoryStream(data);
this->setData(&memoryStream);
}
private:
- std::unique_ptr<SkStreamRewindable> fCompressedData;
+ std::unique_ptr<SkStreamAsset> fCompressedData;
typedef SkPDFDict INHERITED;
};