1 /*
2 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
35 * Note that some implementations may function more efficiently
36 * if they can maintain control over how the data for an image is
37 * stored.
38 * For example, optimizations such as caching an image in video
39 * memory require that the implementation track all modifications
40 * to that data.
41 * Other implementations may operate better if they can store the
42 * data in locations other than a Java array.
43 * To maintain optimum compatibility with various optimizations
44 * it is best to avoid constructors and methods which expose the
45 * underlying storage as a Java array as noted below in the
46 * documentation for those methods.
47 * </a>
48 *
49 * @since 1.4
50 */
51
52 public final class DataBufferFloat extends DataBuffer {
53
54 /** The array of data banks. */
55 float bankdata[][];
56
57 /** A reference to the default data bank. */
58 float data[];
59
60 /**
61 * Constructs a {@code float}-based {@code DataBuffer}
62 * with a specified size.
63 *
64 * @param size The number of elements in the DataBuffer.
65 */
66 public DataBufferFloat(int size) {
67 super(STABLE, TYPE_FLOAT, size);
68 data = new float[size];
69 bankdata = new float[1][];
70 bankdata[0] = data;
71 }
72
73 /**
74 * Constructs a {@code float}-based {@code DataBuffer}
75 * with a specified number of banks, all of which are of a
76 * specified size.
77 *
78 * @param size The number of elements in each bank of the
88 }
89 data = bankdata[0];
90 }
91
92 /**
93 * Constructs a {@code float}-based {@code DataBuffer}
94 * with the specified data array. Only the first
95 * {@code size} elements are available for use by this
96 * {@code DataBuffer}. The array must be large enough to
97 * hold {@code size} elements.
98 * <p>
99 * Note that {@code DataBuffer} objects created by this constructor
100 * may be incompatible with <a href="#optimizations">performance
101 * optimizations</a> used by some implementations (such as caching
102 * an associated image in video memory).
103 *
104 * @param dataArray An array of {@code float}s to be used as the
105 * first and only bank of this {@code DataBuffer}.
106 * @param size The number of elements of the array to be used.
107 */
108 public DataBufferFloat(float dataArray[], int size) {
109 super(UNTRACKABLE, TYPE_FLOAT, size);
110 data = dataArray;
111 bankdata = new float[1][];
112 bankdata[0] = data;
113 }
114
115 /**
116 * Constructs a {@code float}-based {@code DataBuffer}
117 * with the specified data array. Only the elements between
118 * {@code offset} and {@code offset + size - 1} are
119 * available for use by this {@code DataBuffer}. The array
120 * must be large enough to hold {@code offset + size}
121 * elements.
122 * <p>
123 * Note that {@code DataBuffer} objects created by this constructor
124 * may be incompatible with <a href="#optimizations">performance
125 * optimizations</a> used by some implementations (such as caching
126 * an associated image in video memory).
127 *
128 * @param dataArray An array of {@code float}s to be used as the
129 * first and only bank of this {@code DataBuffer}.
130 * @param size The number of elements of the array to be used.
131 * @param offset The offset of the first element of the array
132 * that will be used.
133 */
134 public DataBufferFloat(float dataArray[], int size, int offset) {
135 super(UNTRACKABLE, TYPE_FLOAT, size, 1, offset);
136 data = dataArray;
137 bankdata = new float[1][];
138 bankdata[0] = data;
139 }
140
141 /**
142 * Constructs a {@code float}-based {@code DataBuffer}
143 * with the specified data arrays. Only the first
144 * {@code size} elements of each array are available for use
145 * by this {@code DataBuffer}. The number of banks will be
146 * equal to {@code dataArray.length}.
147 * <p>
148 * Note that {@code DataBuffer} objects created by this constructor
149 * may be incompatible with <a href="#optimizations">performance
150 * optimizations</a> used by some implementations (such as caching
151 * an associated image in video memory).
152 *
153 * @param dataArray An array of arrays of {@code float}s to be
154 * used as the banks of this {@code DataBuffer}.
155 * @param size The number of elements of each array to be used.
156 */
157 public DataBufferFloat(float dataArray[][], int size) {
158 super(UNTRACKABLE, TYPE_FLOAT, size, dataArray.length);
159 bankdata = dataArray.clone();
160 data = bankdata[0];
161 }
162
163 /**
164 * Constructs a {@code float}-based {@code DataBuffer}
165 * with the specified data arrays, size, and per-bank offsets.
166 * The number of banks is equal to {@code dataArray.length}.
167 * Each array must be at least as large as {@code size} plus the
168 * corresponding offset. There must be an entry in the offsets
169 * array for each data array.
170 * <p>
171 * Note that {@code DataBuffer} objects created by this constructor
172 * may be incompatible with <a href="#optimizations">performance
173 * optimizations</a> used by some implementations (such as caching
174 * an associated image in video memory).
175 *
176 * @param dataArray An array of arrays of {@code float}s to be
177 * used as the banks of this {@code DataBuffer}.
178 * @param size The number of elements of each array to be used.
179 * @param offsets An array of integer offsets, one for each bank.
180 */
181 public DataBufferFloat(float dataArray[][], int size, int offsets[]) {
182 super(UNTRACKABLE, TYPE_FLOAT, size,dataArray.length, offsets);
183 bankdata = dataArray.clone();
184 data = bankdata[0];
185 }
186
187 /**
188 * Returns the default (first) {@code float} data array.
189 * <p>
190 * Note that calling this method may cause this {@code DataBuffer}
191 * object to be incompatible with <a href="#optimizations">performance
192 * optimizations</a> used by some implementations (such as caching
193 * an associated image in video memory).
194 *
195 * @return the first float data array.
196 */
197 public float[] getData() {
198 theTrackable.setUntrackable();
199 return data;
200 }
201
|
1 /*
2 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
35 * Note that some implementations may function more efficiently
36 * if they can maintain control over how the data for an image is
37 * stored.
38 * For example, optimizations such as caching an image in video
39 * memory require that the implementation track all modifications
40 * to that data.
41 * Other implementations may operate better if they can store the
42 * data in locations other than a Java array.
43 * To maintain optimum compatibility with various optimizations
44 * it is best to avoid constructors and methods which expose the
45 * underlying storage as a Java array as noted below in the
46 * documentation for those methods.
47 * </a>
48 *
49 * @since 1.4
50 */
51
52 public final class DataBufferFloat extends DataBuffer {
53
54 /** The array of data banks. */
55 float[][] bankdata;
56
57 /** A reference to the default data bank. */
58 float[] data;
59
60 /**
61 * Constructs a {@code float}-based {@code DataBuffer}
62 * with a specified size.
63 *
64 * @param size The number of elements in the DataBuffer.
65 */
66 public DataBufferFloat(int size) {
67 super(STABLE, TYPE_FLOAT, size);
68 data = new float[size];
69 bankdata = new float[1][];
70 bankdata[0] = data;
71 }
72
73 /**
74 * Constructs a {@code float}-based {@code DataBuffer}
75 * with a specified number of banks, all of which are of a
76 * specified size.
77 *
78 * @param size The number of elements in each bank of the
88 }
89 data = bankdata[0];
90 }
91
92 /**
93 * Constructs a {@code float}-based {@code DataBuffer}
94 * with the specified data array. Only the first
95 * {@code size} elements are available for use by this
96 * {@code DataBuffer}. The array must be large enough to
97 * hold {@code size} elements.
98 * <p>
99 * Note that {@code DataBuffer} objects created by this constructor
100 * may be incompatible with <a href="#optimizations">performance
101 * optimizations</a> used by some implementations (such as caching
102 * an associated image in video memory).
103 *
104 * @param dataArray An array of {@code float}s to be used as the
105 * first and only bank of this {@code DataBuffer}.
106 * @param size The number of elements of the array to be used.
107 */
108 public DataBufferFloat(float[] dataArray, int size) {
109 super(UNTRACKABLE, TYPE_FLOAT, size);
110 data = dataArray;
111 bankdata = new float[1][];
112 bankdata[0] = data;
113 }
114
115 /**
116 * Constructs a {@code float}-based {@code DataBuffer}
117 * with the specified data array. Only the elements between
118 * {@code offset} and {@code offset + size - 1} are
119 * available for use by this {@code DataBuffer}. The array
120 * must be large enough to hold {@code offset + size}
121 * elements.
122 * <p>
123 * Note that {@code DataBuffer} objects created by this constructor
124 * may be incompatible with <a href="#optimizations">performance
125 * optimizations</a> used by some implementations (such as caching
126 * an associated image in video memory).
127 *
128 * @param dataArray An array of {@code float}s to be used as the
129 * first and only bank of this {@code DataBuffer}.
130 * @param size The number of elements of the array to be used.
131 * @param offset The offset of the first element of the array
132 * that will be used.
133 */
134 public DataBufferFloat(float[] dataArray, int size, int offset) {
135 super(UNTRACKABLE, TYPE_FLOAT, size, 1, offset);
136 data = dataArray;
137 bankdata = new float[1][];
138 bankdata[0] = data;
139 }
140
141 /**
142 * Constructs a {@code float}-based {@code DataBuffer}
143 * with the specified data arrays. Only the first
144 * {@code size} elements of each array are available for use
145 * by this {@code DataBuffer}. The number of banks will be
146 * equal to {@code dataArray.length}.
147 * <p>
148 * Note that {@code DataBuffer} objects created by this constructor
149 * may be incompatible with <a href="#optimizations">performance
150 * optimizations</a> used by some implementations (such as caching
151 * an associated image in video memory).
152 *
153 * @param dataArray An array of arrays of {@code float}s to be
154 * used as the banks of this {@code DataBuffer}.
155 * @param size The number of elements of each array to be used.
156 */
157 public DataBufferFloat(float[][] dataArray, int size) {
158 super(UNTRACKABLE, TYPE_FLOAT, size, dataArray.length);
159 bankdata = dataArray.clone();
160 data = bankdata[0];
161 }
162
163 /**
164 * Constructs a {@code float}-based {@code DataBuffer}
165 * with the specified data arrays, size, and per-bank offsets.
166 * The number of banks is equal to {@code dataArray.length}.
167 * Each array must be at least as large as {@code size} plus the
168 * corresponding offset. There must be an entry in the offsets
169 * array for each data array.
170 * <p>
171 * Note that {@code DataBuffer} objects created by this constructor
172 * may be incompatible with <a href="#optimizations">performance
173 * optimizations</a> used by some implementations (such as caching
174 * an associated image in video memory).
175 *
176 * @param dataArray An array of arrays of {@code float}s to be
177 * used as the banks of this {@code DataBuffer}.
178 * @param size The number of elements of each array to be used.
179 * @param offsets An array of integer offsets, one for each bank.
180 */
181 public DataBufferFloat(float[][] dataArray, int size, int[] offsets) {
182 super(UNTRACKABLE, TYPE_FLOAT, size,dataArray.length, offsets);
183 bankdata = dataArray.clone();
184 data = bankdata[0];
185 }
186
187 /**
188 * Returns the default (first) {@code float} data array.
189 * <p>
190 * Note that calling this method may cause this {@code DataBuffer}
191 * object to be incompatible with <a href="#optimizations">performance
192 * optimizations</a> used by some implementations (such as caching
193 * an associated image in video memory).
194 *
195 * @return the first float data array.
196 */
197 public float[] getData() {
198 theTrackable.setUntrackable();
199 return data;
200 }
201
|