📄 mastercontrol.java
字号:
/* * $RCSfile: MasterControl.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.35 $ * $Date: 2007/05/31 20:55:44 $ * $State: Exp $ *//* * Portions of this code were derived from work done by the Blackdown * group (www.blackdown.org), who did the initial Linux implementation * of the Java 3D API. */package javax.media.j3d;import java.util.*;import java.awt.*;import java.util.logging.Level;import java.util.logging.Logger;class MasterControl { /** * Options for the runMonitor */ static final int CHECK_FOR_WORK = 0; static final int SET_WORK = 1; static final int RUN_THREADS = 2; static final int THREAD_DONE = 3; static final int SET_WORK_FOR_REQUEST_RENDERER = 5; static final int RUN_RENDERER_CLEANUP = 6; // The thread states for MC static final int SLEEPING = 0; static final int RUNNING = 1; static final int WAITING_FOR_THREADS = 3; static final int WAITING_FOR_CPU = 4; static final int WAITING_FOR_RENDERER_CLEANUP = 5; // Constants used in renderer thread argument static final Integer REQUESTRENDER = new Integer(Renderer.REQUESTRENDER); static final Integer RENDER = new Integer(Renderer.RENDER); static final Integer SWAP = new Integer(Renderer.SWAP); // Constants used for request from user threads static final Integer ACTIVATE_VIEW = new Integer(1); static final Integer DEACTIVATE_VIEW = new Integer(2); static final Integer START_VIEW = new Integer(3); static final Integer STOP_VIEW = new Integer(4); static final Integer REEVALUATE_CANVAS = new Integer(5); static final Integer UNREGISTER_VIEW = new Integer(6); static final Integer PHYSICAL_ENV_CHANGE = new Integer(7); static final Integer INPUTDEVICE_CHANGE = new Integer(8); static final Integer EMPTY_UNIVERSE = new Integer(9); static final Integer START_RENDERER = new Integer(10); static final Integer STOP_RENDERER = new Integer(11); static final Integer RENDER_ONCE = new Integer(12); static final Integer FREE_CONTEXT = new Integer(13); static final Integer FREE_DRAWING_SURFACE = new Integer(14); static final Integer FREE_MESSAGE = new Integer(15); static final Integer RESET_CANVAS = new Integer(16); static final Integer GETBESTCONFIG = new Integer(17); static final Integer ISCONFIGSUPPORT = new Integer(18); static final Integer SET_GRAPHICSCONFIG_FEATURES = new Integer(19); static final Integer SET_QUERYPROPERTIES = new Integer(20); static final Integer SET_VIEW = new Integer(21); // Developer logger for reporting informational messages; see getDevLogger() private static boolean devLoggerEnabled = false; private static Logger devLogger; // Stats logger for reporting runtime statistics; see getStatsLogger() private static boolean statsLoggerEnabled = false; private static Logger statsLogger; // Core logger for reporting internal errors, warning, and // informational messages; see getCoreLogger() private static boolean coreLoggerEnabled = false; private static Logger coreLogger; // Flag indicating that the rendering pipeline libraries are loaded private static boolean librariesLoaded = false; // Issue 257: flag indicating that we are running in "appletLauncher" mode // and should use JNLPAppletLauncher to load any native libraries private static boolean appletLauncher = false; /** * reference to MasterControl thread */ private MasterControlThread mcThread = null; /** * The list of views that are currently registered */ private UnorderList views = new UnorderList(1, View.class); /** * by MIK OF CLASSX * * the flag to indicate whether the background of the offscreen * canvas must be transparent or not false by default */ boolean transparentOffScreen = false; /** * Flag to indicate whether Pbuffers are used for off-screen * rendering; true by default. Set by the "j3d.usePbuffer" * property, When this flag is set to false, Bitmap (Windows) or * Pixmap (UNIX) rendering will be used */ boolean usePbuffer = true; /** * Flag to indicate whether should renderer view frustum culling is done; * true by default. * Set by the -Dj3d.viewFrustumCulling property, When this flag is * set to false, the renderer view frustum culling is turned off. */ boolean viewFrustumCulling = true; /** * the flag to indicate whether the geometry should be locked or not */ private boolean lockGeometry = false; /** * The number of registered views that are active */ private int numActiveViews = 0; /** * The list of active universes get from View */ private UnorderList activeUniverseList = new UnorderList(VirtualUniverse.class); /** * The list of universes register from View */ private UnorderList regUniverseList = new UnorderList(VirtualUniverse.class); /** * A lock used for accessing time structures. */ private Object timeLock = new Object(); /** * The current "time" value */ private long time = 0; /** * Use to assign threadOpts in Renderer thread. */ private long waitTimestamp = 0; /** * The current list of work threads */ private UnorderList stateWorkThreads = new UnorderList(J3dThreadData.class); private UnorderList renderWorkThreads = new UnorderList(J3dThreadData.class); private UnorderList requestRenderWorkThreads = new UnorderList(J3dThreadData.class); /** * The current list of work threads */ private UnorderList renderThreadData = new UnorderList(J3dThreadData.class); /** * The list of input device scheduler thread */ private UnorderList inputDeviceThreads = new UnorderList(1, InputDeviceScheduler.class); /** * A flag that is true when the thread lists need updating */ private boolean threadListsChanged; /** * Markers for the last transform structure update thread * and the last update thread. */ private int lastTransformStructureThread = 0; private int lastStructureUpdateThread = 0; /** * The current time snapshots */ private long currentTime; // Only one Timer thread in the system. TimerThread timerThread; // Only one Notification thread in the system. private NotificationThread notificationThread; /** * This flag indicates that MC is running */ volatile boolean running = true; /** * This flag indicates that MC has work to do */ private boolean workToDo = false; /** * This flag indicates that there is work for requestRenderer */ private boolean requestRenderWorkToDo = false; /** * The number of THREAD_DONE messages pending */ private int threadPending = 0; private int renderPending = 0; private int statePending = 0; /** * State variables for work lists */ private boolean renderWaiting = false; private boolean stateWaiting = false; /** * The current state of the MC thread */ private int state = SLEEPING; // time for sleep in order to met the minimum frame duration private long sleepTime = 0; /** * The number of cpu's Java 3D may use */ private int cpuLimit; /** * A list of mirror objects to be updated */ private UnorderList mirrorObjects = new UnorderList(ObjectUpdate.class); /** * The renderingAttributesStructure for updating node component * objects */ private RenderingAttributesStructure renderingAttributesStructure = new RenderingAttributesStructure(); /** * The default rendering method */ private DefaultRenderMethod defaultRenderMethod = null; /** * The text3D rendering method */ private Text3DRenderMethod text3DRenderMethod = null; /** * The vertex array rendering method */ private VertexArrayRenderMethod vertexArrayRenderMethod = null; /** * The displayList rendering method */ private DisplayListRenderMethod displayListRenderMethod = null; /** * The compressed geometry rendering method */ private CompressedGeometryRenderMethod compressedGeometryRenderMethod = null; /** * The oriented shape3D rendering method */ private OrientedShape3DRenderMethod orientedShape3DRenderMethod = null; /** * This is the start time upon which alpha's and behaviors * are synchronized to. It is initialized once, the first time * that a MasterControl object is created. */ static long systemStartTime = 0L; // Flag indicating that we are on a Windows OS private static boolean isWindowsOs = false; // Flag indicating we are on MacOS private static boolean isMacOs = false; // This is a counter for texture id's, valid id starts from 1 private int textureIdCount = 0; // This is lock for both 2D/3D textureIds; private Object textureIdLock = new Object(); // This is a time stamp used when context is created private long contextTimeStamp = 0; // This is an array of canvasIds in used private boolean[] canvasIds = null; private int canvasFreeIndex = 0; private Object canvasIdLock = new Object(); // This is a counter for rendererBit private int rendererCount = 0; // Flag that indicates whether to shared display context or not boolean isSharedCtx = false; // Flag that tells us to use NV_register_combiners boolean useCombiners = false; // Flag that indicates whether compile is disabled or not boolean disableCompile = false; // Flag that indicates whether or not compaction occurs boolean doCompaction = true; // Flag that indicates whether separate specular color is disabled or not boolean disableSeparateSpecularColor = false; // Flag that indicates whether DisplayList is used or not boolean isDisplayList = true; // If this flag is set, then by-ref geometry will not be // put in display list boolean buildDisplayListIfPossible = false; // If this flag is set, then geometry arrays with vertex attributes can // be in display list. boolean vertexAttrsInDisplayList = false; // Issue 249 - flag that indicates whether the soleUser optimization is permitted boolean allowSoleUser = false; // Issue 266 - Flag indicating whether null graphics configs are allowed // Set by -Dj3d.allowNullGraphicsConfig property // Setting this flag causes Canvas3D to allow a null GraphicsConfiguration // for on-screen canvases. This is only for backward compatibility with // legacy applications. boolean allowNullGraphicsConfig = false; // Issue 239 - Flag indicating whether the stencil buffer is cleared by // default each frame when the color and depth buffers are cleared. // Note that this is a partial solution, since we eventually want an API // to control this. boolean stencilClear = false; // The global shading language being used. Using a ShaderProgram // with a shading language other than the one specified by // globalShadingLanguage will cause a ShaderError to be generated, static int globalShadingLanguage = Shader.SHADING_LANGUAGE_GLSL; // Flags indicating whether the Cg or GLSL libraries are available; we still need // to check for the actual extension support when the Canvas3D with its associated context // is created. Note that these are qualifed by the above globalShadingLanguage, so at // most one of these two flags will be true; static boolean cgLibraryAvailable = false; static boolean glslLibraryAvailable = false; // REQUESTCLEANUP messages argument static Integer REMOVEALLCTXS_CLEANUP = new Integer(1); static Integer REMOVECTX_CLEANUP = new Integer(2); static Integer REMOVENOTIFY_CLEANUP = new Integer(3); static Integer RESETCANVAS_CLEANUP = new Integer(4); static Integer FREECONTEXT_CLEANUP = new Integer(5); // arguments for renderer resource cleanup run Object rendererCleanupArgs[] = {new Integer(Renderer.REQUESTCLEANUP), null, null}; // Context creation should obtain this lock, so that // first_time and all the extension initilialization // are done in the MT safe manner Object contextCreationLock = new Object(); // Flag that indicates whether to lock the DSI while rendering boolean doDsiRenderLock = false; // Flag that indicates the pre-1.5 behavior of enforcing power-of-two // textures. If set, then any non-power-of-two textures will throw an // exception. boolean enforcePowerOfTwo = false; // Flag that indicates whether the framebuffer is sharing the // Z-buffer with both the left and right eyes when in stereo mode. // If this is true, we need to clear the Z-buffer between rendering // to the left and right eyes.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -