blob: 10a40b6f987ff4640c40729c93f2d2a3e2a02641 [file] [log] [blame]
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +00001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
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
29 A stream object in a PDF.
30*/
31// TODO(vandebo) This should handle filters as well.
32class SkPDFStream : public SkPDFObject {
33public:
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
46 /** Add the value to the stream dictionary with the given key.
vandebo@chromium.orgd877fdb2010-10-12 23:08:13 +000047 * @param key The key for this dictionary entry.
48 * @param value The value for this dictionary entry.
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +000049 */
50 void insert(SkPDFName* key, SkPDFObject* value);
51
vandebo@chromium.orgd877fdb2010-10-12 23:08:13 +000052 /** Add the value to the stream dictionary with the given key.
53 * @param key The text of the key for this dictionary entry.
54 * @param value The value for this dictionary entry.
55 */
56 void insert(const char key[], SkPDFObject* value);
57
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +000058private:
59 SkPDFDict fDict;
vandebo@chromium.orga09ef972010-12-01 22:17:20 +000060 size_t fLength;
61 // Only one of the two streams will be valid.
62 SkRefPtr<SkStream> fPlainData;
63 SkDynamicMemoryWStream fCompressedData;
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +000064};
65
66#endif