SkPDFStream.h revision da912d61ede86dd3dfa8f645c6f3977f2183812b
1ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardj/*
2ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardj * Copyright (C) 2010 Google Inc.
3ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardj *
4887a11a609f3e61d2ae8fe4e67f176207715da7esewardj * Licensed under the Apache License, Version 2.0 (the "License");
5ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardj * you may not use this file except in compliance with the License.
6ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardj * You may obtain a copy of the License at
7ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardj *
8ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardj *      http://www.apache.org/licenses/LICENSE-2.0
9887a11a609f3e61d2ae8fe4e67f176207715da7esewardj *
10887a11a609f3e61d2ae8fe4e67f176207715da7esewardj * Unless required by applicable law or agreed to in writing, software
11ac9af021b93dfe6f35c01d9c6fd15a3d67685843sewardj * distributed under the License is distributed on an "AS IS" BASIS,
12887a11a609f3e61d2ae8fe4e67f176207715da7esewardj * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardj * See the License for the specific language governing permissions and
14ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardj * limitations under the License.
15ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardj */
16ac6b7121413a24ce2f63727d50ac4f3a1b9027e6sewardj
17ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardj#ifndef SkPDFStream_DEFINED
18ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardj#define SkPDFStream_DEFINED
19c97096c44637ae5775ed305b19f16f0b505f17d8sewardj
20e3d0d2ea7b2161ae4f627882be33902ce5f3f8besewardj#include "SkPDFTypes.h"
21e3d0d2ea7b2161ae4f627882be33902ce5f3f8besewardj#include "SkRefCnt.h"
226efd4a18cf32c322e03351176873cef33f1fe67esewardj#include "SkStream.h"
236efd4a18cf32c322e03351176873cef33f1fe67esewardj#include "SkTemplates.h"
24d1725d18b61bf7912a9099686179faef5815dba1sewardj
25d1725d18b61bf7912a9099686179faef5815dba1sewardjclass SkPDFCatalog;
26d1725d18b61bf7912a9099686179faef5815dba1sewardj
27e3d0d2ea7b2161ae4f627882be33902ce5f3f8besewardj/** \class SkPDFStream
28e3d0d2ea7b2161ae4f627882be33902ce5f3f8besewardj
2935421a3cfd43bc829d27ee15bd34bbc7cb690805sewardj    A stream object in a PDF.  Note, all streams must be indirect objects (via
30c97096c44637ae5775ed305b19f16f0b505f17d8sewardj    SkObjRef).
31e3d0d2ea7b2161ae4f627882be33902ce5f3f8besewardj*/
32c97096c44637ae5775ed305b19f16f0b505f17d8sewardjclass SkPDFStream : public SkPDFDict {
33ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardjpublic:
34ac6b7121413a24ce2f63727d50ac4f3a1b9027e6sewardj    /** Create a PDF stream. A Length entry is automatically added to the
35e8e9d73817f92d295f45b1c6c823c613bc2e90aesewardj     *  stream dictionary.
36e8e9d73817f92d295f45b1c6c823c613bc2e90aesewardj     *  @param stream The data part of the stream.
37ac6b7121413a24ce2f63727d50ac4f3a1b9027e6sewardj     */
38ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardj    explicit SkPDFStream(SkStream* stream);
39ac6b7121413a24ce2f63727d50ac4f3a1b9027e6sewardj    virtual ~SkPDFStream();
40e3d0d2ea7b2161ae4f627882be33902ce5f3f8besewardj
41ac6b7121413a24ce2f63727d50ac4f3a1b9027e6sewardj    // The SkPDFObject interface.
42ac6b7121413a24ce2f63727d50ac4f3a1b9027e6sewardj    virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog,
43c97096c44637ae5775ed305b19f16f0b505f17d8sewardj                            bool indirect);
44c97096c44637ae5775ed305b19f16f0b505f17d8sewardj    virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect);
45c97096c44637ae5775ed305b19f16f0b505f17d8sewardj
46c97096c44637ae5775ed305b19f16f0b505f17d8sewardjprivate:
47ac6b7121413a24ce2f63727d50ac4f3a1b9027e6sewardj    size_t fLength;
48ac6b7121413a24ce2f63727d50ac4f3a1b9027e6sewardj    // Only one of the two streams will be valid.
49ac6b7121413a24ce2f63727d50ac4f3a1b9027e6sewardj    SkRefPtr<SkStream> fPlainData;
50ec6ad593611ccd69f797e3add4d23a5f31aa84d6sewardj    SkDynamicMemoryWStream fCompressedData;
51c97096c44637ae5775ed305b19f16f0b505f17d8sewardj
52c97096c44637ae5775ed305b19f16f0b505f17d8sewardj    typedef SkPDFDict INHERITED;
53c97096c44637ae5775ed305b19f16f0b505f17d8sewardj};
54c97096c44637ae5775ed305b19f16f0b505f17d8sewardj
55c97096c44637ae5775ed305b19f16f0b505f17d8sewardj#endif
5635421a3cfd43bc829d27ee15bd34bbc7cb690805sewardj