blob: f9e5976e17f6cbb6b0f09cad9ad77eb487ef29f5 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
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.com909994f2009-11-18 16:09:51 +00008#ifndef SkEdgeBuilder_DEFINED
9#define SkEdgeBuilder_DEFINED
10
11#include "SkChunkAlloc.h"
12#include "SkRect.h"
13#include "SkTDArray.h"
14
senorblanco@chromium.orgb1501a32009-12-04 19:53:28 +000015struct SkEdge;
reed@android.com909994f2009-11-18 16:09:51 +000016class SkEdgeClipper;
17class SkPath;
18
19class SkEdgeBuilder {
20public:
21 SkEdgeBuilder();
rmistry@google.comfbfcd562012-08-23 18:09:54 +000022
reed@google.comc8d640b2012-08-02 14:26:43 +000023 // returns the number of built edges. The array of those edge pointers
24 // is returned from edgeList().
reed@android.com909994f2009-11-18 16:09:51 +000025 int build(const SkPath& path, const SkIRect* clip, int shiftUp);
rmistry@google.comfbfcd562012-08-23 18:09:54 +000026
reed@google.comc8d640b2012-08-02 14:26:43 +000027 SkEdge** edgeList() { return fEdgeList; }
rmistry@google.comfbfcd562012-08-23 18:09:54 +000028
reed@android.com909994f2009-11-18 16:09:51 +000029private:
30 SkChunkAlloc fAlloc;
31 SkTDArray<SkEdge*> fList;
rmistry@google.comfbfcd562012-08-23 18:09:54 +000032
reed@google.comc8d640b2012-08-02 14:26:43 +000033 /*
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.com909994f2009-11-18 16:09:51 +000040
reed@google.comc8d640b2012-08-02 14:26:43 +000041 int fShiftUp;
rmistry@google.comfbfcd562012-08-23 18:09:54 +000042
reed@google.com277c3f82013-05-31 15:17:50 +000043public:
reed@android.com909994f2009-11-18 16:09:51 +000044 void addLine(const SkPoint pts[]);
45 void addQuad(const SkPoint pts[]);
46 void addCubic(const SkPoint pts[]);
47 void addClipper(SkEdgeClipper*);
reed@google.comc8d640b2012-08-02 14:26:43 +000048
49 int buildPoly(const SkPath& path, const SkIRect* clip, int shiftUp);
reed@android.com909994f2009-11-18 16:09:51 +000050};
51
52#endif