SkPDFStream.h revision 37c46cad21632cfc1411b08d73af37a1fffe2944
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 28459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org/* 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2010 Google Inc. 48459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org * 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 78459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org */ 88459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org 9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 108459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org#ifndef SkPDFStream_DEFINED 118459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org#define SkPDFStream_DEFINED 128459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org 138459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org#include "SkPDFTypes.h" 148459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org#include "SkRefCnt.h" 15a09ef977b6799f01cd3fd64725fb3069da8be4bcvandebo@chromium.org#include "SkStream.h" 168459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org#include "SkTemplates.h" 178459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org 1837c46cad21632cfc1411b08d73af37a1fffe2944halcanaryclass SkPDFObjNumMap; 198459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org 208459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org/** \class SkPDFStream 218459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org 22da912d61ede86dd3dfa8f645c6f3977f2183812bvandebo@chromium.org A stream object in a PDF. Note, all streams must be indirect objects (via 23da912d61ede86dd3dfa8f645c6f3977f2183812bvandebo@chromium.org SkObjRef). 248459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org*/ 25d90c141feb10c80581c16dbb57fcc97719a0c002vandebo@chromium.orgclass SkPDFStream : public SkPDFDict { 26ab1c13864df34aecfd4840ea7d1e4f8730b44f4ecommit-bot@chromium.org SK_DECLARE_INST_COUNT(SkPDFStream) 278459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.orgpublic: 288459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org /** Create a PDF stream. A Length entry is automatically added to the 29e322482f4d82bc704e40b8c89843f2ea5b6ddc04halcanary * stream dictionary. 30e322482f4d82bc704e40b8c89843f2ea5b6ddc04halcanary * @param data The data part of the stream. Will be ref()ed. 318459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org */ 32421d6443fbd3a913dfa32b6492c4a2969bc6314bvandebo@chromium.org explicit SkPDFStream(SkData* data); 33e322482f4d82bc704e40b8c89843f2ea5b6ddc04halcanary 34e322482f4d82bc704e40b8c89843f2ea5b6ddc04halcanary /** Create a PDF stream. A Length entry is automatically added to the 35e322482f4d82bc704e40b8c89843f2ea5b6ddc04halcanary * stream dictionary. 36e322482f4d82bc704e40b8c89843f2ea5b6ddc04halcanary * @param stream The data part of the stream. Will be duplicate()d. 37e322482f4d82bc704e40b8c89843f2ea5b6ddc04halcanary */ 388459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org explicit SkPDFStream(SkStream* stream); 391f8ed022226c9f960b9fc95af9297d5111a07eadhalcanary 408459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org virtual ~SkPDFStream(); 418459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org 42c1b71d6c30041f01675dd54a77adc9c177afdf44halcanary // The SkPDFObject interface. 4337c46cad21632cfc1411b08d73af37a1fffe2944halcanary virtual void emitObject(SkWStream* stream, 4437c46cad21632cfc1411b08d73af37a1fffe2944halcanary const SkPDFObjNumMap& objNumMap, 4537c46cad21632cfc1411b08d73af37a1fffe2944halcanary const SkPDFSubstituteMap& substitutes) override; 468459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org 47421d6443fbd3a913dfa32b6492c4a2969bc6314bvandebo@chromium.orgprotected: 48d9dfa18372119c8e1318125d2075fa80e0819094edisonn@google.com enum State { 49d9dfa18372119c8e1318125d2075fa80e0819094edisonn@google.com kUnused_State, //!< The stream hasn't been requested yet. 50d9dfa18372119c8e1318125d2075fa80e0819094edisonn@google.com kNoCompression_State, //!< The stream's been requested in an 51d9dfa18372119c8e1318125d2075fa80e0819094edisonn@google.com // uncompressed form. 52d9dfa18372119c8e1318125d2075fa80e0819094edisonn@google.com kCompressed_State, //!< The stream's already been compressed. 53d9dfa18372119c8e1318125d2075fa80e0819094edisonn@google.com }; 54d9dfa18372119c8e1318125d2075fa80e0819094edisonn@google.com 55421d6443fbd3a913dfa32b6492c4a2969bc6314bvandebo@chromium.org /* Create a PDF stream with no data. The setData method must be called to 56421d6443fbd3a913dfa32b6492c4a2969bc6314bvandebo@chromium.org * set the data. 57421d6443fbd3a913dfa32b6492c4a2969bc6314bvandebo@chromium.org */ 58421d6443fbd3a913dfa32b6492c4a2969bc6314bvandebo@chromium.org SkPDFStream(); 59421d6443fbd3a913dfa32b6492c4a2969bc6314bvandebo@chromium.org 60d8d976e7d2d302d4efb53f143034f153adc5565ccommit-bot@chromium.org void setData(SkData* data); 61421d6443fbd3a913dfa32b6492c4a2969bc6314bvandebo@chromium.org void setData(SkStream* stream); 62421d6443fbd3a913dfa32b6492c4a2969bc6314bvandebo@chromium.org 6367ec1f8eecfb48bc0a6ba04c0057f103c1c9696fhalcanary size_t dataSize() const; 6467ec1f8eecfb48bc0a6ba04c0057f103c1c9696fhalcanary 65d9dfa18372119c8e1318125d2075fa80e0819094edisonn@google.com void setState(State state) { 66d9dfa18372119c8e1318125d2075fa80e0819094edisonn@google.com fState = state; 67d9dfa18372119c8e1318125d2075fa80e0819094edisonn@google.com } 68d9dfa18372119c8e1318125d2075fa80e0819094edisonn@google.com 698459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.orgprivate: 70421d6443fbd3a913dfa32b6492c4a2969bc6314bvandebo@chromium.org // Indicates what form (or if) the stream has been requested. 71421d6443fbd3a913dfa32b6492c4a2969bc6314bvandebo@chromium.org State fState; 7283f0d302e8eaa054d0b20303131f953181dd4f47skia.committer@gmail.com 73a1193e4b0e34a7e4e1bd33e9708d7341679f8321scroggo SkAutoTDelete<SkStreamRewindable> fDataStream; 74d90c141feb10c80581c16dbb57fcc97719a0c002vandebo@chromium.org 75d90c141feb10c80581c16dbb57fcc97719a0c002vandebo@chromium.org typedef SkPDFDict INHERITED; 768459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org}; 778459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org 788459d4e5e32608ec6da3f2b81731aaeb7b038843vandebo@chromium.org#endif 79