Bumping manifests a=b2g-bump
[gecko.git] / gfx / thebes / gfxFontTest.h
blobd5163e575c9af89b46760065e69293f238c73c1e
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef GFX_FONT_TEST_H
7 #define GFX_FONT_TEST_H
9 #include "nsString.h"
10 #include "nsTArray.h"
12 #include "cairo/cairo.h"
14 struct gfxFontTestItem {
15 gfxFontTestItem(const nsCString& fontName,
16 cairo_glyph_t *cglyphs, int nglyphs)
17 : platformFont(fontName)
19 glyphs = new cairo_glyph_t[nglyphs];
20 memcpy (glyphs, cglyphs, sizeof(cairo_glyph_t) * nglyphs);
21 num_glyphs = nglyphs;
24 gfxFontTestItem(const gfxFontTestItem& other) {
25 platformFont = other.platformFont;
26 num_glyphs = other.num_glyphs;
27 glyphs = new cairo_glyph_t[num_glyphs];
28 memcpy (glyphs, other.glyphs, sizeof(cairo_glyph_t) * num_glyphs);
31 ~gfxFontTestItem() {
32 delete [] glyphs;
35 nsCString platformFont;
36 cairo_glyph_t *glyphs;
37 int num_glyphs;
41 class gfxFontTestStore {
42 public:
43 gfxFontTestStore() { }
45 void AddItem (const nsCString& fontString,
46 cairo_glyph_t *cglyphs, int nglyphs)
48 items.AppendElement(gfxFontTestItem(fontString, cglyphs, nglyphs));
51 void AddItem (const nsString& fontString,
52 cairo_glyph_t *cglyphs, int nglyphs)
54 items.AppendElement(gfxFontTestItem(NS_ConvertUTF16toUTF8(fontString), cglyphs, nglyphs));
57 nsTArray<gfxFontTestItem> items;
59 public:
60 static gfxFontTestStore *CurrentStore() {
61 return sCurrentStore;
64 static gfxFontTestStore *NewStore() {
65 if (sCurrentStore)
66 delete sCurrentStore;
68 sCurrentStore = new gfxFontTestStore;
69 return sCurrentStore;
72 static void DeleteStore() {
73 if (sCurrentStore)
74 delete sCurrentStore;
76 sCurrentStore = nullptr;
79 protected:
80 static gfxFontTestStore *sCurrentStore;
84 #endif /* GFX_FONT_TEST_H */