1 /*
2 * Copyright (c) 2005, 2010, 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
23 * questions.
24 */
25
26 package sun.java2d.pipe;
27
28 import sun.misc.Unsafe;
29
30 import javax.tools.annotation.GenerateNativeHeader;
31
32 /**
33 * The RenderBuffer class is a simplified, high-performance, Unsafe wrapper
34 * used for buffering rendering operations in a single-threaded rendering
35 * environment. It's functionality is similar to the ByteBuffer and related
36 * NIO classes. However, the methods in this class perform little to no
37 * alignment or bounds checks for performance reasons. Therefore, it is
38 * the caller's responsibility to ensure that all put() calls are properly
39 * aligned and within bounds:
40 * - int and float values must be aligned on 4-byte boundaries
41 * - long and double values must be aligned on 8-byte boundaries
42 *
43 * This class only includes the bare minimum of methods to support
44 * single-threaded rendering. For example, there is no put(double[]) method
45 * because we currently have no need for such a method in the STR classes.
46 */
47 /* No native methods here, but the constants are needed in the supporting JNI code */
48 @GenerateNativeHeader
49 public class RenderBuffer {
50
51 /**
52 * These constants represent the size of various data types (in bytes).
53 */
54 protected static final long SIZEOF_BYTE = 1L;
55 protected static final long SIZEOF_SHORT = 2L;
56 protected static final long SIZEOF_INT = 4L;
57 protected static final long SIZEOF_FLOAT = 4L;
58 protected static final long SIZEOF_LONG = 8L;
59 protected static final long SIZEOF_DOUBLE = 8L;
60
61 /**
62 * Represents the number of elements at which we have empirically
63 * determined that the average cost of a JNI call exceeds the expense
64 * of an element by element copy. In other words, if the number of
65 * elements in an array to be copied exceeds this value, then we should
66 * use the copyFromArray() method to complete the bulk put operation.
67 * (This value can be adjusted if the cost of JNI downcalls is reduced
68 * in a future release.)
|
1 /*
2 * Copyright (c) 2005, 2013, 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
23 * questions.
24 */
25
26 package sun.java2d.pipe;
27
28 import sun.misc.Unsafe;
29
30
31 /**
32 * The RenderBuffer class is a simplified, high-performance, Unsafe wrapper
33 * used for buffering rendering operations in a single-threaded rendering
34 * environment. It's functionality is similar to the ByteBuffer and related
35 * NIO classes. However, the methods in this class perform little to no
36 * alignment or bounds checks for performance reasons. Therefore, it is
37 * the caller's responsibility to ensure that all put() calls are properly
38 * aligned and within bounds:
39 * - int and float values must be aligned on 4-byte boundaries
40 * - long and double values must be aligned on 8-byte boundaries
41 *
42 * This class only includes the bare minimum of methods to support
43 * single-threaded rendering. For example, there is no put(double[]) method
44 * because we currently have no need for such a method in the STR classes.
45 */
46 public class RenderBuffer {
47
48 /**
49 * These constants represent the size of various data types (in bytes).
50 */
51 protected static final long SIZEOF_BYTE = 1L;
52 protected static final long SIZEOF_SHORT = 2L;
53 protected static final long SIZEOF_INT = 4L;
54 protected static final long SIZEOF_FLOAT = 4L;
55 protected static final long SIZEOF_LONG = 8L;
56 protected static final long SIZEOF_DOUBLE = 8L;
57
58 /**
59 * Represents the number of elements at which we have empirically
60 * determined that the average cost of a JNI call exceeds the expense
61 * of an element by element copy. In other words, if the number of
62 * elements in an array to be copied exceeds this value, then we should
63 * use the copyFromArray() method to complete the bulk put operation.
64 * (This value can be adjusted if the cost of JNI downcalls is reduced
65 * in a future release.)
|