Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef GFX_FONT_TEST_H |
michael@0 | 7 | #define GFX_FONT_TEST_H |
michael@0 | 8 | |
michael@0 | 9 | #include "nsString.h" |
michael@0 | 10 | #include "nsTArray.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "cairo/cairo.h" |
michael@0 | 13 | |
michael@0 | 14 | struct gfxFontTestItem { |
michael@0 | 15 | gfxFontTestItem(const nsCString& fontName, |
michael@0 | 16 | cairo_glyph_t *cglyphs, int nglyphs) |
michael@0 | 17 | : platformFont(fontName) |
michael@0 | 18 | { |
michael@0 | 19 | glyphs = new cairo_glyph_t[nglyphs]; |
michael@0 | 20 | memcpy (glyphs, cglyphs, sizeof(cairo_glyph_t) * nglyphs); |
michael@0 | 21 | num_glyphs = nglyphs; |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | gfxFontTestItem(const gfxFontTestItem& other) { |
michael@0 | 25 | platformFont = other.platformFont; |
michael@0 | 26 | num_glyphs = other.num_glyphs; |
michael@0 | 27 | glyphs = new cairo_glyph_t[num_glyphs]; |
michael@0 | 28 | memcpy (glyphs, other.glyphs, sizeof(cairo_glyph_t) * num_glyphs); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | ~gfxFontTestItem() { |
michael@0 | 32 | delete [] glyphs; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | nsCString platformFont; |
michael@0 | 36 | cairo_glyph_t *glyphs; |
michael@0 | 37 | int num_glyphs; |
michael@0 | 38 | }; |
michael@0 | 39 | |
michael@0 | 40 | |
michael@0 | 41 | class gfxFontTestStore { |
michael@0 | 42 | public: |
michael@0 | 43 | gfxFontTestStore() { } |
michael@0 | 44 | |
michael@0 | 45 | void AddItem (const nsCString& fontString, |
michael@0 | 46 | cairo_glyph_t *cglyphs, int nglyphs) |
michael@0 | 47 | { |
michael@0 | 48 | items.AppendElement(gfxFontTestItem(fontString, cglyphs, nglyphs)); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | void AddItem (const nsString& fontString, |
michael@0 | 52 | cairo_glyph_t *cglyphs, int nglyphs) |
michael@0 | 53 | { |
michael@0 | 54 | items.AppendElement(gfxFontTestItem(NS_ConvertUTF16toUTF8(fontString), cglyphs, nglyphs)); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | nsTArray<gfxFontTestItem> items; |
michael@0 | 58 | |
michael@0 | 59 | public: |
michael@0 | 60 | static gfxFontTestStore *CurrentStore() { |
michael@0 | 61 | return sCurrentStore; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | static gfxFontTestStore *NewStore() { |
michael@0 | 65 | if (sCurrentStore) |
michael@0 | 66 | delete sCurrentStore; |
michael@0 | 67 | |
michael@0 | 68 | sCurrentStore = new gfxFontTestStore; |
michael@0 | 69 | return sCurrentStore; |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | static void DeleteStore() { |
michael@0 | 73 | if (sCurrentStore) |
michael@0 | 74 | delete sCurrentStore; |
michael@0 | 75 | |
michael@0 | 76 | sCurrentStore = nullptr; |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | protected: |
michael@0 | 80 | static gfxFontTestStore *sCurrentStore; |
michael@0 | 81 | }; |
michael@0 | 82 | |
michael@0 | 83 | |
michael@0 | 84 | #endif /* GFX_FONT_TEST_H */ |