| vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +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 SkPDFImage_DEFINED |
| 18 | #define SkPDFImage_DEFINED |
| 19 | |
| 20 | #include "SkPDFStream.h" |
| 21 | #include "SkPDFTypes.h" |
| 22 | #include "SkRefCnt.h" |
| 23 | |
| 24 | class SkBitmap; |
| vandebo@chromium.org | befebb8 | 2011-01-29 01:38:50 +0000 | [diff] [blame] | 25 | class SkIRect; |
| vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 26 | class SkPaint; |
| 27 | class SkPDFCatalog; |
| 28 | |
| 29 | /** \class SkPDFImage |
| 30 | |
| 31 | An image XObject. |
| 32 | */ |
| 33 | |
| 34 | // We could play the same trick here as is done in SkPDFGraphicState, storing |
| 35 | // a copy of the Bitmap object (not the pixels), the pixel generation number, |
| 36 | // and settings used from the paint to canonicalize image objects. |
| 37 | class SkPDFImage : public SkPDFObject { |
| 38 | public: |
| 39 | /** Create a PDF image XObject. Entries for the image properties are |
| 40 | * automatically added to the stream dictionary. |
| 41 | * @param bitmap The image to use. |
| 42 | * @param paint Used to calculate alpha, masks, etc. |
| 43 | */ |
| vandebo@chromium.org | befebb8 | 2011-01-29 01:38:50 +0000 | [diff] [blame] | 44 | SkPDFImage(const SkBitmap& bitmap, const SkIRect& srcRect, |
| 45 | const SkPaint& paint); |
| vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 46 | virtual ~SkPDFImage(); |
| 47 | |
| 48 | // The SkPDFObject interface. |
| 49 | virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog, |
| 50 | bool indirect); |
| 51 | virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); |
| 52 | |
| 53 | /** Add the value to the stream dictionary with the given key. |
| 54 | * @param key The key for this dictionary entry. |
| 55 | * @param value The value for this dictionary entry. |
| 56 | */ |
| 57 | void insert(SkPDFName* key, SkPDFObject* value); |
| 58 | |
| 59 | /** Add the value to the stream dictionary with the given key. |
| 60 | * @param key The text of the key for this dictionary entry. |
| 61 | * @param value The value for this dictionary entry. |
| 62 | */ |
| 63 | void insert(const char key[], SkPDFObject* value); |
| 64 | |
| 65 | private: |
| 66 | SkRefPtr<SkPDFStream> fStream; |
| 67 | }; |
| 68 | |
| 69 | #endif |