fix bookmaker

add error handling if bmh has #Populate
but include has been marked deprecated

TBR=reed@google.com

Bug: skia:
Change-Id: I1a577bbf95ebe4f5fe46ea2c6a1e1f10f6b8e684
Reviewed-on: https://skia-review.googlesource.com/c/177062
Reviewed-by: Cary Clark <caryclark@skia.org>
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
This commit is contained in:
Cary Clark 2018-12-12 13:32:56 -05:00 committed by Skia Commit-Bot
parent ef3d04e796
commit 05c1dcfd35
4 changed files with 281 additions and 315 deletions

View File

@ -3399,54 +3399,6 @@ Text_Path describes the geometry of Glyphs used to draw text.
#Subtopic Text_Path ##
# ------------------------------------------------------------------------------
#Subtopic Text_Intercepts
#Line # advanced underline, strike through ##
Text_Intercepts describe the intersection of drawn text Glyphs with a pair
of lines parallel to the text advance. Text_Intercepts permits creating a
underline that skips Descenders.
#Method int getTextBlobIntercepts(const SkTextBlob* blob, const SkScalar bounds[2],
SkScalar* intervals) const
#In Text_Intercepts
#Line # returns where lines intersect Text_Blob; underlines ##
#Populate
#Example
#Height 143
void draw(SkCanvas* canvas) {
SkFont font;
font.setSize(120);
SkPoint textPos = { 20, 110 };
int len = 3;
SkTextBlobBuilder textBlobBuilder;
const SkTextBlobBuilder::RunBuffer& run =
textBlobBuilder.allocRun(font, len, textPos.fX, textPos.fY);
run.glyphs[0] = 10;
run.glyphs[1] = 20;
run.glyphs[2] = 30;
sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
SkPaint paint;
SkScalar bounds[] = { 116, 134 };
int count = paint.getTextBlobIntercepts(blob.get(), bounds, nullptr);
std::vector<SkScalar> intervals;
intervals.resize(count);
(void) paint.getTextBlobIntercepts(blob.get(), bounds, &intervals.front());
canvas->drawTextBlob(blob.get(), 0, 0, paint);
paint.setColor(0xFFFF7777);
SkScalar x = textPos.fX;
for (int i = 0; i < count; i+= 2) {
canvas->drawRect({x, bounds[0], intervals[i], bounds[1]}, paint);
x = intervals[i + 1];
}
canvas->drawRect({intervals[count - 1], bounds[0], 180, bounds[1]}, paint);
}
##
##
#Subtopic Text_Intercepts ##
# ------------------------------------------------------------------------------
#Method bool nothingToDraw() const
#In Utility

View File

@ -96,9 +96,16 @@ for (int index = 0; index < 2; ++index) {
# ------------------------------------------------------------------------------
#Subtopic Text_Intercepts
#Line # advanced underline, strike through ##
Text_Intercepts describe the intersection of drawn text Glyphs with a pair
of lines parallel to the text advance. Text_Intercepts permits creating a
underline that skips Descenders.
#Method int getIntercepts(const SkScalar bounds[2], SkScalar intervals[],
const SkPaint* paint = nullptr) const;
#In Utility
#In Text_Intercepts
#Line # returns where lines intersect Text_Blob; underlines ##
#Populate
@ -135,6 +142,8 @@ for (int index = 0; index < 2; ++index) {
#Method ##
#Subtopic Text_Intercepts ##
# ------------------------------------------------------------------------------
#Method static sk_sp<SkTextBlob> MakeFromText(const void* text, size_t byteLength, const SkFont& font,

View File

@ -1828,7 +1828,9 @@ Definition* IncludeParser::findMethod(const Definition& bmhDef) {
className = className.substr(subClassPos + 2);
}
// match may be constructor; compare strings to see if this is so
SkASSERT(string::npos != methodName.find('('));
if (string::npos == methodName.find('(')) {
return nullptr;
}
auto stripper = [](string s) -> string {
bool last = false;
string result;

View File

@ -1668,7 +1668,10 @@ void MdOut::markTypeOut(Definition* def, const Definition** prior) {
SkASSERT(MarkType::kMethod == parent->fMarkType);
// retrieve parameters, return, description from include
Definition* iMethod = fIncludeParser.findMethod(*parent);
SkASSERT(iMethod); // deprecated or 'in progress' functions should not include populate
if (!iMethod) { // deprecated or 'in progress' functions should not include populate
SkDebugf("#Populate found in deprecated or missing method %s\n", def->fName.c_str());
def->fParent->reportError<void>("Remove #Method");
}
bool wroteParam = false;
SkASSERT(fMethod == iMethod);
for (auto& entry : iMethod->fTokens) {