History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/sun/java2d/loops/ScaledBlit.java (1 of 18352 files). Show all

Unified · Split

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