blob: a975ad6efc97836b4f23652cd1983de9e9d07265 [file] [log] [blame]
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +00001/*
vandebo@chromium.orgd90c1412011-02-24 21:50:04 +00002 * Copyright (C) 2010 Google Inc.
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +00003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SkPDFStream_DEFINED
18#define SkPDFStream_DEFINED
19
20#include "SkPDFTypes.h"
21#include "SkRefCnt.h"
vandebo@chromium.orga09ef972010-12-01 22:17:20 +000022#include "SkStream.h"
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +000023#include "SkTemplates.h"
24
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +000025class SkPDFCatalog;
26
27/** \class SkPDFStream
28
vandebo@chromium.orgda912d62011-03-08 18:31:02 +000029 A stream object in a PDF. Note, all streams must be indirect objects (via
30 SkObjRef).
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +000031*/
vandebo@chromium.orgd90c1412011-02-24 21:50:04 +000032class SkPDFStream : public SkPDFDict {
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +000033public:
34 /** Create a PDF stream. A Length entry is automatically added to the
35 * stream dictionary.
36 * @param stream The data part of the stream.
37 */
38 explicit SkPDFStream(SkStream* stream);
39 virtual ~SkPDFStream();
40
41 // The SkPDFObject interface.
42 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog,
43 bool indirect);
44 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect);
45
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +000046private:
vandebo@chromium.orga09ef972010-12-01 22:17:20 +000047 size_t fLength;
48 // Only one of the two streams will be valid.
49 SkRefPtr<SkStream> fPlainData;
50 SkDynamicMemoryWStream fCompressedData;
vandebo@chromium.orgd90c1412011-02-24 21:50:04 +000051
52 typedef SkPDFDict INHERITED;
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +000053};
54
55#endif