Flutter Engine
Loading...
Searching...
No Matches
range.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef FLUTTER_IMPELLER_CORE_RANGE_H_
6
#define FLUTTER_IMPELLER_CORE_RANGE_H_
7
8
#include <algorithm>
9
#include <cstddef>
10
11
namespace
impeller
{
12
13
struct
Range
{
14
size_t
offset
= 0;
15
size_t
length
= 0;
16
17
constexpr
Range
() {}
18
19
constexpr
Range
(
size_t
p_offset,
size_t
p_length)
20
:
offset
(p_offset),
length
(p_length) {}
21
22
constexpr
bool
operator==
(
const
Range
& o)
const
{
23
return
offset
== o.
offset
&&
length
== o.
length
;
24
}
25
26
/// @brief Create a new range that is a union of this range and other.
27
constexpr
Range
Merge
(
const
Range
& other) {
28
if
(other.
length
== 0) {
29
return
*
this
;
30
}
31
if
(
length
== 0) {
32
return
other;
33
}
34
auto
end_offset = std::max(
offset
+
length
, other.
offset
+ other.
length
);
35
auto
start_offset = std::min(
offset
, other.
offset
);
36
return
Range
{start_offset, end_offset - start_offset};
37
}
38
};
39
40
}
// namespace impeller
41
42
#endif
// FLUTTER_IMPELLER_CORE_RANGE_H_
impeller
Definition
texture.h:16
impeller::Range
Definition
range.h:13
impeller::Range::Range
constexpr Range()
Definition
range.h:17
impeller::Range::length
size_t length
Definition
range.h:15
impeller::Range::Range
constexpr Range(size_t p_offset, size_t p_length)
Definition
range.h:19
impeller::Range::offset
size_t offset
Definition
range.h:14
impeller::Range::Merge
constexpr Range Merge(const Range &other)
Create a new range that is a union of this range and other.
Definition
range.h:27
impeller::Range::operator==
constexpr bool operator==(const Range &o) const
Definition
range.h:22
impeller
core
range.h
Generated on Thu Nov 6 2025 16:11:30 for Flutter Engine by
1.9.8