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