gfx/skia/trunk/src/sfnt/SkOTTable_glyf.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 * Copyright 2012 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef SkOTTable_glyf_DEFINED
michael@0 9 #define SkOTTable_glyf_DEFINED
michael@0 10
michael@0 11 #include "SkEndian.h"
michael@0 12 #include "SkOTTableTypes.h"
michael@0 13 #include "SkOTTable_head.h"
michael@0 14 #include "SkOTTable_loca.h"
michael@0 15 #include "SkTypedEnum.h"
michael@0 16
michael@0 17 #pragma pack(push, 1)
michael@0 18
michael@0 19 struct SkOTTableGlyphData;
michael@0 20
michael@0 21 extern uint8_t const * const SK_OT_GlyphData_NoOutline;
michael@0 22
michael@0 23 struct SkOTTableGlyph {
michael@0 24 static const SK_OT_CHAR TAG0 = 'g';
michael@0 25 static const SK_OT_CHAR TAG1 = 'l';
michael@0 26 static const SK_OT_CHAR TAG2 = 'y';
michael@0 27 static const SK_OT_CHAR TAG3 = 'f';
michael@0 28 static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableGlyph>::value;
michael@0 29
michael@0 30 class Iterator {
michael@0 31 public:
michael@0 32 Iterator(const SkOTTableGlyph& glyf,
michael@0 33 const SkOTTableIndexToLocation& loca,
michael@0 34 SkOTTableHead::IndexToLocFormat locaFormat)
michael@0 35 : fGlyf(glyf)
michael@0 36 , fLocaFormat(SkOTTableHead::IndexToLocFormat::ShortOffsets == locaFormat.value ? 0 : 1)
michael@0 37 , fCurrentGlyphOffset(0)
michael@0 38 { fLocaPtr.shortOffset = reinterpret_cast<const SK_OT_USHORT*>(&loca); }
michael@0 39
michael@0 40 void advance(uint16_t num) {
michael@0 41 fLocaPtr.shortOffset += num << fLocaFormat;
michael@0 42 fCurrentGlyphOffset = fLocaFormat ? SkEndian_SwapBE32(*fLocaPtr.longOffset)
michael@0 43 : uint32_t(SkEndian_SwapBE16(*fLocaPtr.shortOffset) << 1);
michael@0 44 }
michael@0 45 const SkOTTableGlyphData* next() {
michael@0 46 uint32_t previousGlyphOffset = fCurrentGlyphOffset;
michael@0 47 advance(1);
michael@0 48 if (previousGlyphOffset == fCurrentGlyphOffset) {
michael@0 49 return reinterpret_cast<const SkOTTableGlyphData*>(&SK_OT_GlyphData_NoOutline);
michael@0 50 } else {
michael@0 51 return reinterpret_cast<const SkOTTableGlyphData*>(
michael@0 52 reinterpret_cast<const SK_OT_BYTE*>(&fGlyf) + previousGlyphOffset
michael@0 53 );
michael@0 54 }
michael@0 55 }
michael@0 56 private:
michael@0 57 const SkOTTableGlyph& fGlyf;
michael@0 58 uint16_t fLocaFormat; //0 or 1
michael@0 59 uint32_t fCurrentGlyphOffset;
michael@0 60 union LocaPtr {
michael@0 61 const SK_OT_USHORT* shortOffset;
michael@0 62 const SK_OT_ULONG* longOffset;
michael@0 63 } fLocaPtr;
michael@0 64 };
michael@0 65 };
michael@0 66
michael@0 67 struct SkOTTableGlyphData {
michael@0 68 SK_OT_SHORT numberOfContours; //== -1 Composite, > 0 Simple
michael@0 69 SK_OT_FWORD xMin;
michael@0 70 SK_OT_FWORD yMin;
michael@0 71 SK_OT_FWORD xMax;
michael@0 72 SK_OT_FWORD yMax;
michael@0 73
michael@0 74 struct Simple {
michael@0 75 SK_OT_USHORT endPtsOfContours[1/*numberOfContours*/];
michael@0 76
michael@0 77 struct Instructions {
michael@0 78 SK_OT_USHORT length;
michael@0 79 SK_OT_BYTE data[1/*length*/];
michael@0 80 };
michael@0 81
michael@0 82 union Flags {
michael@0 83 struct Field {
michael@0 84 SK_OT_BYTE_BITFIELD(
michael@0 85 OnCurve,
michael@0 86 xShortVector,
michael@0 87 yShortVector,
michael@0 88 Repeat,
michael@0 89 xIsSame_xShortVectorPositive,
michael@0 90 yIsSame_yShortVectorPositive,
michael@0 91 Reserved6,
michael@0 92 Reserved7)
michael@0 93 } field;
michael@0 94 struct Raw {
michael@0 95 static const SK_OT_USHORT OnCurveMask = SkTEndian_SwapBE16(1 << 0);
michael@0 96 static const SK_OT_USHORT xShortVectorMask = SkTEndian_SwapBE16(1 << 1);
michael@0 97 static const SK_OT_USHORT yShortVectorMask = SkTEndian_SwapBE16(1 << 2);
michael@0 98 static const SK_OT_USHORT RepeatMask = SkTEndian_SwapBE16(1 << 3);
michael@0 99 static const SK_OT_USHORT xIsSame_xShortVectorPositiveMask = SkTEndian_SwapBE16(1 << 4);
michael@0 100 static const SK_OT_USHORT yIsSame_yShortVectorPositiveMask = SkTEndian_SwapBE16(1 << 5);
michael@0 101 SK_OT_BYTE value;
michael@0 102 } raw;
michael@0 103 };
michael@0 104
michael@0 105 //xCoordinates
michael@0 106 //yCoordinates
michael@0 107 };
michael@0 108
michael@0 109 struct Composite {
michael@0 110 struct Component {
michael@0 111 union Flags {
michael@0 112 struct Field {
michael@0 113 //8-15
michael@0 114 SK_OT_BYTE_BITFIELD(
michael@0 115 WE_HAVE_INSTRUCTIONS,
michael@0 116 USE_MY_METRICS,
michael@0 117 OVERLAP_COMPOUND,
michael@0 118 SCALED_COMPONENT_OFFSET,
michael@0 119 UNSCALED_COMPONENT_OFFSET,
michael@0 120 Reserved13,
michael@0 121 Reserved14,
michael@0 122 Reserved15)
michael@0 123 //0-7
michael@0 124 SK_OT_BYTE_BITFIELD(
michael@0 125 ARG_1_AND_2_ARE_WORDS,
michael@0 126 ARGS_ARE_XY_VALUES,
michael@0 127 ROUND_XY_TO_GRID,
michael@0 128 WE_HAVE_A_SCALE,
michael@0 129 RESERVED,
michael@0 130 MORE_COMPONENTS,
michael@0 131 WE_HAVE_AN_X_AND_Y_SCALE,
michael@0 132 WE_HAVE_A_TWO_BY_TWO)
michael@0 133 } field;
michael@0 134 struct Raw {
michael@0 135 static const SK_OT_USHORT ARG_1_AND_2_ARE_WORDS_Mask = SkTEndian_SwapBE16(1 << 0);
michael@0 136 static const SK_OT_USHORT ARGS_ARE_XY_VALUES_Mask = SkTEndian_SwapBE16(1 << 1);
michael@0 137 static const SK_OT_USHORT ROUND_XY_TO_GRID_Mask = SkTEndian_SwapBE16(1 << 2);
michael@0 138 static const SK_OT_USHORT WE_HAVE_A_SCALE_Mask = SkTEndian_SwapBE16(1 << 3);
michael@0 139 static const SK_OT_USHORT RESERVED_Mask = SkTEndian_SwapBE16(1 << 4);
michael@0 140 static const SK_OT_USHORT MORE_COMPONENTS_Mask = SkTEndian_SwapBE16(1 << 5);
michael@0 141 static const SK_OT_USHORT WE_HAVE_AN_X_AND_Y_SCALE_Mask = SkTEndian_SwapBE16(1 << 6);
michael@0 142 static const SK_OT_USHORT WE_HAVE_A_TWO_BY_TWO_Mask = SkTEndian_SwapBE16(1 << 7);
michael@0 143
michael@0 144 static const SK_OT_USHORT WE_HAVE_INSTRUCTIONS_Mask = SkTEndian_SwapBE16(1 << 8);
michael@0 145 static const SK_OT_USHORT USE_MY_METRICS_Mask = SkTEndian_SwapBE16(1 << 9);
michael@0 146 static const SK_OT_USHORT OVERLAP_COMPOUND_Mask = SkTEndian_SwapBE16(1 << 10);
michael@0 147 static const SK_OT_USHORT SCALED_COMPONENT_OFFSET_Mask = SkTEndian_SwapBE16(1 << 11);
michael@0 148 static const SK_OT_USHORT UNSCALED_COMPONENT_OFFSET_mask = SkTEndian_SwapBE16(1 << 12);
michael@0 149 //Reserved
michael@0 150 //Reserved
michael@0 151 //Reserved
michael@0 152 SK_OT_USHORT value;
michael@0 153 } raw;
michael@0 154 } flags;
michael@0 155 SK_OT_USHORT glyphIndex;
michael@0 156 union Transform {
michael@0 157 union Matrix {
michael@0 158 /** !WE_HAVE_A_SCALE & !WE_HAVE_AN_X_AND_Y_SCALE & !WE_HAVE_A_TWO_BY_TWO */
michael@0 159 struct None { } none;
michael@0 160 /** WE_HAVE_A_SCALE */
michael@0 161 struct Scale {
michael@0 162 SK_OT_F2DOT14 a_d;
michael@0 163 } scale;
michael@0 164 /** WE_HAVE_AN_X_AND_Y_SCALE */
michael@0 165 struct ScaleXY {
michael@0 166 SK_OT_F2DOT14 a;
michael@0 167 SK_OT_F2DOT14 d;
michael@0 168 } scaleXY;
michael@0 169 /** WE_HAVE_A_TWO_BY_TWO */
michael@0 170 struct TwoByTwo {
michael@0 171 SK_OT_F2DOT14 a;
michael@0 172 SK_OT_F2DOT14 b;
michael@0 173 SK_OT_F2DOT14 c;
michael@0 174 SK_OT_F2DOT14 d;
michael@0 175 } twoByTwo;
michael@0 176 };
michael@0 177 /** ARG_1_AND_2_ARE_WORDS & ARGS_ARE_XY_VALUES */
michael@0 178 struct WordValue {
michael@0 179 SK_OT_FWORD e;
michael@0 180 SK_OT_FWORD f;
michael@0 181 SkOTTableGlyphData::Composite::Component::Transform::Matrix matrix;
michael@0 182 } wordValue;
michael@0 183 /** !ARG_1_AND_2_ARE_WORDS & ARGS_ARE_XY_VALUES */
michael@0 184 struct ByteValue {
michael@0 185 SK_OT_CHAR e;
michael@0 186 SK_OT_CHAR f;
michael@0 187 SkOTTableGlyphData::Composite::Component::Transform::Matrix matrix;
michael@0 188 } byteValue;
michael@0 189 /** ARG_1_AND_2_ARE_WORDS & !ARGS_ARE_XY_VALUES */
michael@0 190 struct WordIndex {
michael@0 191 SK_OT_USHORT compoundPointIndex;
michael@0 192 SK_OT_USHORT componentPointIndex;
michael@0 193 SkOTTableGlyphData::Composite::Component::Transform::Matrix matrix;
michael@0 194 } wordIndex;
michael@0 195 /** !ARG_1_AND_2_ARE_WORDS & !ARGS_ARE_XY_VALUES */
michael@0 196 struct ByteIndex {
michael@0 197 SK_OT_BYTE compoundPointIndex;
michael@0 198 SK_OT_BYTE componentPointIndex;
michael@0 199 SkOTTableGlyphData::Composite::Component::Transform::Matrix matrix;
michael@0 200 } byteIndex;
michael@0 201 } transform;
michael@0 202 } component;//[] last element does not set MORE_COMPONENTS
michael@0 203
michael@0 204 /** Comes after the last Component if the last component has WE_HAVE_INSTR. */
michael@0 205 struct Instructions {
michael@0 206 SK_OT_USHORT length;
michael@0 207 SK_OT_BYTE data[1/*length*/];
michael@0 208 };
michael@0 209 };
michael@0 210 };
michael@0 211
michael@0 212 #pragma pack(pop)
michael@0 213
michael@0 214 #endif

mercurial