epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
reed@android.com | 909994f | 2009-11-18 16:09:51 +0000 | [diff] [blame] | 8 | #ifndef SkEdgeBuilder_DEFINED |
| 9 | #define SkEdgeBuilder_DEFINED |
| 10 | |
| 11 | #include "SkChunkAlloc.h" |
| 12 | #include "SkRect.h" |
| 13 | #include "SkTDArray.h" |
| 14 | |
senorblanco@chromium.org | b1501a3 | 2009-12-04 19:53:28 +0000 | [diff] [blame] | 15 | struct SkEdge; |
reed@android.com | 909994f | 2009-11-18 16:09:51 +0000 | [diff] [blame] | 16 | class SkEdgeClipper; |
| 17 | class SkPath; |
| 18 | |
| 19 | class SkEdgeBuilder { |
| 20 | public: |
| 21 | SkEdgeBuilder(); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 22 | |
reed@google.com | c8d640b | 2012-08-02 14:26:43 +0000 | [diff] [blame] | 23 | // returns the number of built edges. The array of those edge pointers |
| 24 | // is returned from edgeList(). |
reed@android.com | 909994f | 2009-11-18 16:09:51 +0000 | [diff] [blame] | 25 | int build(const SkPath& path, const SkIRect* clip, int shiftUp); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 26 | |
reed@google.com | c8d640b | 2012-08-02 14:26:43 +0000 | [diff] [blame] | 27 | SkEdge** edgeList() { return fEdgeList; } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 28 | |
reed@android.com | 909994f | 2009-11-18 16:09:51 +0000 | [diff] [blame] | 29 | private: |
| 30 | SkChunkAlloc fAlloc; |
| 31 | SkTDArray<SkEdge*> fList; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 32 | |
reed@google.com | c8d640b | 2012-08-02 14:26:43 +0000 | [diff] [blame] | 33 | /* |
| 34 | * If we're in general mode, we allcoate the pointers in fList, and this |
| 35 | * will point at fList.begin(). If we're in polygon mode, fList will be |
| 36 | * empty, as we will have preallocated room for the pointers in fAlloc's |
| 37 | * block, and fEdgeList will point into that. |
| 38 | */ |
| 39 | SkEdge** fEdgeList; |
reed@android.com | 909994f | 2009-11-18 16:09:51 +0000 | [diff] [blame] | 40 | |
reed@google.com | c8d640b | 2012-08-02 14:26:43 +0000 | [diff] [blame] | 41 | int fShiftUp; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 42 | |
reed@google.com | 277c3f8 | 2013-05-31 15:17:50 +0000 | [diff] [blame] | 43 | public: |
reed@android.com | 909994f | 2009-11-18 16:09:51 +0000 | [diff] [blame] | 44 | void addLine(const SkPoint pts[]); |
| 45 | void addQuad(const SkPoint pts[]); |
| 46 | void addCubic(const SkPoint pts[]); |
| 47 | void addClipper(SkEdgeClipper*); |
reed@google.com | c8d640b | 2012-08-02 14:26:43 +0000 | [diff] [blame] | 48 | |
| 49 | int buildPoly(const SkPath& path, const SkIRect* clip, int shiftUp); |
reed@android.com | 909994f | 2009-11-18 16:09:51 +0000 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | #endif |