• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 Google Inc.
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"
22 #include "SkStream.h"
23 #include "SkTemplates.h"
24 
25 class SkPDFCatalog;
26 
27 /** \class SkPDFStream
28 
29     A stream object in a PDF.  Note, all streams must be indirect objects (via
30     SkObjRef).
31 */
32 class SkPDFStream : public SkPDFDict {
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 private:
47     size_t fLength;
48     // Only one of the two streams will be valid.
49     SkRefPtr<SkStream> fPlainData;
50     SkDynamicMemoryWStream fCompressedData;
51 
52     typedef SkPDFDict INHERITED;
53 };
54 
55 #endif
56