michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_FONT_TEST_H michael@0: #define GFX_FONT_TEST_H michael@0: michael@0: #include "nsString.h" michael@0: #include "nsTArray.h" michael@0: michael@0: #include "cairo/cairo.h" michael@0: michael@0: struct gfxFontTestItem { michael@0: gfxFontTestItem(const nsCString& fontName, michael@0: cairo_glyph_t *cglyphs, int nglyphs) michael@0: : platformFont(fontName) michael@0: { michael@0: glyphs = new cairo_glyph_t[nglyphs]; michael@0: memcpy (glyphs, cglyphs, sizeof(cairo_glyph_t) * nglyphs); michael@0: num_glyphs = nglyphs; michael@0: } michael@0: michael@0: gfxFontTestItem(const gfxFontTestItem& other) { michael@0: platformFont = other.platformFont; michael@0: num_glyphs = other.num_glyphs; michael@0: glyphs = new cairo_glyph_t[num_glyphs]; michael@0: memcpy (glyphs, other.glyphs, sizeof(cairo_glyph_t) * num_glyphs); michael@0: } michael@0: michael@0: ~gfxFontTestItem() { michael@0: delete [] glyphs; michael@0: } michael@0: michael@0: nsCString platformFont; michael@0: cairo_glyph_t *glyphs; michael@0: int num_glyphs; michael@0: }; michael@0: michael@0: michael@0: class gfxFontTestStore { michael@0: public: michael@0: gfxFontTestStore() { } michael@0: michael@0: void AddItem (const nsCString& fontString, michael@0: cairo_glyph_t *cglyphs, int nglyphs) michael@0: { michael@0: items.AppendElement(gfxFontTestItem(fontString, cglyphs, nglyphs)); michael@0: } michael@0: michael@0: void AddItem (const nsString& fontString, michael@0: cairo_glyph_t *cglyphs, int nglyphs) michael@0: { michael@0: items.AppendElement(gfxFontTestItem(NS_ConvertUTF16toUTF8(fontString), cglyphs, nglyphs)); michael@0: } michael@0: michael@0: nsTArray items; michael@0: michael@0: public: michael@0: static gfxFontTestStore *CurrentStore() { michael@0: return sCurrentStore; michael@0: } michael@0: michael@0: static gfxFontTestStore *NewStore() { michael@0: if (sCurrentStore) michael@0: delete sCurrentStore; michael@0: michael@0: sCurrentStore = new gfxFontTestStore; michael@0: return sCurrentStore; michael@0: } michael@0: michael@0: static void DeleteStore() { michael@0: if (sCurrentStore) michael@0: delete sCurrentStore; michael@0: michael@0: sCurrentStore = nullptr; michael@0: } michael@0: michael@0: protected: michael@0: static gfxFontTestStore *sCurrentStore; michael@0: }; michael@0: michael@0: michael@0: #endif /* GFX_FONT_TEST_H */