OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 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 SkPicture_DEFINED | 10 #ifndef SkPicture_DEFINED |
11 #define SkPicture_DEFINED | 11 #define SkPicture_DEFINED |
12 | 12 |
13 #include "SkBitmap.h" | 13 #include "SkBitmap.h" |
14 #include "SkRefCnt.h" | 14 #include "SkRefCnt.h" |
15 | 15 |
16 class SkBBoxHierarchy; | 16 class SkBBoxHierarchy; |
17 class SkCanvas; | 17 class SkCanvas; |
18 class SkDrawPictureCallback; | 18 class SkDrawPictureCallback; |
19 class SkData; | |
19 class SkPicturePlayback; | 20 class SkPicturePlayback; |
20 class SkPictureRecord; | 21 class SkPictureRecord; |
21 class SkStream; | 22 class SkStream; |
22 class SkWStream; | 23 class SkWStream; |
23 | 24 |
24 /** \class SkPicture | 25 /** \class SkPicture |
25 | 26 |
26 The SkPicture class records the drawing commands made to a canvas, to | 27 The SkPicture class records the drawing commands made to a canvas, to |
27 be played back at a later time. | 28 be played back at a later time. |
28 */ | 29 */ |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 int width() const { return fWidth; } | 164 int width() const { return fWidth; } |
164 | 165 |
165 /** Return the height of the picture's recording canvas. This | 166 /** Return the height of the picture's recording canvas. This |
166 value reflects what was passed to setSize(), and does not necessarily | 167 value reflects what was passed to setSize(), and does not necessarily |
167 reflect the bounds of what has been recorded into the picture. | 168 reflect the bounds of what has been recorded into the picture. |
168 @return the height of the picture's recording canvas | 169 @return the height of the picture's recording canvas |
169 */ | 170 */ |
170 int height() const { return fHeight; } | 171 int height() const { return fHeight; } |
171 | 172 |
172 /** | 173 /** |
173 * Function to encode an SkBitmap to an SkWStream. A function with this | 174 * Function to encode an SkBitmap to an SkData. A function with this |
174 * signature can be passed to serialize() and SkOrderedWriteBuffer. The | 175 * signature can be passed to serialize() and SkOrderedWriteBuffer. |
175 * function should return true if it succeeds. Otherwise it should return | 176 * Returning NULL will tell the SkOrderedWriteBuffer to use |
176 * false so that SkOrderedWriteBuffer can switch to another method of | 177 * SkBitmap::flatten() to store the bitmap. |
177 * storing SkBitmaps. | 178 * @param pixelRefOffset Output parameter, telling the deserializer what |
179 * offset in the bm's pixelRef corresponds to the encoded data. | |
180 * @return SkData If non-NULL, holds encoded data representing the passed | |
181 * in bitmap. The caller is responsible for calling unref(). | |
178 */ | 182 */ |
179 typedef bool (*EncodeBitmap)(SkWStream*, const SkBitmap&); | 183 typedef SkData* (*EncodeBitmap)(size_t* pixelRefOffset, const SkBitmap& bm); |
reed1
2013/05/21 18:30:47
mike nit: I like the output-param to be last, but
| |
180 | 184 |
181 /** | 185 /** |
182 * Serialize to a stream. If non NULL, encoder will be used to encode | 186 * Serialize to a stream. If non NULL, encoder will be used to encode |
183 * any bitmaps in the picture. | 187 * any bitmaps in the picture. |
188 * encoder will never be called with a NULL pixelRefOffset. | |
184 */ | 189 */ |
185 void serialize(SkWStream*, EncodeBitmap encoder = NULL) const; | 190 void serialize(SkWStream*, EncodeBitmap encoder = NULL) const; |
186 | 191 |
187 #ifdef SK_BUILD_FOR_ANDROID | 192 #ifdef SK_BUILD_FOR_ANDROID |
188 /** Signals that the caller is prematurely done replaying the drawing | 193 /** Signals that the caller is prematurely done replaying the drawing |
189 commands. This can be called from a canvas virtual while the picture | 194 commands. This can be called from a canvas virtual while the picture |
190 is drawing. Has no effect if the picture is not drawing. | 195 is drawing. Has no effect if the picture is not drawing. |
191 @deprecated preserving for legacy purposes | 196 @deprecated preserving for legacy purposes |
192 */ | 197 */ |
193 void abortPlayback(); | 198 void abortPlayback(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 */ | 264 */ |
260 class SkDrawPictureCallback { | 265 class SkDrawPictureCallback { |
261 public: | 266 public: |
262 SkDrawPictureCallback() {} | 267 SkDrawPictureCallback() {} |
263 virtual ~SkDrawPictureCallback() {} | 268 virtual ~SkDrawPictureCallback() {} |
264 | 269 |
265 virtual bool abortDrawing() = 0; | 270 virtual bool abortDrawing() = 0; |
266 }; | 271 }; |
267 | 272 |
268 #endif | 273 #endif |
OLD | NEW |