Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions
SkPathRef.h File Reference
#include "include/core/SkArc.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkTypes.h"
#include "include/private/SkIDChangeListener.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkTArray.h"
#include "include/private/base/SkTo.h"
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <tuple>
#include <utility>

Go to the source code of this file.

Classes

struct  SkPathVerbAnalysis
 
class  SkPathRef
 
class  SkPathRef::Editor
 
class  SkPathRef::Iter
 

Functions

SkPathVerbAnalysis sk_path_analyze_verbs (const uint8_t verbs[], int count)
 

Function Documentation

◆ sk_path_analyze_verbs()

SkPathVerbAnalysis sk_path_analyze_verbs ( const uint8_t  verbs[],
int  count 
)

Definition at line 3447 of file SkPath.cpp.

3447 {
3448 SkPathVerbAnalysis info = {false, 0, 0, 0};
3449 bool needMove = true;
3450 bool invalid = false;
3451
3452 if (verbCount >= (INT_MAX / 3)) {
3453 // A path with an extremely high number of quad, conic or cubic verbs could cause
3454 // `info.points` to overflow. To prevent against this, we reject extremely large paths. This
3455 // check is conservative and assumes the worst case (in particular, it assumes that every
3456 // verb consumes 3 points, which would only happen for a path composed entirely of cubics).
3457 // This limits us to 700 million verbs, which is large enough for any reasonable use case.
3458 invalid = true;
3459 } else {
3460 for (int i = 0; i < verbCount; ++i) {
3461 switch ((SkPathVerb)vbs[i]) {
3462 case SkPathVerb::kMove:
3463 needMove = false;
3464 info.points += 1;
3465 break;
3466 case SkPathVerb::kLine:
3467 invalid |= needMove;
3468 info.segmentMask |= kLine_SkPathSegmentMask;
3469 info.points += 1;
3470 break;
3471 case SkPathVerb::kQuad:
3472 invalid |= needMove;
3473 info.segmentMask |= kQuad_SkPathSegmentMask;
3474 info.points += 2;
3475 break;
3476 case SkPathVerb::kConic:
3477 invalid |= needMove;
3478 info.segmentMask |= kConic_SkPathSegmentMask;
3479 info.points += 2;
3480 info.weights += 1;
3481 break;
3482 case SkPathVerb::kCubic:
3483 invalid |= needMove;
3484 info.segmentMask |= kCubic_SkPathSegmentMask;
3485 info.points += 3;
3486 break;
3487 case SkPathVerb::kClose:
3488 invalid |= needMove;
3489 needMove = true;
3490 break;
3491 default:
3492 invalid = true;
3493 break;
3494 }
3495 }
3496 }
3497 info.valid = !invalid;
3498 return info;
3499}
static bool invalid(const SkISize &size)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
@ kCubic_SkPathSegmentMask
Definition SkPathTypes.h:45
@ kConic_SkPathSegmentMask
Definition SkPathTypes.h:44
@ kQuad_SkPathSegmentMask
Definition SkPathTypes.h:43
@ kLine_SkPathSegmentMask
Definition SkPathTypes.h:42
SkPathVerb
Definition SkPathTypes.h:48
@ kClose
SkPath::RawIter returns 0 points.
@ kCubic
SkPath::RawIter returns 4 points.
@ kConic
SkPath::RawIter returns 3 points + 1 weight.
@ kQuad
SkPath::RawIter returns 3 points.
@ kMove
SkPath::RawIter returns 1 point.
@ kLine
SkPath::RawIter returns 2 points.