001: /*
002: * $RCSfile: J3dMessage.java,v $
003: *
004: * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006: *
007: * This code is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License version 2 only, as
009: * published by the Free Software Foundation. Sun designates this
010: * particular file as subject to the "Classpath" exception as provided
011: * by Sun in the LICENSE file that accompanied this code.
012: *
013: * This code is distributed in the hope that it will be useful, but WITHOUT
014: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: * version 2 for more details (a copy is included in the LICENSE file that
017: * accompanied this code).
018: *
019: * You should have received a copy of the GNU General Public License version
020: * 2 along with this work; if not, write to the Free Software Foundation,
021: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022: *
023: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024: * CA 95054 USA or visit www.sun.com if you need additional information or
025: * have any questions.
026: *
027: * $Revision: 1.11 $
028: * $Date: 2008/02/28 20:17:25 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: /**
035: * The J3dMessage is the super class of all messages in Java 3D. It implements
036: * all of the common data members needed.
037: */
038:
039: class J3dMessage extends Object {
040: /**
041: * The various message types.
042: */
043: static final int INVALID_TYPE = -1;
044: static final int INSERT_NODES = 0;
045: static final int REMOVE_NODES = 1;
046: static final int RUN = 2;
047: static final int TRANSFORM_CHANGED = 3;
048: static final int UPDATE_VIEW = 4;
049: static final int STOP_THREAD = 5;
050: static final int COLORINGATTRIBUTES_CHANGED = 6;
051: static final int LINEATTRIBUTES_CHANGED = 7;
052: static final int POINTATTRIBUTES_CHANGED = 8;
053: static final int POLYGONATTRIBUTES_CHANGED = 9;
054: static final int RENDERINGATTRIBUTES_CHANGED = 10;
055: static final int TEXTUREATTRIBUTES_CHANGED = 11;
056: static final int TRANSPARENCYATTRIBUTES_CHANGED = 12;
057: static final int MATERIAL_CHANGED = 13;
058: static final int TEXCOORDGENERATION_CHANGED = 14;
059: static final int TEXTURE_CHANGED = 15;
060: static final int MORPH_CHANGED = 16;
061: static final int GEOMETRY_CHANGED = 17;
062: static final int APPEARANCE_CHANGED = 18;
063: static final int LIGHT_CHANGED = 19;
064: static final int BACKGROUND_CHANGED = 20;
065: static final int CLIP_CHANGED = 21;
066: static final int FOG_CHANGED = 22;
067: static final int BOUNDINGLEAF_CHANGED = 23;
068: static final int SHAPE3D_CHANGED = 24;
069: static final int TEXT3D_TRANSFORM_CHANGED = 25;
070: static final int TEXT3D_DATA_CHANGED = 26;
071: static final int SWITCH_CHANGED = 27;
072: static final int COND_MET = 28;
073: static final int BEHAVIOR_ENABLE = 29;
074: static final int BEHAVIOR_DISABLE = 30;
075: static final int INSERT_RENDERATOMS = 31;
076: static final int ORDERED_GROUP_INSERTED = 32;
077: static final int ORDERED_GROUP_REMOVED = 33;
078: static final int COLLISION_BOUND_CHANGED = 34;
079: static final int REGION_BOUND_CHANGED = 35;
080: static final int MODELCLIP_CHANGED = 36;
081: static final int BOUNDS_AUTO_COMPUTE_CHANGED = 37;
082: static final int SOUND_ATTRIB_CHANGED = 38;
083: static final int AURALATTRIBUTES_CHANGED = 39;
084: static final int SOUNDSCAPE_CHANGED = 40;
085: static final int ALTERNATEAPPEARANCE_CHANGED = 41;
086: static final int RENDER_OFFSCREEN = 42;
087: static final int RENDER_RETAINED = 43;
088: static final int RENDER_IMMEDIATE = 44;
089: static final int SOUND_STATE_CHANGED = 45;
090: static final int ORIENTEDSHAPE3D_CHANGED = 46;
091: static final int TEXTURE_UNIT_STATE_CHANGED = 47;
092: static final int UPDATE_VIEWPLATFORM = 48;
093: static final int BEHAVIOR_ACTIVATE = 49;
094: static final int GEOMETRYARRAY_CHANGED = 50;
095: static final int MEDIA_CONTAINER_CHANGED = 51;
096: static final int RESIZE_CANVAS = 52;
097: static final int TOGGLE_CANVAS = 53;
098: static final int IMAGE_COMPONENT_CHANGED = 54;
099: static final int SCHEDULING_INTERVAL_CHANGED = 55;
100: static final int VIEWSPECIFICGROUP_CHANGED = 56;
101: static final int VIEWSPECIFICGROUP_INIT = 57;
102: static final int VIEWSPECIFICGROUP_CLEAR = 58;
103: static final int ORDERED_GROUP_TABLE_CHANGED = 59;
104: static final int BEHAVIOR_REEVALUATE = 60;
105: static final int CREATE_OFFSCREENBUFFER = 61;
106: static final int DESTROY_CTX_AND_OFFSCREENBUFFER = 62;
107: static final int SHADER_ATTRIBUTE_CHANGED = 63;
108: static final int SHADER_ATTRIBUTE_SET_CHANGED = 64;
109: static final int SHADER_APPEARANCE_CHANGED = 65;
110: static final int ALLOCATE_CANVASID = 66;
111: static final int FREE_CANVASID = 67;
112:
113: /**
114: * This is the time snapshot at which this change occured
115: */
116: long time = -1;
117:
118: /**
119: * This is the number of references to this message
120: */
121: private int refcount = 0;
122:
123: /**
124: * This is a bitmask of the types of threads that need to be run
125: * once this message is consumed.
126: */
127: int threads = 0;
128:
129: /**
130: * The universe that this message originated from
131: */
132: VirtualUniverse universe;
133:
134: /**
135: * This holds the type of this message
136: */
137: int type = -1;
138:
139: /**
140: * This holds the target view of this message, null means all views
141: */
142: View view = null;
143:
144: /**
145: * The arguements for a message, 5 for now
146: */
147: static final int MAX_ARGS = 6;
148:
149: Object[] args = new Object[MAX_ARGS];
150:
151: /**
152: * This constructor does nothing
153: */
154: J3dMessage() {
155: }
156:
157: final synchronized void clear() {
158: // System.err.println("J3dMessage : " + this );
159: view = null;
160: universe = null;
161: args[0] = null;
162: args[1] = null;
163: args[2] = null;
164: args[3] = null;
165: args[4] = null;
166: args[5] = null;
167: }
168:
169: /**
170: * This increments the reference count for this message
171: */
172: final synchronized void incRefcount() {
173: refcount++;
174: }
175:
176: /**
177: * This decrements the reference count for this message. If it goes
178: * to 0, the message is put on the MasterControl freelist.
179: */
180: final synchronized void decRefcount() {
181: if (--refcount == 0) {
182: clear();
183: }
184: }
185:
186: final synchronized int getRefcount() {
187: return refcount;
188: }
189: }
|