Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
core
SkScalar.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2010 The Android Open Source Project
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 "
include/core/SkScalar.h
"
9
10
SkScalar
SkScalarInterpFunc
(
SkScalar
searchKey,
const
SkScalar
keys[],
11
const
SkScalar
values[],
int
length
) {
12
SkASSERT
(
length
> 0);
13
SkASSERT
(keys !=
nullptr
);
14
SkASSERT
(values !=
nullptr
);
15
#ifdef SK_DEBUG
16
for
(
int
i = 1; i <
length
; i++) {
17
SkASSERT
(keys[i-1] <= keys[i]);
18
}
19
#endif
20
int
right
= 0;
21
while
(
right
<
length
&& keys[
right
] < searchKey) {
22
++
right
;
23
}
24
// Could use sentinel values to eliminate conditionals, but since the
25
// tables are taken as input, a simpler format is better.
26
if
(
right
==
length
) {
27
return
values[
length
-1];
28
}
29
if
(
right
== 0) {
30
return
values[0];
31
}
32
// Otherwise, interpolate between right - 1 and right.
33
SkScalar
leftKey = keys[
right
-1];
34
SkScalar
rightKey = keys[
right
];
35
SkScalar
fract = (searchKey - leftKey) / (rightKey - leftKey);
36
return
SkScalarInterp
(values[
right
-1], values[
right
], fract);
37
}
SkASSERT
#define SkASSERT(cond)
Definition
SkAssert.h:116
right
static bool right(const SkPoint &p0, const SkPoint &p1)
Definition
SkPolyUtils.cpp:532
SkScalarInterpFunc
SkScalar SkScalarInterpFunc(SkScalar searchKey, const SkScalar keys[], const SkScalar values[], int length)
Definition
SkScalar.cpp:10
SkScalar.h
SkScalarInterp
static SkScalar SkScalarInterp(SkScalar A, SkScalar B, SkScalar t)
Definition
SkScalar.h:131
SkScalar
float SkScalar
Definition
extension.cpp:12
length
size_t length
Definition
key_event_handler.cc:41
Generated on Fri Apr 26 2024 06:16:48 for Flutter Engine by
1.9.8