diff options
author | 2014-07-15 12:34:26 -0700 | |
---|---|---|
committer | 2014-07-15 12:34:26 -0700 | |
commit | 352c2181d15ed053c3b759f08ff1f51d50e2d3bb (patch) | |
tree | a4f92290a66062343ea9bf8ca4a5170167ccdc0a /include/utils/SkCanvasStateUtils.h | |
parent | 3944a1d2374d2de8622b0192aa080dba6fb92c76 (diff) |
Change SkCanvasState to use inheritance.
The base class, SkCanvasState, now holds the version, width, and
height. These fields will always be a necessary part of the class.
(Also add in some padding.)
The other fields, which may change, have been moved into the
subclass, SkCanvasState_v1. If/when the version changes, it will
correspond to a new subclass.
In SkCanvasStateUtils::CreateFromCanvasState, check the version on
the base class, then do a static_cast to the version corresponding
to SkCanvasState::version.
Remove CANVAS_STATE_VERSION, which is redundant with the version
specified by the subclass.
Use unambiguous type for rowBytes.
Build Android with SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG. This allows us
to run the full suite of CanvasState tests. It is also representative
of what will be used on Android by WebView.
Fix CanvasStateTest where it was broken inside ifdef'ed out code.
Use SkCanvas::getBaseLayerSize() instead of the deprecated
SkCanvas::getDeviceSize().
Update the comments in the header to be more clear. In particular,
an SkCanvasState can only be used to pass an SkCanvas' state to a
future version of Skia (or the same); not an older version.
NOTREECHECKS=true
BUG=b/15693384
R=reed@google.com, mtklein@google.com, djsollen@google.com
Author: scroggo@google.com
Review URL: https://codereview.chromium.org/372003002
Diffstat (limited to 'include/utils/SkCanvasStateUtils.h')
-rw-r--r-- | include/utils/SkCanvasStateUtils.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/include/utils/SkCanvasStateUtils.h b/include/utils/SkCanvasStateUtils.h index f8266c9b32..6ea7b10307 100644 --- a/include/utils/SkCanvasStateUtils.h +++ b/include/utils/SkCanvasStateUtils.h @@ -13,9 +13,9 @@ class SkCanvasState; /** - * A set of functions that are useful for copying an SkCanvas across a library - * boundary where the Skia libraries on either side of the boundary may not be - * version identical. The expected usage is outline below... + * A set of functions that are useful for copying the state of an SkCanvas + * across a library boundary where the Skia library on the other side of the + * boundary may be newer. The expected usage is outline below... * * Lib Boundary * CaptureCanvasState(...) ||| @@ -30,8 +30,8 @@ class SkCanvasState; namespace SkCanvasStateUtils { /** * Captures the current state of the canvas into an opaque ptr that is safe - * to pass between different instances of Skia (which may or may not be the - * same version). The function will return NULL in the event that one of the + * to pass to a different instance of Skia (which may be the same version, + * or may be newer). The function will return NULL in the event that one of the * following conditions are true. * 1) the canvas device type is not supported (currently only raster is supported) * 2) the canvas clip type is not supported (currently only non-AA clips are supported) @@ -56,7 +56,7 @@ namespace SkCanvasStateUtils { * 1) the captured state is in an unrecognized format * 2) the captured canvas device type is not supported * - * @param canvas The canvas you wish to capture the current state of. + * @param state Opaque object created by CaptureCanvasState. * @return NULL or an SkCanvas* whose devices and matrix/clip state are * identical to the captured canvas. The caller is responsible for * calling unref on the SkCanvas. @@ -66,7 +66,8 @@ namespace SkCanvasStateUtils { /** * Free the memory associated with the captured canvas state. The state * should not be released until all SkCanvas objects created using that - * state have been dereferenced. + * state have been dereferenced. Must be called from the same library + * instance that created the state via CaptureCanvasState. * * @param state The captured state you wish to dispose of. */ |