Flutter Engine
The Flutter Engine
third_party
skia
src
sksl
SkSLPosition.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2022 Google LLC.
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 "
src/sksl/SkSLPosition.h
"
9
10
#include <algorithm>
11
12
namespace
SkSL
{
13
14
int
Position::line
(std::string_view
source
)
const
{
15
SkASSERT
(this->
valid
());
16
if
(fStartOffset == -1) {
17
return
-1;
18
}
19
if
(!
source
.data()) {
20
return
-1;
21
}
22
// we allow the offset to equal the length, because that's where TK_END_OF_FILE is reported
23
SkASSERT
(fStartOffset <= (
int
)
source
.length());
24
int
offset
=
std::min
(fStartOffset, (
int
)
source
.length());
25
int
line
= 1;
26
for
(
int
i
= 0;
i
<
offset
;
i
++) {
27
if
(
source
[
i
] ==
'\n'
) {
28
++
line
;
29
}
30
}
31
return
line
;
32
}
33
34
}
// namespace SkSL
SkASSERT
#define SkASSERT(cond)
Definition:
SkAssert.h:116
SkSLPosition.h
SkSL::Position::line
int line(std::string_view source) const
Definition:
SkSLPosition.cpp:14
SkSL::Position::valid
bool valid() const
Definition:
SkSLPosition.h:34
source
SkBitmap source
Definition:
examples.cpp:28
i
int i
Definition:
fl_socket_accessible.cc:18
min
static float min(float r, float g, float b)
Definition:
hsl.cpp:48
SkSL
Definition:
SkCapabilities.h:15
offset
SeparatedVector2 offset
Definition:
stroke_path_geometry.cc:311
Generated on Sun Jun 23 2024 21:56:35 for Flutter Engine by
1.9.4