OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkDeferredCanvas_DEFINED | 8 #ifndef SkDeferredCanvas_DEFINED |
9 #define SkDeferredCanvas_DEFINED | 9 #define SkDeferredCanvas_DEFINED |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 * of the previous frame. For example, if a canvas is cleared before | 82 * of the previous frame. For example, if a canvas is cleared before |
83 * drawing each frame, the frames will all be considered fresh. | 83 * drawing each frame, the frames will all be considered fresh. |
84 * A frame is defined as the graphics image produced by as a result | 84 * A frame is defined as the graphics image produced by as a result |
85 * of all the canvas draws operation executed between two successive | 85 * of all the canvas draws operation executed between two successive |
86 * calls to isFreshFrame. The result of isFreshFrame is computed | 86 * calls to isFreshFrame. The result of isFreshFrame is computed |
87 * conservatively, so it may report false negatives. | 87 * conservatively, so it may report false negatives. |
88 */ | 88 */ |
89 bool isFreshFrame() const; | 89 bool isFreshFrame() const; |
90 | 90 |
91 /** | 91 /** |
| 92 * Returns canvas's size. |
| 93 */ |
| 94 SkISize getCanvasSize(); |
| 95 |
| 96 /** |
92 * Returns true if the canvas has recorded draw commands that have | 97 * Returns true if the canvas has recorded draw commands that have |
93 * not yet been played back. | 98 * not yet been played back. |
94 */ | 99 */ |
95 bool hasPendingCommands() const; | 100 bool hasPendingCommands() const; |
96 | 101 |
97 /** | 102 /** |
98 * Flushes pending draw commands, if any, and returns an image of the | 103 * Flushes pending draw commands, if any, and returns an image of the |
99 * current state of the surface pixels up to this point. Subsequent | 104 * current state of the surface pixels up to this point. Subsequent |
100 * changes to the surface (by drawing into its canvas) will not be | 105 * changes to the surface (by drawing into its canvas) will not be |
101 * reflected in this image. Will return NULL if the deferred canvas | 106 * reflected in this image. Will return NULL if the deferred canvas |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 protected: | 241 protected: |
237 virtual SkCanvas* canvasForDrawIter(); | 242 virtual SkCanvas* canvasForDrawIter(); |
238 SkDeferredDevice* getDeferredDevice() const; | 243 SkDeferredDevice* getDeferredDevice() const; |
239 | 244 |
240 private: | 245 private: |
241 SkDeferredCanvas(SkDeferredDevice*); | 246 SkDeferredCanvas(SkDeferredDevice*); |
242 | 247 |
243 void recordedDrawCommand(); | 248 void recordedDrawCommand(); |
244 SkCanvas* drawingCanvas() const; | 249 SkCanvas* drawingCanvas() const; |
245 SkCanvas* immediateCanvas() const; | 250 SkCanvas* immediateCanvas() const; |
246 bool isFullFrame(const SkRect*, const SkPaint*) const; | 251 bool isFullFrame(const SkRect*, const SkPaint*); |
247 void validate() const; | 252 void validate() const; |
248 void init(); | 253 void init(); |
249 | 254 |
250 size_t fBitmapSizeThreshold; | 255 size_t fBitmapSizeThreshold; |
251 bool fDeferredDrawing; | 256 bool fDeferredDrawing; |
| 257 bool fCanvasSizeChanged; |
| 258 SkISize fCanvasSize; |
252 | 259 |
253 friend class SkDeferredCanvasTester; // for unit testing | 260 friend class SkDeferredCanvasTester; // for unit testing |
254 typedef SkCanvas INHERITED; | 261 typedef SkCanvas INHERITED; |
255 }; | 262 }; |
256 | 263 |
257 | 264 |
258 #endif | 265 #endif |
OLD | NEW |