Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/windows/native/sun/java2d/d3d/D3DVertexCacher.h
32288 views
/*1* Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifndef D3DVERTEXCACHER_H26#define D3DVERTEXCACHER_H2728#include "jni.h"29#include "D3DContext.h"3031#define MAX_BATCH_SIZE 102432#define APPEND_ACTION 0x033#define RESET_ACTION 0x134#define D3DFVF_J2DLVERTEX \35(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2 | \36D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEXCOORDSIZE2(1) )37typedef struct _J2DLVERTEX {38float x, y, z;39DWORD color;40float tu1, tv1;41float tu2, tv2;42} J2DLVERTEX;4344typedef struct {45D3DPRIMITIVETYPE pType; // type of primitives in this batch46UINT pNum; // number of primitives of pType in this batch47} VertexBatch;4849class D3DContext;5051class D3DPIPELINE_API D3DVertexCacher {52public:53HRESULT Init(D3DContext *pCtx);54~D3DVertexCacher() { ReleaseDefPoolResources(); }55void ReleaseDefPoolResources();5657jint GetColor() { return color; }58void SetColor(jint newColor) { color = newColor; }59HRESULT DrawLine(int x1, int y1, int x2, int y2);60HRESULT DrawPoly(jint nPoints, jboolean isClosed,61jint transX, jint transY,62jint *xPoints, jint *yPoints);63HRESULT DrawScanlines(jint scanlineCount, jint *scanlines);64HRESULT DrawRect(int x1, int y1, int x2, int y2);65HRESULT FillRect(int x1, int y1, int x2, int y2);66HRESULT FillParallelogramAA(float fx11, float fy11,67float dx21, float dy21,68float dx12, float dy12);69HRESULT DrawParallelogramAA(float ox11, float oy11,70float ox21, float oy21,71float ox12, float oy12,72float ix11, float iy11,73float ix21, float iy21,74float ix12, float iy12);75HRESULT FillParallelogram(float fx11, float fy11,76float dx21, float dy21,77float dx12, float dy12);78HRESULT FillSpans(jint spansCount, jint *spans);79HRESULT DrawTexture(float dx1, float dy1, float dx2, float dy2,80float tx1, float ty1, float tx2, float ty2);81HRESULT DrawTexture(float dx1, float dy1, float dx2, float dy2,82float t1x1, float t1y1, float t1x2, float t1y2,83float t2x1, float t2y1, float t2x2, float t2y2);84HRESULT Render(int actionType = APPEND_ACTION);85UINT GetFreeVertices() { return (MAX_BATCH_SIZE - firstUnusedVertex); }8687static88HRESULT CreateInstance(D3DContext *pCtx, D3DVertexCacher **ppVC);8990private:91D3DVertexCacher();92HRESULT EnsureCapacity(D3DPRIMITIVETYPE newPType, UINT vNum);9394private:95UINT firstPendingBatch;96UINT firstPendingVertex;97UINT firstUnusedVertex;98UINT currentBatch;99J2DLVERTEX vertices[MAX_BATCH_SIZE];100VertexBatch batches[MAX_BATCH_SIZE];101IDirect3DVertexBuffer9 *lpD3DVertexBuffer;102IDirect3DDevice9 *lpD3DDevice;103D3DContext *pCtx;104jint color;105};106107#endif // D3DVERTEXCACHER_H108109110