Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: src/utils/SkPatchUtils.cpp

Issue 424663006: SkCanvas interface for drawing a patch. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Renamed static functions Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/core/SkGeometry.h ('K') | « src/utils/SkDeferredCanvas.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "SkPatchUtils.h"
9
10 #include "SkGeometry.h"
11
12 SkIPoint SkPatchUtils::GetLevelOfDetail(const SkPatch& patch, const SkMatrix* ma trix) {
13
14 SkPoint mapPts[12];
15 matrix->mapPoints(mapPts, patch.getControlPoints(), 12);
16
17 // Approximate length of each cubic.
18 SkPoint pts[4];
19 patch.getTopPoints(pts);
20 matrix->mapPoints(pts, 4);
21 int topLength = approx_arc_length(pts, 4);
22
23 patch.getBottomPoints(pts);
24 matrix->mapPoints(pts, 4);
25 int bottomLength = approx_arc_length(pts, 4);
26
27 patch.getLeftPoints(pts);
28 matrix->mapPoints(pts, 4);
29 int leftLength = approx_arc_length(pts, 4);
30
31 patch.getRightPoints(pts);
32 matrix->mapPoints(pts, 4);
33 int rightLength = approx_arc_length(pts, 4);
34
35 // Level of detail per axis, based on the larger side between top and bottom or left and right
36 int lodX = SkMaxScalar(topLength, bottomLength) / kPartitionSize;
37 int lodY = SkMaxScalar(leftLength, rightLength) / kPartitionSize;
38
39 return SkIPoint::Make(SkMax32(4, lodX), SkMax32(4, lodY));
40 }
OLDNEW
« src/core/SkGeometry.h ('K') | « src/utils/SkDeferredCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698