1/*
2 * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26#ifndef D3DTextRenderer_h_Included
27#define D3DTextRenderer_h_Included
28
29#include <jni.h>
30#include <jlong.h>
31#include "sun_java2d_pipe_BufferedTextPipe.h"
32#include "AccelGlyphCache.h"
33#include "D3DContext.h"
34#include "D3DSurfaceData.h"
35
36/**
37 * The following constants define the inner and outer bounds of the
38 * accelerated glyph cache.
39 */
40#define D3DTR_CACHE_WIDTH       512
41#define D3DTR_CACHE_HEIGHT      512
42#define D3DTR_CACHE_CELL_WIDTH  16
43#define D3DTR_CACHE_CELL_HEIGHT 16
44
45/**
46 * This constant defines the size of the tile to use in the
47 * D3DTR_DrawLCDGlyphNoCache() method.  See below for more on why we
48 * restrict this value to a particular size.
49 */
50#define D3DTR_NOCACHE_TILE_SIZE 32
51
52/**
53 * These constants define the size of the "cached destination" texture.
54 * This texture is only used when rendering LCD-optimized text, as that
55 * codepath needs direct access to the destination.  There is no way to
56 * access the framebuffer directly from a Direct3D shader, so we need to first
57 * copy the destination region corresponding to a particular glyph into
58 * this cached texture, and then that texture will be accessed inside the
59 * shader.  Copying the destination into this cached texture can be a very
60 * expensive operation (accounting for about half the rendering time for
61 * LCD text), so to mitigate this cost we try to bulk read a horizontal
62 * region of the destination at a time.  (These values are empirically
63 * derived for the common case where text runs horizontally.)
64 *
65 * Note: It is assumed in various calculations below that:
66 *     (D3DTR_CACHED_DEST_WIDTH  >= D3DTR_CACHE_CELL_WIDTH)  &&
67 *     (D3DTR_CACHED_DEST_WIDTH  >= D3DTR_NOCACHE_TILE_SIZE) &&
68 *     (D3DTR_CACHED_DEST_HEIGHT >= D3DTR_CACHE_CELL_HEIGHT) &&
69 *     (D3DTR_CACHED_DEST_HEIGHT >= D3DTR_NOCACHE_TILE_SIZE)
70 */
71#define D3DTR_CACHED_DEST_WIDTH  512
72#define D3DTR_CACHED_DEST_HEIGHT 32
73
74#define BYTES_PER_GLYPH_IMAGE \
75    sun_java2d_pipe_BufferedTextPipe_BYTES_PER_GLYPH_IMAGE
76#define BYTES_PER_GLYPH_POSITION \
77    sun_java2d_pipe_BufferedTextPipe_BYTES_PER_GLYPH_POSITION
78#define BYTES_PER_POSITIONED_GLYPH \
79    (BYTES_PER_GLYPH_IMAGE + BYTES_PER_GLYPH_POSITION)
80
81#define OFFSET_CONTRAST  sun_java2d_pipe_BufferedTextPipe_OFFSET_CONTRAST
82#define OFFSET_RGBORDER  sun_java2d_pipe_BufferedTextPipe_OFFSET_RGBORDER
83#define OFFSET_SUBPIXPOS sun_java2d_pipe_BufferedTextPipe_OFFSET_SUBPIXPOS
84#define OFFSET_POSITIONS sun_java2d_pipe_BufferedTextPipe_OFFSET_POSITIONS
85
86HRESULT D3DTR_EnableGlyphVertexCache(D3DContext *d3dc);
87HRESULT D3DTR_DisableGlyphVertexCache(D3DContext *d3dc);
88
89HRESULT D3DTR_DrawGlyphList(D3DContext *d3dc, D3DSDOps *dstOps,
90                            jint totalGlyphs, jboolean usePositions,
91                            jboolean subPixPos, jboolean rgbOrder,
92                            jint lcdContrast,
93                            jfloat glyphListOrigX, jfloat glyphListOrigY,
94                            unsigned char *images, unsigned char *positions);
95
96#endif /* D3DTextRenderer_h_Included */
97