diff options
author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-04-14 14:28:22 +0000 |
---|---|---|
committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-04-14 14:28:22 +0000 |
commit | 9781ca586618cc8ea055f54021e706824313d4f5 (patch) | |
tree | 2d6d4dffba13e109d846a049d21c0239f4acbf8f /src/utils | |
parent | fc3ac327d8e041e11049d7f0dfc7f491590cda75 (diff) |
add SkSfntUtils to parse some known truetype tables
add comments and cleanup to count_tables in SkFontHost_tables.cpp
fix transparency bug in gifs
use (alpha+1) for blending in srcover mode, to ensure opaque results
git-svn-id: http://skia.googlecode.com/svn/trunk@155 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/SkNinePatch.cpp | 2 | ||||
-rw-r--r-- | src/utils/SkSfntUtils.cpp | 87 | ||||
-rw-r--r-- | src/utils/utils_files.mk | 10 |
3 files changed, 98 insertions, 1 deletions
diff --git a/src/utils/SkNinePatch.cpp b/src/utils/SkNinePatch.cpp index b8e11fbcaf..3d85edcf93 100644 --- a/src/utils/SkNinePatch.cpp +++ b/src/utils/SkNinePatch.cpp @@ -186,7 +186,7 @@ void SkNinePatch::DrawMesh(SkCanvas* canvas, const SkRect& bounds, if (numXDivs == 2 && numYDivs <= 2) { mesh.fIndices = g3x3Indices; } else { - int n = fillIndices(indices, numXDivs + 1, numYDivs + 1); + SkDEBUGCODE(int n =) fillIndices(indices, numXDivs + 1, numYDivs + 1); SkASSERT(n == indexCount); mesh.fIndices = indices; } diff --git a/src/utils/SkSfntUtils.cpp b/src/utils/SkSfntUtils.cpp new file mode 100644 index 0000000000..36f1f97da9 --- /dev/null +++ b/src/utils/SkSfntUtils.cpp @@ -0,0 +1,87 @@ +#include "SkEndian.h" +#include "SkSfntUtils.h" + +static uint16_t parse_be16(const uint8_t*& p) { + uint16_t value = (p[0] << 8) | p[1]; + p += 2; + return value; +} + +static uint32_t parse_be32(const uint8_t*& p) { + uint32_t value = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; + p += 4; + return value; +} + +static Sk64 parse_be64(const uint8_t*& p) { + Sk64 value; + value.fHi = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; + value.fLo = (p[4] << 24) | (p[5] << 16) | (p[6] << 8) | p[7]; + p += 8; + return value; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool SkSfntUtils::ReadTable_head(SkFontID fontID, SkSfntTable_head* head) { + static const uint32_t gTag = SkSetFourByteTag('h', 'e', 'a', 'd'); + static const ssize_t gSize = 54; + + uint8_t storage[gSize]; + ssize_t size = SkFontHost::GetTableData(fontID, gTag, 0, gSize, storage); + if (size != gSize) { + return false; + } + + const uint8_t* p = storage; + head->fVersion = parse_be32(p); + head->fRevision = parse_be32(p); + head->fCheckSumAdjustment = parse_be32(p); + head->fMagicNumber = parse_be32(p); + head->fFlags = parse_be16(p); + head->fUnitsPerEm = parse_be16(p); + head->fDateCreated = parse_be64(p); + head->fDateModified = parse_be64(p); + head->fXMin = parse_be16(p); + head->fXMin = parse_be16(p); + head->fXMin = parse_be16(p); + head->fXMin = parse_be16(p); + head->fMacStyle = parse_be16(p); + head->fLowestPPEM = parse_be16(p); + head->fFontDirectionHint = parse_be16(p); + head->fIndexToLocFormat = parse_be16(p); + head->fGlyphDataFormat = parse_be16(p); + SkASSERT(p - storage == size); + return true; +} + +bool SkSfntUtils::ReadTable_maxp(SkFontID fontID, SkSfntTable_maxp* maxp) { + static const uint32_t gTag = SkSetFourByteTag('m', 'a', 'x', 'p'); + static const ssize_t gSize = 32; + + uint8_t storage[gSize]; + ssize_t size = SkFontHost::GetTableData(fontID, gTag, 0, gSize, storage); + if (size != gSize) { + return false; + } + + const uint8_t* p = storage; + maxp->fVersion = parse_be32(p); + maxp->fNumGlyphs = parse_be16(p); + maxp->fMaxPoints = parse_be16(p); + maxp->fMaxContours = parse_be16(p); + maxp->fMaxComponentPoints = parse_be16(p); + maxp->fMaxComponentContours = parse_be16(p); + maxp->fMaxZones = parse_be16(p); + maxp->fMaxTwilightPoints = parse_be16(p); + maxp->fMaxStorage = parse_be16(p); + maxp->fMaxFunctionDefs = parse_be16(p); + maxp->fMaxInstructionDefs = parse_be16(p); + maxp->fMaxStackElements = parse_be16(p); + maxp->fMaxSizeOfInstructions = parse_be16(p); + maxp->fMaxComponentElements = parse_be16(p); + maxp->fMaxComponentDepth = parse_be16(p); + SkASSERT(p - storage == size); + return true; +} + diff --git a/src/utils/utils_files.mk b/src/utils/utils_files.mk new file mode 100644 index 0000000000..a8c9496a86 --- /dev/null +++ b/src/utils/utils_files.mk @@ -0,0 +1,10 @@ +SOURCE := \ + SkCamera.cpp \ + SkColorMatrix.cpp \ + SkCullPoints.cpp \ + SkDumpCanvas.cpp \ + SkInterpolator.cpp \ + SkNinePatch.cpp \ + SkProxyCanvas.cpp \ + SkSfntUtils.cpp \ + SkUnitMappers.cpp |