blob: 6a16709bdf0b4a67b9d3eee2c2181be938b68f0f [file] [log] [blame]
vandebo@chromium.orgeb6c7592010-10-26 19:54:45 +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 SkPDFFormXObject_DEFINED
18#define SkPDFFormXObject_DEFINED
19
20#include "SkPDFStream.h"
21#include "SkPDFTypes.h"
22#include "SkRefCnt.h"
23#include "SkString.h"
24
25class SkMatrix;
26class SkPDFDevice;
27class SkPDFCatalog;
28
29/** \class SkPDFFormXObject
30
31 A form XObject; a self containted description of graphics objects. A form
32 XObject is basically a page object with slightly different syntax, that
33 can be drawn onto a page.
34*/
35
36// The caller could keep track of the form XObjects it creates and
37// canonicalize them, but the Skia API doesn't provide enough context to
38// automatically do it (trivially).
39class SkPDFFormXObject : public SkPDFObject {
40public:
41 /** Create a PDF form XObject. Entries for the dictionary entries are
42 * automatically added.
43 * @param device The set of graphical elements on this form.
44 * @param matrix The mapping from user space to form space.
45 */
46 SkPDFFormXObject(SkPDFDevice* device, const SkMatrix& matrix);
47 virtual ~SkPDFFormXObject();
48
49 // The SkPDFObject interface.
50 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog,
51 bool indirect);
52 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect);
53 virtual void getResources(SkTDArray<SkPDFObject*>* resourceList);
54
vandebo@chromium.orgf7c15762011-02-01 22:19:44 +000055 /** Add the value to the stream dictionary with the given key. Refs value.
vandebo@chromium.orgeb6c7592010-10-26 19:54:45 +000056 * @param key The key for this dictionary entry.
57 * @param value The value for this dictionary entry.
vandebo@chromium.orgf7c15762011-02-01 22:19:44 +000058 * @return The value argument is returned.
vandebo@chromium.orgeb6c7592010-10-26 19:54:45 +000059 */
vandebo@chromium.orgf7c15762011-02-01 22:19:44 +000060 SkPDFObject* insert(SkPDFName* key, SkPDFObject* value);
vandebo@chromium.orgeb6c7592010-10-26 19:54:45 +000061
vandebo@chromium.orgf7c15762011-02-01 22:19:44 +000062 /** Add the value to the stream dictionary with the given key. Refs value.
vandebo@chromium.orgeb6c7592010-10-26 19:54:45 +000063 * @param key The text of the key for this dictionary entry.
64 * @param value The value for this dictionary entry.
vandebo@chromium.orgf7c15762011-02-01 22:19:44 +000065 * @return The value argument is returned.
vandebo@chromium.orgeb6c7592010-10-26 19:54:45 +000066 */
vandebo@chromium.orgf7c15762011-02-01 22:19:44 +000067 SkPDFObject* insert(const char key[], SkPDFObject* value);
vandebo@chromium.orgeb6c7592010-10-26 19:54:45 +000068
69private:
70 SkString fContent;
71 SkRefPtr<SkPDFDevice> fDevice;
72 SkRefPtr<SkPDFStream> fStream;
73};
74
75#endif