D3DVertexCacher.h revision 10731:e66f69113b89
1202375Srdivacky/* 2202375Srdivacky * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3202375Srdivacky * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4202375Srdivacky * 5202375Srdivacky * This code is free software; you can redistribute it and/or modify it 6202375Srdivacky * under the terms of the GNU General Public License version 2 only, as 7202375Srdivacky * published by the Free Software Foundation. Oracle designates this 8202375Srdivacky * particular file as subject to the "Classpath" exception as provided 9202375Srdivacky * by Oracle in the LICENSE file that accompanied this code. 10202375Srdivacky * 11202375Srdivacky * This code is distributed in the hope that it will be useful, but WITHOUT 12202375Srdivacky * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13202375Srdivacky * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14202375Srdivacky * version 2 for more details (a copy is included in the LICENSE file that 15202375Srdivacky * accompanied this code). 16202375Srdivacky * 17202375Srdivacky * You should have received a copy of the GNU General Public License version 18202375Srdivacky * 2 along with this work; if not, write to the Free Software Foundation, 19202375Srdivacky * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20202375Srdivacky * 21202375Srdivacky * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22202375Srdivacky * or visit www.oracle.com if you need additional information or have any 23202375Srdivacky * questions. 24202375Srdivacky */ 25202375Srdivacky 26202375Srdivacky#ifndef D3DVERTEXCACHER_H 27202375Srdivacky#define D3DVERTEXCACHER_H 28202375Srdivacky 29202375Srdivacky#include "jni.h" 30202375Srdivacky#include "D3DContext.h" 31202375Srdivacky 32202375Srdivacky#define MAX_BATCH_SIZE 1024 33202375Srdivacky#define APPEND_ACTION 0x0 34202375Srdivacky#define RESET_ACTION 0x1 35202375Srdivacky#define D3DFVF_J2DLVERTEX \ 36202375Srdivacky (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2 | \ 37202375Srdivacky D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEXCOORDSIZE2(1) ) 38202375Srdivackytypedef struct _J2DLVERTEX { 39249423Sdim float x, y, z; 40249423Sdim DWORD color; 41249423Sdim float tu1, tv1; 42249423Sdim float tu2, tv2; 43202375Srdivacky} J2DLVERTEX; 44202375Srdivacky 45202375Srdivackytypedef struct { 46249423Sdim D3DPRIMITIVETYPE pType; // type of primitives in this batch 47249423Sdim UINT pNum; // number of primitives of pType in this batch 48202375Srdivacky} VertexBatch; 49249423Sdim 50202375Srdivackyclass D3DContext; 51202375Srdivacky 52202375Srdivackyclass D3DPIPELINE_API D3DVertexCacher { 53226633Sdimpublic: 54249423Sdim HRESULT Init(D3DContext *pCtx); 55249423Sdim ~D3DVertexCacher() { ReleaseDefPoolResources(); } 56202375Srdivacky void ReleaseDefPoolResources(); 57202375Srdivacky 58202375Srdivacky jint GetColor() { return color; } 59202375Srdivacky void SetColor(jint newColor) { color = newColor; } 60202375Srdivacky HRESULT DrawLine(int x1, int y1, int x2, int y2); 61202375Srdivacky HRESULT DrawPoly(jint nPoints, jboolean isClosed, 62202375Srdivacky jint transX, jint transY, 63202375Srdivacky jint *xPoints, jint *yPoints); 64202375Srdivacky HRESULT DrawScanlines(jint scanlineCount, jint *scanlines); 65218893Sdim HRESULT DrawRect(int x1, int y1, int x2, int y2); 66218893Sdim HRESULT FillRect(int x1, int y1, int x2, int y2); 67218893Sdim HRESULT FillParallelogramAA(float fx11, float fy11, 68202375Srdivacky float dx21, float dy21, 69249423Sdim float dx12, float dy12); 70249423Sdim HRESULT DrawParallelogramAA(float ox11, float oy11, 71249423Sdim float ox21, float oy21, 72249423Sdim float ox12, float oy12, 73249423Sdim float ix11, float iy11, 74218893Sdim float ix21, float iy21, 75218893Sdim float ix12, float iy12); 76218893Sdim HRESULT FillParallelogram(float fx11, float fy11, 77218893Sdim float dx21, float dy21, 78202375Srdivacky float dx12, float dy12); 79218893Sdim HRESULT FillSpans(jint spansCount, jint *spans); 80218893Sdim HRESULT DrawTexture(float dx1, float dy1, float dx2, float dy2, 81218893Sdim float tx1, float ty1, float tx2, float ty2); 82218893Sdim HRESULT DrawTexture(float dx1, float dy1, float dx2, float dy2, 83202375Srdivacky float t1x1, float t1y1, float t1x2, float t1y2, 84234353Sdim float t2x1, float t2y1, float t2x2, float t2y2); 85218893Sdim HRESULT Render(int actionType = APPEND_ACTION); 86234353Sdim UINT GetFreeVertices() { return (MAX_BATCH_SIZE - firstUnusedVertex); } 87234353Sdim 88234353Sdimstatic 89202375Srdivacky HRESULT CreateInstance(D3DContext *pCtx, D3DVertexCacher **ppVC); 90202375Srdivacky 91202375Srdivackyprivate: 92234353Sdim D3DVertexCacher(); 93202375Srdivacky HRESULT EnsureCapacity(D3DPRIMITIVETYPE newPType, UINT vNum); 94202375Srdivacky 95202375Srdivackyprivate: 96239462Sdim UINT firstPendingBatch; 97243830Sdim UINT firstPendingVertex; 98239462Sdim UINT firstUnusedVertex; 99239462Sdim UINT currentBatch; 100202375Srdivacky J2DLVERTEX vertices[MAX_BATCH_SIZE]; 101202375Srdivacky VertexBatch batches[MAX_BATCH_SIZE]; 102202375Srdivacky IDirect3DVertexBuffer9 *lpD3DVertexBuffer; 103226633Sdim IDirect3DDevice9 *lpD3DDevice; 104204642Srdivacky D3DContext *pCtx; 105239462Sdim jint color; 106202375Srdivacky}; 107202375Srdivacky 108239462Sdim#endif // D3DVERTEXCACHER_H 109202375Srdivacky