Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SamplingOptions.java
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google Inc.
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
8package org.skia.jetski;
9
10public class SamplingOptions {
11 private FilterMode mFilter;
12 private MipmapMode mMipmap;
13 private float mCubicCoeffB,
14 mCubicCoeffC;
15 private boolean mUseCubic;
16
17 public enum FilterMode {
20 };
21
22 public enum MipmapMode {
26 }
27
28 public SamplingOptions() {
29 this(FilterMode.NEAREST);
30 }
31
33 this(f, MipmapMode.NONE);
34 }
35
37 mFilter = f;
38 mMipmap = m;
39 mUseCubic = false;
40 }
41
42 public SamplingOptions(float cubicCoeffB, float cubicCoeffC) {
43 mFilter = FilterMode.NEAREST;
44 mMipmap = MipmapMode.NONE;
45 mCubicCoeffB = cubicCoeffB;
46 mCubicCoeffC = cubicCoeffC;
47 mUseCubic = true;
48 }
49
50 public static SamplingOptions MITCHELL() {
51 return new SamplingOptions(1/3.0f, 1/3.0f);
52 }
53
54 public static SamplingOptions CATMULLROM() {
55 return new SamplingOptions(0.0f, 1/2.0f);
56 }
57
58 // package private
60 // Encode all options except coefficients in a bit field:
61 //
62 // b0 -> useCubic
63 // b1 -> filter
64 // b2,3 -> mipmap
65
66 int desc = mUseCubic ? 0x01 : 0x00;
67
68 switch (mFilter) {
69 case NEAREST:
70 break;
71 case LINEAR:
72 desc |= 0x02;
73 break;
74 }
75
76 switch (mMipmap) {
77 case NONE:
78 break;
79 case NEAREST:
80 desc |= 0x04;
81 break;
82 case LINEAR:
83 desc |= 0x08;
84 break;
85 }
86
87 return desc;
88 }
89
91 return mCubicCoeffB;
92 }
93
95 return mCubicCoeffC;
96 }
97}
static SamplingOptions MITCHELL()
static SamplingOptions CATMULLROM()
SamplingOptions(float cubicCoeffB, float cubicCoeffC)
SamplingOptions(FilterMode f, MipmapMode m)