Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: src/pdf/SkPDFImage.h

Issue 25054002: Use SkPicture::ExtractBitmap callback in pdf too. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix return on another funtion with signature change Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/pdf/SkPDFDevice.h ('k') | src/pdf/SkPDFImage.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 The Android Open Source Project 3 * Copyright 2010 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkPDFImage_DEFINED 10 #ifndef SkPDFImage_DEFINED
11 #define SkPDFImage_DEFINED 11 #define SkPDFImage_DEFINED
12 12
13 #include "SkPicture.h"
13 #include "SkPDFDevice.h" 14 #include "SkPDFDevice.h"
14 #include "SkPDFStream.h" 15 #include "SkPDFStream.h"
15 #include "SkPDFTypes.h" 16 #include "SkPDFTypes.h"
16 #include "SkRefCnt.h" 17 #include "SkRefCnt.h"
17 18
18 class SkBitmap; 19 class SkBitmap;
19 class SkPDFCatalog; 20 class SkPDFCatalog;
20 struct SkIRect; 21 struct SkIRect;
21 22
22 /** \class SkPDFImage 23 /** \class SkPDFImage
23 24
24 An image XObject. 25 An image XObject.
25 */ 26 */
26 27
27 // We could play the same trick here as is done in SkPDFGraphicState, storing 28 // We could play the same trick here as is done in SkPDFGraphicState, storing
28 // a copy of the Bitmap object (not the pixels), the pixel generation number, 29 // a copy of the Bitmap object (not the pixels), the pixel generation number,
29 // and settings used from the paint to canonicalize image objects. 30 // and settings used from the paint to canonicalize image objects.
30 class SkPDFImage : public SkPDFStream { 31 class SkPDFImage : public SkPDFStream {
31 public: 32 public:
32 /** Create a new Image XObject to represent the passed bitmap. 33 /** Create a new Image XObject to represent the passed bitmap.
33 * @param bitmap The image to encode. 34 * @param bitmap The image to encode.
34 * @param srcRect The rectangle to cut out of bitmap. 35 * @param srcRect The rectangle to cut out of bitmap.
35 * @param paint Used to calculate alpha, masks, etc. 36 * @param paint Used to calculate alpha, masks, etc.
36 * @return The image XObject or NUll if there is nothing to draw for 37 * @return The image XObject or NUll if there is nothing to draw for
37 * the given parameters. 38 * the given parameters.
38 */ 39 */
39 static SkPDFImage* CreateImage(const SkBitmap& bitmap, 40 static SkPDFImage* CreateImage(const SkBitmap& bitmap,
40 const SkIRect& srcRect, 41 const SkIRect& srcRect,
41 EncodeToDCTStream encoder); 42 SkPicture::EncodeBitmap encoder);
42 43
43 virtual ~SkPDFImage(); 44 virtual ~SkPDFImage();
44 45
45 /** Add a Soft Mask (alpha or shape channel) to the image. Refs mask. 46 /** Add a Soft Mask (alpha or shape channel) to the image. Refs mask.
46 * @param mask A gray scale image representing the mask. 47 * @param mask A gray scale image representing the mask.
47 * @return The mask argument is returned. 48 * @return The mask argument is returned.
48 */ 49 */
49 SkPDFImage* addSMask(SkPDFImage* mask); 50 SkPDFImage* addSMask(SkPDFImage* mask);
50 51
51 bool isEmpty() { 52 bool isEmpty() {
52 return fSrcRect.isEmpty(); 53 return fSrcRect.isEmpty();
53 } 54 }
54 55
55 // The SkPDFObject interface. 56 // The SkPDFObject interface.
56 virtual void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, 57 virtual void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects,
57 SkTSet<SkPDFObject*>* newResourceObjects); 58 SkTSet<SkPDFObject*>* newResourceObjects);
58 59
59 private: 60 private:
60 SkBitmap fBitmap; 61 SkBitmap fBitmap;
61 bool fIsAlpha; 62 bool fIsAlpha;
62 SkIRect fSrcRect; 63 SkIRect fSrcRect;
63 EncodeToDCTStream fEncoder; 64 SkPicture::EncodeBitmap fEncoder;
64 bool fStreamValid; 65 bool fStreamValid;
65 66
66 SkTDArray<SkPDFObject*> fResources; 67 SkTDArray<SkPDFObject*> fResources;
67 68
68 /** Create a PDF image XObject. Entries for the image properties are 69 /** Create a PDF image XObject. Entries for the image properties are
69 * automatically added to the stream dictionary. 70 * automatically added to the stream dictionary.
70 * @param stream The image stream. May be NULL. Otherwise, this 71 * @param stream The image stream. May be NULL. Otherwise, this
71 * (instead of the input bitmap) will be used as the 72 * (instead of the input bitmap) will be used as the
72 * PDF's content stream, possibly with lossless encoding. 73 * PDF's content stream, possibly with lossless encoding.
73 * @param bitmap The image. If a stream is not given, its color data 74 * @param bitmap The image. If a stream is not given, its color data
74 * will be used as the image. If a stream is given, this 75 * will be used as the image. If a stream is given, this
75 * is used for configuration only. 76 * is used for configuration only.
76 * @param isAlpha Whether or not this is the alpha of an image. 77 * @param isAlpha Whether or not this is the alpha of an image.
77 * @param srcRect The clipping applied to bitmap before generating 78 * @param srcRect The clipping applied to bitmap before generating
78 * imageData. 79 * imageData.
79 * @param encoder A function used to encode the bitmap for compression. 80 * @param encoder A function used to encode the bitmap for compression.
80 * May be NULL. 81 * May be NULL.
81 */ 82 */
82 SkPDFImage(SkStream* stream, const SkBitmap& bitmap, bool isAlpha, 83 SkPDFImage(SkStream* stream, const SkBitmap& bitmap, bool isAlpha,
83 const SkIRect& srcRect, EncodeToDCTStream encoder); 84 const SkIRect& srcRect, SkPicture::EncodeBitmap encoder);
84 85
85 /** Copy constructor, used to generate substitutes. 86 /** Copy constructor, used to generate substitutes.
86 * @param image The SkPDFImage to copy. 87 * @param image The SkPDFImage to copy.
87 */ 88 */
88 SkPDFImage(SkPDFImage& pdfImage); 89 SkPDFImage(SkPDFImage& pdfImage);
89 90
90 // Populate the stream dictionary. This method returns false if 91 // Populate the stream dictionary. This method returns false if
91 // fSubstitute should be used. 92 // fSubstitute should be used.
92 virtual bool populate(SkPDFCatalog* catalog); 93 virtual bool populate(SkPDFCatalog* catalog);
93 94
94 typedef SkPDFStream INHERITED; 95 typedef SkPDFStream INHERITED;
95 }; 96 };
96 97
97 #endif 98 #endif
OLDNEW
« no previous file with comments | « include/pdf/SkPDFDevice.h ('k') | src/pdf/SkPDFImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698