1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 2909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com/* 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2009 The Android Open Source Project 4909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com * 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 7909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com */ 8909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com 9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 10909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com#ifndef SkEdgeClipper_DEFINED 11909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com#define SkEdgeClipper_DEFINED 12909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com 13909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com#include "SkPath.h" 14909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com 15909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com/** This is basically an iterator. It is initialized with an edge and a clip, 16909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com and then next() is called until it returns kDone_Verb. 17909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com */ 18909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.comclass SkEdgeClipper { 19909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.compublic: 2031223e0cb74f47f63b094520a9830c525b72fe87reed SkEdgeClipper(bool canCullToTheRight) : fCanCullToTheRight(canCullToTheRight) {} 2131223e0cb74f47f63b094520a9830c525b72fe87reed 22909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com bool clipQuad(const SkPoint pts[3], const SkRect& clip); 23909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com bool clipCubic(const SkPoint pts[4], const SkRect& clip); 24909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com 25909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com SkPath::Verb next(SkPoint pts[]); 26fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 2731223e0cb74f47f63b094520a9830c525b72fe87reed bool canCullToTheRight() const { return fCanCullToTheRight; } 2831223e0cb74f47f63b094520a9830c525b72fe87reed 29909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.comprivate: 30909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com SkPoint* fCurrPoint; 31909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com SkPath::Verb* fCurrVerb; 3231223e0cb74f47f63b094520a9830c525b72fe87reed const bool fCanCullToTheRight; 33fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 34909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com enum { 35909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com kMaxVerbs = 13, 36909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com kMaxPoints = 32 37909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com }; 38909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com SkPoint fPoints[kMaxPoints]; 39909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com SkPath::Verb fVerbs[kMaxVerbs]; 40909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com 41909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com void clipMonoQuad(const SkPoint srcPts[3], const SkRect& clip); 42909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com void clipMonoCubic(const SkPoint srcPts[4], const SkRect& clip); 43909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com void appendVLine(SkScalar x, SkScalar y0, SkScalar y1, bool reverse); 44909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com void appendQuad(const SkPoint pts[3], bool reverse); 45909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com void appendCubic(const SkPoint pts[4], bool reverse); 46909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com}; 47909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com 48909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com#ifdef SK_DEBUG 49909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com void sk_assert_monotonic_x(const SkPoint pts[], int count); 50909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com void sk_assert_monotonic_y(const SkPoint pts[], int count); 51909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com#else 52909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com #define sk_assert_monotonic_x(pts, count) 53909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com #define sk_assert_monotonic_y(pts, count) 54909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com#endif 55909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com 56909994fbae0ffb532f42feac8859f8d86bbf64dereed@android.com#endif 57