Ejemplo n.º 1
0
void GrContext::drawFontCache(const SkRect& rect, GrMaskFormat format, const SkPaint& paint,
                              GrRenderTarget* target) {
    GrBatchFontCache* cache = this->getBatchFontCache();

    GrTexture* atlas = cache->getTexture(format);

    SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(target));
    // TODO: add drawContext method to encapsulate this.

    GrPaint grPaint;
    SkMatrix mat;
    mat.reset();
    if (!SkPaintToGrPaint(this, paint, mat, &grPaint)) {
        return;
    }
    SkMatrix textureMat;
    textureMat.reset();
    // TODO: use setScaleTranslate()
    textureMat[SkMatrix::kMScaleX] = 1.0f/rect.width();
    textureMat[SkMatrix::kMScaleY] = 1.0f/rect.height();
    textureMat[SkMatrix::kMTransX] = -rect.fLeft/rect.width();
    textureMat[SkMatrix::kMTransY] = -rect.fTop/rect.height();

    grPaint.addColorTextureProcessor(atlas, textureMat);

    GrClip clip;
    drawContext->drawRect(clip, grPaint, mat, rect);
}
Ejemplo n.º 2
0
GrTexture* GrContext::getFontAtlasTexture(GrMaskFormat format) {
    GrBatchFontCache* cache = this->getBatchFontCache();

    return cache->getTexture(format);
}