Source Code Cross Referenced for XBlitter.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » awt » gl » linux » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » org package » org.apache.harmony.awt.gl.linux 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:        /**
018:         * @author Oleg V. Khaschansky
019:         * @version $Revision$
020:         */package org.apache.harmony.awt.gl.linux;
021:
022:        import java.awt.geom.AffineTransform;
023:        import java.awt.geom.Rectangle2D;
024:        import java.awt.*;
025:        import java.awt.image.ColorModel;
026:        import java.awt.image.BufferedImage;
027:        import java.awt.image.WritableRaster;
028:        import java.awt.image.AffineTransformOp;
029:
030:        import org.apache.harmony.awt.gl.*;
031:        import org.apache.harmony.awt.gl.render.Blitter;
032:        import org.apache.harmony.awt.gl.render.JavaBlitter;
033:        import org.apache.harmony.awt.gl.render.NativeImageBlitter;
034:        import org.apache.harmony.awt.nativebridge.linux.X11;
035:        import org.apache.harmony.awt.nativebridge.linux.X11Defs;
036:
037:        import org.apache.harmony.awt.internal.nls.Messages;
038:
039:        public class XBlitter implements  Blitter {
040:
041:            static final XBlitter inst = new XBlitter();
042:
043:            public static XBlitter getInstance() {
044:                return inst;
045:            }
046:
047:            public void blit(int srcX, int srcY, Surface srcSurf, int dstX,
048:                    int dstY, Surface dstSurf, int width, int height,
049:                    AffineTransform sysxform, AffineTransform xform,
050:                    Composite comp, Color bgcolor, MultiRectArea clip) {
051:
052:                if (xform == null) {
053:                    blit(srcX, srcY, srcSurf, dstX, dstY, dstSurf, width,
054:                            height, sysxform, comp, bgcolor, clip);
055:                } else {
056:                    double scaleX = xform.getScaleX();
057:                    double scaleY = xform.getScaleY();
058:                    double scaledX = dstX / scaleX;
059:                    double scaledY = dstY / scaleY;
060:                    AffineTransform at = new AffineTransform();
061:                    at.setToTranslation(scaledX, scaledY);
062:                    xform.concatenate(at);
063:                    sysxform.concatenate(xform);
064:                    blit(srcX, srcY, srcSurf, 0, 0, dstSurf, width, height,
065:                            sysxform, comp, bgcolor, clip);
066:                }
067:            }
068:
069:            public void blit(int srcX, int srcY, Surface srcSurf, int dstX,
070:                    int dstY, Surface dstSurf, int width, int height,
071:                    AffineTransform sysxform, Composite comp, Color bgcolor,
072:                    MultiRectArea clip) {
073:
074:                if (srcSurf.isNativeDrawable()) {
075:                    double matrix[] = null;
076:                    if (sysxform != null) {
077:                        int type = sysxform.getType();
078:                        switch (type) {
079:
080:                        case AffineTransform.TYPE_TRANSLATION:
081:                            dstX += sysxform.getTranslateX();
082:                            dstY += sysxform.getTranslateY();
083:                        case AffineTransform.TYPE_IDENTITY:
084:                            break;
085:
086:                        default:
087:                            matrix = new double[6];
088:                            sysxform.getMatrix(matrix);
089:                            Rectangle transDstBounds = JavaBlitter.getBounds2D(
090:                                    sysxform,
091:                                    new Rectangle(dstX, dstY, width, height))
092:                                    .getBounds();
093:                            dstX = transDstBounds.x;
094:                            dstY = transDstBounds.y;
095:
096:                            Rectangle transSrcBounds = JavaBlitter.getBounds2D(
097:                                    sysxform,
098:                                    new Rectangle(srcX, srcY, width, height))
099:                                    .getBounds();
100:                            srcX = transSrcBounds.x;
101:                            srcY = transSrcBounds.y;
102:                            width = transSrcBounds.width;
103:                            height = transSrcBounds.height;
104:
105:                        }
106:
107:                    }
108:
109:                    long dstSurfStruct = dstSurf.getSurfaceDataPtr();
110:                    long srcSurfStruct = srcSurf.getSurfaceDataPtr();
111:                    int clipRects[] = null;
112:                    int numVertex = 0;
113:                    if (clip != null) {
114:                        clipRects = clip.rect;
115:                        numVertex = clipRects[0] - 1;
116:                    }
117:
118:                    if (comp instanceof  AlphaComposite) {
119:                        AlphaComposite ac = (AlphaComposite) comp;
120:                        int compType = ac.getRule();
121:                        float alpha = ac.getAlpha();
122:
123:                        if (srcSurf instanceof  ImageSurface) {
124:                            Object data = srcSurf.getData();
125:
126:                            int dirtyRegions[] = ((ImageSurface) srcSurf)
127:                                    .getDirtyRegions();
128:                            int regCount = 0;
129:                            if (dirtyRegions != null)
130:                                regCount = dirtyRegions[0] - 1;
131:
132:                            boolean hasBackground = false;
133:                            int bgc = 0;
134:
135:                            if (bgcolor != null
136:                                    && srcSurf.getTransparency() != Transparency.OPAQUE) {
137:                                hasBackground = true;
138:                                bgc = bgcolor.getRGB();
139:                            }
140:
141:                            synchronized (data) {
142:                                bltImage(srcX, srcY, srcSurfStruct, srcSurf
143:                                        .getData(), dstX, dstY, dstSurfStruct,
144:                                        width, height, hasBackground, bgc,
145:                                        compType, alpha, matrix, clipRects,
146:                                        numVertex, srcSurf.invalidated(),
147:                                        dirtyRegions, regCount);
148:                            }
149:                            srcSurf.validate();
150:                        } else {
151:                            bltPixmap(srcX, srcY, srcSurfStruct, dstX, dstY,
152:                                    dstSurfStruct, width, height, compType,
153:                                    alpha, matrix, clipRects, numVertex);
154:                        }
155:                    } else if (comp instanceof  XORComposite) {
156:                        XORComposite xcomp = (XORComposite) comp;
157:                        if (srcSurf instanceof  ImageSurface) {
158:                            Object data = srcSurf.getData();
159:
160:                            int dirtyRegions[] = ((ImageSurface) srcSurf)
161:                                    .getDirtyRegions();
162:                            int regCount = 0;
163:                            if (dirtyRegions != null)
164:                                regCount = dirtyRegions[0] - 1;
165:
166:                            synchronized (data) {
167:                                xorImage(srcX, srcY, srcSurfStruct, data, dstX,
168:                                        dstY, dstSurfStruct, width, height,
169:                                        xcomp.getXORColor().getRGB(), matrix,
170:                                        clipRects, numVertex, srcSurf
171:                                                .invalidated(), dirtyRegions,
172:                                        regCount);
173:                            }
174:                            srcSurf.validate();
175:                        } else {
176:                            xorPixmap(srcX, srcY, srcSurfStruct, dstX, dstY,
177:                                    dstSurfStruct, width, height, xcomp
178:                                            .getXORColor().getRGB(), matrix,
179:                                    clipRects, numVertex);
180:                        }
181:                    } else {
182:                        // awt.17=Unknown Composite type : {0}
183:                        throw new IllegalArgumentException(Messages.getString(
184:                                "awt.17", //$NON-NLS-1$
185:                                comp.getClass()));
186:                    }
187:                } else {
188:                    BufferedImage bi;
189:                    if (srcSurf.getTransparency() == Transparency.OPAQUE) {
190:                        bi = new BufferedImage(srcSurf.getWidth(), srcSurf
191:                                .getHeight(), BufferedImage.TYPE_INT_RGB);
192:                    } else {
193:                        bi = new BufferedImage(srcSurf.getWidth(), srcSurf
194:                                .getHeight(), BufferedImage.TYPE_INT_ARGB);
195:                    }
196:                    Surface tmpSurf = AwtImageBackdoorAccessor.getInstance()
197:                            .getImageSurface(bi);
198:                    JavaBlitter.getInstance().blit(0, 0, srcSurf, 0, 0,
199:                            tmpSurf, srcSurf.getWidth(), srcSurf.getHeight(),
200:                            AlphaComposite.Src, null, null);
201:                    blit(srcX, srcY, tmpSurf, dstX, dstY, dstSurf, width,
202:                            height, comp, bgcolor, clip);
203:                }
204:            }
205:
206:            // Native methods
207:
208:            public void blit(int srcX, int srcY, Surface srcSurf, int dstX,
209:                    int dstY, Surface dstSurf, int width, int height,
210:                    Composite comp, Color bgcolor, MultiRectArea clip) {
211:
212:                blit(srcX, srcY, srcSurf, dstX, dstY, dstSurf, width, height,
213:                        null, comp, bgcolor, clip);
214:            }
215:
216:            private native void bltImage(int srcX, int srcY,
217:                    long srsSurfDataPtr, Object srcData, int dstX, int dstY,
218:                    long dstSurfDataPtr, int width, int height,
219:                    boolean hasBackground, int bgcolor, int compType,
220:                    float alpha, double matrix[], int clip[], int numVertex,
221:                    boolean invalidated, int[] dirtyRegions, int regCount);
222:
223:            private native void bltPixmap(int srcX, int srcY,
224:                    long srsSurfDataPtr, int dstX, int dstY,
225:                    long dstSurfDataPtr, int width, int height, int compType,
226:                    float alpha, double matrix[], int clip[], int numVertex);
227:
228:            private native void xorImage(int srcX, int srcY,
229:                    long srsSurfDataPtr, Object srcData, int dstX, int dstY,
230:                    long dstSurfDataPtr, int width, int height, int xorcolor,
231:                    double matrix[], int clip[], int numVertex,
232:                    boolean invalidated, int[] dirtyRegions, int regCount);
233:
234:            private native void xorPixmap(int srcX, int srcY,
235:                    long srsSurfDataPtr, int dstX, int dstY,
236:                    long dstSurfDataPtr, int width, int height, int xorcolor,
237:                    double matrix[], int clip[], int numVertex);
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.