Debian Codegraph @

rs/java/android/renderscript/ScriptIntrinsicResize.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package android.renderscript;
18
19 /**
20 * Intrinsic for performing a resize of a 2D allocation.
21 *
22 * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a
23 * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration
24 * guide</a> for the proposed alternatives.
25 */
26 @Deprecated
27 public final class ScriptIntrinsicResize extends ScriptIntrinsic {
28 private Allocation mInput;
29
30 private ScriptIntrinsicResize(long id, RenderScript rs) {
31 super(id, rs);
32 }
33
34 /**
35 * Supported elements types are {@link Element#U8}, {@link
36 * Element#U8_2}, {@link Element#U8_3}, {@link Element#U8_4}
37 * {@link Element#F32}, {@link Element#F32_2}, {@link
38 * Element#F32_3}, {@link Element#F32_4}
39 *
40 * @param rs The RenderScript context
41 *
42 * @return ScriptIntrinsicResize
43 */
44 public static ScriptIntrinsicResize create(RenderScript rs) {
45 long id = rs.nScriptIntrinsicCreate(12, 0);
46 ScriptIntrinsicResize si = new ScriptIntrinsicResize(id, rs);
47 return si;
48
49 }
50
51 /**
52 * Set the input of the resize.
53 * Must match the element type supplied during create.
54 *
55 * @param ain The input allocation.
56 */
57 public void setInput(Allocation ain) {
58 Element e = ain.getElement();
59 if (!e.isCompatible(Element.U8(mRS)) &&
60 !e.isCompatible(Element.U8_2(mRS)) &&
61 !e.isCompatible(Element.U8_3(mRS)) &&
62 !e.isCompatible(Element.U8_4(mRS)) &&
63 !e.isCompatible(Element.F32(mRS)) &&
64 !e.isCompatible(Element.F32_2(mRS)) &&
65 !e.isCompatible(Element.F32_3(mRS)) &&
66 !e.isCompatible(Element.F32_4(mRS))) {
67 throw new RSIllegalArgumentException("Unsupported element type.");
68 }
69
70 mInput = ain;
71 setVar(0, ain);
72 }
73
74 /**
75 * Get a FieldID for the input field of this intrinsic.
76 *
77 * @return Script.FieldID The FieldID object.
78 */
79 public Script.FieldID getFieldID_Input() {
80 return createFieldID(0, null);
81 }
82
83
84 /**
85 * Resize copy the input allocation to the output specified. The
86 * Allocation is rescaled if necessary using bi-cubic
87 * interpolation.
88 *
89 * @param aout Output allocation. Element type must match
90 * current input. Must not be same as input.
91 */
92 public void forEach_bicubic(Allocation aout) {
93 if (aout == mInput) {
94 throw new RSIllegalArgumentException("Output cannot be same as Input.");
95 }
96 forEach_bicubic(aout, null);
97 }
98
99 /**
100 * Resize copy the input allocation to the output specified. The
101 * Allocation is rescaled if necessary using bi-cubic
102 * interpolation.
103 *
104 * @param aout Output allocation. Element type must match
105 * current input.
106 * @param opt LaunchOptions for clipping
107 */
108 public void forEach_bicubic(Allocation aout, Script.LaunchOptions opt) {
109 forEach(0, (Allocation) null, aout, null, opt);
110 }
111
112 /**
113 * Get a KernelID for this intrinsic kernel.
114 *
115 * @return Script.KernelID The KernelID object.
116 */
117 public Script.KernelID getKernelID_bicubic() {
118 return createKernelID(0, 2, null, null);
119 }
120
121
122 }