void SkGlyphCache::AddPoints(const SkPoint* pts, int ptCount, const SkScalar bounds[2], bool yAxis, SkGlyph::Intercept* intercept) { for (int i = 0; i < ptCount; ++i) { SkScalar val = *(&pts[i].fY - yAxis); if (bounds[0] < val && val < bounds[1]) { AddInterval(*(&pts[i].fX + yAxis), intercept); } } }
void SkGlyphCache::AddLine(const SkPoint pts[2], SkScalar axis, bool yAxis, SkGlyph::Intercept* intercept) { SkScalar t = yAxis ? (axis - pts[0].fX) / (pts[1].fX - pts[0].fX) : (axis - pts[0].fY) / (pts[1].fY - pts[0].fY); if (0 <= t && t < 1) { // this handles divide by zero above AddInterval(yAxis ? pts[0].fY + t * (pts[1].fY - pts[0].fY) : pts[0].fX + t * (pts[1].fX - pts[0].fX), intercept); } }
void SkGlyphCache::AddCubic(const SkPoint pts[3], SkScalar axis, bool yAxis, SkGlyph::Intercept* intercept) { SkDCubic cubic; cubic.set(pts); double roots[3]; int count = yAxis ? cubic.verticalIntersect(axis, roots) : cubic.horizontalIntersect(axis, roots); while (--count >= 0) { SkPoint pt = cubic.ptAtT(roots[count]).asSkPoint(); AddInterval(*(&pt.fX + yAxis), intercept); } }
void SkGlyphCache::AddQuad(const SkPoint pts[2], SkScalar axis, bool yAxis, SkGlyph::Intercept* intercept) { SkDQuad quad; quad.set(pts); double roots[2]; int count = yAxis ? quad.verticalIntersect(axis, roots) : quad.horizontalIntersect(axis, roots); while (--count >= 0) { SkPoint pt = quad.ptAtT(roots[count]).asSkPoint(); AddInterval(*(&pt.fX + yAxis), intercept); } }
static void FindInterval( ChewingData *pgdata, TreeDataType *ptd ) { int end, begin, pho_id; Phrase *p_phrase, *puserphrase, *pdictphrase; UsedPhraseMode i_used_phrase; uint16_t new_phoneSeq[ MAX_PHONE_SEQ_LEN ]; for ( begin = 0; begin < pgdata->nPhoneSeq; begin++ ) { for ( end = begin; end < pgdata->nPhoneSeq; end++ ) { if ( ! CheckBreakpoint( begin, end + 1, pgdata->bArrBrkpt ) ) continue; /* set new_phoneSeq */ memcpy( new_phoneSeq, &pgdata->phoneSeq[ begin ], sizeof( uint16_t ) * ( end - begin + 1 ) ); new_phoneSeq[ end - begin + 1 ] = 0; puserphrase = pdictphrase = NULL; i_used_phrase = USED_PHRASE_NONE; /* check user phrase */ if ( UserGetPhraseFirst( pgdata, new_phoneSeq ) && CheckUserChoose( pgdata, new_phoneSeq, begin, end + 1, &p_phrase, pgdata->selectStr, pgdata->selectInterval, pgdata->nSelect ) ) { puserphrase = p_phrase; } /* check dict phrase */ pho_id = TreeFindPhrase( pgdata, begin, end, pgdata->phoneSeq ); if ( ( pho_id != -1 ) && CheckChoose( pgdata, pho_id, begin, end + 1, &p_phrase, pgdata->selectStr, pgdata->selectInterval, pgdata->nSelect ) ) { pdictphrase = p_phrase; } /* add only one interval, which has the largest freqency * but when the phrase is the same, the user phrase overrides * static dict */ if ( puserphrase != NULL && pdictphrase == NULL ) { i_used_phrase = USED_PHRASE_USER; } else if ( puserphrase == NULL && pdictphrase != NULL ) { i_used_phrase = USED_PHRASE_DICT; } else if ( puserphrase != NULL && pdictphrase != NULL ) { /* the same phrase, userphrase overrides */ if ( ! strcmp( puserphrase->phrase, pdictphrase->phrase ) ) { i_used_phrase = USED_PHRASE_USER; } else { if ( puserphrase->freq > pdictphrase->freq ) { i_used_phrase = USED_PHRASE_USER; } else { i_used_phrase = USED_PHRASE_DICT; } } } switch ( i_used_phrase ) { case USED_PHRASE_USER: AddInterval( ptd, begin, end, -1, puserphrase, IS_USER_PHRASE ); break; case USED_PHRASE_DICT: AddInterval( ptd, begin, end, pho_id, pdictphrase, IS_DICT_PHRASE ); break; case USED_PHRASE_NONE: default: break; } internal_release_Phrase( i_used_phrase, puserphrase, pdictphrase ); } } }