788b91678f
Use std::min and std::max everywhere. SkTPin still exists. We can't use std::clamp yet, and even when we can, it has undefined behavior with NaN. SkTPin is written to ensure that we return a value in the [lo, hi] range. Change-Id: I506852a36e024ae405358d5078a872e2c77fa71e Docs-Preview: https://skia.org/?cl=269357 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269357 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
26 lines
1.0 KiB
C++
26 lines
1.0 KiB
C++
// Copyright 2019 Google LLC.
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
#include "tools/fiddle/examples.h"
|
|
// HASH=2ec66880966a6133ddd9331ce7323438
|
|
REG_FIDDLE(Path_getVerbs, 256, 256, true, 0) {
|
|
void draw(SkCanvas* canvas) {
|
|
auto debugster = [](const char* prefix, const SkPath& path, uint8_t* verbs, int max) -> void {
|
|
int count = path.getVerbs(verbs, max);
|
|
SkDebugf("%s verb count: %d ", prefix, count);
|
|
const char* verbStr[] = { "move", "line", "quad", "conic", "cubic", "close" };
|
|
for (int i = 0; i < std::min(count, max) && verbs; ++i) {
|
|
SkDebugf("%s ", verbStr[verbs[i]]);
|
|
}
|
|
SkDebugf("\n");
|
|
};
|
|
SkPath path;
|
|
path.lineTo(20, 20);
|
|
path.lineTo(-10, -10);
|
|
uint8_t verbs[3];
|
|
debugster("no verbs", path, nullptr, 0);
|
|
debugster("zero max", path, verbs, 0);
|
|
debugster("too small", path, verbs, 2);
|
|
debugster("just right", path, verbs, path.countVerbs());
|
|
}
|
|
} // END FIDDLE
|