diff options
author | 2014-04-22 15:21:18 +0000 | |
---|---|---|
committer | 2014-04-22 15:21:18 +0000 | |
commit | aec143824c9be4e4af6e2cb7cce3d2d2268c0b15 (patch) | |
tree | 72b17b11f32c788da1e114ebd6305f470b94acf3 /include/core | |
parent | fd4ee4dea13f083c81cc80180fa09ee0127158a1 (diff) |
Add asADash entry point into SkPathEffect to allow extracting Dash info from PathEffects
BUG=skia:
R=bsalomon@google.com, reed@google.com
Author: egdaniel@google.com
Review URL: https://codereview.chromium.org/212103010
git-svn-id: http://skia.googlecode.com/svn/trunk@14297 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkPathEffect.h | 27 | ||||
-rw-r--r-- | include/core/SkPicture.h | 3 |
2 files changed, 29 insertions, 1 deletions
diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h index 86ccf86a92..638287d07c 100644 --- a/include/core/SkPathEffect.h +++ b/include/core/SkPathEffect.h @@ -104,6 +104,33 @@ public: const SkStrokeRec&, const SkMatrix&, const SkRect* cullR) const; + /** + * If the PathEffect can be represented as a dash pattern, asADash will return kDash_DashType + * and None otherwise. If a non NULL info is passed in, the various DashInfo will be filled + * in if the PathEffect can be a dash pattern. If passed in info has an fCount equal or + * greater to that of the effect, it will memcpy the values of the dash intervals into the + * info. Thus the general approach will be call asADash once with default info to get DashType + * and fCount. If effect can be represented as a dash pattern, allocate space for the intervals + * in info, then call asADash again with the same info and the intervals will get copied in. + */ + + enum DashType { + kNone_DashType, //!< ignores the info parameter + kDash_DashType, //!< fills in all of the info parameter + }; + + struct DashInfo { + DashInfo() : fIntervals(NULL), fCount(0), fPhase(0) {} + + SkScalar* fIntervals; //!< Length of on/off intervals for dashed lines + // Even values represent ons, and odds offs + int32_t fCount; //!< Number of intervals in the dash. Should be even number + SkScalar fPhase; //!< Offset into the dashed interval pattern + // mod the sum of all intervals + }; + + virtual DashType asADash(DashInfo* info) const; + SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect) protected: diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h index bf9ec4f8bb..996d85716e 100644 --- a/include/core/SkPicture.h +++ b/include/core/SkPicture.h @@ -324,13 +324,14 @@ protected: // V22: SK_PICT_FACTORY_TAG's size is now the chunk size in bytes // V23: SkPaint::FilterLevel became a real enum // V24: SkTwoPointConicalGradient now has fFlipped flag for gradient flipping + // V25: SkDashPathEffect now only writes phase and interval array when flattening // Note: If the picture version needs to be increased then please follow the // steps to generate new SKPs in (only accessible to Googlers): http://goo.gl/qATVcw // Only SKPs within the min/current picture version range (inclusive) can be read. static const uint32_t MIN_PICTURE_VERSION = 19; - static const uint32_t CURRENT_PICTURE_VERSION = 24; + static const uint32_t CURRENT_PICTURE_VERSION = 25; mutable uint32_t fUniqueID; |