~ubuntu-branches/ubuntu/intrepid/cairo/intrepid-updates

« back to all changes in this revision

Viewing changes to src/cairo-svg-surface.c

  • Committer: Bazaar Package Importer
  • Author(s): Fabien Tassin
  • Date: 2008-09-25 16:22:33 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20080925162233-btx61ymk181i7mcc
Tags: 1.7.6-0ubuntu1
* New upstream version. Most noticable changes are:
  - some API changes with especially the removal of
    cairo_font_options_set_lcd_filter and cairo_font_options_get_lcd_filter
  - xlib: Faster bookkeeping
  - PS: Fix gradients with non-constant alpha
  - Fix deadlock in user-font code
* debian/patches/00list: Remove 03_from_git_fix_lcd_filter_default.dpatch,
  add debian/patches/03_fix_ftbfs_withing_xcb.dpatch
* debian/libcairo2.symbols, debian/libcairo-directfb2.symbols: update
  list of symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
651
651
    cairo_image_surface_t *image;
652
652
    cairo_scaled_glyph_t *scaled_glyph;
653
653
    cairo_status_t status;
654
 
    unsigned char *row, *byte;
 
654
    uint8_t *row, *byte;
655
655
    int rows, cols;
656
656
    int x, y, bit;
657
657
 
677
677
 
678
678
    for (y = 0, row = image->data, rows = image->height; rows; row += image->stride, rows--, y++) {
679
679
        for (x = 0, byte = row, cols = (image->width + 7) / 8; cols; byte++, cols--) {
680
 
            unsigned char output_byte = CAIRO_BITSWAP8_IF_LITTLE_ENDIAN (*byte);
 
680
            uint8_t output_byte = CAIRO_BITSWAP8_IF_LITTLE_ENDIAN (*byte);
681
681
            for (bit = 7; bit >= 0 && x < image->width; bit--, x++) {
682
682
                if (output_byte & (1 << bit)) {
683
683
                    _cairo_output_stream_printf (document->xml_node_glyphs,
752
752
    status = _cairo_scaled_font_subsets_foreach_scaled (document->font_subsets,
753
753
                                                        _cairo_svg_document_emit_font_subset,
754
754
                                                        document);
755
 
 
 
755
    if (status)
 
756
        goto FAIL;
 
757
 
 
758
    status = _cairo_scaled_font_subsets_foreach_user (document->font_subsets,
 
759
                                                      _cairo_svg_document_emit_font_subset,
 
760
                                                      document);
 
761
 
 
762
  FAIL:
756
763
    _cairo_scaled_font_subsets_destroy (document->font_subsets);
757
764
    document->font_subsets = NULL;
758
765
 
870
877
typedef struct {
871
878
    cairo_output_stream_t *output;
872
879
    unsigned int in_mem;
 
880
    unsigned int trailing;
873
881
    unsigned char src[3];
874
 
    unsigned char dst[5];
875
 
    unsigned int trailing;
876
882
} base64_write_closure_t;
877
883
 
878
 
static char const *base64_table =
 
884
static char const base64_table[64] =
879
885
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
880
886
 
881
887
static cairo_status_t
885
891
{
886
892
    base64_write_closure_t *info = (base64_write_closure_t *) closure;
887
893
    unsigned int i;
888
 
    unsigned char *src, *dst;
 
894
    unsigned char *src;
889
895
 
890
 
    dst = info->dst;
891
896
    src = info->src;
892
897
 
893
898
    if (info->in_mem + length < 3) {
894
899
        for (i = 0; i < length; i++) {
895
 
            src[i + info->in_mem] = *data;
896
 
            data++;
 
900
            src[i + info->in_mem] = *data++;
897
901
        }
898
902
        info->in_mem += length;
899
903
        return CAIRO_STATUS_SUCCESS;
900
904
    }
901
905
 
902
 
    while (info->in_mem + length >= 3) {
903
 
        for (i = 0; i < 3 - info->in_mem; i++) {
904
 
            src[i + info->in_mem] = *data;
905
 
            data++;
 
906
    do {
 
907
        unsigned char dst[4];
 
908
 
 
909
        for (i = info->in_mem; i < 3; i++) {
 
910
            src[i] = *data++;
906
911
            length--;
907
912
        }
 
913
        info->in_mem = 0;
 
914
 
908
915
        dst[0] = base64_table[src[0] >> 2];
909
916
        dst[1] = base64_table[(src[0] & 0x03) << 4 | src[1] >> 4];
910
917
        dst[2] = base64_table[(src[1] & 0x0f) << 2 | src[2] >> 6];
919
926
                break;
920
927
        }
921
928
        _cairo_output_stream_write (info->output, dst, 4);
922
 
        info->in_mem = 0;
923
 
    }
 
929
    } while (length >= 3);
924
930
 
925
931
    for (i = 0; i < length; i++) {
926
 
        src[i] = *data;
927
 
        data++;
 
932
        src[i] = *data++;
928
933
    }
929
934
    info->in_mem = length;
930
935
 
931
 
    return CAIRO_STATUS_SUCCESS;
 
936
    return _cairo_output_stream_get_status (info->output);
932
937
}
933
938
 
934
939
static cairo_int_status_t
942
947
    info.output = output;
943
948
    info.in_mem = 0;
944
949
    info.trailing = 0;
945
 
    memset (info.dst, '\x0', 5);
946
950
 
947
951
    _cairo_output_stream_printf (info.output, "data:image/png;base64,");
948
952