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

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

Issue 23545017: Create a semi-stable API for capturing the state of an SkCanvas and reconstructing that state acros… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkCanvasUtils_DEFINED
9 #define SkCanvasUtils_DEFINED
10
11 #include "SkCanvas.h"
12
13 struct SkCanvasState;
14
15 class SK_API SkCanvasUtils {
scroggo 2013/08/28 17:22:01 This seems to be a rather generic name, considerin
djsollen 2013/08/29 15:09:19 Done.
16 public:
17 /**
18 * Captures the current state of the canvas into an opaque ptr that is safe
19 * to pass between different instances of Skia (which may or may not be the
20 * same version). The function will return NULL in the event that one of the
21 * following conditions are true.
22 * 1) the canvas device type is not supported (currently only raster is sup ported)
23 * 2) the canvas clip type is not supported (currently only non-AA clips ar e supported)
24 *
25 * It is required that the original SkCanvas remain valid until all canvases
mtklein 2013/08/28 18:20:46 Can we have the SkCanvasState grab a ref on the Sk
djsollen 2013/08/29 15:09:19 Done.
26 * that have been created using its captured state have been dereferenced. I t
27 * is also recommended that the original canvas also to be used during this
scroggo 2013/08/28 17:22:01 I'm not sure what this sentence means.
joth 2013/08/28 21:04:59 recommended that the original canvas NOT be used..
djsollen 2013/08/29 15:09:19 Done.
28 * time.
29 *
30 * Finally, it is important to note that any draw filters attached to the
31 * canvas are NOT currently captured.
mtklein 2013/08/28 18:20:46 A unit test for this will make sure we don't get t
djsollen 2013/08/29 15:09:19 Done.
32 *
33 * @param canvas The canvas you wish to capture the current state of.
34 * @return NULL or an opaque ptr that can be passed to CreateFromCanvasState
35 * to reconstruct the canvas. The caller is responsible for calling
36 * ReleaseCanvasState to free the memory associated with this state.
37 */
38 static SkCanvasState* CaptureCanvasState(SkCanvas* canvas);
mtklein 2013/08/28 18:20:46 Given that this is opaque, maybe we can use typede
39
40 /**
41 * Create a new SkCanvas from the captured state of another SkCanvas. The
42 * function will return NULL in the event that one of the
43 * following conditions are true.
44 * 1) the captured state is in an unrecognized format
45 * 2) the captured canvas device type is not supported
46 *
47 * @param canvas The canvas you wish to capture the current state of.
48 * @return NULL or an SkCanvas* whose devices and matrix/clip state are
49 * identical to the captured canvas. The caller is responsible for
50 * calling unref on the SkCanvas.
51 */
52 static SkCanvas* CreateFromCanvasState(SkCanvasState* state);
mtklein 2013/08/28 18:20:46 Can this be a const* or const&? (Or if * is typed
53
54 /**
55 * Free the memory associated with the captured canvas state. This function
56 * can be called as soon as the caller is finished using the state (e.g. cal ling
57 * CreateFromCanvasState) and does not need to be retained for the lifecycle
58 * of any SkCanvas objects that it was used to create.
mtklein 2013/08/28 18:20:46 This is what needs update after what we all just t
djsollen 2013/08/29 15:09:19 Done.
59 *
60 * @param state The captured state you wish to dispose of.
61 */
62 static void ReleaseCanvasState(SkCanvasState* state);
scroggo 2013/08/28 17:22:01 I think it would be useful to be explicit in the c
joth 2013/08/28 21:04:59 Yes. I'd group CaptureCanvasState & ReleaseCanva
djsollen 2013/08/29 15:09:19 Done.
63 };
64
65 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698