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/opengl/OGLRenderer.java (1 of 18352 files). Show all

Unified · Split

java/pkg/sun/java2d/opengl/OGLRenderer.java+206−0
@@ -0,0 +1,206 @@
1/*
2 * Copyright (c) 2003, 2008, 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.opengl;
27
28import java.awt.Transparency;
29import java.awt.geom.Path2D;
30import sun.java2d.SunGraphics2D;
31import sun.java2d.loops.GraphicsPrimitive;
32import sun.java2d.pipe.BufferedRenderPipe;
33import sun.java2d.pipe.ParallelogramPipe;
34import sun.java2d.pipe.RenderQueue;
35import sun.java2d.pipe.SpanIterator;
36import static sun.java2d.pipe.BufferedOpCodes.*;
37
38class OGLRenderer extends BufferedRenderPipe {
39
40 OGLRenderer(RenderQueue rq) {
41 super(rq);
42 }
43
44 @Override
45 protected void validateContext(SunGraphics2D sg2d) {
46 int ctxflags =
47 sg2d.paint.getTransparency() == Transparency.OPAQUE ?
48 OGLContext.SRC_IS_OPAQUE : OGLContext.NO_CONTEXT_FLAGS;
49 OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
50 OGLContext.validateContext(dstData, dstData,
51 sg2d.getCompClip(), sg2d.composite,
52 null, sg2d.paint, sg2d, ctxflags);
53 }
54
55 @Override
56 protected void validateContextAA(SunGraphics2D sg2d) {
57 int ctxflags = OGLContext.NO_CONTEXT_FLAGS;
58 OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
59 OGLContext.validateContext(dstData, dstData,
60 sg2d.getCompClip(), sg2d.composite,
61 null, sg2d.paint, sg2d, ctxflags);
62 }
63
64 void copyArea(SunGraphics2D sg2d,
65 int x, int y, int w, int h, int dx, int dy)
66 {
67 rq.lock();
68 try {
69 int ctxflags =
70 sg2d.surfaceData.getTransparency() == Transparency.OPAQUE ?
71 OGLContext.SRC_IS_OPAQUE : OGLContext.NO_CONTEXT_FLAGS;
72 OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
73 OGLContext.validateContext(dstData, dstData,
74 sg2d.getCompClip(), sg2d.composite,
75 null, null, null, ctxflags);
76
77 rq.ensureCapacity(28);
78 buf.putInt(COPY_AREA);
79 buf.putInt(x).putInt(y).putInt(w).putInt(h);
80 buf.putInt(dx).putInt(dy);
81 } finally {
82 rq.unlock();
83 }
84 }
85
86 @Override
87 protected native void drawPoly(int[] xPoints, int[] yPoints,
88 int nPoints, boolean isClosed,
89 int transX, int transY);
90
91 OGLRenderer traceWrap() {
92 return new Tracer(this);
93 }
94
95 private class Tracer extends OGLRenderer {
96 private OGLRenderer oglr;
97 Tracer(OGLRenderer oglr) {
98 super(oglr.rq);
99 this.oglr = oglr;
100 }
101 public ParallelogramPipe getAAParallelogramPipe() {
102 final ParallelogramPipe realpipe = oglr.getAAParallelogramPipe();
103 return new ParallelogramPipe() {
104 public void fillParallelogram(SunGraphics2D sg2d,
105 double ux1, double uy1,
106 double ux2, double uy2,
107 double x, double y,
108 double dx1, double dy1,
109 double dx2, double dy2)
110 {
111 GraphicsPrimitive.tracePrimitive("OGLFillAAParallelogram");
112 realpipe.fillParallelogram(sg2d,
113 ux1, uy1, ux2, uy2,
114 x, y, dx1, dy1, dx2, dy2);
115 }
116 public void drawParallelogram(SunGraphics2D sg2d,
117 double ux1, double uy1,
118 double ux2, double uy2,
119 double x, double y,
120 double dx1, double dy1,
121 double dx2, double dy2,
122 double lw1, double lw2)
123 {
124 GraphicsPrimitive.tracePrimitive("OGLDrawAAParallelogram");
125 realpipe.drawParallelogram(sg2d,
126 ux1, uy1, ux2, uy2,
127 x, y, dx1, dy1, dx2, dy2,
128 lw1, lw2);
129 }
130 };
131 }
132 protected void validateContext(SunGraphics2D sg2d) {
133 oglr.validateContext(sg2d);
134 }
135 public void drawLine(SunGraphics2D sg2d,
136 int x1, int y1, int x2, int y2)
137 {
138 GraphicsPrimitive.tracePrimitive("OGLDrawLine");
139 oglr.drawLine(sg2d, x1, y1, x2, y2);
140 }
141 public void drawRect(SunGraphics2D sg2d, int x, int y, int w, int h) {
142 GraphicsPrimitive.tracePrimitive("OGLDrawRect");
143 oglr.drawRect(sg2d, x, y, w, h);
144 }
145 protected void drawPoly(SunGraphics2D sg2d,
146 int[] xPoints, int[] yPoints,
147 int nPoints, boolean isClosed)
148 {
149 GraphicsPrimitive.tracePrimitive("OGLDrawPoly");
150 oglr.drawPoly(sg2d, xPoints, yPoints, nPoints, isClosed);
151 }
152 public void fillRect(SunGraphics2D sg2d, int x, int y, int w, int h) {
153 GraphicsPrimitive.tracePrimitive("OGLFillRect");
154 oglr.fillRect(sg2d, x, y, w, h);
155 }
156 protected void drawPath(SunGraphics2D sg2d,
157 Path2D.Float p2df, int transx, int transy)
158 {
159 GraphicsPrimitive.tracePrimitive("OGLDrawPath");
160 oglr.drawPath(sg2d, p2df, transx, transy);
161 }
162 protected void fillPath(SunGraphics2D sg2d,
163 Path2D.Float p2df, int transx, int transy)
164 {
165 GraphicsPrimitive.tracePrimitive("OGLFillPath");
166 oglr.fillPath(sg2d, p2df, transx, transy);
167 }
168 protected void fillSpans(SunGraphics2D sg2d, SpanIterator si,
169 int transx, int transy)
170 {
171 GraphicsPrimitive.tracePrimitive("OGLFillSpans");
172 oglr.fillSpans(sg2d, si, transx, transy);
173 }
174 public void fillParallelogram(SunGraphics2D sg2d,
175 double ux1, double uy1,
176 double ux2, double uy2,
177 double x, double y,
178 double dx1, double dy1,
179 double dx2, double dy2)
180 {
181 GraphicsPrimitive.tracePrimitive("OGLFillParallelogram");
182 oglr.fillParallelogram(sg2d,
183 ux1, uy1, ux2, uy2,
184 x, y, dx1, dy1, dx2, dy2);
185 }
186 public void drawParallelogram(SunGraphics2D sg2d,
187 double ux1, double uy1,
188 double ux2, double uy2,
189 double x, double y,
190 double dx1, double dy1,
191 double dx2, double dy2,
192 double lw1, double lw2)
193 {
194 GraphicsPrimitive.tracePrimitive("OGLDrawParallelogram");
195 oglr.drawParallelogram(sg2d,
196 ux1, uy1, ux2, uy2,
197 x, y, dx1, dy1, dx2, dy2, lw1, lw2);
198 }
199 public void copyArea(SunGraphics2D sg2d,
200 int x, int y, int w, int h, int dx, int dy)
201 {
202 GraphicsPrimitive.tracePrimitive("OGLCopyArea");
203 oglr.copyArea(sg2d, x, y, w, h, dx, dy);
204 }
205 }
206}