gfx/skia/trunk/src/pdf/SkPDFStream.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/pdf/SkPDFStream.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,100 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2010 Google Inc.
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +#ifndef SkPDFStream_DEFINED
    1.14 +#define SkPDFStream_DEFINED
    1.15 +
    1.16 +#include "SkPDFTypes.h"
    1.17 +#include "SkRefCnt.h"
    1.18 +#include "SkStream.h"
    1.19 +#include "SkTemplates.h"
    1.20 +
    1.21 +class SkPDFCatalog;
    1.22 +
    1.23 +/** \class SkPDFStream
    1.24 +
    1.25 +    A stream object in a PDF.  Note, all streams must be indirect objects (via
    1.26 +    SkObjRef).
    1.27 +    TODO(vandebo): SkStream should be replaced by SkStreamRewindable when that
    1.28 +    is feasible.
    1.29 +*/
    1.30 +class SkPDFStream : public SkPDFDict {
    1.31 +    SK_DECLARE_INST_COUNT(SkPDFStream)
    1.32 +public:
    1.33 +    /** Create a PDF stream. A Length entry is automatically added to the
    1.34 +     *  stream dictionary. The stream may be retained (stream->ref() may be
    1.35 +     *  called) so its contents must not be changed after calling this.
    1.36 +     *  @param data  The data part of the stream.
    1.37 +     */
    1.38 +    explicit SkPDFStream(SkData* data);
    1.39 +    /** Deprecated constructor. */
    1.40 +    explicit SkPDFStream(SkStream* stream);
    1.41 +    /** Create a PDF stream with the same content and dictionary entries
    1.42 +     *  as the passed one.
    1.43 +     */
    1.44 +    explicit SkPDFStream(const SkPDFStream& pdfStream);
    1.45 +    virtual ~SkPDFStream();
    1.46 +
    1.47 +    // The SkPDFObject interface.
    1.48 +    virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog,
    1.49 +                            bool indirect);
    1.50 +    virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect);
    1.51 +
    1.52 +protected:
    1.53 +    enum State {
    1.54 +        kUnused_State,         //!< The stream hasn't been requested yet.
    1.55 +        kNoCompression_State,  //!< The stream's been requested in an
    1.56 +                               //   uncompressed form.
    1.57 +        kCompressed_State,     //!< The stream's already been compressed.
    1.58 +    };
    1.59 +
    1.60 +    /* Create a PDF stream with no data.  The setData method must be called to
    1.61 +     * set the data.
    1.62 +     */
    1.63 +    SkPDFStream();
    1.64 +
    1.65 +    // Populate the stream dictionary.  This method returns false if
    1.66 +    // fSubstitute should be used.
    1.67 +    virtual bool populate(SkPDFCatalog* catalog);
    1.68 +
    1.69 +    void setSubstitute(SkPDFStream* stream) {
    1.70 +        fSubstitute.reset(stream);
    1.71 +    }
    1.72 +
    1.73 +    SkPDFStream* getSubstitute() {
    1.74 +        return fSubstitute.get();
    1.75 +    }
    1.76 +
    1.77 +    void setData(SkData* data);
    1.78 +    void setData(SkStream* stream);
    1.79 +
    1.80 +    SkStream* getData() {
    1.81 +        return fData.get();
    1.82 +    }
    1.83 +
    1.84 +    void setState(State state) {
    1.85 +        fState = state;
    1.86 +    }
    1.87 +
    1.88 +    State getState() {
    1.89 +        return fState;
    1.90 +    }
    1.91 +
    1.92 +private:
    1.93 +    // Indicates what form (or if) the stream has been requested.
    1.94 +    State fState;
    1.95 +
    1.96 +    // TODO(vandebo): Use SkData (after removing deprecated constructor).
    1.97 +    SkAutoTUnref<SkStream> fData;
    1.98 +    SkAutoTUnref<SkPDFStream> fSubstitute;
    1.99 +
   1.100 +    typedef SkPDFDict INHERITED;
   1.101 +};
   1.102 +
   1.103 +#endif

mercurial