Flutter Engine
The Flutter Engine
lib
web_ui
skwasm
helpers.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_LIB_WEB_UI_SKWASM_HELPERS_H_
6
#define FLUTTER_LIB_WEB_UI_SKWASM_HELPERS_H_
7
8
#include "
third_party/skia/include/core/SkMatrix.h
"
9
#include "
third_party/skia/include/core/SkRRect.h
"
10
#include "
third_party/skia/include/core/SkSamplingOptions.h
"
11
12
namespace
Skwasm
{
13
14
inline
SkMatrix
createMatrix
(
const
SkScalar
*
f
) {
15
return
SkMatrix::MakeAll
(
f
[0],
f
[1],
f
[2],
f
[3],
f
[4],
f
[5],
f
[6],
f
[7],
16
f
[8]);
17
}
18
19
inline
SkRRect
createRRect
(
const
SkScalar
*
f
) {
20
const
SkRect
*
rect
=
reinterpret_cast<
const
SkRect
*
>
(
f
);
21
const
SkVector
* radiiValues =
reinterpret_cast<
const
SkVector
*
>
(
f
+ 4);
22
23
SkRRect
rr;
24
rr.
setRectRadii
(*
rect
, radiiValues);
25
return
rr;
26
}
27
28
// This needs to be kept in sync with the "FilterQuality" enum in dart:ui
29
enum class
FilterQuality
{
30
none
,
31
low
,
32
medium
,
33
high
,
34
};
35
36
inline
SkFilterMode
filterModeForQuality
(
FilterQuality
quality) {
37
switch
(quality) {
38
case
FilterQuality::none
:
39
case
FilterQuality::low
:
40
return
SkFilterMode::kNearest
;
41
case
FilterQuality::medium
:
42
case
FilterQuality::high
:
43
return
SkFilterMode::kLinear
;
44
}
45
}
46
47
inline
SkSamplingOptions
samplingOptionsForQuality
(
FilterQuality
quality) {
48
switch
(quality) {
49
case
FilterQuality::none
:
50
return
SkSamplingOptions
(
SkFilterMode::kNearest
,
SkMipmapMode::kNone
);
51
case
FilterQuality::low
:
52
return
SkSamplingOptions
(
SkFilterMode::kLinear
,
SkMipmapMode::kNone
);
53
case
FilterQuality::medium
:
54
return
SkSamplingOptions
(
SkFilterMode::kLinear
,
SkMipmapMode::kLinear
);
55
case
FilterQuality::high
:
56
// Cubic equation coefficients recommended by Mitchell & Netravali
57
// in their paper on cubic interpolation.
58
return
SkSamplingOptions
(
SkCubicResampler::Mitchell
());
59
}
60
}
61
}
// namespace Skwasm
62
63
#endif
// FLUTTER_LIB_WEB_UI_SKWASM_HELPERS_H_
SkMatrix.h
SkRRect.h
SkSamplingOptions.h
SkFilterMode
SkFilterMode
Definition:
SkSamplingOptions.h:16
SkFilterMode::kLinear
@ kLinear
SkFilterMode::kNearest
@ kNearest
SkMipmapMode::kNone
@ kNone
SkMipmapMode::kLinear
@ kLinear
SkMatrix
Definition:
SkMatrix.h:54
SkMatrix::MakeAll
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
Definition:
SkMatrix.h:179
SkRRect
Definition:
SkRRect.h:35
SkRRect::setRectRadii
void setRectRadii(const SkRect &rect, const SkVector radii[4])
Definition:
SkRRect.cpp:189
SkScalar
float SkScalar
Definition:
extension.cpp:12
SkRecords::rect
sk_sp< SkBlender > blender SkRect rect
Definition:
SkRecords.h:350
Skwasm
Definition:
helpers.h:12
Skwasm::createRRect
SkRRect createRRect(const SkScalar *f)
Definition:
helpers.h:19
Skwasm::samplingOptionsForQuality
SkSamplingOptions samplingOptionsForQuality(FilterQuality quality)
Definition:
helpers.h:47
Skwasm::FilterQuality
FilterQuality
Definition:
helpers.h:29
Skwasm::FilterQuality::medium
@ medium
Skwasm::FilterQuality::none
@ none
Skwasm::FilterQuality::low
@ low
Skwasm::FilterQuality::high
@ high
Skwasm::filterModeForQuality
SkFilterMode filterModeForQuality(FilterQuality quality)
Definition:
helpers.h:36
Skwasm::createMatrix
SkMatrix createMatrix(const SkScalar *f)
Definition:
helpers.h:14
skcms_private::f
float f
Definition:
skcms_Transform.h:121
skiagm::SkSamplingOptions
SkSamplingOptions(SkFilterMode::kLinear))
SkCubicResampler::Mitchell
static constexpr SkCubicResampler Mitchell()
Definition:
SkSamplingOptions.h:54
SkPoint
Definition:
SkPoint_impl.h:163
SkRect
Definition:
extension.cpp:13
SkSamplingOptions
Definition:
SkSamplingOptions.h:58
Generated on Sun Jun 23 2024 21:55:06 for Flutter Engine by
1.9.4