• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "SkColorPriv.h"
12 #include "SkMatrix.h"
13 #include "SkVertices.h"
14 
15 class SK_API SkPatchUtils {
16 
17 public:
18     // Enums for control points based on the order specified in the constructor (clockwise).
19     enum {
20         kNumCtrlPts = 12,
21         kNumCorners = 4,
22         kNumPtsCubic = 4
23     };
24 
25     /**
26      * Get the points corresponding to the top cubic of cubics.
27      */
28     static void GetTopCubic(const SkPoint cubics[12], SkPoint points[4]);
29 
30     /**
31      * Get the points corresponding to the bottom cubic of cubics.
32      */
33     static void GetBottomCubic(const SkPoint cubics[12], SkPoint points[4]);
34 
35     /**
36      * Get the points corresponding to the left cubic of cubics.
37      */
38     static void GetLeftCubic(const SkPoint cubics[12], SkPoint points[4]);
39 
40     /**
41      * Get the points corresponding to the right cubic of cubics.
42      */
43     static void GetRightCubic(const SkPoint cubics[12], SkPoint points[4]);
44 
45     /**
46      * Method that calculates a level of detail (number of subdivisions) for a patch in both axis.
47      */
48     static SkISize GetLevelOfDetail(const SkPoint cubics[12], const SkMatrix* matrix);
49 
50     static sk_sp<SkVertices> MakeVertices(const SkPoint cubics[12], const SkColor colors[4],
51                                           const SkPoint texCoords[4], int lodX, int lodY,
52                                           bool interpColorsLinearly = false);
53 };
54 
55 #endif
56