Source Code Cross Referenced for OGLContext.java in  » 6.0-JDK-Modules-sun » java2d » sun » java2d » opengl » 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 » 6.0 JDK Modules sun » java2d » sun.java2d.opengl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004-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.AlphaComposite;
029:        import java.awt.Composite;
030:        import java.awt.Paint;
031:        import java.awt.geom.AffineTransform;
032:        import sun.java2d.SunGraphics2D;
033:        import sun.java2d.pipe.BufferedContext;
034:        import sun.java2d.pipe.Region;
035:        import sun.java2d.pipe.RenderBuffer;
036:        import sun.java2d.pipe.RenderQueue;
037:        import static sun.java2d.pipe.BufferedOpCodes.*;
038:
039:        /**
040:         * Note that the RenderQueue lock must be acquired before calling any of
041:         * the methods in this class.
042:         */
043:        class OGLContext extends BufferedContext {
044:
045:            /** Indicates that the context has no capabilities. */
046:            static final int CAPS_EMPTY = (0 << 0);
047:            /** Indicates that the context is doublebuffered. */
048:            static final int CAPS_DOUBLEBUFFERED = (1 << 0);
049:            /** Indicates that the context supports a stored alpha channel. */
050:            static final int CAPS_STORED_ALPHA = (1 << 1);
051:            /** Indicates the presence of the GL_ARB_multitexture extension. */
052:            static final int CAPS_EXT_MULTITEXTURE = (1 << 2);
053:            /** Indicates the presence of the GL_ARB_texture_non_power_of_two ext. */
054:            static final int CAPS_EXT_TEXNONPOW2 = (1 << 3);
055:            /**
056:             * Indicates the presence of the GL_EXT_framebuffer_object extension.
057:             * This cap will only be set if the fbobject system property has been
058:             * enabled and we are able to create an FBO with depth buffer.
059:             */
060:            static final int CAPS_EXT_FBOBJECT = (1 << 4);
061:            /**
062:             * Indicates the presence of the GL_ARB_fragment_shader extension.
063:             * This cap will only be set if the lcdshader system property has been
064:             * enabled and the hardware supports the minimum number of texture units.
065:             */
066:            static final int CAPS_EXT_LCD_SHADER = (1 << 5);
067:            /** Indicates the presence of the GL_ARB_texture_rectangle extension. */
068:            static final int CAPS_EXT_TEXRECT = (1 << 6);
069:            /**
070:             * Indicates the presence of the GL_ARB_fragment_shader extension.
071:             * This cap will only be set if the biopshader system property has been
072:             * enabled and the hardware meets our minimum requirements.
073:             */
074:            static final int CAPS_EXT_BIOP_SHADER = (1 << 7);
075:            /**
076:             * Indicates the presence of the GL_ARB_fragment_shader extension.
077:             * This cap will only be set if the gradshader system property has been
078:             * enabled and the hardware meets our minimum requirements.
079:             */
080:            static final int CAPS_EXT_GRAD_SHADER = (1 << 8);
081:
082:            OGLContext(RenderQueue rq) {
083:                super (rq);
084:            }
085:
086:            /**
087:             * Fetches the OGLContext associated with the current GraphicsConfig
088:             * and validates the context using the given parameters.  Most rendering
089:             * operations will call this method first in order to set the necessary
090:             * state before issuing rendering commands.
091:             */
092:            static void validateContext(OGLSurfaceData srcData,
093:                    OGLSurfaceData dstData, Region clip, Composite comp,
094:                    AffineTransform xform, Paint paint, SunGraphics2D sg2d,
095:                    int flags) {
096:                // assert rq.lock.isHeldByCurrentThread();
097:                OGLContext oglc = dstData.getContext();
098:                oglc.validate(srcData, dstData, clip, comp, xform, paint, sg2d,
099:                        flags);
100:            }
101:
102:            /**
103:             * Simplified version of validateContext() that disables all context
104:             * state settings.
105:             */
106:            static void validateContext(OGLSurfaceData dstData) {
107:                // assert rq.lock.isHeldByCurrentThread();
108:                validateContext(dstData, dstData, null, null, null, null, null,
109:                        NO_CONTEXT_FLAGS);
110:            }
111:
112:            /**
113:             * Convenience method that delegates to setScratchSurface() below.
114:             */
115:            static void setScratchSurface(OGLGraphicsConfig gc) {
116:                setScratchSurface(gc.getNativeConfigInfo());
117:            }
118:
119:            /**
120:             * Makes the given GraphicsConfig's context current to its associated
121:             * "scratch surface".  Each GraphicsConfig maintains a native context
122:             * (GLXContext on Unix, HGLRC on Windows) as well as a native pbuffer
123:             * known as the "scratch surface".  By making the context current to the
124:             * scratch surface, we are assured that we have a current context for
125:             * the relevant GraphicsConfig, and can therefore perform operations
126:             * depending on the capabilities of that GraphicsConfig.  For example,
127:             * if the GraphicsConfig supports the GL_ARB_texture_non_power_of_two
128:             * extension, then we should be able to make a non-pow2 texture for this
129:             * GraphicsConfig once we make the context current to the scratch surface.
130:             *
131:             * This method should be used for operations with an OpenGL texture
132:             * as the destination surface (e.g. a sw->texture blit loop), or in those
133:             * situations where we may not otherwise have a current context (e.g.
134:             * when disposing a texture-based surface).
135:             */
136:            static void setScratchSurface(long pConfigInfo) {
137:                // assert OGLRenderQueue.getInstance().lock.isHeldByCurrentThread();
138:
139:                // invalidate the current context
140:                currentContext = null;
141:
142:                // set the scratch context
143:                OGLRenderQueue rq = OGLRenderQueue.getInstance();
144:                RenderBuffer buf = rq.getBuffer();
145:                rq.ensureCapacityAndAlignment(12, 4);
146:                buf.putInt(SET_SCRATCH_SURFACE);
147:                buf.putLong(pConfigInfo);
148:            }
149:
150:            /**
151:             * Invalidates the currentContext field to ensure that we properly
152:             * revalidate the OGLContext (make it current, etc.) next time through
153:             * the validate() method.  This is typically invoked from methods
154:             * that affect the current context state (e.g. disposing a context or
155:             * surface).
156:             */
157:            static void invalidateCurrentContext() {
158:                // assert OGLRenderQueue.getInstance().lock.isHeldByCurrentThread();
159:
160:                // first invalidate the context reference at the native level, and
161:                // then flush the queue so that we have no pending operations
162:                // dependent on the current context
163:                OGLRenderQueue rq = OGLRenderQueue.getInstance();
164:                rq.ensureCapacity(4);
165:                rq.getBuffer().putInt(INVALIDATE_CONTEXT);
166:                rq.flushNow();
167:
168:                // then invalidate the current Java-level context so that we
169:                // revalidate everything the next time around
170:                if (currentContext != null) {
171:                    currentContext.invalidateSurfaces();
172:                    currentContext = null;
173:                }
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.