remove code for TextDecorations
BUG=skia:6250 Change-Id: I8c67c69017e0514b09f4583f5f2f9d16dec4f830 Reviewed-on: https://skia-review.googlesource.com/8497 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
7ad8793898
commit
ea91b11872
@ -1647,11 +1647,6 @@ private:
|
||||
// shared by save() and saveLayer()
|
||||
void internalSave();
|
||||
void internalRestore();
|
||||
static void DrawRect(const SkDraw& draw, const SkPaint& paint,
|
||||
const SkRect& r, SkScalar textSize);
|
||||
static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint,
|
||||
const char text[], size_t byteLength,
|
||||
SkScalar x, SkScalar y);
|
||||
|
||||
/*
|
||||
* Returns true if drawing the specified rect (or all if it is null) with the specified
|
||||
|
@ -2669,76 +2669,6 @@ private:
|
||||
SkLazyPaint fLazy;
|
||||
};
|
||||
|
||||
void SkCanvas::DrawRect(const SkDraw& draw, const SkPaint& paint,
|
||||
const SkRect& r, SkScalar textSize) {
|
||||
if (paint.getStyle() == SkPaint::kFill_Style) {
|
||||
draw.fDevice->drawRect(draw, r, paint);
|
||||
} else {
|
||||
SkPaint p(paint);
|
||||
p.setStrokeWidth(textSize * paint.getStrokeWidth());
|
||||
draw.fDevice->drawRect(draw, r, p);
|
||||
}
|
||||
}
|
||||
|
||||
void SkCanvas::DrawTextDecorations(const SkDraw& draw, const SkPaint& paint,
|
||||
const char text[], size_t byteLength,
|
||||
SkScalar x, SkScalar y) {
|
||||
SkASSERT(byteLength == 0 || text != nullptr);
|
||||
|
||||
// nothing to draw
|
||||
if (text == nullptr || byteLength == 0 ||
|
||||
draw.fRC->isEmpty() ||
|
||||
(paint.getAlpha() == 0 && paint.isSrcOver())) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkScalar width = 0;
|
||||
SkPoint start;
|
||||
|
||||
start.set(0, 0); // to avoid warning
|
||||
if (paint.getFlags() & (SkPaint::kUnderlineText_Flag |
|
||||
SkPaint::kStrikeThruText_Flag)) {
|
||||
width = paint.measureText(text, byteLength);
|
||||
|
||||
SkScalar offsetX = 0;
|
||||
if (paint.getTextAlign() == SkPaint::kCenter_Align) {
|
||||
offsetX = SkScalarHalf(width);
|
||||
} else if (paint.getTextAlign() == SkPaint::kRight_Align) {
|
||||
offsetX = width;
|
||||
}
|
||||
start.set(x - offsetX, y);
|
||||
}
|
||||
|
||||
if (0 == width) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t flags = paint.getFlags();
|
||||
|
||||
if (flags & (SkPaint::kUnderlineText_Flag |
|
||||
SkPaint::kStrikeThruText_Flag)) {
|
||||
SkScalar textSize = paint.getTextSize();
|
||||
SkScalar height = textSize * kStdUnderline_Thickness;
|
||||
SkRect r;
|
||||
|
||||
r.fLeft = start.fX;
|
||||
r.fRight = start.fX + width;
|
||||
|
||||
if (flags & SkPaint::kUnderlineText_Flag) {
|
||||
SkScalar offset = textSize * kStdUnderline_Offset + start.fY;
|
||||
r.fTop = offset;
|
||||
r.fBottom = offset + height;
|
||||
DrawRect(draw, paint, r, 1);
|
||||
}
|
||||
if (flags & SkPaint::kStrikeThruText_Flag) {
|
||||
SkScalar offset = textSize * kStdStrikeThru_Offset + start.fY;
|
||||
r.fTop = offset;
|
||||
r.fBottom = offset + height;
|
||||
DrawRect(draw, paint, r, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SkCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
|
||||
const SkPaint& paint) {
|
||||
LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, nullptr)
|
||||
@ -2746,8 +2676,6 @@ void SkCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkSca
|
||||
while (iter.next()) {
|
||||
SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint());
|
||||
iter.fDevice->drawText(iter, text, byteLength, x, y, dfp.paint());
|
||||
DrawTextDecorations(iter, dfp.paint(),
|
||||
static_cast<const char*>(text), byteLength, x, y);
|
||||
}
|
||||
|
||||
LOOPER_END
|
||||
|
Loading…
Reference in New Issue
Block a user