diff options
author | 2015-07-01 08:41:14 -0700 | |
---|---|---|
committer | 2015-07-01 08:41:15 -0700 | |
commit | a89f55198bdc58f0b6f6196907ab25a6afc1a661 (patch) | |
tree | a608ef4f5fe9fd724bd57ddade2b62c00bf60ae5 /include/private/SkPathPriv.h | |
parent | bd929d95704d052a5c8477b881761eff03582487 (diff) |
Move headers used by headers in include/ to include/private.
Some of this is transitive, like SkRecords.h used by SkMiniRecorder.h
used by (public) SkPictureRecorder.h.
BUG=skia:
Review URL: https://codereview.chromium.org/1217293004
Diffstat (limited to 'include/private/SkPathPriv.h')
-rw-r--r-- | include/private/SkPathPriv.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/include/private/SkPathPriv.h b/include/private/SkPathPriv.h new file mode 100644 index 0000000000..934c730660 --- /dev/null +++ b/include/private/SkPathPriv.h @@ -0,0 +1,64 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkPathPriv_DEFINED +#define SkPathPriv_DEFINED + +#include "SkPath.h" + +class SkPathPriv { +public: + enum FirstDirection { + kCW_FirstDirection, // == SkPath::kCW_Direction + kCCW_FirstDirection, // == SkPath::kCCW_Direction + kUnknown_FirstDirection, + }; + + static FirstDirection AsFirstDirection(SkPath::Direction dir) { + // since we agree numerically for the values in Direction, we can just cast. + return (FirstDirection)dir; + } + + /** + * Return the opposite of the specified direction. kUnknown is its own + * opposite. + */ + static FirstDirection OppositeFirstDirection(FirstDirection dir) { + static const FirstDirection gOppositeDir[] = { + kCCW_FirstDirection, kCW_FirstDirection, kUnknown_FirstDirection, + }; + return gOppositeDir[dir]; + } + + /** + * Tries to quickly compute the direction of the first non-degenerate + * contour. If it can be computed, return true and set dir to that + * direction. If it cannot be (quickly) determined, return false and ignore + * the dir parameter. If the direction was determined, it is cached to make + * subsequent calls return quickly. + */ + static bool CheapComputeFirstDirection(const SkPath&, FirstDirection* dir); + + /** + * Returns true if the path's direction can be computed via + * cheapComputDirection() and if that computed direction matches the + * specified direction. If dir is kUnknown, returns true if the direction + * cannot be computed. + */ + static bool CheapIsFirstDirection(const SkPath& path, FirstDirection dir) { + FirstDirection computedDir = kUnknown_FirstDirection; + (void)CheapComputeFirstDirection(path, &computedDir); + return computedDir == dir; + } + + static bool LastVerbIsClose(const SkPath& path) { + int count = path.countVerbs(); + return count >= 1 && path.fPathRef->verbs()[~(count - 1)] == SkPath::Verb::kClose_Verb; + } +}; + +#endif |