michael@0: michael@0: /* michael@0: * Copyright 2011 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: #ifndef SkEdgeBuilder_DEFINED michael@0: #define SkEdgeBuilder_DEFINED michael@0: michael@0: #include "SkChunkAlloc.h" michael@0: #include "SkRect.h" michael@0: #include "SkTDArray.h" michael@0: michael@0: struct SkEdge; michael@0: class SkEdgeClipper; michael@0: class SkPath; michael@0: michael@0: class SkEdgeBuilder { michael@0: public: michael@0: SkEdgeBuilder(); michael@0: michael@0: // returns the number of built edges. The array of those edge pointers michael@0: // is returned from edgeList(). michael@0: int build(const SkPath& path, const SkIRect* clip, int shiftUp); michael@0: michael@0: SkEdge** edgeList() { return fEdgeList; } michael@0: michael@0: private: michael@0: SkChunkAlloc fAlloc; michael@0: SkTDArray fList; michael@0: michael@0: /* michael@0: * If we're in general mode, we allcoate the pointers in fList, and this michael@0: * will point at fList.begin(). If we're in polygon mode, fList will be michael@0: * empty, as we will have preallocated room for the pointers in fAlloc's michael@0: * block, and fEdgeList will point into that. michael@0: */ michael@0: SkEdge** fEdgeList; michael@0: michael@0: int fShiftUp; michael@0: michael@0: public: michael@0: void addLine(const SkPoint pts[]); michael@0: void addQuad(const SkPoint pts[]); michael@0: void addCubic(const SkPoint pts[]); michael@0: void addClipper(SkEdgeClipper*); michael@0: michael@0: int buildPoly(const SkPath& path, const SkIRect* clip, int shiftUp); michael@0: }; michael@0: michael@0: #endif