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

Side by Side Diff: include/core/SkPicture.h

Issue 15489004: New API for encoding bitmaps during serialization. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Remove dead code, keep original data in rerecord. Created 7 years, 7 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 | « no previous file | src/core/SkBitmap.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 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 SkData;
18 class SkPicturePlayback; 19 class SkPicturePlayback;
19 class SkPictureRecord; 20 class SkPictureRecord;
20 class SkStream; 21 class SkStream;
21 class SkWStream; 22 class SkWStream;
22 23
23 /** \class SkPicture 24 /** \class SkPicture
24 25
25 The SkPicture class records the drawing commands made to a canvas, to 26 The SkPicture class records the drawing commands made to a canvas, to
26 be played back at a later time. 27 be played back at a later time.
27 */ 28 */
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 */ 162 */
162 int width() const { return fWidth; } 163 int width() const { return fWidth; }
163 164
164 /** Return the height of the picture's recording canvas. This 165 /** Return the height of the picture's recording canvas. This
165 value reflects what was passed to setSize(), and does not necessarily 166 value reflects what was passed to setSize(), and does not necessarily
166 reflect the bounds of what has been recorded into the picture. 167 reflect the bounds of what has been recorded into the picture.
167 @return the height of the picture's recording canvas 168 @return the height of the picture's recording canvas
168 */ 169 */
169 int height() const { return fHeight; } 170 int height() const { return fHeight; }
170 171
172 enum RecordPixelRefOffset {
173 kYes_RecordPixelRefOffset,
174 kNo_RecordPixelRefOffset,
175 };
176
171 /** 177 /**
172 * Function to encode an SkBitmap to an SkWStream. A function with this 178 * Function to encode an SkBitmap to an SkData. A function with this
173 * signature can be passed to serialize() and SkOrderedWriteBuffer. The 179 * signature can be passed to serialize() and SkOrderedWriteBuffer.
174 * function should return true if it succeeds. Otherwise it should return 180 * Returning NULL will tell the SkOrderedWriteBuffer to use
175 * false so that SkOrderedWriteBuffer can switch to another method of 181 * SkBitmap::flatten() to store the bitmap.
176 * storing SkBitmaps. 182 * @param RecordPixelRefOffset Output parameter, telling the
183 * SkOrderedWriteBuffer whether to record the bitmap's pixelRefOffset.
184 * If set to kYes_RecordPixelRefOffset, the returned SkData contains
185 * compressed data containing the entire image, so the pixelRefOffset
186 * should also be recorded to the stream. If set to
187 * kNo_RecordPixelRefOffset, only the extracted subset is written to
188 * the returned SkData, so the offset should not be written to the
189 * stream.
190 * @return SkData If non-NULL, holds encoded data representing the passed
191 * in bitmap. The caller is responsible for calling unref().
177 */ 192 */
178 typedef bool (*EncodeBitmap)(SkWStream*, const SkBitmap&); 193 typedef SkData* (*EncodeBitmap)(RecordPixelRefOffset*, const SkBitmap&);
scroggo 2013/05/20 19:50:52 Mike, you mentioned perhaps wanting to use the sam
179 194
180 /** 195 /**
181 * Serialize to a stream. If non NULL, encoder will be used to encode 196 * Serialize to a stream. If non NULL, encoder will be used to encode
182 * any bitmaps in the picture. 197 * any bitmaps in the picture.
183 */ 198 */
184 void serialize(SkWStream*, EncodeBitmap encoder = NULL) const; 199 void serialize(SkWStream*, EncodeBitmap encoder = NULL) const;
185 200
186 #ifdef SK_BUILD_FOR_ANDROID 201 #ifdef SK_BUILD_FOR_ANDROID
187 /** Signals that the caller is prematurely done replaying the drawing 202 /** Signals that the caller is prematurely done replaying the drawing
188 commands. This can be called from a canvas virtual while the picture 203 commands. This can be called from a canvas virtual while the picture
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 */ 256 */
242 SkCanvas* getRecordingCanvas() const { return fCanvas; } 257 SkCanvas* getRecordingCanvas() const { return fCanvas; }
243 258
244 private: 259 private:
245 SkPicture* fPicture; 260 SkPicture* fPicture;
246 SkCanvas* fCanvas; 261 SkCanvas* fCanvas;
247 }; 262 };
248 263
249 264
250 #endif 265 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698