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 |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkPixelRef.h" | 12 #include "SkPixelRef.h" |
13 | 13 |
14 class DeferredDevice; | 14 class DeferredDevice; |
15 class SkImage; | 15 class SkImage; |
16 class SkSurface; | 16 class SkSurface; |
17 | 17 |
18 #if !defined(SK_DEFERRED_CANVAS_USES_FACTORIES) | |
19 // This is temporary, for rolling the API change into Chromium/Blink | |
20 #define SK_DEFERRED_CANVAS_USES_FACTORIES 0 | |
21 #endif | |
22 | |
23 /** \class SkDeferredCanvas | 18 /** \class SkDeferredCanvas |
24 Subclass of SkCanvas that encapsulates an SkPicture or SkGPipe for deferred | 19 Subclass of SkCanvas that encapsulates an SkPicture or SkGPipe for deferred |
25 drawing. The main difference between this class and SkPictureRecord (the | 20 drawing. The main difference between this class and SkPictureRecord (the |
26 canvas provided by SkPicture) is that this is a full drop-in replacement | 21 canvas provided by SkPicture) is that this is a full drop-in replacement |
27 for SkCanvas, while SkPictureRecord only supports draw operations. | 22 for SkCanvas, while SkPictureRecord only supports draw operations. |
28 SkDeferredCanvas will transparently trigger the flushing of deferred | 23 SkDeferredCanvas will transparently trigger the flushing of deferred |
29 draw operations when an attempt is made to access the pixel data. | 24 draw operations when an attempt is made to access the pixel data. |
30 */ | 25 */ |
31 class SK_API SkDeferredCanvas : public SkCanvas { | 26 class SK_API SkDeferredCanvas : public SkCanvas { |
32 public: | 27 public: |
33 class NotificationClient; | 28 class NotificationClient; |
34 | 29 |
35 /** Construct a canvas with the specified surface to draw into. | 30 /** Construct a canvas with the specified surface to draw into. |
36 This factory must be used for newImageSnapshot to work. | 31 This factory must be used for newImageSnapshot to work. |
37 @param surface Specifies a surface for the canvas to draw into. | 32 @param surface Specifies a surface for the canvas to draw into. |
38 */ | 33 */ |
39 static SkDeferredCanvas* Create(SkSurface* surface); | 34 static SkDeferredCanvas* Create(SkSurface* surface); |
40 | 35 |
41 #ifdef SK_DEVELOPER | 36 static SkDeferredCanvas* Create(SkDevice* device); |
42 static SkDeferredCanvas* Create(SkDevice* device); // Used for testing | |
43 #endif | |
44 | |
45 #if !SK_DEFERRED_CANVAS_USES_FACTORIES | |
46 /** DEPRECATED | |
47 */ | |
48 SkDeferredCanvas(); | |
49 | |
50 /** DEPRACATED, use create instead | |
51 Construct a canvas with the specified device to draw into. | |
52 Equivalent to calling default constructor, then setDevice. | |
53 @param device Specifies a device for the canvas to draw into. | |
54 */ | |
55 explicit SkDeferredCanvas(SkDevice* device); | |
56 | |
57 /** DEPRECATED, use create instead | |
58 Construct a canvas with the specified surface to draw into. | |
59 This constructor must be used for newImageSnapshot to work. | |
60 @param surface Specifies a surface for the canvas to draw into. | |
61 */ | |
62 explicit SkDeferredCanvas(SkSurface* surface); | |
63 #endif | |
64 | 37 |
65 virtual ~SkDeferredCanvas(); | 38 virtual ~SkDeferredCanvas(); |
66 | 39 |
67 /** DEPRECATED | |
68 * Specify a device to be used by this canvas. Calling setDevice will | |
69 * release the previously set device, if any. Takes a reference on the | |
70 * device. | |
71 * | |
72 * @param device The device that the canvas will raw into | |
73 * @return The device argument, for convenience. | |
74 */ | |
75 virtual SkDevice* setDevice(SkDevice* device); | |
76 | |
77 /** | 40 /** |
78 * Specify the surface to be used by this canvas. Calling setSurface will | 41 * Specify the surface to be used by this canvas. Calling setSurface will |
79 * release the previously set surface or device. Takes a reference on the | 42 * release the previously set surface or device. Takes a reference on the |
80 * surface. | 43 * surface. |
81 * | 44 * |
82 * @param surface The surface that the canvas will raw into | 45 * @param surface The surface that the canvas will raw into |
83 * @return The surface argument, for convenience. | 46 * @return The surface argument, for convenience. |
84 */ | 47 */ |
85 SkSurface* setSurface(SkSurface* surface); | 48 SkSurface* setSurface(SkSurface* surface); |
86 | 49 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 void validate() const; | 247 void validate() const; |
285 void init(); | 248 void init(); |
286 bool fDeferredDrawing; | 249 bool fDeferredDrawing; |
287 | 250 |
288 friend class SkDeferredCanvasTester; // for unit testing | 251 friend class SkDeferredCanvasTester; // for unit testing |
289 typedef SkCanvas INHERITED; | 252 typedef SkCanvas INHERITED; |
290 }; | 253 }; |
291 | 254 |
292 | 255 |
293 #endif | 256 #endif |
OLD | NEW |