forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
display_list_sampling_options.h
64 lines (53 loc) · 1.84 KB
/
display_list_sampling_options.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_DISPLAY_LIST_DISPLAY_LIST_SAMPLING_OPTIONS_H_
#define FLUTTER_DISPLAY_LIST_DISPLAY_LIST_SAMPLING_OPTIONS_H_
#include "include/core/SkColorSpace.h"
#include "include/core/SkSamplingOptions.h"
namespace flutter {
enum class DlFilterMode {
kNearest, // single sample point (nearest neighbor)
kLinear, // interporate between 2x2 sample points (bilinear interpolation)
kLast = kLinear,
};
inline DlFilterMode ToDl(const SkFilterMode filter_mode) {
return static_cast<DlFilterMode>(filter_mode);
}
inline SkFilterMode ToSk(const DlFilterMode filter_mode) {
return static_cast<SkFilterMode>(filter_mode);
}
enum class DlImageSampling {
kNearestNeighbor,
kLinear,
kMipmapLinear,
kCubic,
};
inline DlImageSampling ToDl(const SkSamplingOptions& so) {
if (so.useCubic) {
return DlImageSampling::kCubic;
}
if (so.filter == SkFilterMode::kLinear) {
if (so.mipmap == SkMipmapMode::kNone) {
return DlImageSampling::kLinear;
}
if (so.mipmap == SkMipmapMode::kLinear) {
return DlImageSampling::kMipmapLinear;
}
}
return DlImageSampling::kNearestNeighbor;
}
inline SkSamplingOptions ToSk(DlImageSampling sampling) {
switch (sampling) {
case DlImageSampling::kCubic:
return SkSamplingOptions(SkCubicResampler{1 / 3.0f, 1 / 3.0f});
case DlImageSampling::kLinear:
return SkSamplingOptions(SkFilterMode::kLinear);
case DlImageSampling::kMipmapLinear:
return SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear);
case DlImageSampling::kNearestNeighbor:
return SkSamplingOptions(SkFilterMode::kNearest);
}
}
} // namespace flutter
#endif // FLUTTER_DISPLAY_LIST_DISPLAY_LIST_SAMPLING_OPTIONS_H_