1 /* 2 * Copyright 2014 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkPatchUtils_DEFINED 9 #define SkPatchUtils_DEFINED 10 11 #include "include/core/SkColor.h" 12 #include "include/core/SkRefCnt.h" 13 14 class SkColorSpace; 15 class SkMatrix; 16 class SkVertices; 17 struct SkISize; 18 struct SkPoint; 19 20 class SkPatchUtils { 21 22 public: 23 // Enums for control points based on the order specified in the constructor (clockwise). 24 enum { 25 kNumCtrlPts = 12, 26 kNumCorners = 4, 27 kNumPtsCubic = 4 28 }; 29 30 /** 31 * Get the points corresponding to the top cubic of cubics. 32 */ 33 static void GetTopCubic(const SkPoint cubics[12], SkPoint points[4]); 34 35 /** 36 * Get the points corresponding to the bottom cubic of cubics. 37 */ 38 static void GetBottomCubic(const SkPoint cubics[12], SkPoint points[4]); 39 40 /** 41 * Get the points corresponding to the left cubic of cubics. 42 */ 43 static void GetLeftCubic(const SkPoint cubics[12], SkPoint points[4]); 44 45 /** 46 * Get the points corresponding to the right cubic of cubics. 47 */ 48 static void GetRightCubic(const SkPoint cubics[12], SkPoint points[4]); 49 50 /** 51 * Method that calculates a level of detail (number of subdivisions) for a patch in both axis. 52 */ 53 static SkISize GetLevelOfDetail(const SkPoint cubics[12], const SkMatrix* matrix); 54 55 static sk_sp<SkVertices> MakeVertices(const SkPoint cubics[12], const SkColor colors[4], 56 const SkPoint texCoords[4], int lodX, int lodY, 57 SkColorSpace* colorSpace = nullptr); 58 }; 59 60 #endif 61