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