Rev 1897 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1897 | Rev 3959 | ||
---|---|---|---|
Line 39... | Line 39... | ||
39 | * Carl Worth |
39 | * Carl Worth |
40 | */ |
40 | */ |
Line 41... | Line 41... | ||
41 | 41 | ||
42 | #define _BSD_SOURCE /* for snprintf() */ |
42 | #define _BSD_SOURCE /* for snprintf() */ |
- | 43 | #include "cairoint.h" |
|
43 | #include "cairoint.h" |
44 | |
- | 45 | #include "cairo-svg.h" |
|
- | 46 | ||
44 | #include "cairo-svg.h" |
47 | #include "cairo-array-private.h" |
- | 48 | #include "cairo-analysis-surface-private.h" |
|
45 | #include "cairo-analysis-surface-private.h" |
49 | #include "cairo-default-context-private.h" |
46 | #include "cairo-error-private.h" |
50 | #include "cairo-error-private.h" |
- | 51 | #include "cairo-image-info-private.h" |
|
47 | #include "cairo-image-info-private.h" |
52 | #include "cairo-image-surface-private.h" |
48 | #include "cairo-recording-surface-private.h" |
53 | #include "cairo-recording-surface-inline.h" |
49 | #include "cairo-output-stream-private.h" |
54 | #include "cairo-output-stream-private.h" |
50 | #include "cairo-path-fixed-private.h" |
55 | #include "cairo-path-fixed-private.h" |
51 | #include "cairo-paginated-private.h" |
56 | #include "cairo-paginated-private.h" |
52 | #include "cairo-scaled-font-subsets-private.h" |
57 | #include "cairo-scaled-font-subsets-private.h" |
- | 58 | #include "cairo-surface-clipper-private.h" |
|
53 | #include "cairo-surface-clipper-private.h" |
59 | #include "cairo-surface-snapshot-inline.h" |
Line 54... | Line 60... | ||
54 | #include "cairo-svg-surface-private.h" |
60 | #include "cairo-svg-surface-private.h" |
55 | 61 | ||
56 | /** |
62 | /** |
57 | * SECTION:cairo-svg |
63 | * SECTION:cairo-svg |
58 | * @Title: SVG Surfaces |
64 | * @Title: SVG Surfaces |
59 | * @Short_Description: Rendering SVG documents |
65 | * @Short_Description: Rendering SVG documents |
60 | * @See_Also: #cairo_surface_t |
66 | * @See_Also: #cairo_surface_t |
61 | * |
67 | * |
62 | * The SVG surface is used to render cairo graphics to |
68 | * The SVG surface is used to render cairo graphics to |
Line 63... | Line 69... | ||
63 | * SVG files and is a multi-page vector surface backend. |
69 | * SVG files and is a multi-page vector surface backend. |
64 | */ |
70 | **/ |
65 | 71 | ||
66 | /** |
72 | /** |
67 | * CAIRO_HAS_SVG_SURFACE: |
73 | * CAIRO_HAS_SVG_SURFACE: |
- | 74 | * |
|
- | 75 | * Defined if the SVG surface backend is available. |
|
68 | * |
76 | * This macro can be used to conditionally compile backend-specific code. |
Line 69... | Line 77... | ||
69 | * Defined if the SVG surface backend is available. |
77 | * |
Line 70... | Line 78... | ||
70 | * This macro can be used to conditionally compile backend-specific code. |
78 | * Since: 1.2 |
Line 80... | Line 88... | ||
80 | CAIRO_SVG_VERSION_1_2 |
88 | CAIRO_SVG_VERSION_1_2 |
81 | }; |
89 | }; |
Line 82... | Line 90... | ||
82 | 90 | ||
Line -... | Line 91... | ||
- | 91 | #define CAIRO_SVG_VERSION_LAST ARRAY_LENGTH (_cairo_svg_versions) |
|
- | 92 | ||
- | 93 | static const char *_cairo_svg_supported_mime_types[] = |
|
- | 94 | { |
|
- | 95 | CAIRO_MIME_TYPE_JPEG, |
|
- | 96 | CAIRO_MIME_TYPE_PNG, |
|
- | 97 | CAIRO_MIME_TYPE_URI, |
|
- | 98 | NULL |
|
83 | #define CAIRO_SVG_VERSION_LAST ARRAY_LENGTH (_cairo_svg_versions) |
99 | }; |
84 | 100 | ||
85 | static void |
101 | static void |
86 | _cairo_svg_surface_emit_path (cairo_output_stream_t *output, |
102 | _cairo_svg_surface_emit_path (cairo_output_stream_t *output, |
Line 87... | Line 103... | ||
87 | cairo_path_fixed_t *path, |
103 | const cairo_path_fixed_t *path, |
88 | const cairo_matrix_t *ctm_inverse); |
104 | const cairo_matrix_t *ctm_inverse); |
89 | 105 | ||
Line 190... | Line 206... | ||
190 | * This function always returns a valid pointer, but it will return a |
206 | * This function always returns a valid pointer, but it will return a |
191 | * pointer to a "nil" surface if an error such as out of memory |
207 | * pointer to a "nil" surface if an error such as out of memory |
192 | * occurs. You can use cairo_surface_status() to check for this. |
208 | * occurs. You can use cairo_surface_status() to check for this. |
193 | * |
209 | * |
194 | * Since: 1.2 |
210 | * Since: 1.2 |
195 | */ |
211 | **/ |
196 | cairo_surface_t * |
212 | cairo_surface_t * |
197 | cairo_svg_surface_create_for_stream (cairo_write_func_t write_func, |
213 | cairo_svg_surface_create_for_stream (cairo_write_func_t write_func, |
198 | void *closure, |
214 | void *closure, |
199 | double width, |
215 | double width, |
200 | double height) |
216 | double height) |
Line 559... | Line 575... | ||
559 | } |
575 | } |
Line 560... | Line 576... | ||
560 | 576 | ||
561 | static cairo_svg_page_t * |
577 | static cairo_svg_page_t * |
562 | _cairo_svg_surface_store_page (cairo_svg_surface_t *surface) |
578 | _cairo_svg_surface_store_page (cairo_svg_surface_t *surface) |
563 | { |
- | |
564 | unsigned int i; |
579 | { |
565 | cairo_svg_page_t page; |
580 | cairo_svg_page_t page; |
566 | cairo_output_stream_t *stream; |
581 | cairo_output_stream_t *stream; |
- | 582 | cairo_int_status_t status; |
|
Line 567... | Line 583... | ||
567 | cairo_status_t status; |
583 | unsigned int i; |
568 | 584 | ||
569 | stream = _cairo_memory_stream_create (); |
585 | stream = _cairo_memory_stream_create (); |
570 | if (_cairo_output_stream_get_status (stream)) { |
586 | if (_cairo_output_stream_get_status (stream)) { |
Line 712... | Line 728... | ||
712 | return CAIRO_STATUS_SUCCESS; |
728 | return CAIRO_STATUS_SUCCESS; |
713 | } |
729 | } |
Line 714... | Line 730... | ||
714 | 730 | ||
715 | static void |
731 | static void |
716 | _cairo_svg_surface_emit_path (cairo_output_stream_t *output, |
732 | _cairo_svg_surface_emit_path (cairo_output_stream_t *output, |
717 | cairo_path_fixed_t *path, |
733 | const cairo_path_fixed_t *path, |
718 | const cairo_matrix_t *ctm_inverse) |
734 | const cairo_matrix_t *ctm_inverse) |
719 | { |
735 | { |
720 | cairo_status_t status; |
736 | cairo_status_t status; |
Line 721... | Line 737... | ||
721 | svg_path_info_t info; |
737 | svg_path_info_t info; |
Line 722... | Line 738... | ||
722 | 738 | ||
723 | _cairo_output_stream_printf (output, "d=\""); |
739 | _cairo_output_stream_printf (output, "d=\""); |
724 | 740 | ||
725 | info.output = output; |
- | |
726 | info.ctm_inverse = ctm_inverse; |
741 | info.output = output; |
727 | status = _cairo_path_fixed_interpret (path, |
742 | info.ctm_inverse = ctm_inverse; |
728 | CAIRO_DIRECTION_FORWARD, |
743 | status = _cairo_path_fixed_interpret (path, |
729 | _cairo_svg_path_move_to, |
744 | _cairo_svg_path_move_to, |
730 | _cairo_svg_path_line_to, |
745 | _cairo_svg_path_line_to, |
Line 812... | Line 827... | ||
812 | cairo_surface_destroy (&image->base); |
827 | cairo_surface_destroy (&image->base); |
Line 813... | Line 828... | ||
813 | 828 | ||
814 | return CAIRO_STATUS_SUCCESS; |
829 | return CAIRO_STATUS_SUCCESS; |
Line 815... | Line 830... | ||
815 | } |
830 | } |
816 | 831 | ||
817 | static cairo_status_t |
832 | static cairo_int_status_t |
818 | _cairo_svg_document_emit_glyph (cairo_svg_document_t *document, |
833 | _cairo_svg_document_emit_glyph (cairo_svg_document_t *document, |
819 | cairo_scaled_font_t *scaled_font, |
834 | cairo_scaled_font_t *scaled_font, |
820 | unsigned long scaled_font_glyph_index, |
835 | unsigned long scaled_font_glyph_index, |
821 | unsigned int font_id, |
836 | unsigned int font_id, |
822 | unsigned int subset_glyph_index) |
837 | unsigned int subset_glyph_index) |
Line 823... | Line 838... | ||
823 | { |
838 | { |
824 | cairo_status_t status; |
839 | cairo_int_status_t status; |
825 | 840 | ||
826 | _cairo_output_stream_printf (document->xml_node_glyphs, |
841 | _cairo_output_stream_printf (document->xml_node_glyphs, |
Line 838... | Line 853... | ||
838 | if (unlikely (status)) |
853 | if (unlikely (status)) |
839 | return status; |
854 | return status; |
Line 840... | Line 855... | ||
840 | 855 | ||
Line 841... | Line 856... | ||
841 | _cairo_output_stream_printf (document->xml_node_glyphs, "\n"); |
856 | _cairo_output_stream_printf (document->xml_node_glyphs, "\n"); |
842 | 857 | ||
Line 843... | Line 858... | ||
843 | return CAIRO_STATUS_SUCCESS; |
858 | return CAIRO_INT_STATUS_SUCCESS; |
844 | } |
859 | } |
845 | 860 | ||
846 | static cairo_status_t |
861 | static cairo_int_status_t |
847 | _cairo_svg_document_emit_font_subset (cairo_scaled_font_subset_t *font_subset, |
862 | _cairo_svg_document_emit_font_subset (cairo_scaled_font_subset_t *font_subset, |
- | 863 | void *closure) |
|
848 | void *closure) |
864 | { |
849 | { |
- | |
Line 850... | Line 865... | ||
850 | cairo_svg_document_t *document = closure; |
865 | cairo_svg_document_t *document = closure; |
851 | unsigned int i; |
866 | cairo_int_status_t status = CAIRO_INT_STATUS_SUCCESS; |
852 | cairo_status_t status = CAIRO_STATUS_SUCCESS; |
867 | unsigned int i; |
853 | 868 | ||
Line 933... | Line 948... | ||
933 | surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) |
948 | surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) |
934 | { |
949 | { |
935 | return CAIRO_INT_STATUS_UNSUPPORTED; |
950 | return CAIRO_INT_STATUS_UNSUPPORTED; |
936 | } |
951 | } |
Line -... | Line 952... | ||
- | 952 | ||
- | 953 | if (pattern->type == CAIRO_PATTERN_TYPE_MESH) |
|
- | 954 | return CAIRO_INT_STATUS_UNSUPPORTED; |
|
937 | 955 | ||
938 | /* SVG doesn't support extend reflect for image pattern */ |
956 | /* SVG doesn't support extend reflect for image pattern */ |
939 | if (pattern->type == CAIRO_PATTERN_TYPE_SURFACE && |
957 | if (pattern->type == CAIRO_PATTERN_TYPE_SURFACE && |
940 | pattern->extend == CAIRO_EXTEND_REFLECT) |
958 | pattern->extend == CAIRO_EXTEND_REFLECT) |
Line 1158... | Line 1176... | ||
1158 | 1176 | ||
1159 | static cairo_int_status_t |
1177 | static cairo_int_status_t |
1160 | _cairo_surface_base64_encode (cairo_surface_t *surface, |
1178 | _cairo_surface_base64_encode (cairo_surface_t *surface, |
1161 | cairo_output_stream_t *output) |
1179 | cairo_output_stream_t *output) |
1162 | { |
1180 | { |
1163 | cairo_status_t status; |
1181 | cairo_int_status_t status; |
Line 1164... | Line 1182... | ||
1164 | base64_write_closure_t info; |
1182 | base64_write_closure_t info; |
1165 | 1183 | ||
1166 | status = _cairo_surface_base64_encode_jpeg (surface, output); |
1184 | status = _cairo_surface_base64_encode_jpeg (surface, output); |
Line 1382... | Line 1400... | ||
1382 | { |
1400 | { |
1383 | return CAIRO_STATUS_SUCCESS; |
1401 | return CAIRO_STATUS_SUCCESS; |
1384 | } |
1402 | } |
Line 1385... | Line 1403... | ||
1385 | 1403 | ||
1386 | paginated_surface = _cairo_svg_surface_create_for_document (document, |
1404 | paginated_surface = _cairo_svg_surface_create_for_document (document, |
1387 | source->content, |
1405 | source->base.content, |
1388 | source->extents_pixels.width, |
1406 | source->extents_pixels.width, |
1389 | source->extents_pixels.height); |
1407 | source->extents_pixels.height); |
1390 | if (unlikely (paginated_surface->status)) |
1408 | if (unlikely (paginated_surface->status)) |
Line 1421... | Line 1439... | ||
1421 | svg_surface->base_clip, |
1439 | svg_surface->base_clip, |
1422 | svg_surface->width, |
1440 | svg_surface->width, |
1423 | svg_surface->height); |
1441 | svg_surface->height); |
1424 | } |
1442 | } |
Line 1425... | Line 1443... | ||
1425 | 1443 | ||
1426 | if (source->content == CAIRO_CONTENT_ALPHA) { |
1444 | if (source->base.content == CAIRO_CONTENT_ALPHA) { |
1427 | _cairo_svg_surface_emit_alpha_filter (document); |
1445 | _cairo_svg_surface_emit_alpha_filter (document); |
1428 | _cairo_output_stream_printf (document->xml_node_defs, |
1446 | _cairo_output_stream_printf (document->xml_node_defs, |
1429 | " |
1447 | " |
1430 | "clip-path=\"url(#clip%d)\" " |
1448 | "clip-path=\"url(#clip%d)\" " |
Line 1468... | Line 1486... | ||
1468 | return _cairo_user_data_array_set_data (&source->base.user_data, |
1486 | return _cairo_user_data_array_set_data (&source->base.user_data, |
1469 | (cairo_user_data_key_t *) document, |
1487 | (cairo_user_data_key_t *) document, |
1470 | document, NULL); |
1488 | document, NULL); |
1471 | } |
1489 | } |
Line -... | Line 1490... | ||
- | 1490 | ||
- | 1491 | static cairo_recording_surface_t * |
|
- | 1492 | to_recording_surface (const cairo_surface_pattern_t *pattern) |
|
- | 1493 | { |
|
- | 1494 | cairo_surface_t *surface = pattern->surface; |
|
- | 1495 | if (_cairo_surface_is_paginated (surface)) |
|
- | 1496 | surface = _cairo_paginated_surface_get_recording (surface); |
|
- | 1497 | if (_cairo_surface_is_snapshot (surface)) |
|
- | 1498 | surface = _cairo_surface_snapshot_get_target (surface); |
|
- | 1499 | return (cairo_recording_surface_t *) surface; |
|
- | 1500 | } |
|
1472 | 1501 | ||
1473 | static cairo_status_t |
1502 | static cairo_status_t |
1474 | _cairo_svg_surface_emit_composite_recording_pattern (cairo_output_stream_t *output, |
1503 | _cairo_svg_surface_emit_composite_recording_pattern (cairo_output_stream_t *output, |
1475 | cairo_svg_surface_t *surface, |
1504 | cairo_svg_surface_t *surface, |
1476 | cairo_operator_t op, |
1505 | cairo_operator_t op, |
Line 1487... | Line 1516... | ||
1487 | p2u = pattern->base.matrix; |
1516 | p2u = pattern->base.matrix; |
1488 | status = cairo_matrix_invert (&p2u); |
1517 | status = cairo_matrix_invert (&p2u); |
1489 | /* cairo_pattern_set_matrix ensures the matrix is invertible */ |
1518 | /* cairo_pattern_set_matrix ensures the matrix is invertible */ |
1490 | assert (status == CAIRO_STATUS_SUCCESS); |
1519 | assert (status == CAIRO_STATUS_SUCCESS); |
Line 1491... | Line 1520... | ||
1491 | 1520 | ||
1492 | recording_surface = (cairo_recording_surface_t *) pattern->surface; |
1521 | recording_surface = to_recording_surface (pattern); |
1493 | status = _cairo_svg_surface_emit_recording_surface (document, recording_surface); |
1522 | status = _cairo_svg_surface_emit_recording_surface (document, recording_surface); |
1494 | if (unlikely (status)) |
1523 | if (unlikely (status)) |
Line 1495... | Line 1524... | ||
1495 | return status; |
1524 | return status; |
Line 1534... | Line 1563... | ||
1534 | int pattern_id, |
1563 | int pattern_id, |
1535 | const cairo_matrix_t *parent_matrix, |
1564 | const cairo_matrix_t *parent_matrix, |
1536 | const char *extra_attributes) |
1565 | const char *extra_attributes) |
1537 | { |
1566 | { |
Line 1538... | Line 1567... | ||
1538 | 1567 | ||
1539 | if (_cairo_surface_is_recording (pattern->surface)) { |
1568 | if (pattern->surface->type == CAIRO_SURFACE_TYPE_RECORDING) { |
1540 | return _cairo_svg_surface_emit_composite_recording_pattern (output, surface, |
1569 | return _cairo_svg_surface_emit_composite_recording_pattern (output, surface, |
1541 | op, pattern, |
1570 | op, pattern, |
1542 | pattern_id, |
1571 | pattern_id, |
1543 | parent_matrix, |
1572 | parent_matrix, |
Line 1780... | Line 1809... | ||
1780 | cairo_output_stream_t *style, |
1809 | cairo_output_stream_t *style, |
1781 | cairo_bool_t is_stroke, |
1810 | cairo_bool_t is_stroke, |
1782 | const cairo_matrix_t *parent_matrix) |
1811 | const cairo_matrix_t *parent_matrix) |
1783 | { |
1812 | { |
1784 | cairo_svg_document_t *document = surface->document; |
1813 | cairo_svg_document_t *document = surface->document; |
1785 | double x0, y0, x1, y1; |
- | |
1786 | cairo_matrix_t p2u; |
1814 | cairo_matrix_t p2u; |
1787 | cairo_status_t status; |
1815 | cairo_status_t status; |
Line 1788... | Line 1816... | ||
1788 | 1816 | ||
1789 | p2u = pattern->base.base.matrix; |
1817 | p2u = pattern->base.base.matrix; |
1790 | status = cairo_matrix_invert (&p2u); |
1818 | status = cairo_matrix_invert (&p2u); |
1791 | /* cairo_pattern_set_matrix ensures the matrix is invertible */ |
1819 | /* cairo_pattern_set_matrix ensures the matrix is invertible */ |
Line 1792... | Line -... | ||
1792 | assert (status == CAIRO_STATUS_SUCCESS); |
- | |
1793 | - | ||
1794 | x0 = _cairo_fixed_to_double (pattern->p1.x); |
- | |
1795 | y0 = _cairo_fixed_to_double (pattern->p1.y); |
- | |
1796 | x1 = _cairo_fixed_to_double (pattern->p2.x); |
- | |
1797 | y1 = _cairo_fixed_to_double (pattern->p2.y); |
1820 | assert (status == CAIRO_STATUS_SUCCESS); |
1798 | 1821 | ||
1799 | _cairo_output_stream_printf (document->xml_node_defs, |
1822 | _cairo_output_stream_printf (document->xml_node_defs, |
1800 | " |
1823 | " |
1801 | "gradientUnits=\"userSpaceOnUse\" " |
1824 | "gradientUnits=\"userSpaceOnUse\" " |
1802 | "x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" ", |
1825 | "x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" ", |
- | 1826 | document->linear_pattern_id, |
|
Line 1803... | Line 1827... | ||
1803 | document->linear_pattern_id, |
1827 | pattern->pd1.x, pattern->pd1.y, |
1804 | x0, y0, x1, y1); |
1828 | pattern->pd2.x, pattern->pd2.y); |
1805 | 1829 | ||
Line 1838... | Line 1862... | ||
1838 | cairo_extend_t extend; |
1862 | cairo_extend_t extend; |
1839 | double x0, y0, x1, y1, r0, r1; |
1863 | double x0, y0, x1, y1, r0, r1; |
1840 | double fx, fy; |
1864 | double fx, fy; |
1841 | cairo_bool_t reverse_stops; |
1865 | cairo_bool_t reverse_stops; |
1842 | cairo_status_t status; |
1866 | cairo_status_t status; |
1843 | cairo_point_t *c0, *c1; |
1867 | cairo_circle_double_t *c0, *c1; |
1844 | cairo_fixed_t radius0, radius1; |
- | |
Line 1845... | Line 1868... | ||
1845 | 1868 | ||
Line 1846... | Line 1869... | ||
1846 | extend = pattern->base.base.extend; |
1869 | extend = pattern->base.base.extend; |
1847 | 1870 | ||
1848 | if (pattern->r1 < pattern->r2) { |
1871 | if (pattern->cd1.radius < pattern->cd2.radius) { |
1849 | c0 = &pattern->c1; |
- | |
1850 | c1 = &pattern->c2; |
- | |
1851 | radius0 = pattern->r1; |
1872 | c0 = &pattern->cd1; |
1852 | radius1 = pattern->r2; |
1873 | c1 = &pattern->cd2; |
1853 | reverse_stops = FALSE; |
1874 | reverse_stops = FALSE; |
1854 | } else { |
1875 | } else { |
1855 | c0 = &pattern->c2; |
- | |
1856 | c1 = &pattern->c1; |
- | |
1857 | radius0 = pattern->r2; |
1876 | c0 = &pattern->cd2; |
1858 | radius1 = pattern->r1; |
1877 | c1 = &pattern->cd1; |
Line 1859... | Line 1878... | ||
1859 | reverse_stops = TRUE; |
1878 | reverse_stops = TRUE; |
1860 | } |
1879 | } |
1861 | 1880 | ||
1862 | x0 = _cairo_fixed_to_double (c0->x); |
1881 | x0 = c0->center.x; |
1863 | y0 = _cairo_fixed_to_double (c0->y); |
1882 | y0 = c0->center.y; |
1864 | r0 = _cairo_fixed_to_double (radius0); |
1883 | r0 = c0->radius; |
Line 1865... | Line 1884... | ||
1865 | x1 = _cairo_fixed_to_double (c1->x); |
1884 | x1 = c1->center.x; |
1866 | y1 = _cairo_fixed_to_double (c1->y); |
1885 | y1 = c1->center.y; |
1867 | r1 = _cairo_fixed_to_double (radius1); |
1886 | r1 = c1->radius; |
1868 | 1887 | ||
Line 1869... | Line 1888... | ||
1869 | p2u = pattern->base.base.matrix; |
1888 | p2u = pattern->base.base.matrix; |
1870 | status = cairo_matrix_invert (&p2u); |
1889 | status = cairo_matrix_invert (&p2u); |
Line 1871... | Line 1890... | ||
1871 | /* cairo_pattern_set_matrix ensures the matrix is invertible */ |
1890 | /* cairo_pattern_set_matrix ensures the matrix is invertible */ |
1872 | assert (status == CAIRO_STATUS_SUCCESS); |
1891 | assert (status == CAIRO_STATUS_SUCCESS); |
1873 | 1892 | ||
Line 2034... | Line 2053... | ||
2034 | output, is_stroke, parent_matrix); |
2053 | output, is_stroke, parent_matrix); |
Line 2035... | Line 2054... | ||
2035 | 2054 | ||
2036 | case CAIRO_PATTERN_TYPE_RADIAL: |
2055 | case CAIRO_PATTERN_TYPE_RADIAL: |
2037 | return _cairo_svg_surface_emit_radial_pattern (surface, (cairo_radial_pattern_t *) pattern, |
2056 | return _cairo_svg_surface_emit_radial_pattern (surface, (cairo_radial_pattern_t *) pattern, |
- | 2057 | output, is_stroke, parent_matrix); |
|
- | 2058 | ||
- | 2059 | case CAIRO_PATTERN_TYPE_MESH: |
|
- | 2060 | case CAIRO_PATTERN_TYPE_RASTER_SOURCE: |
|
2038 | output, is_stroke, parent_matrix); |
2061 | ASSERT_NOT_REACHED; |
2039 | } |
2062 | } |
2040 | return _cairo_error (CAIRO_STATUS_PATTERN_TYPE_MISMATCH); |
2063 | return _cairo_error (CAIRO_STATUS_PATTERN_TYPE_MISMATCH); |
Line 2041... | Line 2064... | ||
2041 | } |
2064 | } |
Line 2139... | Line 2162... | ||
2139 | cairo_operator_t fill_op, |
2162 | cairo_operator_t fill_op, |
2140 | const cairo_pattern_t *fill_source, |
2163 | const cairo_pattern_t *fill_source, |
2141 | cairo_fill_rule_t fill_rule, |
2164 | cairo_fill_rule_t fill_rule, |
2142 | double fill_tolerance, |
2165 | double fill_tolerance, |
2143 | cairo_antialias_t fill_antialias, |
2166 | cairo_antialias_t fill_antialias, |
2144 | cairo_path_fixed_t *path, |
2167 | const cairo_path_fixed_t*path, |
2145 | cairo_operator_t stroke_op, |
2168 | cairo_operator_t stroke_op, |
2146 | const cairo_pattern_t *stroke_source, |
2169 | const cairo_pattern_t *stroke_source, |
2147 | const cairo_stroke_style_t *stroke_style, |
2170 | const cairo_stroke_style_t *stroke_style, |
2148 | const cairo_matrix_t *stroke_ctm, |
2171 | const cairo_matrix_t *stroke_ctm, |
2149 | const cairo_matrix_t *stroke_ctm_inverse, |
2172 | const cairo_matrix_t *stroke_ctm_inverse, |
2150 | double stroke_tolerance, |
2173 | double stroke_tolerance, |
2151 | cairo_antialias_t stroke_antialias, |
2174 | cairo_antialias_t stroke_antialias, |
2152 | cairo_clip_t *clip) |
2175 | const cairo_clip_t *clip) |
2153 | { |
2176 | { |
2154 | cairo_svg_surface_t *surface = abstract_surface; |
2177 | cairo_svg_surface_t *surface = abstract_surface; |
2155 | cairo_status_t status; |
2178 | cairo_status_t status; |
Line 2156... | Line 2179... | ||
2156 | 2179 | ||
Line 2181... | Line 2204... | ||
2181 | 2204 | ||
2182 | static cairo_int_status_t |
2205 | static cairo_int_status_t |
2183 | _cairo_svg_surface_fill (void *abstract_surface, |
2206 | _cairo_svg_surface_fill (void *abstract_surface, |
2184 | cairo_operator_t op, |
2207 | cairo_operator_t op, |
2185 | const cairo_pattern_t *source, |
2208 | const cairo_pattern_t *source, |
2186 | cairo_path_fixed_t *path, |
2209 | const cairo_path_fixed_t*path, |
2187 | cairo_fill_rule_t fill_rule, |
2210 | cairo_fill_rule_t fill_rule, |
2188 | double tolerance, |
2211 | double tolerance, |
2189 | cairo_antialias_t antialias, |
2212 | cairo_antialias_t antialias, |
2190 | cairo_clip_t *clip) |
2213 | const cairo_clip_t *clip) |
2191 | { |
2214 | { |
2192 | cairo_svg_surface_t *surface = abstract_surface; |
2215 | cairo_svg_surface_t *surface = abstract_surface; |
Line 2193... | Line 2216... | ||
2193 | cairo_status_t status; |
2216 | cairo_status_t status; |
Line 2276... | Line 2299... | ||
2276 | 2299 | ||
2277 | static cairo_int_status_t |
2300 | static cairo_int_status_t |
2278 | _cairo_svg_surface_paint (void *abstract_surface, |
2301 | _cairo_svg_surface_paint (void *abstract_surface, |
2279 | cairo_operator_t op, |
2302 | cairo_operator_t op, |
2280 | const cairo_pattern_t *source, |
2303 | const cairo_pattern_t *source, |
2281 | cairo_clip_t *clip) |
2304 | const cairo_clip_t *clip) |
2282 | { |
2305 | { |
2283 | cairo_status_t status; |
2306 | cairo_status_t status; |
Line 2284... | Line 2307... | ||
2284 | cairo_svg_surface_t *surface = abstract_surface; |
2307 | cairo_svg_surface_t *surface = abstract_surface; |
Line 2342... | Line 2365... | ||
2342 | static cairo_int_status_t |
2365 | static cairo_int_status_t |
2343 | _cairo_svg_surface_mask (void *abstract_surface, |
2366 | _cairo_svg_surface_mask (void *abstract_surface, |
2344 | cairo_operator_t op, |
2367 | cairo_operator_t op, |
2345 | const cairo_pattern_t *source, |
2368 | const cairo_pattern_t *source, |
2346 | const cairo_pattern_t *mask, |
2369 | const cairo_pattern_t *mask, |
2347 | cairo_clip_t *clip) |
2370 | const cairo_clip_t *clip) |
2348 | { |
2371 | { |
2349 | cairo_status_t status; |
2372 | cairo_status_t status; |
2350 | cairo_svg_surface_t *surface = abstract_surface; |
2373 | cairo_svg_surface_t *surface = abstract_surface; |
2351 | cairo_svg_document_t *document = surface->document; |
2374 | cairo_svg_document_t *document = surface->document; |
2352 | cairo_output_stream_t *mask_stream; |
2375 | cairo_output_stream_t *mask_stream; |
Line 2380... | Line 2403... | ||
2380 | if (unlikely (status)) |
2403 | if (unlikely (status)) |
2381 | return status; |
2404 | return status; |
Line 2382... | Line 2405... | ||
2382 | 2405 | ||
2383 | if (mask->type == CAIRO_PATTERN_TYPE_SURFACE) { |
2406 | if (mask->type == CAIRO_PATTERN_TYPE_SURFACE) { |
2384 | const cairo_surface_pattern_t *surface_pattern = (const cairo_surface_pattern_t*) mask; |
2407 | const cairo_surface_pattern_t *surface_pattern = (const cairo_surface_pattern_t*) mask; |
2385 | cairo_content_t content = cairo_surface_get_content (surface_pattern->surface); |
2408 | cairo_content_t content = surface_pattern->surface->content; |
2386 | if (content == CAIRO_CONTENT_ALPHA) |
2409 | if (content == CAIRO_CONTENT_ALPHA) |
2387 | discard_filter = TRUE; |
2410 | discard_filter = TRUE; |
Line 2388... | Line 2411... | ||
2388 | } |
2411 | } |
Line 2432... | Line 2455... | ||
2432 | 2455 | ||
2433 | static cairo_int_status_t |
2456 | static cairo_int_status_t |
2434 | _cairo_svg_surface_stroke (void *abstract_dst, |
2457 | _cairo_svg_surface_stroke (void *abstract_dst, |
2435 | cairo_operator_t op, |
2458 | cairo_operator_t op, |
2436 | const cairo_pattern_t *source, |
2459 | const cairo_pattern_t *source, |
2437 | cairo_path_fixed_t *path, |
2460 | const cairo_path_fixed_t*path, |
2438 | const cairo_stroke_style_t *stroke_style, |
2461 | const cairo_stroke_style_t *stroke_style, |
2439 | const cairo_matrix_t *ctm, |
2462 | const cairo_matrix_t *ctm, |
2440 | const cairo_matrix_t *ctm_inverse, |
2463 | const cairo_matrix_t *ctm_inverse, |
2441 | double tolerance, |
2464 | double tolerance, |
2442 | cairo_antialias_t antialias, |
2465 | cairo_antialias_t antialias, |
2443 | cairo_clip_t *clip) |
2466 | const cairo_clip_t *clip) |
2444 | { |
2467 | { |
2445 | cairo_svg_surface_t *surface = abstract_dst; |
2468 | cairo_svg_surface_t *surface = abstract_dst; |
Line 2446... | Line 2469... | ||
2446 | cairo_status_t status; |
2469 | cairo_status_t status; |
Line 2475... | Line 2498... | ||
2475 | cairo_operator_t op, |
2498 | cairo_operator_t op, |
2476 | const cairo_pattern_t *pattern, |
2499 | const cairo_pattern_t *pattern, |
2477 | cairo_glyph_t *glyphs, |
2500 | cairo_glyph_t *glyphs, |
2478 | int num_glyphs, |
2501 | int num_glyphs, |
2479 | cairo_scaled_font_t *scaled_font, |
2502 | cairo_scaled_font_t *scaled_font, |
2480 | cairo_clip_t *clip, |
2503 | const cairo_clip_t *clip) |
2481 | int *remaining_glyphs) |
- | |
2482 | { |
2504 | { |
2483 | cairo_svg_surface_t *surface = abstract_surface; |
2505 | cairo_svg_surface_t *surface = abstract_surface; |
2484 | cairo_svg_document_t *document = surface->document; |
2506 | cairo_svg_document_t *document = surface->document; |
2485 | cairo_path_fixed_t path; |
2507 | cairo_path_fixed_t path; |
2486 | cairo_status_t status; |
2508 | cairo_int_status_t status; |
2487 | cairo_scaled_font_subsets_glyph_t subset_glyph; |
2509 | cairo_scaled_font_subsets_glyph_t subset_glyph; |
2488 | int i; |
2510 | int i; |
Line 2489... | Line 2511... | ||
2489 | 2511 | ||
2490 | if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) |
2512 | if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) |
Line 2572... | Line 2594... | ||
2572 | _cairo_font_options_init_default (options); |
2594 | _cairo_font_options_init_default (options); |
Line 2573... | Line 2595... | ||
2573 | 2595 | ||
2574 | cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE); |
2596 | cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE); |
2575 | cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF); |
2597 | cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF); |
- | 2598 | cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_GRAY); |
|
- | 2599 | _cairo_font_options_set_round_glyph_positions (options, CAIRO_ROUND_GLYPH_POS_OFF); |
|
- | 2600 | } |
|
- | 2601 | ||
- | 2602 | ||
- | 2603 | static const char ** |
|
- | 2604 | _cairo_svg_surface_get_supported_mime_types (void *abstract_surface) |
|
- | 2605 | { |
|
2576 | cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_GRAY); |
2606 | return _cairo_svg_supported_mime_types; |
Line 2577... | Line 2607... | ||
2577 | } |
2607 | } |
2578 | 2608 | ||
2579 | static const cairo_surface_backend_t cairo_svg_surface_backend = { |
- | |
2580 | CAIRO_SURFACE_TYPE_SVG, |
2609 | static const cairo_surface_backend_t cairo_svg_surface_backend = { |
- | 2610 | CAIRO_SURFACE_TYPE_SVG, |
|
- | 2611 | _cairo_svg_surface_finish, |
|
- | 2612 | ||
- | 2613 | _cairo_default_context_create, |
|
- | 2614 | ||
- | 2615 | NULL, /* create_similar: handled by wrapper */ |
|
- | 2616 | NULL, /* create_similar_image */ |
|
- | 2617 | NULL, /* map to image */ |
|
- | 2618 | NULL, /* unmap image */ |
|
2581 | NULL, /* create_similar: handled by wrapper */ |
2619 | |
2582 | _cairo_svg_surface_finish, |
2620 | _cairo_surface_default_source, |
2583 | NULL, /* acquire_source_image */ |
- | |
2584 | NULL, /* release_source_image */ |
- | |
2585 | NULL, /* acquire_dest_image */ |
2621 | NULL, /* acquire_source_image */ |
2586 | NULL, /* release_dest_image */ |
- | |
2587 | NULL, /* clone_similar */ |
- | |
2588 | NULL, /* _cairo_svg_surface_composite, */ |
- | |
2589 | NULL, /* _cairo_svg_surface_fill_rectangles, */ |
- | |
2590 | NULL, /* _cairo_svg_surface_composite_trapezoids,*/ |
- | |
- | 2622 | NULL, /* release_source_image */ |
|
2591 | NULL, /* create_span_renderer */ |
2623 | NULL, /* snapshot */ |
2592 | NULL, /* check_span_renderer */ |
2624 | |
- | 2625 | _cairo_svg_surface_copy_page, |
|
2593 | _cairo_svg_surface_copy_page, |
2626 | _cairo_svg_surface_show_page, |
2594 | _cairo_svg_surface_show_page, |
- | |
2595 | _cairo_svg_surface_get_extents, |
2627 | |
- | 2628 | _cairo_svg_surface_get_extents, |
|
2596 | NULL, /* _cairo_svg_surface_old_show_glyphs, */ |
2629 | _cairo_svg_surface_get_font_options, |
2597 | _cairo_svg_surface_get_font_options, |
2630 | |
2598 | NULL, /* flush */ |
- | |
2599 | NULL, /* mark dirty rectangle */ |
- | |
- | 2631 | NULL, /* flush */ |
|
2600 | NULL, /* scaled font fini */ |
2632 | NULL, /* mark dirty rectangle */ |
2601 | NULL, /* scaled glyph fini */ |
2633 | |
2602 | _cairo_svg_surface_paint, |
2634 | _cairo_svg_surface_paint, |
2603 | _cairo_svg_surface_mask, |
2635 | _cairo_svg_surface_mask, |
- | 2636 | _cairo_svg_surface_stroke, |
|
2604 | _cairo_svg_surface_stroke, |
2637 | _cairo_svg_surface_fill, |
2605 | _cairo_svg_surface_fill, |
2638 | _cairo_svg_surface_fill_stroke, |
2606 | _cairo_svg_surface_show_glyphs, |
2639 | _cairo_svg_surface_show_glyphs, |
2607 | NULL, /* snapshot */ |
2640 | NULL, /* has_show_text_glyphs */ |
2608 | NULL, /* is_similar */ |
2641 | NULL, /* show_text_glyphs */ |
Line 2609... | Line 2642... | ||
2609 | _cairo_svg_surface_fill_stroke |
2642 | _cairo_svg_surface_get_supported_mime_types, |
2610 | }; |
2643 | }; |
2611 | 2644 | ||
Line 2833... | Line 2866... | ||
2833 | if (surface->document->svg_version >= CAIRO_SVG_VERSION_1_2) { |
2866 | if (surface->document->svg_version >= CAIRO_SVG_VERSION_1_2) { |
2834 | status = _cairo_svg_surface_analyze_operator (surface, |
2867 | status = _cairo_svg_surface_analyze_operator (surface, |
2835 | CAIRO_OPERATOR_SOURCE); |
2868 | CAIRO_OPERATOR_SOURCE); |
2836 | } |
2869 | } |
Line 2837... | Line 2870... | ||
2837 | 2870 | ||
2838 | return status == CAIRO_STATUS_SUCCESS; |
2871 | return status == CAIRO_INT_STATUS_SUCCESS; |
Line 2839... | Line 2872... | ||
2839 | } |
2872 | } |
2840 | 2873 | ||
2841 | static const cairo_paginated_surface_backend_t cairo_svg_surface_paginated_backend = { |
2874 | static const cairo_paginated_surface_backend_t cairo_svg_surface_paginated_backend = { |