コード例 #1
0
ファイル: WebFontImpl.cpp プロジェクト: kjthegod/WebKit
void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFloatPoint& leftBaseline,
                           WebColor color, const WebRect& clip, bool canvasIsOpaque,
                           int from, int to) const
{
    FontCachePurgePreventer fontCachePurgePreventer;
    FloatRect textClipRect(clip);
    TextRun textRun(run);
    TextRunPaintInfo runInfo(textRun);
    runInfo.from = from;
    runInfo.to = to == -1 ? textRun.length() : to;
    runInfo.bounds = textClipRect;
    GraphicsContext gc(canvas, nullptr);

    gc.save();
    gc.setCertainlyOpaque(canvasIsOpaque);
    gc.setFillColor(color);
    gc.clip(textClipRect);
    m_font.drawText(&gc, runInfo, leftBaseline);
    gc.restore();
}
コード例 #2
0
ファイル: WebFontImpl.cpp プロジェクト: windyuuy/opera
void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFloatPoint& leftBaseline,
                           WebColor color, const WebRect& clip, bool canvasIsOpaque,
                           int from, int to) const
{
    FontCachePurgePreventer fontCachePurgePreventer;
    WebCore::FloatRect textClipRect(clip);
    TextRun textRun(run);
    TextRunPaintInfo runInfo(textRun);
    runInfo.from = from;
    runInfo.to = to == -1 ? textRun.length() : to;
    runInfo.bounds = textClipRect;
    GraphicsContext gc(canvas);

    gc.save();
    gc.setCertainlyOpaque(canvasIsOpaque);
    gc.setFillColor(color);
    gc.clip(textClipRect);
    m_font.drawText(&gc, runInfo, leftBaseline);
    gc.restore();

#if defined(WIN32)
    if (canvasIsOpaque && SkColorGetA(color) == 0xFF && !canvas->isDrawingToLayer()) {
        // The text drawing logic on Windows ignores the alpha component
        // intentionally, for performance reasons.
        // (Please see TransparencyAwareFontPainter::initializeForGDI in
        // FontChromiumWin.cpp.)
        const SkBitmap& bitmap = canvas->getTopDevice()->accessBitmap(true);
        IntRect textBounds = estimateTextBounds(run, leftBaseline);
        IntRect destRect = gc.getCTM().mapRect(textBounds);
        destRect.intersect(IntRect(0, 0, bitmap.width(), bitmap.height()));
        for (int y = destRect.y(), maxY = destRect.maxY(); y < maxY; y++) {
            uint32_t* row = bitmap.getAddr32(0, y);
            for (int x = destRect.x(), maxX = destRect.maxX(); x < maxX; x++)
                row[x] |= (0xFF << SK_A32_SHIFT);
        }
    }
#endif
}
コード例 #3
0
ファイル: WebFont.cpp プロジェクト: endlessm/chromium-browser
void WebFont::drawText(WebCanvas* canvas, const WebTextRun& run,
    const WebFloatPoint& leftBaseline, WebColor color, const WebRect& clip) const
{
    FontCachePurgePreventer fontCachePurgePreventer;
    FloatRect textClipRect(clip);
    TextRun textRun(run);
    TextRunPaintInfo runInfo(textRun);
    runInfo.bounds = textClipRect;

    IntRect intRect(clip);
    SkPictureBuilder pictureBuilder(intRect);
    GraphicsContext& context = pictureBuilder.context();

    {
        DrawingRecorder drawingRecorder(context, pictureBuilder, DisplayItem::WebFont, intRect);
        context.save();
        context.setFillColor(color);
        context.clip(textClipRect);
        context.drawText(m_private->getFont(), runInfo, leftBaseline);
        context.restore();
    }

    pictureBuilder.endRecording()->playback(canvas);
}