// static void TextPainter::updateGraphicsContext(GraphicsContext& context, const Style& textStyle, bool horizontal, GraphicsContextStateSaver& stateSaver) { TextDrawingModeFlags mode = context.textDrawingMode(); if (textStyle.strokeWidth > 0) { TextDrawingModeFlags newMode = mode | TextModeStroke; if (mode != newMode) { if (!stateSaver.saved()) stateSaver.save(); context.setTextDrawingMode(newMode); mode = newMode; } } if (mode & TextModeFill && textStyle.fillColor != context.fillColor()) context.setFillColor(textStyle.fillColor); if (mode & TextModeStroke) { if (textStyle.strokeColor != context.strokeColor()) context.setStrokeColor(textStyle.strokeColor); if (textStyle.strokeWidth != context.strokeThickness()) context.setStrokeThickness(textStyle.strokeWidth); } if (textStyle.shadow) { if (!stateSaver.saved()) stateSaver.save(); context.setDrawLooper(textStyle.shadow->createDrawLooper( DrawLooperBuilder::ShadowIgnoresAlpha, textStyle.currentColor, horizontal)); } }
// static void TextPainter::updateGraphicsContext(GraphicsContext* context, const Style& textStyle, bool horizontal, GraphicsContextStateSaver& stateSaver) { TextDrawingModeFlags mode = context->textDrawingMode(); if (textStyle.strokeWidth > 0) { TextDrawingModeFlags newMode = mode | TextModeStroke; if (mode != newMode) { if (!stateSaver.saved()) stateSaver.save(); context->setTextDrawingMode(newMode); mode = newMode; } } if (mode & TextModeFill && textStyle.fillColor != context->fillColor()) context->setFillColor(textStyle.fillColor); if (mode & TextModeStroke) { if (textStyle.strokeColor != context->strokeColor()) context->setStrokeColor(textStyle.strokeColor); if (textStyle.strokeWidth != context->strokeThickness()) context->setStrokeThickness(textStyle.strokeWidth); } // Text shadows are disabled when printing. http://crbug.com/258321 if (textStyle.shadow && !context->printing()) { if (!stateSaver.saved()) stateSaver.save(); context->setDrawLooper(textStyle.shadow->createDrawLooper(DrawLooperBuilder::ShadowIgnoresAlpha, textStyle.currentColor, horizontal)); } }