Chromium Code Reviews| 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 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 SkCanvas* getRecordingCanvas() const; | 144 SkCanvas* getRecordingCanvas() const; |
| 144 /** Signal that the caller is done recording. This invalidates the canvas | 145 /** Signal that the caller is done recording. This invalidates the canvas |
| 145 returned by beginRecording/getRecordingCanvas, and prepares the picture | 146 returned by beginRecording/getRecordingCanvas, and prepares the picture |
| 146 for drawing. Note: this happens implicitly the first time the picture | 147 for drawing. Note: this happens implicitly the first time the picture |
| 147 is drawn. | 148 is drawn. |
| 148 */ | 149 */ |
| 149 void endRecording(); | 150 void endRecording(); |
| 150 | 151 |
| 151 /** Replays the drawing commands on the specified canvas. This internally | 152 /** Replays the drawing commands on the specified canvas. This internally |
| 152 calls endRecording() if that has not already been called. | 153 calls endRecording() if that has not already been called. |
| 153 @param surface the canvas receiving the drawing commands. | 154 @param canvas the canvas receiving the drawing commands. |
|
robertphillips
2013/05/20 17:05:19
document 'callback' parameter?
| |
| 154 */ | 155 */ |
| 155 void draw(SkCanvas* surface); | 156 void draw(SkCanvas* canvas, SkDrawPictureCallback* = NULL); |
| 156 | 157 |
| 157 /** Return the width of the picture's recording canvas. This | 158 /** Return the width of the picture's recording canvas. This |
| 158 value reflects what was passed to setSize(), and does not necessarily | 159 value reflects what was passed to setSize(), and does not necessarily |
| 159 reflect the bounds of what has been recorded into the picture. | 160 reflect the bounds of what has been recorded into the picture. |
| 160 @return the width of the picture's recording canvas | 161 @return the width of the picture's recording canvas |
| 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 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 | 240 |
| 240 /** Return the canvas to draw into for recording into the picture. | 241 /** Return the canvas to draw into for recording into the picture. |
| 241 */ | 242 */ |
| 242 SkCanvas* getRecordingCanvas() const { return fCanvas; } | 243 SkCanvas* getRecordingCanvas() const { return fCanvas; } |
| 243 | 244 |
| 244 private: | 245 private: |
| 245 SkPicture* fPicture; | 246 SkPicture* fPicture; |
| 246 SkCanvas* fCanvas; | 247 SkCanvas* fCanvas; |
| 247 }; | 248 }; |
| 248 | 249 |
| 250 /** | |
| 251 * Subclasses of this can be passed to canvas.drawPicture. During the drawing | |
| 252 * of the picture, this callback will periodically be invoked. If its | |
| 253 * abortDrawing() returns true, then picture playback will be interrupted. | |
| 254 * | |
| 255 * The resulting drawing is undefined, as there is no guarantee how often the | |
| 256 * callback will be invoked. If the abort happens inside some level of nested | |
| 257 * calls to save(), restore will automatically be called to return the state | |
| 258 * to the same level it was before the drawPicture call was made. | |
| 259 */ | |
| 260 class SkDrawPictureCallback { | |
| 261 public: | |
| 262 SkDrawPictureCallback() {} | |
| 263 virtual ~SkDrawPictureCallback() {} | |
| 264 | |
| 265 virtual bool abortDrawing() = 0; | |
| 266 }; | |
| 249 | 267 |
| 250 #endif | 268 #endif |
| OLD | NEW |