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/ScaledBlit.java
+++ new/src/java.desktop/share/classes/sun/java2d/loops/ScaledBlit.java
1 1 /*
2 2 * Copyright (c) 2001, 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 package sun.java2d.loops;
27 27
28 28 import java.awt.Composite;
29 29 import sun.java2d.loops.GraphicsPrimitive;
30 30 import sun.java2d.SurfaceData;
31 31 import sun.java2d.pipe.Region;
32 32
33 33 /**
34 34 * ScaledBlit
35 35 * 1) copies rectangle of pixels from one surface to another
36 36 * while scaling the pixels to meet the sizes specified
37 37 * 2) performs compositing of colors based upon a Composite
38 38 * parameter
39 39 *
40 40 * precise behavior is undefined if the source surface
41 41 * and the destination surface are the same surface
42 42 * with overlapping regions of pixels
43 43 */
44 44
45 45 public class ScaledBlit extends GraphicsPrimitive
46 46 {
47 47 public static final String methodSignature = "ScaledBlit(...)".toString();
48 48
49 49 public static final int primTypeID = makePrimTypeID();
50 50
51 51 private static RenderCache blitcache = new RenderCache(20);
52 52
53 53 public static ScaledBlit locate(SurfaceType srctype,
54 54 CompositeType comptype,
55 55 SurfaceType dsttype)
56 56 {
57 57 return (ScaledBlit)
58 58 GraphicsPrimitiveMgr.locate(primTypeID,
59 59 srctype, comptype, dsttype);
60 60 }
61 61
62 62 public static ScaledBlit getFromCache(SurfaceType src,
63 63 CompositeType comp,
64 64 SurfaceType dst)
65 65 {
66 66 Object o = blitcache.get(src, comp, dst);
67 67 if (o != null) {
68 68 return (ScaledBlit) o;
69 69 }
70 70 ScaledBlit blit = locate(src, comp, dst);
71 71 if (blit == null) {
72 72 /*
73 73 System.out.println("blit loop not found for:");
74 74 System.out.println("src: "+src);
75 75 System.out.println("comp: "+comp);
76 76 System.out.println("dst: "+dst);
77 77 */
78 78 } else {
79 79 blitcache.put(src, comp, dst, blit);
80 80 }
81 81 return blit;
82 82 }
83 83
84 84 protected ScaledBlit(SurfaceType srctype,
85 85 CompositeType comptype,
86 86 SurfaceType dsttype)
87 87 {
88 88 super(methodSignature, primTypeID, srctype, comptype, dsttype);
89 89 }
90 90
91 91 public ScaledBlit(long pNativePrim,
92 92 SurfaceType srctype,
93 93 CompositeType comptype,
94 94 SurfaceType dsttype)
95 95 {
96 96 super(pNativePrim, methodSignature, primTypeID,
97 97 srctype, comptype, dsttype);
98 98 }
99 99
100 100 public native void Scale(SurfaceData src, SurfaceData dst,
101 101 Composite comp, Region clip,
102 102 int sx1, int sy1,
103 103 int sx2, int sy2,
104 104 double dx1, double dy1,
105 105 double dx2, double dy2);
106 106
107 107 static {
108 108 GraphicsPrimitiveMgr.registerGeneral(new ScaledBlit(null, null, null));
109 109 }
110 110
111 111 public GraphicsPrimitive makePrimitive(SurfaceType srctype,
112 112 CompositeType comptype,
113 113 SurfaceType dsttype)
114 114 {
115 115 /*
116 116 System.out.println("Constructing general blit for:");
117 117 System.out.println("src: "+srctype);
118 118 System.out.println("comp: "+comptype);
119 119 System.out.println("dst: "+dsttype);
120 120 */
121 121 return null;
122 122 }
123 123
124 124 public GraphicsPrimitive traceWrap() {
125 125 return new TraceScaledBlit(this);
126 126 }
127 127
128 128 private static class TraceScaledBlit extends ScaledBlit {
129 129 ScaledBlit target;
130 130
131 131 public TraceScaledBlit(ScaledBlit target) {
132 132 super(target.getSourceType(),
133 133 target.getCompositeType(),
134 134 target.getDestType());
135 135 this.target = target;
136 136 }
137 137
138 138 public GraphicsPrimitive traceWrap() {
↓ open down ↓ |
138 lines elided |
↑ open up ↑ |
139 139 return this;
140 140 }
141 141
142 142 public void Scale(SurfaceData src, SurfaceData dst,
143 143 Composite comp, Region clip,
144 144 int sx1, int sy1,
145 145 int sx2, int sy2,
146 146 double dx1, double dy1,
147 147 double dx2, double dy2)
148 148 {
149 - tracePrimitive(target);
149 + if ((traceflags & TRACEPTIME) == 0) {
150 + tracePrimitive(target);
151 + }
152 + long time = System.nanoTime();
150 153 target.Scale(src, dst, comp, clip,
151 154 sx1, sy1, sx2, sy2,
152 155 dx1, dy1, dx2, dy2);
156 + tracePrimitiveTime(target, System.nanoTime() - time);
153 157 }
154 158 }
155 159 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX