Merge "underline is now only tracked by android"
This commit is contained in:
committed by
Android (Google) Code Review
commit
11eb33214e
@@ -84,15 +84,15 @@ namespace PaintGlue {
|
||||
}
|
||||
|
||||
static jlong init(JNIEnv* env, jobject) {
|
||||
static_assert(1 << 0 == SkPaint::kAntiAlias_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 2 == SkPaint::kDither_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 3 == SkPaint::kUnderlineText_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 4 == SkPaint::kStrikeThruText_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 5 == SkPaint::kFakeBoldText_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 6 == SkPaint::kLinearText_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 7 == SkPaint::kSubpixelText_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 8 == SkPaint::kDevKernText_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 10 == SkPaint::kEmbeddedBitmapText_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 0 == SkPaint::kAntiAlias_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 2 == SkPaint::kDither_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 3 == SkPaint::kUnderlineText_ReserveFlag, "paint_flags_mismatch");
|
||||
static_assert(1 << 4 == SkPaint::kStrikeThruText_ReserveFlag, "paint_flags_mismatch");
|
||||
static_assert(1 << 5 == SkPaint::kFakeBoldText_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 6 == SkPaint::kLinearText_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 7 == SkPaint::kSubpixelText_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 8 == SkPaint::kDevKernText_Flag, "paint_flags_mismatch");
|
||||
static_assert(1 << 10 == SkPaint::kEmbeddedBitmapText_Flag, "paint_flags_mismatch");
|
||||
|
||||
Paint* obj = new Paint();
|
||||
defaultSettingsForAndroid(obj);
|
||||
@@ -692,11 +692,25 @@ namespace PaintGlue {
|
||||
}
|
||||
|
||||
static void setUnderlineText(jlong paintHandle, jboolean underlineText) {
|
||||
reinterpret_cast<Paint*>(paintHandle)->setUnderlineText(underlineText);
|
||||
Paint* paint = reinterpret_cast<Paint*>(paintHandle);
|
||||
uint32_t flags = paint->getFlags();
|
||||
if (underlineText) {
|
||||
flags |= Paint::kUnderlineText_ReserveFlag;
|
||||
} else {
|
||||
flags &= ~Paint::kUnderlineText_ReserveFlag;
|
||||
}
|
||||
paint->setFlags(flags);
|
||||
}
|
||||
|
||||
static void setStrikeThruText(jlong paintHandle, jboolean strikeThruText) {
|
||||
reinterpret_cast<Paint*>(paintHandle)->setStrikeThruText(strikeThruText);
|
||||
Paint* paint = reinterpret_cast<Paint*>(paintHandle);
|
||||
uint32_t flags = paint->getFlags();
|
||||
if (strikeThruText) {
|
||||
flags |= Paint::kStrikeThruText_ReserveFlag;
|
||||
} else {
|
||||
flags &= ~Paint::kStrikeThruText_ReserveFlag;
|
||||
}
|
||||
paint->setFlags(flags);
|
||||
}
|
||||
|
||||
static void setFakeBoldText(jlong paintHandle, jboolean fakeBoldText) {
|
||||
|
||||
@@ -45,7 +45,7 @@ void Canvas::drawTextDecorations(float x, float y, float length, const SkPaint&
|
||||
} else {
|
||||
flags = paint.getFlags();
|
||||
}
|
||||
if (flags & (SkPaint::kUnderlineText_Flag | SkPaint::kStrikeThruText_Flag)) {
|
||||
if (flags & (SkPaint::kUnderlineText_ReserveFlag | SkPaint::kStrikeThruText_ReserveFlag)) {
|
||||
// Same values used by Skia
|
||||
const float kStdStrikeThru_Offset = (-6.0f / 21.0f);
|
||||
const float kStdUnderline_Offset = (1.0f / 9.0f);
|
||||
@@ -55,12 +55,12 @@ void Canvas::drawTextDecorations(float x, float y, float length, const SkPaint&
|
||||
SkScalar right = x + length;
|
||||
float textSize = paint.getTextSize();
|
||||
float strokeWidth = fmax(textSize * kStdUnderline_Thickness, 1.0f);
|
||||
if (flags & SkPaint::kUnderlineText_Flag) {
|
||||
if (flags & SkPaint::kUnderlineText_ReserveFlag) {
|
||||
SkScalar top = y + textSize * kStdUnderline_Offset - 0.5f * strokeWidth;
|
||||
SkScalar bottom = y + textSize * kStdUnderline_Offset + 0.5f * strokeWidth;
|
||||
drawRect(left, top, right, bottom, paint);
|
||||
}
|
||||
if (flags & SkPaint::kStrikeThruText_Flag) {
|
||||
if (flags & SkPaint::kStrikeThruText_ReserveFlag) {
|
||||
SkScalar top = y + textSize * kStdStrikeThru_Offset - 0.5f * strokeWidth;
|
||||
SkScalar bottom = y + textSize * kStdStrikeThru_Offset + 0.5f * strokeWidth;
|
||||
drawRect(left, top, right, bottom, paint);
|
||||
|
||||
Reference in New Issue
Block a user