Print this page
rev 54883 : JDK-8220154 Improve java2d rendering performance on macOS by using Metal framework
Split |
Close |
Expand all |
Collapse all |
--- old/src/java.desktop/share/classes/sun/java2d/loops/FillSpans.java
+++ new/src/java.desktop/share/classes/sun/java2d/loops/FillSpans.java
1 1 /*
2 2 * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation. Oracle designates this
8 8 * particular file as subject to the "Classpath" exception as provided
9 9 * by Oracle in the LICENSE file that accompanied this code.
10 10 *
11 11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 14 * version 2 for more details (a copy is included in the LICENSE file that
15 15 * accompanied this code).
16 16 *
17 17 * You should have received a copy of the GNU General Public License version
18 18 * 2 along with this work; if not, write to the Free Software Foundation,
19 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 20 *
21 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 22 * or visit www.oracle.com if you need additional information or have any
23 23 * questions.
24 24 */
25 25
26 26 /*
27 27 * @author Jim Graham
28 28 * @author Charlton Innovations, Inc.
29 29 */
30 30
31 31 package sun.java2d.loops;
32 32
33 33 import sun.java2d.loops.GraphicsPrimitive;
34 34 import sun.java2d.pipe.SpanIterator;
35 35 import sun.java2d.SunGraphics2D;
36 36 import sun.java2d.SurfaceData;
37 37
38 38 /**
39 39 * FillSpans
40 40 * 1) draw solid color onto destination surface
41 41 * 2) rectangular areas to fill come from SpanIterator
42 42 */
43 43 public class FillSpans extends GraphicsPrimitive
44 44 {
45 45 public static final String methodSignature = "FillSpans(...)".toString();
46 46
47 47 public static final int primTypeID = makePrimTypeID();
48 48
49 49 public static FillSpans locate(SurfaceType srctype,
50 50 CompositeType comptype,
51 51 SurfaceType dsttype)
52 52 {
53 53 return (FillSpans)
54 54 GraphicsPrimitiveMgr.locate(primTypeID,
55 55 srctype, comptype, dsttype);
56 56 }
57 57
58 58 protected FillSpans(SurfaceType srctype,
59 59 CompositeType comptype,
60 60 SurfaceType dsttype)
61 61 {
62 62 super(methodSignature, primTypeID, srctype, comptype, dsttype);
63 63 }
64 64
65 65 public FillSpans(long pNativePrim,
66 66 SurfaceType srctype,
67 67 CompositeType comptype,
68 68 SurfaceType dsttype)
69 69 {
70 70 super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);
71 71 }
72 72
73 73 private native void FillSpans(SunGraphics2D sg2d, SurfaceData dest,
74 74 int pixel, long pIterator, SpanIterator si);
75 75
76 76 /**
77 77 * All FillSpan implementors must have this invoker method
78 78 */
79 79 public void FillSpans(SunGraphics2D sg2d, SurfaceData dest,
80 80 SpanIterator si)
81 81 {
82 82 FillSpans(sg2d, dest, sg2d.pixel, si.getNativeIterator(), si);
83 83 }
84 84
85 85 public GraphicsPrimitive makePrimitive(SurfaceType srctype,
86 86 CompositeType comptype,
87 87 SurfaceType dsttype)
88 88 {
89 89 // REMIND: iterate with a FillRect primitive?
90 90 throw new InternalError("FillSpans not implemented for "+
91 91 srctype+" with "+comptype);
92 92 }
93 93
94 94 public GraphicsPrimitive traceWrap() {
95 95 return new TraceFillSpans(this);
96 96 }
97 97
98 98 private static class TraceFillSpans extends FillSpans {
99 99 FillSpans target;
100 100
101 101 public TraceFillSpans(FillSpans target) {
102 102 super(target.getSourceType(),
103 103 target.getCompositeType(),
104 104 target.getDestType());
↓ open down ↓ |
104 lines elided |
↑ open up ↑ |
105 105 this.target = target;
106 106 }
107 107
108 108 public GraphicsPrimitive traceWrap() {
109 109 return this;
110 110 }
111 111
112 112 public void FillSpans(SunGraphics2D sg2d, SurfaceData dest,
113 113 SpanIterator si)
114 114 {
115 - tracePrimitive(target);
115 + if ((traceflags & TRACEPTIME) == 0) {
116 + tracePrimitive(target);
117 + }
118 + long time = System.nanoTime();
116 119 target.FillSpans(sg2d, dest, si);
120 + tracePrimitiveTime(target, System.nanoTime() - time);
117 121 }
118 122 }
119 123 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX