SkPDF: Glyph validation change
authorhalcanary <halcanary@google.com>
Fri, 2 Sep 2016 14:28:17 +0000 (07:28 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 2 Sep 2016 14:28:17 +0000 (07:28 -0700)
commit9baacd93a1fa5e2518b492bfd293c13e2020e62c
treebcee167ec593eb630a0f4e575abab569ce3dde19
parent9d08cbc8c6131ff61a1e71cc5c8cf27841d62b42
SkPDF: Glyph validation change

[cherry-pick https://skia.googlesource.com/skia.git/+/4871f22 to m54]

Instead of mapping invaid glyphIDs to zero or maxGlyphID,
don't draw them at all.

Validate glyphs when glyph is written, not ahead of time.

Don't allocate array to copy user-provided glyphs.

Easy early exit from SkPDFDevice::internalDrawText()
    GlyphPositioner::flush() called ~GlyphPositioner()
    SkScopeExit class now exists.

Assume SkTypeface* pointers are now never null in more
places.

precalculate alignmentFactor to clean up code.

SkPDFDevice::updateFont must be called with validated
glyphID.  Skip bad glyphs to make this true.

SkPDFDevice::updateFont always succeeds.

SkPDFFont::GetFontResource always succeeds (preconditions are
asserted).  If GetMetrics fails, don't call GetFontResource.

SkPDFFont::glyphsToPDFFontEncodingCount() becomes
SkPDFFont::countStretch() and is inlined.

SkPDFFont::glyphsToPDFFontEncoding now works one Glyph at a
time and is inlined.

SkPDFFont::noteGlyphUsage() operates one glyph at a time.

Add SkScopeExit.h; also a unit test for it.

SkPostConfig: Fix SK_UNUSED for Win32.

No public API changes.
TBR=reed@google.com

BUG=625995

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2278703002

Review-Url: https://codereview.chromium.org/2278703002
NOTREECHECKS=true
NOTRY=true
NOPRESUBMIT=true

Review-Url: https://codereview.chromium.org/2302353002
include/core/SkPostConfig.h
src/pdf/SkPDFDevice.cpp
src/pdf/SkPDFDevice.h
src/pdf/SkPDFFont.cpp
src/pdf/SkPDFFont.h
src/pdf/SkScopeExit.h [new file with mode: 0644]
tests/CPlusPlusEleven.cpp