blob: 009c3c66bf202a4635d4ac7792afa0ef187657c0 [file] [log] [blame]
dandovecfff212014-08-04 10:02:00 -07001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "src/utils/SkPatchUtils.h"
dandovecfff212014-08-04 10:02:00 -07009
Brian Osmanf5ecf512020-04-01 09:29:13 -040010#include "include/core/SkVertices.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/private/SkColorData.h"
Mike Klein8aa0edf2020-10-16 11:04:18 -050012#include "include/private/SkTPin.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "include/private/SkTo.h"
Ben Wagner729a23f2019-05-17 16:29:34 -040014#include "src/core/SkArenaAlloc.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050015#include "src/core/SkColorSpacePriv.h"
16#include "src/core/SkConvertPixels.h"
17#include "src/core/SkGeometry.h"
dandovb3c9d1c2014-08-12 08:34:29 -070018
Mike Reed4ebb43e2017-04-05 11:06:15 -040019namespace {
20 enum CubicCtrlPts {
21 kTopP0_CubicCtrlPts = 0,
22 kTopP1_CubicCtrlPts = 1,
23 kTopP2_CubicCtrlPts = 2,
24 kTopP3_CubicCtrlPts = 3,
25
26 kRightP0_CubicCtrlPts = 3,
27 kRightP1_CubicCtrlPts = 4,
28 kRightP2_CubicCtrlPts = 5,
29 kRightP3_CubicCtrlPts = 6,
30
31 kBottomP0_CubicCtrlPts = 9,
32 kBottomP1_CubicCtrlPts = 8,
33 kBottomP2_CubicCtrlPts = 7,
34 kBottomP3_CubicCtrlPts = 6,
35
36 kLeftP0_CubicCtrlPts = 0,
37 kLeftP1_CubicCtrlPts = 11,
38 kLeftP2_CubicCtrlPts = 10,
39 kLeftP3_CubicCtrlPts = 9,
40 };
41
42 // Enum for corner also clockwise.
43 enum Corner {
44 kTopLeft_Corner = 0,
45 kTopRight_Corner,
46 kBottomRight_Corner,
47 kBottomLeft_Corner
48 };
John Stilesa6841be2020-08-06 14:11:56 -040049} // namespace
Mike Reed4ebb43e2017-04-05 11:06:15 -040050
dandovb3c9d1c2014-08-12 08:34:29 -070051/**
52 * Evaluator to sample the values of a cubic bezier using forward differences.
53 * Forward differences is a method for evaluating a nth degree polynomial at a uniform step by only
54 * adding precalculated values.
55 * For a linear example we have the function f(t) = m*t+b, then the value of that function at t+h
56 * would be f(t+h) = m*(t+h)+b. If we want to know the uniform step that we must add to the first
57 * evaluation f(t) then we need to substract f(t+h) - f(t) = m*t + m*h + b - m*t + b = mh. After
58 * obtaining this value (mh) we could just add this constant step to our first sampled point
59 * to compute the next one.
60 *
61 * For the cubic case the first difference gives as a result a quadratic polynomial to which we can
62 * apply again forward differences and get linear function to which we can apply again forward
63 * differences to get a constant difference. This is why we keep an array of size 4, the 0th
64 * position keeps the sampled value while the next ones keep the quadratic, linear and constant
65 * difference values.
66 */
67
68class FwDCubicEvaluator {
halcanary9d524f22016-03-29 09:03:52 -070069
dandovb3c9d1c2014-08-12 08:34:29 -070070public:
halcanary9d524f22016-03-29 09:03:52 -070071
dandovb3c9d1c2014-08-12 08:34:29 -070072 /**
73 * Receives the 4 control points of the cubic bezier.
74 */
halcanary9d524f22016-03-29 09:03:52 -070075
caryclark5ba2b962016-01-26 17:02:30 -080076 explicit FwDCubicEvaluator(const SkPoint points[4])
77 : fCoefs(points) {
dandovb3c9d1c2014-08-12 08:34:29 -070078 memcpy(fPoints, points, 4 * sizeof(SkPoint));
halcanary9d524f22016-03-29 09:03:52 -070079
dandovb3c9d1c2014-08-12 08:34:29 -070080 this->restart(1);
81 }
halcanary9d524f22016-03-29 09:03:52 -070082
dandovb3c9d1c2014-08-12 08:34:29 -070083 /**
84 * Restarts the forward differences evaluator to the first value of t = 0.
85 */
86 void restart(int divisions) {
87 fDivisions = divisions;
dandovb3c9d1c2014-08-12 08:34:29 -070088 fCurrent = 0;
89 fMax = fDivisions + 1;
caryclark5ba2b962016-01-26 17:02:30 -080090 Sk2s h = Sk2s(1.f / fDivisions);
91 Sk2s h2 = h * h;
92 Sk2s h3 = h2 * h;
93 Sk2s fwDiff3 = Sk2s(6) * fCoefs.fA * h3;
94 fFwDiff[3] = to_point(fwDiff3);
95 fFwDiff[2] = to_point(fwDiff3 + times_2(fCoefs.fB) * h2);
96 fFwDiff[1] = to_point(fCoefs.fA * h3 + fCoefs.fB * h2 + fCoefs.fC * h);
97 fFwDiff[0] = to_point(fCoefs.fD);
dandovb3c9d1c2014-08-12 08:34:29 -070098 }
halcanary9d524f22016-03-29 09:03:52 -070099
dandovb3c9d1c2014-08-12 08:34:29 -0700100 /**
101 * Check if the evaluator is still within the range of 0<=t<=1
102 */
103 bool done() const {
104 return fCurrent > fMax;
105 }
halcanary9d524f22016-03-29 09:03:52 -0700106
dandovb3c9d1c2014-08-12 08:34:29 -0700107 /**
108 * Call next to obtain the SkPoint sampled and move to the next one.
109 */
110 SkPoint next() {
111 SkPoint point = fFwDiff[0];
112 fFwDiff[0] += fFwDiff[1];
113 fFwDiff[1] += fFwDiff[2];
114 fFwDiff[2] += fFwDiff[3];
115 fCurrent++;
116 return point;
117 }
halcanary9d524f22016-03-29 09:03:52 -0700118
dandovb3c9d1c2014-08-12 08:34:29 -0700119 const SkPoint* getCtrlPoints() const {
120 return fPoints;
121 }
halcanary9d524f22016-03-29 09:03:52 -0700122
dandovb3c9d1c2014-08-12 08:34:29 -0700123private:
caryclark5ba2b962016-01-26 17:02:30 -0800124 SkCubicCoeff fCoefs;
dandovb3c9d1c2014-08-12 08:34:29 -0700125 int fMax, fCurrent, fDivisions;
caryclark5ba2b962016-01-26 17:02:30 -0800126 SkPoint fFwDiff[4], fPoints[4];
dandovb3c9d1c2014-08-12 08:34:29 -0700127};
128
129////////////////////////////////////////////////////////////////////////////////
130
dandovecfff212014-08-04 10:02:00 -0700131// size in pixels of each partition per axis, adjust this knob
dandovb3c9d1c2014-08-12 08:34:29 -0700132static const int kPartitionSize = 10;
dandovecfff212014-08-04 10:02:00 -0700133
134/**
Mike Reedf4f06ad2018-05-02 15:11:42 -0400135 * Calculate the approximate arc length given a bezier curve's control points.
136 * Returns -1 if bad calc (i.e. non-finite)
dandovecfff212014-08-04 10:02:00 -0700137 */
Mike Reedf4f06ad2018-05-02 15:11:42 -0400138static SkScalar approx_arc_length(const SkPoint points[], int count) {
dandovecfff212014-08-04 10:02:00 -0700139 if (count < 2) {
140 return 0;
141 }
142 SkScalar arcLength = 0;
143 for (int i = 0; i < count - 1; i++) {
144 arcLength += SkPoint::Distance(points[i], points[i + 1]);
145 }
Mike Reedf4f06ad2018-05-02 15:11:42 -0400146 return SkScalarIsFinite(arcLength) ? arcLength : -1;
dandovecfff212014-08-04 10:02:00 -0700147}
148
dandovb3c9d1c2014-08-12 08:34:29 -0700149static SkScalar bilerp(SkScalar tx, SkScalar ty, SkScalar c00, SkScalar c10, SkScalar c01,
Mike Reed435071e2017-05-23 11:22:56 -0400150 SkScalar c11) {
dandovb3c9d1c2014-08-12 08:34:29 -0700151 SkScalar a = c00 * (1.f - tx) + c10 * tx;
152 SkScalar b = c01 * (1.f - tx) + c11 * tx;
153 return a * (1.f - ty) + b * ty;
154}
155
Mike Reed435071e2017-05-23 11:22:56 -0400156static Sk4f bilerp(SkScalar tx, SkScalar ty,
157 const Sk4f& c00, const Sk4f& c10, const Sk4f& c01, const Sk4f& c11) {
158 Sk4f a = c00 * (1.f - tx) + c10 * tx;
159 Sk4f b = c01 * (1.f - tx) + c11 * tx;
160 return a * (1.f - ty) + b * ty;
161}
162
dandovb3c9d1c2014-08-12 08:34:29 -0700163SkISize SkPatchUtils::GetLevelOfDetail(const SkPoint cubics[12], const SkMatrix* matrix) {
dandovecfff212014-08-04 10:02:00 -0700164 // Approximate length of each cubic.
dandovb3c9d1c2014-08-12 08:34:29 -0700165 SkPoint pts[kNumPtsCubic];
Mike Reed4ebb43e2017-04-05 11:06:15 -0400166 SkPatchUtils::GetTopCubic(cubics, pts);
dandovb3c9d1c2014-08-12 08:34:29 -0700167 matrix->mapPoints(pts, kNumPtsCubic);
168 SkScalar topLength = approx_arc_length(pts, kNumPtsCubic);
halcanary9d524f22016-03-29 09:03:52 -0700169
Mike Reed4ebb43e2017-04-05 11:06:15 -0400170 SkPatchUtils::GetBottomCubic(cubics, pts);
dandovb3c9d1c2014-08-12 08:34:29 -0700171 matrix->mapPoints(pts, kNumPtsCubic);
172 SkScalar bottomLength = approx_arc_length(pts, kNumPtsCubic);
halcanary9d524f22016-03-29 09:03:52 -0700173
Mike Reed4ebb43e2017-04-05 11:06:15 -0400174 SkPatchUtils::GetLeftCubic(cubics, pts);
dandovb3c9d1c2014-08-12 08:34:29 -0700175 matrix->mapPoints(pts, kNumPtsCubic);
176 SkScalar leftLength = approx_arc_length(pts, kNumPtsCubic);
halcanary9d524f22016-03-29 09:03:52 -0700177
Mike Reed4ebb43e2017-04-05 11:06:15 -0400178 SkPatchUtils::GetRightCubic(cubics, pts);
dandovb3c9d1c2014-08-12 08:34:29 -0700179 matrix->mapPoints(pts, kNumPtsCubic);
180 SkScalar rightLength = approx_arc_length(pts, kNumPtsCubic);
halcanary9d524f22016-03-29 09:03:52 -0700181
Mike Reedf4f06ad2018-05-02 15:11:42 -0400182 if (topLength < 0 || bottomLength < 0 || leftLength < 0 || rightLength < 0) {
183 return {0, 0}; // negative length is a sentinel for bad length (i.e. non-finite)
184 }
185
dandovecfff212014-08-04 10:02:00 -0700186 // Level of detail per axis, based on the larger side between top and bottom or left and right
Brian Osman116b33e2020-02-05 13:34:09 -0500187 int lodX = static_cast<int>(std::max(topLength, bottomLength) / kPartitionSize);
188 int lodY = static_cast<int>(std::max(leftLength, rightLength) / kPartitionSize);
halcanary9d524f22016-03-29 09:03:52 -0700189
Brian Osman7f364052020-02-06 11:25:43 -0500190 return SkISize::Make(std::max(8, lodX), std::max(8, lodY));
dandovb3c9d1c2014-08-12 08:34:29 -0700191}
192
Mike Reed4ebb43e2017-04-05 11:06:15 -0400193void SkPatchUtils::GetTopCubic(const SkPoint cubics[12], SkPoint points[4]) {
dandovb3c9d1c2014-08-12 08:34:29 -0700194 points[0] = cubics[kTopP0_CubicCtrlPts];
195 points[1] = cubics[kTopP1_CubicCtrlPts];
196 points[2] = cubics[kTopP2_CubicCtrlPts];
197 points[3] = cubics[kTopP3_CubicCtrlPts];
198}
199
Mike Reed4ebb43e2017-04-05 11:06:15 -0400200void SkPatchUtils::GetBottomCubic(const SkPoint cubics[12], SkPoint points[4]) {
dandovb3c9d1c2014-08-12 08:34:29 -0700201 points[0] = cubics[kBottomP0_CubicCtrlPts];
202 points[1] = cubics[kBottomP1_CubicCtrlPts];
203 points[2] = cubics[kBottomP2_CubicCtrlPts];
204 points[3] = cubics[kBottomP3_CubicCtrlPts];
205}
206
Mike Reed4ebb43e2017-04-05 11:06:15 -0400207void SkPatchUtils::GetLeftCubic(const SkPoint cubics[12], SkPoint points[4]) {
dandovb3c9d1c2014-08-12 08:34:29 -0700208 points[0] = cubics[kLeftP0_CubicCtrlPts];
209 points[1] = cubics[kLeftP1_CubicCtrlPts];
210 points[2] = cubics[kLeftP2_CubicCtrlPts];
211 points[3] = cubics[kLeftP3_CubicCtrlPts];
212}
213
Mike Reed4ebb43e2017-04-05 11:06:15 -0400214void SkPatchUtils::GetRightCubic(const SkPoint cubics[12], SkPoint points[4]) {
dandovb3c9d1c2014-08-12 08:34:29 -0700215 points[0] = cubics[kRightP0_CubicCtrlPts];
216 points[1] = cubics[kRightP1_CubicCtrlPts];
217 points[2] = cubics[kRightP2_CubicCtrlPts];
218 points[3] = cubics[kRightP3_CubicCtrlPts];
219}
220
Brian Osman358558a2018-09-21 16:49:55 -0400221static void skcolor_to_float(SkPMColor4f* dst, const SkColor* src, int count, SkColorSpace* dstCS) {
222 SkImageInfo srcInfo = SkImageInfo::Make(count, 1, kBGRA_8888_SkColorType,
223 kUnpremul_SkAlphaType, SkColorSpace::MakeSRGB());
224 SkImageInfo dstInfo = SkImageInfo::Make(count, 1, kRGBA_F32_SkColorType,
225 kPremul_SkAlphaType, sk_ref_sp(dstCS));
Brian Salomonc24c8ef2021-02-01 13:32:30 -0500226 SkAssertResult(SkConvertPixels(dstInfo, dst, 0, srcInfo, src, 0));
Mike Reed435071e2017-05-23 11:22:56 -0400227}
228
Brian Osman358558a2018-09-21 16:49:55 -0400229static void float_to_skcolor(SkColor* dst, const SkPMColor4f* src, int count, SkColorSpace* srcCS) {
230 SkImageInfo srcInfo = SkImageInfo::Make(count, 1, kRGBA_F32_SkColorType,
231 kPremul_SkAlphaType, sk_ref_sp(srcCS));
232 SkImageInfo dstInfo = SkImageInfo::Make(count, 1, kBGRA_8888_SkColorType,
233 kUnpremul_SkAlphaType, SkColorSpace::MakeSRGB());
Brian Salomonc24c8ef2021-02-01 13:32:30 -0500234 SkAssertResult(SkConvertPixels(dstInfo, dst, 0, srcInfo, src, 0));
Mike Reed435071e2017-05-23 11:22:56 -0400235}
236
Mike Reed795c5ea2017-03-17 14:29:05 -0400237sk_sp<SkVertices> SkPatchUtils::MakeVertices(const SkPoint cubics[12], const SkColor srcColors[4],
Mike Reed435071e2017-05-23 11:22:56 -0400238 const SkPoint srcTexCoords[4], int lodX, int lodY,
Brian Osmane0a99622018-07-09 16:12:27 -0400239 SkColorSpace* colorSpace) {
Mike Reed795c5ea2017-03-17 14:29:05 -0400240 if (lodX < 1 || lodY < 1 || nullptr == cubics) {
241 return nullptr;
242 }
243
244 // check for overflow in multiplication
245 const int64_t lodX64 = (lodX + 1),
246 lodY64 = (lodY + 1),
247 mult64 = lodX64 * lodY64;
248 if (mult64 > SK_MaxS32) {
249 return nullptr;
250 }
251
Mike Kleine28a6b52018-07-25 13:05:17 -0400252 // Treat null interpolation space as sRGB.
Brian Osmane0a99622018-07-09 16:12:27 -0400253 if (!colorSpace) {
Mike Kleine28a6b52018-07-25 13:05:17 -0400254 colorSpace = sk_srgb_singleton();
Brian Osmane0a99622018-07-09 16:12:27 -0400255 }
256
Mike Reed795c5ea2017-03-17 14:29:05 -0400257 int vertexCount = SkToS32(mult64);
258 // it is recommended to generate draw calls of no more than 65536 indices, so we never generate
259 // more than 60000 indices. To accomplish that we resize the LOD and vertex count
260 if (vertexCount > 10000 || lodX > 200 || lodY > 200) {
261 float weightX = static_cast<float>(lodX) / (lodX + lodY);
262 float weightY = static_cast<float>(lodY) / (lodX + lodY);
263
264 // 200 comes from the 100 * 2 which is the max value of vertices because of the limit of
265 // 60000 indices ( sqrt(60000 / 6) that comes from data->fIndexCount = lodX * lodY * 6)
Mike Reed70bebb02018-05-09 14:07:21 -0400266 // Need a min of 1 since we later divide by lod
267 lodX = std::max(1, sk_float_floor2int_no_saturate(weightX * 200));
268 lodY = std::max(1, sk_float_floor2int_no_saturate(weightY * 200));
Mike Reed795c5ea2017-03-17 14:29:05 -0400269 vertexCount = (lodX + 1) * (lodY + 1);
270 }
271 const int indexCount = lodX * lodY * 6;
272 uint32_t flags = 0;
273 if (srcTexCoords) {
274 flags |= SkVertices::kHasTexCoords_BuilderFlag;
275 }
276 if (srcColors) {
277 flags |= SkVertices::kHasColors_BuilderFlag;
278 }
279
Florin Malita14a64302017-05-24 14:53:44 -0400280 SkSTArenaAlloc<2048> alloc;
Brian Osmand25b7c12018-09-21 16:01:59 -0400281 SkPMColor4f* cornerColors = srcColors ? alloc.makeArray<SkPMColor4f>(4) : nullptr;
282 SkPMColor4f* tmpColors = srcColors ? alloc.makeArray<SkPMColor4f>(vertexCount) : nullptr;
Mike Reed435071e2017-05-23 11:22:56 -0400283
Mike Reed887cdf12017-04-03 11:11:09 -0400284 SkVertices::Builder builder(SkVertices::kTriangles_VertexMode, vertexCount, indexCount, flags);
Mike Reed795c5ea2017-03-17 14:29:05 -0400285 SkPoint* pos = builder.positions();
286 SkPoint* texs = builder.texCoords();
Mike Reed795c5ea2017-03-17 14:29:05 -0400287 uint16_t* indices = builder.indices();
288
Mike Reed435071e2017-05-23 11:22:56 -0400289 if (cornerColors) {
Brian Osman358558a2018-09-21 16:49:55 -0400290 skcolor_to_float(cornerColors, srcColors, kNumCorners, colorSpace);
Mike Reed795c5ea2017-03-17 14:29:05 -0400291 }
292
293 SkPoint pts[kNumPtsCubic];
Mike Reed4ebb43e2017-04-05 11:06:15 -0400294 SkPatchUtils::GetBottomCubic(cubics, pts);
Mike Reed795c5ea2017-03-17 14:29:05 -0400295 FwDCubicEvaluator fBottom(pts);
Mike Reed4ebb43e2017-04-05 11:06:15 -0400296 SkPatchUtils::GetTopCubic(cubics, pts);
Mike Reed795c5ea2017-03-17 14:29:05 -0400297 FwDCubicEvaluator fTop(pts);
Mike Reed4ebb43e2017-04-05 11:06:15 -0400298 SkPatchUtils::GetLeftCubic(cubics, pts);
Mike Reed795c5ea2017-03-17 14:29:05 -0400299 FwDCubicEvaluator fLeft(pts);
Mike Reed4ebb43e2017-04-05 11:06:15 -0400300 SkPatchUtils::GetRightCubic(cubics, pts);
Mike Reed795c5ea2017-03-17 14:29:05 -0400301 FwDCubicEvaluator fRight(pts);
302
303 fBottom.restart(lodX);
304 fTop.restart(lodX);
305
306 SkScalar u = 0.0f;
307 int stride = lodY + 1;
308 for (int x = 0; x <= lodX; x++) {
309 SkPoint bottom = fBottom.next(), top = fTop.next();
310 fLeft.restart(lodY);
311 fRight.restart(lodY);
312 SkScalar v = 0.f;
313 for (int y = 0; y <= lodY; y++) {
314 int dataIndex = x * (lodY + 1) + y;
315
316 SkPoint left = fLeft.next(), right = fRight.next();
317
318 SkPoint s0 = SkPoint::Make((1.0f - v) * top.x() + v * bottom.x(),
319 (1.0f - v) * top.y() + v * bottom.y());
320 SkPoint s1 = SkPoint::Make((1.0f - u) * left.x() + u * right.x(),
321 (1.0f - u) * left.y() + u * right.y());
322 SkPoint s2 = SkPoint::Make(
323 (1.0f - v) * ((1.0f - u) * fTop.getCtrlPoints()[0].x()
324 + u * fTop.getCtrlPoints()[3].x())
325 + v * ((1.0f - u) * fBottom.getCtrlPoints()[0].x()
326 + u * fBottom.getCtrlPoints()[3].x()),
327 (1.0f - v) * ((1.0f - u) * fTop.getCtrlPoints()[0].y()
328 + u * fTop.getCtrlPoints()[3].y())
329 + v * ((1.0f - u) * fBottom.getCtrlPoints()[0].y()
330 + u * fBottom.getCtrlPoints()[3].y()));
331 pos[dataIndex] = s0 + s1 - s2;
332
Mike Reed435071e2017-05-23 11:22:56 -0400333 if (cornerColors) {
Brian Osman81cbd032018-09-21 11:09:15 -0400334 bilerp(u, v, Sk4f::Load(cornerColors[kTopLeft_Corner].vec()),
335 Sk4f::Load(cornerColors[kTopRight_Corner].vec()),
336 Sk4f::Load(cornerColors[kBottomLeft_Corner].vec()),
337 Sk4f::Load(cornerColors[kBottomRight_Corner].vec()))
338 .store(tmpColors[dataIndex].vec());
Mike Reed795c5ea2017-03-17 14:29:05 -0400339 }
340
341 if (texs) {
342 texs[dataIndex] = SkPoint::Make(bilerp(u, v, srcTexCoords[kTopLeft_Corner].x(),
343 srcTexCoords[kTopRight_Corner].x(),
344 srcTexCoords[kBottomLeft_Corner].x(),
345 srcTexCoords[kBottomRight_Corner].x()),
346 bilerp(u, v, srcTexCoords[kTopLeft_Corner].y(),
347 srcTexCoords[kTopRight_Corner].y(),
348 srcTexCoords[kBottomLeft_Corner].y(),
349 srcTexCoords[kBottomRight_Corner].y()));
350
351 }
352
353 if(x < lodX && y < lodY) {
354 int i = 6 * (x * lodY + y);
355 indices[i] = x * stride + y;
356 indices[i + 1] = x * stride + 1 + y;
357 indices[i + 2] = (x + 1) * stride + 1 + y;
358 indices[i + 3] = indices[i];
359 indices[i + 4] = indices[i + 2];
360 indices[i + 5] = (x + 1) * stride + y;
361 }
Brian Osmanaba642c2020-02-06 12:52:25 -0500362 v = SkTPin(v + 1.f / lodY, 0.0f, 1.0f);
Mike Reed795c5ea2017-03-17 14:29:05 -0400363 }
Brian Osmanaba642c2020-02-06 12:52:25 -0500364 u = SkTPin(u + 1.f / lodX, 0.0f, 1.0f);
Mike Reed795c5ea2017-03-17 14:29:05 -0400365 }
Mike Reed435071e2017-05-23 11:22:56 -0400366
367 if (tmpColors) {
Brian Osmane0a99622018-07-09 16:12:27 -0400368 float_to_skcolor(builder.colors(), tmpColors, vertexCount, colorSpace);
Mike Reed435071e2017-05-23 11:22:56 -0400369 }
Mike Reed795c5ea2017-03-17 14:29:05 -0400370 return builder.detach();
371}