2362N/A * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A// - State switching optimizations ----------------------------------- 0N/A * The goal is to reduce device state switching as much as possible. 0N/A * This means: don't reset the texture if not needed, don't change 0N/A * the texture stage states unless necessary. 0N/A * For this we need to track the current device state. So each operation 0N/A * supplies its own operation type to BeginScene, which updates the state 0N/A * Another optimization is to use a single vertex format for 0N/A * See D3DContext::UpdateState() and D3DContext::BeginScene() for 0N/A// The max. stage number we currently use (could not be 0N/A// - Texture pixel format table ------------------------------------- 0N/A// - D3DContext class ----------------------------------------------- 0N/A * This class provides the following functionality: 0N/A * - holds the state of D3DContext java class (current pixel color, 0N/A * alpha compositing mode, extra alpha) 430N/A * - provides access to IDirect3DDevice9 interface (creation, 0N/A * disposal, exclusive access) 0N/A * - handles state changes of the direct3d device (transform, 0N/A * compositing mode, current texture) 0N/A * - provides means of creating textures, plain surfaces 0N/A * - holds a glyph cache texture for the associated device 0N/A * - implements primitives batching mechanism 0N/A * Releases the old device (if there was one) and all associated 0N/A * resources, re-creates, initializes and tests the new device. 0N/A * If the device doesn't pass the test, it's released. 0N/A * Used when the context is first created, and then after a 0N/A * display change event. 0N/A * Note that this method also does the necessary registry checks, 0N/A * and if the registry shows that we've crashed when attempting 0N/A * to initialize and test the device last time, it doesn't attempt 430N/A // creates a new D3D windowed device with swap copy effect and default 430N/A // creates or resets a D3D device given the parameters 430N/A // resets existing D3D device with the current presentation parameters 430N/A // saves the state of the D3D device in a state block, resets 430N/A // context's state to STATE_CHANGE 430N/A // restores the state of the D3D device from existing state block, 430N/A // resets context's state to STATE_CHANGE 0N/A // methods replicating java-level D3DContext objext 430N/A * Glyph cache-related methods 430N/A // out: num of pixels in first and last 430N/A // columns, only counted for LCD glyph uploads 430N/A // returns capabilities of the Direct3D device 430N/A // returns caps in terms of the D3DContext 0N/A * This method only sets the texture if it's not already set. 430N/A * This method only updates the texture color state if it hasn't changed. 430N/A // clipping-related methods 430N/A * Shader-related methods 430N/A// REMIND: for now for performance testing 430N/A// { return (getenv("J2D_D3D_USE_DYNAMIC_TEX") != NULL); } 0N/A // primitives batching-related methods 0N/A * Calls devices's BeginScene if there weren't one already pending, 0N/A * sets the pending flag. 430N/A * Flushes the vertex queue and does end scene if 430N/A * a BeginScene is pending 430N/A * Fields that track native-specific state. 0N/A * Current operation state. 0N/A * See STATE_* macros above. 430N/A * The handle to the LCD text pixel shader program. 430N/A * The handle to the AA pixel and vertex shader programs. 430N/A // finds appropriate to the target surface depth format, 430N/A // creates the depth buffer and installs it onto the device 430N/A // returns true if the current depth buffer is compatible 430N/A // with the new target, and the dimensions fit, false otherwise 430N/A // updates the texture transform(s) used for better texel to pixel mapping 430N/A // for the passed in sampler; 430N/A // if -1 is passed as the sampler, texture transforms for 430N/A // samplers [0..MAX_USED_TEXTURE_SAMPLER] are updated 430N/A // REMIND: see the comment in the method implementation before enabling. 430N/A // array of the textures currently set to the device 0N/A * Used to implement simple primitive batching. 0N/A// - Helper Macros --------------------------------------------------- 430N/A * This constant determines the size of the shared tile texture used 430N/A * by a number of image rendering methods. For example, the blit tile texture 430N/A * will have dimensions with width D3DC_BLIT_TILE_SIZE and height 430N/A * D3DC_BLIT_TILE_SIZE (the tile will always be square).