001: /*
002: * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package sun.java2d.opengl;
027:
028: import java.awt.Transparency;
029: import java.awt.geom.Path2D;
030: import sun.java2d.SunGraphics2D;
031: import sun.java2d.loops.GraphicsPrimitive;
032: import sun.java2d.pipe.BufferedRenderPipe;
033: import sun.java2d.pipe.RenderQueue;
034: import sun.java2d.pipe.SpanIterator;
035: import static sun.java2d.pipe.BufferedOpCodes.*;
036:
037: class OGLRenderer extends BufferedRenderPipe {
038:
039: OGLRenderer(RenderQueue rq) {
040: super (rq);
041: }
042:
043: @Override
044: protected void validateContext(SunGraphics2D sg2d) {
045: int ctxflags = sg2d.paint.getTransparency() == Transparency.OPAQUE ? OGLContext.SRC_IS_OPAQUE
046: : OGLContext.NO_CONTEXT_FLAGS;
047: OGLSurfaceData dstData = (OGLSurfaceData) sg2d.surfaceData;
048: OGLContext.validateContext(dstData, dstData,
049: sg2d.getCompClip(), sg2d.composite, null, sg2d.paint,
050: sg2d, ctxflags);
051: }
052:
053: void copyArea(SunGraphics2D sg2d, int x, int y, int w, int h,
054: int dx, int dy) {
055: rq.lock();
056: try {
057: int ctxflags = sg2d.surfaceData.getTransparency() == Transparency.OPAQUE ? OGLContext.SRC_IS_OPAQUE
058: : OGLContext.NO_CONTEXT_FLAGS;
059: OGLSurfaceData dstData = (OGLSurfaceData) sg2d.surfaceData;
060: OGLContext.validateContext(dstData, dstData, sg2d
061: .getCompClip(), sg2d.composite, null, null, null,
062: ctxflags);
063:
064: rq.ensureCapacity(28);
065: buf.putInt(COPY_AREA);
066: buf.putInt(x).putInt(y).putInt(w).putInt(h);
067: buf.putInt(dx).putInt(dy);
068: } finally {
069: rq.unlock();
070: }
071: }
072:
073: @Override
074: protected native void drawPoly(int[] xPoints, int[] yPoints,
075: int nPoints, boolean isClosed, int transX, int transY);
076:
077: OGLRenderer traceWrap() {
078: return new Tracer(this );
079: }
080:
081: private class Tracer extends OGLRenderer {
082: private OGLRenderer oglr;
083:
084: Tracer(OGLRenderer oglr) {
085: super (oglr.rq);
086: this .oglr = oglr;
087: }
088:
089: protected void validateContext(SunGraphics2D sg2d) {
090: oglr.validateContext(sg2d);
091: }
092:
093: public void drawLine(SunGraphics2D sg2d, int x1, int y1,
094: int x2, int y2) {
095: GraphicsPrimitive.tracePrimitive("OGLDrawLine");
096: oglr.drawLine(sg2d, x1, y1, x2, y2);
097: }
098:
099: public void drawRect(SunGraphics2D sg2d, int x, int y, int w,
100: int h) {
101: GraphicsPrimitive.tracePrimitive("OGLDrawRect");
102: oglr.drawRect(sg2d, x, y, w, h);
103: }
104:
105: protected void drawPoly(SunGraphics2D sg2d, int[] xPoints,
106: int[] yPoints, int nPoints, boolean isClosed) {
107: GraphicsPrimitive.tracePrimitive("OGLDrawPoly");
108: oglr.drawPoly(sg2d, xPoints, yPoints, nPoints, isClosed);
109: }
110:
111: public void fillRect(SunGraphics2D sg2d, int x, int y, int w,
112: int h) {
113: GraphicsPrimitive.tracePrimitive("OGLFillRect");
114: oglr.fillRect(sg2d, x, y, w, h);
115: }
116:
117: protected void drawPath(SunGraphics2D sg2d, Path2D.Float p2df,
118: int transx, int transy) {
119: GraphicsPrimitive.tracePrimitive("OGLDrawPath");
120: oglr.drawPath(sg2d, p2df, transx, transy);
121: }
122:
123: protected void fillPath(SunGraphics2D sg2d, Path2D.Float p2df,
124: int transx, int transy) {
125: GraphicsPrimitive.tracePrimitive("OGLFillPath");
126: oglr.fillPath(sg2d, p2df, transx, transy);
127: }
128:
129: protected void fillSpans(SunGraphics2D sg2d, SpanIterator si,
130: int transx, int transy) {
131: GraphicsPrimitive.tracePrimitive("OGLFillSpans");
132: oglr.fillSpans(sg2d, si, transx, transy);
133: }
134:
135: public void copyArea(SunGraphics2D sg2d, int x, int y, int w,
136: int h, int dx, int dy) {
137: GraphicsPrimitive.tracePrimitive("OGLCopyArea");
138: oglr.copyArea(sg2d, x, y, w, h, dx, dy);
139: }
140: }
141: }
|