gfx/skia/trunk/include/core/SkFontHost.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2006 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #ifndef SkFontHost_DEFINED
michael@0 11 #define SkFontHost_DEFINED
michael@0 12
michael@0 13 #include "SkTypeface.h"
michael@0 14
michael@0 15 class SkDescriptor;
michael@0 16 class SkScalerContext;
michael@0 17 struct SkScalerContextRec;
michael@0 18 class SkStream;
michael@0 19 class SkWStream;
michael@0 20
michael@0 21 /** \class SkFontHost
michael@0 22
michael@0 23 This class is ported to each environment. It is responsible for bridging
michael@0 24 the gap between the (sort of) abstract class SkTypeface and the
michael@0 25 platform-specific implementation that provides access to font files.
michael@0 26
michael@0 27 One basic task is for each create (subclass of) SkTypeface, the FontHost is
michael@0 28 responsible for assigning a uniqueID. The ID should be unique for the
michael@0 29 underlying font file/data, not unique per typeface instance. Thus it is
michael@0 30 possible/common to request a typeface for the same font more than once
michael@0 31 (e.g. asking for the same font by name several times). The FontHost may
michael@0 32 return seperate typeface instances in that case, or it may choose to use a
michael@0 33 cache and return the same instance (but calling typeface->ref(), since the
michael@0 34 caller is always responsible for calling unref() on each instance that is
michael@0 35 returned). Either way, the fontID for those instance(s) will be the same.
michael@0 36 In addition, the fontID should never be set to 0. That value is used as a
michael@0 37 sentinel to indicate no-font-id.
michael@0 38
michael@0 39 The major aspects are:
michael@0 40 1) Given either a name/style, return a subclass of SkTypeface that
michael@0 41 references the closest matching font available on the host system.
michael@0 42 2) Given the data for a font (either in a stream or a file name), return
michael@0 43 a typeface that allows access to that data.
michael@0 44 3) Each typeface instance carries a 32bit ID for its corresponding font.
michael@0 45 SkFontHost turns that ID into a stream to access the font's data.
michael@0 46 4) Given a font ID, return a subclass of SkScalerContext, which connects a
michael@0 47 font scaler (e.g. freetype or other) to the font's data.
michael@0 48 5) Utilites to manage the font cache (budgeting) and gamma correction
michael@0 49 */
michael@0 50 class SK_API SkFontHost {
michael@0 51 public:
michael@0 52 /** LCDs either have their color elements arranged horizontally or
michael@0 53 vertically. When rendering subpixel glyphs we need to know which way
michael@0 54 round they are.
michael@0 55
michael@0 56 Note, if you change this after startup, you'll need to flush the glyph
michael@0 57 cache because it'll have the wrong type of masks cached.
michael@0 58
michael@0 59 @deprecated use SkPixelGeometry instead.
michael@0 60 */
michael@0 61 enum LCDOrientation {
michael@0 62 kHorizontal_LCDOrientation = 0, //!< this is the default
michael@0 63 kVertical_LCDOrientation = 1
michael@0 64 };
michael@0 65
michael@0 66 /** @deprecated set on Device creation. */
michael@0 67 static void SetSubpixelOrientation(LCDOrientation orientation);
michael@0 68 /** @deprecated get from Device. */
michael@0 69 static LCDOrientation GetSubpixelOrientation();
michael@0 70
michael@0 71 /** LCD color elements can vary in order. For subpixel text we need to know
michael@0 72 the order which the LCDs uses so that the color fringes are in the
michael@0 73 correct place.
michael@0 74
michael@0 75 Note, if you change this after startup, you'll need to flush the glyph
michael@0 76 cache because it'll have the wrong type of masks cached.
michael@0 77
michael@0 78 kNONE_LCDOrder means that the subpixel elements are not spatially
michael@0 79 separated in any usable fashion.
michael@0 80
michael@0 81 @deprecated use SkPixelGeometry instead.
michael@0 82 */
michael@0 83 enum LCDOrder {
michael@0 84 kRGB_LCDOrder = 0, //!< this is the default
michael@0 85 kBGR_LCDOrder = 1,
michael@0 86 kNONE_LCDOrder = 2
michael@0 87 };
michael@0 88
michael@0 89 /** @deprecated set on Device creation. */
michael@0 90 static void SetSubpixelOrder(LCDOrder order);
michael@0 91 /** @deprecated get from Device. */
michael@0 92 static LCDOrder GetSubpixelOrder();
michael@0 93
michael@0 94 private:
michael@0 95 /** Return a new, closest matching typeface given either an existing family
michael@0 96 (specified by a typeface in that family) or by a familyName and a
michael@0 97 requested style.
michael@0 98 1) If familyFace is null, use familyName.
michael@0 99 2) If familyName is null, use data (UTF-16 to cover).
michael@0 100 3) If all are null, return the default font that best matches style
michael@0 101 */
michael@0 102 static SkTypeface* CreateTypeface(const SkTypeface* familyFace,
michael@0 103 const char familyName[],
michael@0 104 SkTypeface::Style style);
michael@0 105
michael@0 106 /** Return a new typeface given the data buffer. If the data does not
michael@0 107 represent a valid font, returns null.
michael@0 108
michael@0 109 If a typeface instance is returned, the caller is responsible for
michael@0 110 calling unref() on the typeface when they are finished with it.
michael@0 111
michael@0 112 The returned typeface may or may not have called ref() on the stream
michael@0 113 parameter. If the typeface has not called ref(), then it may have made
michael@0 114 a copy of the releveant data. In either case, the caller is still
michael@0 115 responsible for its refcnt ownership of the stream.
michael@0 116 */
michael@0 117 static SkTypeface* CreateTypefaceFromStream(SkStream*);
michael@0 118
michael@0 119 /** Return a new typeface from the specified file path. If the file does not
michael@0 120 represent a valid font, this returns null. If a typeface is returned,
michael@0 121 the caller is responsible for calling unref() when it is no longer used.
michael@0 122 */
michael@0 123 static SkTypeface* CreateTypefaceFromFile(const char path[]);
michael@0 124
michael@0 125 ///////////////////////////////////////////////////////////////////////////
michael@0 126
michael@0 127 friend class SkScalerContext;
michael@0 128 friend class SkTypeface;
michael@0 129 };
michael@0 130
michael@0 131 #endif

mercurial