| vandebo@chromium.org | 8459d4e | 2010-09-24 22:25:30 +0000 | [diff] [blame] | 1 | /* |
| 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.org | a09ef97 | 2010-12-01 22:17:20 +0000 | [diff] [blame^] | 22 | #include "SkStream.h" |
| vandebo@chromium.org | 8459d4e | 2010-09-24 22:25:30 +0000 | [diff] [blame] | 23 | #include "SkTemplates.h" |
| 24 | |
| vandebo@chromium.org | 8459d4e | 2010-09-24 22:25:30 +0000 | [diff] [blame] | 25 | class SkPDFCatalog; |
| 26 | |
| 27 | /** \class SkPDFStream |
| 28 | |
| 29 | A stream object in a PDF. |
| 30 | */ |
| 31 | // TODO(vandebo) This should handle filters as well. |
| 32 | class SkPDFStream : public SkPDFObject { |
| 33 | public: |
| 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.org | d877fdb | 2010-10-12 23:08:13 +0000 | [diff] [blame] | 47 | * @param key The key for this dictionary entry. |
| 48 | * @param value The value for this dictionary entry. |
| vandebo@chromium.org | 8459d4e | 2010-09-24 22:25:30 +0000 | [diff] [blame] | 49 | */ |
| 50 | void insert(SkPDFName* key, SkPDFObject* value); |
| 51 | |
| vandebo@chromium.org | d877fdb | 2010-10-12 23:08:13 +0000 | [diff] [blame] | 52 | /** 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.org | 8459d4e | 2010-09-24 22:25:30 +0000 | [diff] [blame] | 58 | private: |
| 59 | SkPDFDict fDict; |
| vandebo@chromium.org | a09ef97 | 2010-12-01 22:17:20 +0000 | [diff] [blame^] | 60 | size_t fLength; |
| 61 | // Only one of the two streams will be valid. |
| 62 | SkRefPtr<SkStream> fPlainData; |
| 63 | SkDynamicMemoryWStream fCompressedData; |
| vandebo@chromium.org | 8459d4e | 2010-09-24 22:25:30 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | #endif |