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 D3DGLYPHCACHE_H 27 #define D3DGLYPHCACHE_H 28 29 #include "AccelGlyphCache.h" 30 #include "D3DContext.h" 31 #include "D3DResourceManager.h" 32 33 typedef enum { 34 CACHE_GRAY, 35 CACHE_LCD 36 } GlyphCacheType; 37 38 class D3DContext; 39 class D3DResource; 40 41 class D3DGlyphCache { 42 public: 43 // creates accel. glyph cache if it wasn't created, and the glyph 44 // cache texure 45 HRESULT Init(D3DContext *pCtx); 46 // releases the glyph cache texture, invalidates the accel. glyph cache 47 void ReleaseDefPoolResources(); 48 // releases texture and deletes the accel. glyph cache 49 ~D3DGlyphCache(); 50 51 // adds the glyph to the accel. glyph cache and uploads it into the glyph 52 // cache texture 53 HRESULT AddGlyph(GlyphInfo *glyph); 54 GetGlyphCache()55 GlyphCacheInfo* GetGlyphCache() { return pGlyphCache; } GetGlyphCacheTexture()56 D3DResource* GetGlyphCacheTexture() { return pGlyphCacheRes; } 57 58 // Note: only applicable to CACHE_LCD type of the cache 59 // if the new rgb order doesn't match the current one, invalidates 60 // the accel. glyph cache, also resets the current tileFormat 61 HRESULT CheckGlyphCacheByteOrder(jboolean rgbOrder); 62 63 static 64 HRESULT CreateInstance(D3DContext *pCtx, 65 GlyphCacheType gcType, 66 D3DGlyphCache **ppGlyphCache); 67 68 private: 69 D3DGlyphCache(GlyphCacheType gcType); 70 71 D3DContext *pCtx; 72 GlyphCacheType gcType; 73 D3DResource *pGlyphCacheRes; 74 GlyphCacheInfo *pGlyphCache; 75 TileFormat tileFormat; 76 /** 77 * Relevant only for the CACHE_LCD cache type. 78 * 79 * This value tracks the previous LCD rgbOrder setting, so if the rgbOrder 80 * value has changed since the last time, it indicates that we need to 81 * invalidate the cache, which may already store glyph images in the 82 * reverse order. Note that in most real world applications this value 83 * will not change over the course of the application, but tests like 84 * Font2DTest allow for changing the ordering at runtime, so we need to 85 * handle that case. 86 */ 87 jboolean lastRGBOrder; 88 }; 89 #endif // D3DGLYPHCACHE_H 90