[cairo] optimizing cairo_show_text for directfb.

haithem rahmani haithem.rahmani at gmail.com
Tue Oct 28 08:59:41 PDT 2008


Hi all,

I'm trying to optimize the "cairo_show_text" for the "DirectFB/freetype"
backend.
So I added the following function to the cairo-directfb-surface.c.

It compiles fine.

but calling it from the cairo_show_text,

I got the "printf"  put at the end of the function but NOTHING on the
screen.

any Idea?

Notice:


   -  I took the same code of "_cairo_directfb_surface_show_glyphs" and
   juste modified it a bit to call the DrawString.
   -  I don't know how to set the Font File so I setting it in a envirement
   Variable.
   - I failed to enable the debug messages from cairo. Do they need the
   build to be in debug mode ?

regards.



_cairo_directfb_surface_show_text (cairo_surface_t      *surface,
                                   cairo_operator_t      op,
                                   cairo_pattern_t      *pattern,
                                   const char            *utf8,
                                   double                 x,
                                   double                 y,
                                   cairo_scaled_font_t  *scaled_font)
{
    cairo_directfb_surface_t      *dst = surface;
    cairo_directfb_font_cache_t   *cache;
    cairo_status_t               ret;
    DFBSurfaceBlittingFlags      flags;
    DFBSurfaceBlendFunction      sblend;
    DFBSurfaceBlendFunction      dblend;
    DFBColor                     color;
    /********** SEE the _cairo_directfb_surface_show_glyphs *********
     * going to call the IDirectFBSurface->DrawString(...)
     * need to prepare the font
     * the drawing flags
     * the font size */
     if (pattern->type != CAIRO_PATTERN_TYPE_SOLID)
        return CAIRO_INT_STATUS_UNSUPPORTED;

     if (_directfb_get_operator (op, &sblend, &dblend) ||
        sblend == DSBF_DESTALPHA || sblend == DSBF_INVDESTALPHA)
        return CAIRO_INT_STATUS_UNSUPPORTED;
/*
    ret = _directfb_acquire_font_cache (dst, scaled_font, glyphs,
num_glyphs,
                                        &cache, &rects[0], &points[0],
&num);
    if (ret) {
        if (ret == CAIRO_INT_STATUS_NOTHING_TO_DO)
            ret = CAIRO_STATUS_SUCCESS;
        return ret;
    }
*/

    color.a = ((cairo_solid_pattern_t *)pattern)->color.alpha_short >> 8;
    color.r = ((cairo_solid_pattern_t *)pattern)->color.red_short   >> 8;
    color.g = ((cairo_solid_pattern_t *)pattern)->color.green_short >> 8;
    color.b = ((cairo_solid_pattern_t *)pattern)->color.blue_short  >> 8;

    flags = DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_COLORIZE;
    if (color.a != 0xff)
        flags |= DSBLIT_BLEND_COLORALPHA;

    if (!_directfb_argb_font) {
        if (sblend == DSBF_ONE) {
            sblend = DSBF_SRCALPHA;
            if (dblend == DSBF_ZERO)
                dblend = DSBF_INVSRCALPHA;
        }
    }
    dst->dfbsurface->SetBlittingFlags (dst->dfbsurface, flags);
    dst->dfbsurface->SetSrcBlendFunction (dst->dfbsurface, sblend);
    dst->dfbsurface->SetDstBlendFunction (dst->dfbsurface, dblend);
    dst->dfbsurface->SetColor (dst->dfbsurface, color.r, color.g, color.b,
color.a);

    dst->dfbsurface->GetFont(dst->dfbsurface, &font);
    if (font == NULL)
    {
      DFBFontDescription font_dsc;
      char *defaultFont = getenv("DEFAULT_FONT_FILE");
      printf("dst->dfbsurface->Getfont : returned NULL \n");
      dst->dfb->CreateFont (dst->dfb, ((defaultFont == NULL) ?
"./default.ttf" : defaultFont), &font_dsc, &font);
      dst->dfbsurface->SetFont(dst->dfbsurface, font);
    }
  /*RUN_CLIPPED(dst, NULL,  (dst->dfbsurface->DrawString(dst->dfbsurface,
utf8, -1, (int)x, (int)y, DSTF_LEFT)));*/
  dst->dfbsurface->DrawString(dst->dfbsurface, utf8, -1, (int)x, (int)y,
DSTF_LEFT);
printf("RMH : DrawString : %s , %d, %d\n", utf8, ((int)x), ((int)y));
    return CAIRO_STATUS_SUCCESS;

 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20081028/bee9eddb/attachment-0001.htm 


More information about the cairo mailing list