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

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

Issue 333823007: Enable basic drawing with SkRecord-based pictures. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ref accel data Created 6 years, 6 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
« no previous file with comments | « debugger/QT/SkDebuggerGUI.cpp ('k') | src/core/SkPicture.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
(...skipping 12 matching lines...) Expand all
23 class SkCanvas; 23 class SkCanvas;
24 class SkDrawPictureCallback; 24 class SkDrawPictureCallback;
25 class SkData; 25 class SkData;
26 class SkPicturePlayback; 26 class SkPicturePlayback;
27 class SkPictureRecord; 27 class SkPictureRecord;
28 class SkStream; 28 class SkStream;
29 class SkWStream; 29 class SkWStream;
30 30
31 struct SkPictInfo; 31 struct SkPictInfo;
32 32
33 class SkRecord;
34
33 /** \class SkPicture 35 /** \class SkPicture
34 36
35 The SkPicture class records the drawing commands made to a canvas, to 37 The SkPicture class records the drawing commands made to a canvas, to
36 be played back at a later time. 38 be played back at a later time.
37 */ 39 */
38 class SK_API SkPicture : public SkRefCnt { 40 class SK_API SkPicture : public SkRefCnt {
39 public: 41 public:
40 SK_DECLARE_INST_COUNT(SkPicture) 42 SK_DECLARE_INST_COUNT(SkPicture)
41 43
42 // AccelData provides a base class for device-specific acceleration 44 // AccelData provides a base class for device-specific acceleration
(...skipping 17 matching lines...) Expand all
60 typedef SkRefCnt INHERITED; 62 typedef SkRefCnt INHERITED;
61 }; 63 };
62 64
63 SkPicture(); 65 SkPicture();
64 /** Make a copy of the contents of src. If src records more drawing after 66 /** Make a copy of the contents of src. If src records more drawing after
65 this call, those elements will not appear in this picture. 67 this call, those elements will not appear in this picture.
66 */ 68 */
67 SkPicture(const SkPicture& src); 69 SkPicture(const SkPicture& src);
68 70
69 /** PRIVATE / EXPERIMENTAL -- do not call */ 71 /** PRIVATE / EXPERIMENTAL -- do not call */
70 void EXPERIMENTAL_addAccelData(const AccelData* data) const { 72 void EXPERIMENTAL_addAccelData(const AccelData*) const;
71 SkRefCnt_SafeAssign(fAccelData, data); 73
72 }
73 /** PRIVATE / EXPERIMENTAL -- do not call */ 74 /** PRIVATE / EXPERIMENTAL -- do not call */
74 const AccelData* EXPERIMENTAL_getAccelData(AccelData::Key key) const { 75 const AccelData* EXPERIMENTAL_getAccelData(AccelData::Key) const;
75 if (NULL != fAccelData && fAccelData->getKey() == key) {
76 return fAccelData;
77 }
78 return NULL;
79 }
80 76
81 /** 77 /**
82 * Function signature defining a function that sets up an SkBitmap from enc oded data. On 78 * Function signature defining a function that sets up an SkBitmap from enc oded data. On
83 * success, the SkBitmap should have its Config, width, height, rowBytes an d pixelref set. 79 * success, the SkBitmap should have its Config, width, height, rowBytes an d pixelref set.
84 * If the installed pixelref has decoded the data into pixels, then the src buffer need not be 80 * If the installed pixelref has decoded the data into pixels, then the src buffer need not be
85 * copied. If the pixelref defers the actual decode until its lockPixels() is called, then it 81 * copied. If the pixelref defers the actual decode until its lockPixels() is called, then it
86 * must make a copy of the src buffer. 82 * must make a copy of the src buffer.
87 * @param src Encoded data. 83 * @param src Encoded data.
88 * @param length Size of the encoded data, in bytes. 84 * @param length Size of the encoded data, in bytes.
89 * @param dst SkBitmap to install the pixel ref on. 85 * @param dst SkBitmap to install the pixel ref on.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 244
249 // Note: If the picture version needs to be increased then please follow the 245 // Note: If the picture version needs to be increased then please follow the
250 // steps to generate new SKPs in (only accessible to Googlers): http://goo.g l/qATVcw 246 // steps to generate new SKPs in (only accessible to Googlers): http://goo.g l/qATVcw
251 247
252 // Only SKPs within the min/current picture version range (inclusive) can be read. 248 // Only SKPs within the min/current picture version range (inclusive) can be read.
253 static const uint32_t MIN_PICTURE_VERSION = 19; 249 static const uint32_t MIN_PICTURE_VERSION = 19;
254 static const uint32_t CURRENT_PICTURE_VERSION = 28; 250 static const uint32_t CURRENT_PICTURE_VERSION = 28;
255 251
256 mutable uint32_t fUniqueID; 252 mutable uint32_t fUniqueID;
257 253
258 // fPlayback, fRecord, fWidth & fHeight are protected to allow derived class es to 254 // fPlayback, fWidth & fHeight are protected to allow derived classes to
259 // install their own SkPicturePlayback-derived players,SkPictureRecord-deriv ed 255 // install their own SkPicturePlayback-derived players,SkPictureRecord-deriv ed
260 // recorders and set the picture size 256 // recorders and set the picture size
261 SkPicturePlayback* fPlayback; 257 SkAutoTDelete<SkPicturePlayback> fPlayback;
262 int fWidth, fHeight; 258 int fWidth, fHeight;
263 mutable const AccelData* fAccelData; 259 mutable SkAutoTUnref<const AccelData> fAccelData;
264 260
265 void needsNewGenID() { fUniqueID = SK_InvalidGenID; } 261 void needsNewGenID() { fUniqueID = SK_InvalidGenID; }
266 262
267 // Create a new SkPicture from an existing SkPicturePlayback. Ref count of 263 // Create a new SkPicture from an existing SkPicturePlayback. Ref count of
268 // playback is unchanged. 264 // playback is unchanged.
269 SkPicture(SkPicturePlayback*, int width, int height); 265 SkPicture(SkPicturePlayback*, int width, int height);
270 266
271 SkPicture(int width, int height, const SkPictureRecord& record, bool deepCop yOps); 267 SkPicture(int width, int height, const SkPictureRecord& record, bool deepCop yOps);
272 268
273 private: 269 private:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 307
312 friend class SkFlatPicture; 308 friend class SkFlatPicture;
313 friend class SkPicturePlayback; 309 friend class SkPicturePlayback;
314 friend class SkPictureRecorder; // just for SkPicture-based constructor 310 friend class SkPictureRecorder; // just for SkPicture-based constructor
315 friend class SkGpuDevice; 311 friend class SkGpuDevice;
316 friend class GrGatherCanvas; 312 friend class GrGatherCanvas;
317 friend class GrGatherDevice; 313 friend class GrGatherDevice;
318 friend class SkDebugCanvas; 314 friend class SkDebugCanvas;
319 315
320 typedef SkRefCnt INHERITED; 316 typedef SkRefCnt INHERITED;
317
318 SkPicture(int width, int height, SkRecord*); // Takes ownership.
319 SkAutoTDelete<SkRecord> fRecord;
321 }; 320 };
322 321
323 /** 322 /**
324 * Subclasses of this can be passed to canvas.drawPicture. During the drawing 323 * Subclasses of this can be passed to canvas.drawPicture. During the drawing
325 * of the picture, this callback will periodically be invoked. If its 324 * of the picture, this callback will periodically be invoked. If its
326 * abortDrawing() returns true, then picture playback will be interrupted. 325 * abortDrawing() returns true, then picture playback will be interrupted.
327 * 326 *
328 * The resulting drawing is undefined, as there is no guarantee how often the 327 * The resulting drawing is undefined, as there is no guarantee how often the
329 * callback will be invoked. If the abort happens inside some level of nested 328 * callback will be invoked. If the abort happens inside some level of nested
330 * calls to save(), restore will automatically be called to return the state 329 * calls to save(), restore will automatically be called to return the state
331 * to the same level it was before the drawPicture call was made. 330 * to the same level it was before the drawPicture call was made.
332 */ 331 */
333 class SK_API SkDrawPictureCallback { 332 class SK_API SkDrawPictureCallback {
334 public: 333 public:
335 SkDrawPictureCallback() {} 334 SkDrawPictureCallback() {}
336 virtual ~SkDrawPictureCallback() {} 335 virtual ~SkDrawPictureCallback() {}
337 336
338 virtual bool abortDrawing() = 0; 337 virtual bool abortDrawing() = 0;
339 }; 338 };
340 339
341 #endif 340 #endif
OLDNEW
« no previous file with comments | « debugger/QT/SkDebuggerGUI.cpp ('k') | src/core/SkPicture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698