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

Side by Side Diff: include/utils/SkCanvasStateUtils.h

Issue 372003002: Change SkCanvasState to use inheritance. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix Windows failures. Created 6 years, 5 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 | « no previous file | src/utils/SkCanvasStateUtils.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 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 SkCanvasStateUtils_DEFINED 8 #ifndef SkCanvasStateUtils_DEFINED
9 #define SkCanvasStateUtils_DEFINED 9 #define SkCanvasStateUtils_DEFINED
10 10
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 12
13 class SkCanvasState; 13 class SkCanvasState;
14 14
15 /** 15 /**
16 * A set of functions that are useful for copying an SkCanvas across a library 16 * A set of functions that are useful for copying the state of an SkCanvas
17 * boundary where the Skia libraries on either side of the boundary may not be 17 * across a library boundary where the Skia library on the other side of the
18 * version identical. The expected usage is outline below... 18 * boundary may be newer. The expected usage is outline below...
19 * 19 *
20 * Lib Boundary 20 * Lib Boundary
21 * CaptureCanvasState(...) ||| 21 * CaptureCanvasState(...) |||
22 * SkCanvas --> SkCanvasState ||| 22 * SkCanvas --> SkCanvasState |||
23 * ||| CreateFromCanvasState(...) 23 * ||| CreateFromCanvasState(...)
24 * ||| SkCanvasState --> SkCanvas` 24 * ||| SkCanvasState --> SkCanvas`
25 * ||| Draw into SkCanvas` 25 * ||| Draw into SkCanvas`
26 * ||| Unref SkCanvas` 26 * ||| Unref SkCanvas`
27 * ReleaseCanvasState(...) ||| 27 * ReleaseCanvasState(...) |||
28 * 28 *
29 */ 29 */
30 namespace SkCanvasStateUtils { 30 namespace SkCanvasStateUtils {
31 /** 31 /**
32 * Captures the current state of the canvas into an opaque ptr that is safe 32 * Captures the current state of the canvas into an opaque ptr that is safe
33 * to pass between different instances of Skia (which may or may not be the 33 * to pass to a different instance of Skia (which may be the same version,
34 * same version). The function will return NULL in the event that one of the 34 * or may be newer). The function will return NULL in the event that one of the
35 * following conditions are true. 35 * following conditions are true.
36 * 1) the canvas device type is not supported (currently only raster is sup ported) 36 * 1) the canvas device type is not supported (currently only raster is sup ported)
37 * 2) the canvas clip type is not supported (currently only non-AA clips ar e supported) 37 * 2) the canvas clip type is not supported (currently only non-AA clips ar e supported)
38 * 38 *
39 * It is recommended that the original canvas also not be used until all 39 * It is recommended that the original canvas also not be used until all
40 * canvases that have been created using its captured state have been derefe renced. 40 * canvases that have been created using its captured state have been derefe renced.
41 * 41 *
42 * Finally, it is important to note that any draw filters attached to the 42 * Finally, it is important to note that any draw filters attached to the
43 * canvas are NOT currently captured. 43 * canvas are NOT currently captured.
44 * 44 *
45 * @param canvas The canvas you wish to capture the current state of. 45 * @param canvas The canvas you wish to capture the current state of.
46 * @return NULL or an opaque ptr that can be passed to CreateFromCanvasState 46 * @return NULL or an opaque ptr that can be passed to CreateFromCanvasState
47 * to reconstruct the canvas. The caller is responsible for calling 47 * to reconstruct the canvas. The caller is responsible for calling
48 * ReleaseCanvasState to free the memory associated with this state. 48 * ReleaseCanvasState to free the memory associated with this state.
49 */ 49 */
50 SK_API SkCanvasState* CaptureCanvasState(SkCanvas* canvas); 50 SK_API SkCanvasState* CaptureCanvasState(SkCanvas* canvas);
51 51
52 /** 52 /**
53 * Create a new SkCanvas from the captured state of another SkCanvas. The 53 * Create a new SkCanvas from the captured state of another SkCanvas. The
54 * function will return NULL in the event that one of the 54 * function will return NULL in the event that one of the
55 * following conditions are true. 55 * following conditions are true.
56 * 1) the captured state is in an unrecognized format 56 * 1) the captured state is in an unrecognized format
57 * 2) the captured canvas device type is not supported 57 * 2) the captured canvas device type is not supported
58 * 58 *
59 * @param canvas The canvas you wish to capture the current state of. 59 * @param state Opaque object created by CaptureCanvasState.
60 * @return NULL or an SkCanvas* whose devices and matrix/clip state are 60 * @return NULL or an SkCanvas* whose devices and matrix/clip state are
61 * identical to the captured canvas. The caller is responsible for 61 * identical to the captured canvas. The caller is responsible for
62 * calling unref on the SkCanvas. 62 * calling unref on the SkCanvas.
63 */ 63 */
64 SK_API SkCanvas* CreateFromCanvasState(const SkCanvasState* state); 64 SK_API SkCanvas* CreateFromCanvasState(const SkCanvasState* state);
65 65
66 /** 66 /**
67 * Free the memory associated with the captured canvas state. The state 67 * Free the memory associated with the captured canvas state. The state
68 * should not be released until all SkCanvas objects created using that 68 * should not be released until all SkCanvas objects created using that
69 * state have been dereferenced. 69 * state have been dereferenced. Must be called from the same library
70 * instance that created the state via CaptureCanvasState.
70 * 71 *
71 * @param state The captured state you wish to dispose of. 72 * @param state The captured state you wish to dispose of.
72 */ 73 */
73 SK_API void ReleaseCanvasState(SkCanvasState* state); 74 SK_API void ReleaseCanvasState(SkCanvasState* state);
74 }; 75 };
75 76
76 #endif 77 #endif
OLDNEW
« no previous file with comments | « no previous file | src/utils/SkCanvasStateUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698