本文整理汇总了C++中SkPaint::countText方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPaint::countText方法的具体用法?C++ SkPaint::countText怎么用?C++ SkPaint::countText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPaint
的用法示例。
在下文中一共展示了SkPaint::countText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawPosTextH
void SkPictureRecord::drawPosTextH(const void* text, size_t byteLength,
const SkScalar xpos[], SkScalar constY,
const SkPaint& paint) {
size_t points = paint.countText(text, byteLength);
if (0 == points)
return;
bool fast = paint.canComputeFastBounds();
addDraw(fast ? DRAW_POS_TEXT_H_TOP_BOTTOM : DRAW_POS_TEXT_H);
addPaint(paint);
addText(text, byteLength);
addInt(points);
#ifdef SK_DEBUG_SIZE
size_t start = fWriter.size();
#endif
if (fast) {
addFontMetricsTopBottom(paint, constY);
}
addScalar(constY);
fWriter.writeMul4(xpos, points * sizeof(SkScalar));
#ifdef SK_DEBUG_SIZE
fPointBytes += fWriter.size() - start;
fPointWrites += points;
#endif
validate();
}
示例2: drawPosTextH
void SkRecorder::drawPosTextH(const void* text, size_t byteLength,
const SkScalar xpos[], SkScalar constY, const SkPaint& paint) {
const unsigned points = paint.countText(text, byteLength);
APPEND(DrawPosTextH,
this->copy((const char*)text, byteLength), byteLength,
this->copy(xpos, points), constY, delay_copy(paint));
}
示例3: onDrawTextRSXform
void SkPipeCanvas::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
const SkRect* cull, const SkPaint& paint) {
SkASSERT(byteLength);
bool compact = fits_in(byteLength, 23);
unsigned extra = compact ? (byteLength << 1) : 0;
if (cull) {
extra |= 1;
}
SkPipeWriter writer(this);
writer.write32(pack_verb(SkPipeVerb::kDrawTextRSXform, extra));
if (!compact) {
writer.write32(SkToU32(byteLength));
}
write_pad(&writer, text, byteLength);
int count = paint.countText(text, byteLength);
writer.write32(count); // maybe we can/should store this in extra as well?
writer.write(xform, count * sizeof(SkRSXform));
if (cull) {
writer.writeRect(*cull);
}
write_paint(writer, paint, kText_PaintUsage);
}
示例4: operator
void operator()(const char text[], size_t length, SkScalar x, SkScalar y,
const SkPaint& paint) override {
SkPaint p(paint);
p.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
const int count = paint.countText(text, length);
paint.textToGlyphs(text, length, fBuilder.allocRun(p, count, x, y).glyphs);
}
示例5: onDrawTextRSXform
void SkRecorder::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
const SkRect* cull, const SkPaint& paint) {
APPEND(DrawTextRSXform,
paint,
this->copy((const char*)text, byteLength),
byteLength,
this->copy(xform, paint.countText(text, byteLength)),
this->copy(cull));
}
示例6: onDrawPosText
void SkRecorder::onDrawPosText(const void* text, size_t byteLength,
const SkPoint pos[], const SkPaint& paint) {
const int points = paint.countText(text, byteLength);
APPEND(DrawPosText,
paint,
this->copy((const char*)text, byteLength),
byteLength,
this->copy(pos, points));
}
示例7: onDrawPosTextH
void SkRecorder::onDrawPosTextH(const void* text, size_t byteLength,
const SkScalar xpos[], SkScalar constY, const SkPaint& paint) {
const int points = paint.countText(text, byteLength);
APPEND(DrawPosTextH,
paint,
this->copy((const char*)text, byteLength),
SkToUInt(byteLength),
constY,
this->copy(xpos, points));
}
示例8: onDrawPosText
void LoggingCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint& paint)
{
AutoLogger logger(this);
RefPtr<JSONObject> params = logger.logItemWithParams("drawPosText");
params->setString("text", stringForText(text, byteLength, paint));
size_t pointsCount = paint.countText(text, byteLength);
params->setArray("pos", arrayForSkPoints(pointsCount, pos));
params->setObject("paint", objectForSkPaint(paint));
this->SkCanvas::onDrawPosText(text, byteLength, pos, paint);
}
示例9: drawPosText
void SkPictureRecord::drawPosText(const void* text, size_t byteLength,
const SkPoint pos[], const SkPaint& paint) {
size_t points = paint.countText(text, byteLength);
if (0 == points)
return;
bool canUseDrawH = true;
// check if the caller really should have used drawPosTextH()
{
const SkScalar firstY = pos[0].fY;
for (size_t index = 1; index < points; index++) {
if (pos[index].fY != firstY) {
canUseDrawH = false;
break;
}
}
}
bool fast = canUseDrawH && paint.canComputeFastBounds();
if (fast) {
addDraw(DRAW_POS_TEXT_H_TOP_BOTTOM);
} else {
addDraw(canUseDrawH ? DRAW_POS_TEXT_H : DRAW_POS_TEXT);
}
addPaint(paint);
addText(text, byteLength);
addInt(points);
#ifdef SK_DEBUG_SIZE
size_t start = fWriter.size();
#endif
if (canUseDrawH) {
if (fast) {
addFontMetricsTopBottom(paint, pos[0].fY);
}
addScalar(pos[0].fY);
SkScalar* xptr = (SkScalar*)fWriter.reserve(points * sizeof(SkScalar));
for (size_t index = 0; index < points; index++)
*xptr++ = pos[index].fX;
}
else {
fWriter.writeMul4(pos, points * sizeof(SkPoint));
}
#ifdef SK_DEBUG_SIZE
fPointBytes += fWriter.size() - start;
fPointWrites += points;
#endif
validate();
}
示例10: onDrawPosText
void SkPipeCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
const SkPaint& paint) {
SkASSERT(byteLength);
bool compact = fits_in(byteLength, 24);
SkPipeWriter writer(this);
writer.write32(pack_verb(SkPipeVerb::kDrawPosText, compact ? (unsigned)byteLength : 0));
if (!compact) {
writer.write32(SkToU32(byteLength));
}
write_pad(&writer, text, byteLength);
writer.writePointArray(pos, paint.countText(text, byteLength));
write_paint(writer, paint, kText_PaintUsage);
}
示例11: exercise_draw_pos_text_h
static void exercise_draw_pos_text_h(SkCanvas* canvas,
const char* text,
SkScalar x, SkScalar y,
const SkPaint& paint) {
size_t textLen = strlen(text);
int count = paint.countText(text, textLen);
SkAutoTArray<SkScalar> widths(count);
paint.getTextWidths(text, textLen, &widths[0]);
SkAutoTArray<SkScalar> pos(count);
for (int i = 0; i < count; ++i) {
pos[i] = x;
x += widths[i];
}
canvas->drawPosTextH(text, textLen, &pos[0], y, paint);
}
示例12: onDrawPosText
void SkPictureRecord::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
const SkPaint& paint) {
int points = paint.countText(text, byteLength);
// op + paint index + length + 'length' worth of data + num points + x&y point data
size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + points * sizeof(SkPoint);
DrawType op = DRAW_POS_TEXT;
size_t initialOffset = this->addDraw(op, &size);
this->addPaint(paint);
this->addText(text, byteLength);
this->addInt(points);
fWriter.writeMul4(pos, points * sizeof(SkPoint));
this->validate(initialOffset, size);
}
示例13: onDrawPosTextH
void SkPictureRecord::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
SkScalar constY, const SkPaint& paint) {
int points = paint.countText(text, byteLength);
// op + paint index + length + 'length' worth of data + num points
size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 1 * kUInt32Size;
// + y + the actual points
size += 1 * kUInt32Size + points * sizeof(SkScalar);
size_t initialOffset = this->addDraw(DRAW_POS_TEXT_H, &size);
this->addPaint(paint);
this->addText(text, byteLength);
this->addInt(points);
this->addScalar(constY);
fWriter.writeMul4(xpos, points * sizeof(SkScalar));
this->validate(initialOffset, size);
}
示例14: drawPosText
void SkBBoxRecord::drawPosText(const void* text, size_t byteLength,
const SkPoint pos[], const SkPaint& paint) {
SkRect bbox;
bbox.set(pos, paint.countText(text, byteLength));
SkPaint::FontMetrics metrics;
paint.getFontMetrics(&metrics);
bbox.fTop += metrics.fTop;
bbox.fBottom += metrics.fBottom;
// pad on left and right by half of max vertical glyph extents
SkScalar pad = (metrics.fTop - metrics.fBottom) / 2;
bbox.fLeft += pad;
bbox.fRight -= pad;
if (this->transformBounds(bbox, &paint)) {
INHERITED::drawPosText(text, byteLength, pos, paint);
}
}
示例15: INHERITED
SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength,
const SkPoint pos[], const SkPaint& paint)
: INHERITED(DRAW_POS_TEXT) {
size_t numPts = paint.countText(text, byteLength);
fText = new char[byteLength];
memcpy(fText, text, byteLength);
fByteLength = byteLength;
fPos = new SkPoint[numPts];
memcpy(fPos, pos, numPts * sizeof(SkPoint));
fPaint = paint;
fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
// TODO(chudy): Test that this works.
fInfo.push(SkObjectParser::PointsToString(pos, 1));
fInfo.push(SkObjectParser::PaintToString(paint));
}