Subversion Repositories Kolibri OS

Rev

Rev 1892 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1892 Rev 3959
Line 47... Line 47...
47
#include "cairo-paginated-private.h"
47
#include "cairo-paginated-private.h"
48
#include "cairo-paginated-surface-private.h"
48
#include "cairo-paginated-surface-private.h"
49
#include "cairo-recording-surface-private.h"
49
#include "cairo-recording-surface-private.h"
50
#include "cairo-analysis-surface-private.h"
50
#include "cairo-analysis-surface-private.h"
51
#include "cairo-error-private.h"
51
#include "cairo-error-private.h"
-
 
52
#include "cairo-image-surface-private.h"
-
 
53
#include "cairo-surface-subsurface-inline.h"
Line 52... Line 54...
52
 
54
 
Line 53... Line 55...
53
static const cairo_surface_backend_t cairo_paginated_surface_backend;
55
static const cairo_surface_backend_t cairo_paginated_surface_backend;
54
 
56
 
Line 145... Line 147...
145
    cairo_paginated_surface_t *paginated_surface;
147
    cairo_paginated_surface_t *paginated_surface;
Line 146... Line 148...
146
 
148
 
Line 147... Line 149...
147
    assert (_cairo_surface_is_paginated (surface));
149
    assert (_cairo_surface_is_paginated (surface));
148
 
-
 
149
    paginated_surface = (cairo_paginated_surface_t *) surface;
150
 
150
 
151
    paginated_surface = (cairo_paginated_surface_t *) surface;
Line -... Line 152...
-
 
152
    return paginated_surface->target;
-
 
153
}
-
 
154
 
-
 
155
cairo_surface_t *
-
 
156
_cairo_paginated_surface_get_recording (cairo_surface_t *surface)
-
 
157
{
-
 
158
    cairo_paginated_surface_t *paginated_surface;
-
 
159
 
-
 
160
    assert (_cairo_surface_is_paginated (surface));
-
 
161
 
-
 
162
    paginated_surface = (cairo_paginated_surface_t *) surface;
151
    return paginated_surface->target;
163
    return paginated_surface->recording_surface;
152
}
164
}
153
 
165
 
154
cairo_status_t
166
cairo_status_t
155
_cairo_paginated_surface_set_size (cairo_surface_t	*surface,
167
_cairo_paginated_surface_set_size (cairo_surface_t	*surface,
Line 228... Line 240...
228
    _cairo_surface_set_font_options (image, &options);
240
    _cairo_surface_set_font_options (image, &options);
Line 229... Line 241...
229
 
241
 
230
    return image;
242
    return image;
Line -... Line 243...
-
 
243
}
-
 
244
 
-
 
245
static cairo_surface_t *
-
 
246
_cairo_paginated_surface_source (void	       *abstract_surface,
-
 
247
				 cairo_rectangle_int_t *extents)
-
 
248
{
-
 
249
    cairo_paginated_surface_t *surface = abstract_surface;
-
 
250
    return _cairo_surface_get_source (surface->target, extents);
231
}
251
}
232
 
252
 
233
static cairo_status_t
253
static cairo_status_t
234
_cairo_paginated_surface_acquire_source_image (void	       *abstract_surface,
254
_cairo_paginated_surface_acquire_source_image (void	       *abstract_surface,
235
					       cairo_image_surface_t **image_out,
255
					       cairo_image_surface_t **image_out,
Line 277... Line 297...
277
    double y_scale = surface->base.y_fallback_resolution / surface->target->y_resolution;
297
    double y_scale = surface->base.y_fallback_resolution / surface->target->y_resolution;
278
    int x, y, width, height;
298
    int x, y, width, height;
279
    cairo_status_t status;
299
    cairo_status_t status;
280
    cairo_surface_t *image;
300
    cairo_surface_t *image;
281
    cairo_surface_pattern_t pattern;
301
    cairo_surface_pattern_t pattern;
282
    cairo_clip_t clip;
302
    cairo_clip_t *clip;
Line 283... Line 303...
283
 
303
 
284
    x = rect->x;
304
    x = rect->x;
285
    y = rect->y;
305
    y = rect->y;
286
    width = rect->width;
306
    width = rect->width;
Line 302... Line 322...
302
		       x_scale, 0, 0, y_scale, -x*x_scale, -y*y_scale);
322
		       x_scale, 0, 0, y_scale, -x*x_scale, -y*y_scale);
303
    /* the fallback should be rendered at native resolution, so disable
323
    /* the fallback should be rendered at native resolution, so disable
304
     * filtering (if possible) to avoid introducing potential artifacts. */
324
     * filtering (if possible) to avoid introducing potential artifacts. */
305
    pattern.base.filter = CAIRO_FILTER_NEAREST;
325
    pattern.base.filter = CAIRO_FILTER_NEAREST;
Line 306... Line -...
306
 
-
 
307
    _cairo_clip_init (&clip);
326
 
308
    status = _cairo_clip_rectangle (&clip, rect);
-
 
309
    if (likely (status == CAIRO_STATUS_SUCCESS)) {
327
    clip = _cairo_clip_intersect_rectangle (NULL, rect);
310
	status = _cairo_surface_paint (surface->target,
328
    status = _cairo_surface_paint (surface->target,
311
				       CAIRO_OPERATOR_SOURCE,
329
				   CAIRO_OPERATOR_SOURCE,
312
				       &pattern.base, &clip);
-
 
313
    }
-
 
314
 
330
				   &pattern.base, clip);
315
    _cairo_clip_fini (&clip);
331
    _cairo_clip_destroy (clip);
Line 316... Line 332...
316
    _cairo_pattern_fini (&pattern.base);
332
    _cairo_pattern_fini (&pattern.base);
317
 
333
 
Line 323... Line 339...
323
 
339
 
324
static cairo_int_status_t
340
static cairo_int_status_t
325
_paint_page (cairo_paginated_surface_t *surface)
341
_paint_page (cairo_paginated_surface_t *surface)
326
{
342
{
327
    cairo_surface_t *analysis;
343
    cairo_surface_t *analysis;
328
    cairo_status_t status;
344
    cairo_int_status_t status;
Line 329... Line 345...
329
    cairo_bool_t has_supported, has_page_fallback, has_finegrained_fallback;
345
    cairo_bool_t has_supported, has_page_fallback, has_finegrained_fallback;
330
 
346
 
Line 337... Line 353...
337
 
353
 
338
    surface->backend->set_paginated_mode (surface->target,
354
    surface->backend->set_paginated_mode (surface->target,
339
	                                  CAIRO_PAGINATED_MODE_ANALYZE);
355
	                                  CAIRO_PAGINATED_MODE_ANALYZE);
340
    status = _cairo_recording_surface_replay_and_create_regions (surface->recording_surface,
356
    status = _cairo_recording_surface_replay_and_create_regions (surface->recording_surface,
341
								 analysis);
357
								 analysis);
342
    if (status || analysis->status) {
-
 
343
	if (status == CAIRO_STATUS_SUCCESS)
-
 
344
	    status = analysis->status;
358
    if (status)
345
	goto FAIL;
359
	goto FAIL;
-
 
360
 
Line 346... Line 361...
346
    }
361
    assert (analysis->status == CAIRO_STATUS_SUCCESS);
347
 
362
 
Line 348... Line 363...
348
     if (surface->backend->set_bounding_box) {
363
     if (surface->backend->set_bounding_box) {
Line 540... Line 555...
540
 
555
 
541
static cairo_int_status_t
556
static cairo_int_status_t
542
_cairo_paginated_surface_paint (void			*abstract_surface,
557
_cairo_paginated_surface_paint (void			*abstract_surface,
543
				cairo_operator_t	 op,
558
				cairo_operator_t	 op,
544
				const cairo_pattern_t	*source,
559
				const cairo_pattern_t	*source,
545
				cairo_clip_t		*clip)
560
				const cairo_clip_t	*clip)
546
{
561
{
Line 547... Line 562...
547
    cairo_paginated_surface_t *surface = abstract_surface;
562
    cairo_paginated_surface_t *surface = abstract_surface;
548
 
563
 
Line 552... Line 567...
552
static cairo_int_status_t
567
static cairo_int_status_t
553
_cairo_paginated_surface_mask (void		*abstract_surface,
568
_cairo_paginated_surface_mask (void		*abstract_surface,
554
			       cairo_operator_t	 op,
569
			       cairo_operator_t	 op,
555
			       const cairo_pattern_t	*source,
570
			       const cairo_pattern_t	*source,
556
			       const cairo_pattern_t	*mask,
571
			       const cairo_pattern_t	*mask,
557
			       cairo_clip_t		*clip)
572
			       const cairo_clip_t		*clip)
558
{
573
{
559
    cairo_paginated_surface_t *surface = abstract_surface;
574
    cairo_paginated_surface_t *surface = abstract_surface;
Line 560... Line 575...
560
 
575
 
561
    return _cairo_surface_mask (surface->recording_surface, op, source, mask, clip);
576
    return _cairo_surface_mask (surface->recording_surface, op, source, mask, clip);
Line 562... Line 577...
562
}
577
}
563
 
578
 
564
static cairo_int_status_t
579
static cairo_int_status_t
565
_cairo_paginated_surface_stroke (void			*abstract_surface,
580
_cairo_paginated_surface_stroke (void			*abstract_surface,
566
				 cairo_operator_t	 op,
581
				 cairo_operator_t	 op,
567
				 const cairo_pattern_t	*source,
582
				 const cairo_pattern_t	*source,
568
				 cairo_path_fixed_t	*path,
583
				 const cairo_path_fixed_t	*path,
569
				 const cairo_stroke_style_t	*style,
584
				 const cairo_stroke_style_t	*style,
570
				 const cairo_matrix_t		*ctm,
585
				 const cairo_matrix_t		*ctm,
571
				 const cairo_matrix_t		*ctm_inverse,
586
				 const cairo_matrix_t		*ctm_inverse,
572
				 double			 tolerance,
587
				 double			 tolerance,
573
				 cairo_antialias_t	 antialias,
588
				 cairo_antialias_t	 antialias,
574
				 cairo_clip_t		*clip)
589
				 const cairo_clip_t		*clip)
Line 575... Line 590...
575
{
590
{
576
    cairo_paginated_surface_t *surface = abstract_surface;
591
    cairo_paginated_surface_t *surface = abstract_surface;
Line 584... Line 599...
584
 
599
 
585
static cairo_int_status_t
600
static cairo_int_status_t
586
_cairo_paginated_surface_fill (void			*abstract_surface,
601
_cairo_paginated_surface_fill (void			*abstract_surface,
587
			       cairo_operator_t		 op,
602
			       cairo_operator_t		 op,
588
			       const cairo_pattern_t	*source,
603
			       const cairo_pattern_t	*source,
589
			       cairo_path_fixed_t	*path,
604
			       const cairo_path_fixed_t	*path,
590
			       cairo_fill_rule_t	 fill_rule,
605
			       cairo_fill_rule_t	 fill_rule,
591
			       double			 tolerance,
606
			       double			 tolerance,
592
			       cairo_antialias_t	 antialias,
607
			       cairo_antialias_t	 antialias,
593
			       cairo_clip_t		*clip)
608
			       const cairo_clip_t		*clip)
594
{
609
{
Line 595... Line 610...
595
    cairo_paginated_surface_t *surface = abstract_surface;
610
    cairo_paginated_surface_t *surface = abstract_surface;
596
 
611
 
Line 618... Line 633...
618
					   int			       num_glyphs,
633
					   int			       num_glyphs,
619
					   const cairo_text_cluster_t *clusters,
634
					   const cairo_text_cluster_t *clusters,
620
					   int			       num_clusters,
635
					   int			       num_clusters,
621
					   cairo_text_cluster_flags_t  cluster_flags,
636
					   cairo_text_cluster_flags_t  cluster_flags,
622
					   cairo_scaled_font_t	      *scaled_font,
637
					   cairo_scaled_font_t	      *scaled_font,
623
					   cairo_clip_t		      *clip)
638
					   const cairo_clip_t		      *clip)
624
{
639
{
625
    cairo_paginated_surface_t *surface = abstract_surface;
640
    cairo_paginated_surface_t *surface = abstract_surface;
Line 626... Line 641...
626
 
641
 
627
    return _cairo_surface_show_text_glyphs (surface->recording_surface, op, source,
642
    return _cairo_surface_show_text_glyphs (surface->recording_surface, op, source,
Line 631... Line 646...
631
					    cluster_flags,
646
					    cluster_flags,
632
					    scaled_font,
647
					    scaled_font,
633
					    clip);
648
					    clip);
634
}
649
}
Line -... Line 650...
-
 
650
 
-
 
651
static const char **
-
 
652
_cairo_paginated_surface_get_supported_mime_types (void *abstract_surface)
-
 
653
{
-
 
654
    cairo_paginated_surface_t *surface = abstract_surface;
-
 
655
 
-
 
656
    if (surface->target->backend->get_supported_mime_types)
-
 
657
	return surface->target->backend->get_supported_mime_types (surface->target);
-
 
658
 
-
 
659
    return NULL;
-
 
660
}
635
 
661
 
636
static cairo_surface_t *
662
static cairo_surface_t *
637
_cairo_paginated_surface_snapshot (void *abstract_other)
663
_cairo_paginated_surface_snapshot (void *abstract_other)
638
{
664
{
Line 639... Line 665...
639
    cairo_paginated_surface_t *other = abstract_other;
665
    cairo_paginated_surface_t *other = abstract_other;
-
 
666
 
-
 
667
    return other->recording_surface->backend->snapshot (other->recording_surface);
-
 
668
}
-
 
669
 
-
 
670
static cairo_t *
-
 
671
_cairo_paginated_context_create (void *target)
-
 
672
{
-
 
673
    cairo_paginated_surface_t *surface = target;
-
 
674
 
-
 
675
    if (_cairo_surface_is_subsurface (&surface->base))
-
 
676
	surface = (cairo_paginated_surface_t *)
-
 
677
	    _cairo_surface_subsurface_get_target (&surface->base);
640
 
678
 
Line 641... Line 679...
641
    return _cairo_surface_snapshot (other->recording_surface);
679
    return surface->recording_surface->backend->create_context (target);
642
}
680
}
643
 
-
 
644
static const cairo_surface_backend_t cairo_paginated_surface_backend = {
681
 
-
 
682
static const cairo_surface_backend_t cairo_paginated_surface_backend = {
-
 
683
    CAIRO_INTERNAL_SURFACE_TYPE_PAGINATED,
-
 
684
    _cairo_paginated_surface_finish,
-
 
685
 
-
 
686
    _cairo_paginated_context_create,
-
 
687
 
-
 
688
    _cairo_paginated_surface_create_similar,
-
 
689
    NULL, /* create simlar image */
-
 
690
    NULL, /* map to image */
645
    CAIRO_INTERNAL_SURFACE_TYPE_PAGINATED,
691
    NULL, /* unmap image */
646
    _cairo_paginated_surface_create_similar,
692
 
647
    _cairo_paginated_surface_finish,
-
 
648
    _cairo_paginated_surface_acquire_source_image,
-
 
649
    _cairo_paginated_surface_release_source_image,
-
 
650
    NULL, /* acquire_dest_image */
-
 
651
    NULL, /* release_dest_image */
-
 
652
    NULL, /* clone_similar */
-
 
653
    NULL, /* composite */
693
    _cairo_paginated_surface_source,
654
    NULL, /* fill_rectangles */
-
 
-
 
694
    _cairo_paginated_surface_acquire_source_image,
655
    NULL, /* composite_trapezoids */
695
    _cairo_paginated_surface_release_source_image,
656
    NULL, /* create_span_renderer */
696
    _cairo_paginated_surface_snapshot,
-
 
697
 
657
    NULL, /* check_span_renderer */
698
    _cairo_paginated_surface_copy_page,
658
    _cairo_paginated_surface_copy_page,
-
 
659
    _cairo_paginated_surface_show_page,
699
    _cairo_paginated_surface_show_page,
-
 
700
 
660
    _cairo_paginated_surface_get_extents,
701
    _cairo_paginated_surface_get_extents,
661
    NULL, /* old_show_glyphs */
702
    _cairo_paginated_surface_get_font_options,
662
    _cairo_paginated_surface_get_font_options,
-
 
663
    NULL, /* flush */
-
 
-
 
703
 
664
    NULL, /* mark_dirty_rectangle */
704
    NULL, /* flush */
665
    NULL, /* scaled_font_fini */
705
    NULL, /* mark_dirty_rectangle */
666
    NULL, /* scaled_glyph_fini */
706
 
667
    _cairo_paginated_surface_paint,
707
    _cairo_paginated_surface_paint,
668
    _cairo_paginated_surface_mask,
-
 
669
    _cairo_paginated_surface_stroke,
-
 
670
    _cairo_paginated_surface_fill,
-
 
671
    NULL, /* show_glyphs */
708
    _cairo_paginated_surface_mask,
672
    _cairo_paginated_surface_snapshot,
709
    _cairo_paginated_surface_stroke,
673
    NULL, /* is_similar */
-
 
674
    NULL, /* fill_stroke */
710
    _cairo_paginated_surface_fill,
675
    NULL, /* create_solid_pattern_surface */
711
    NULL, /* fill_stroke */
-
 
712
    NULL, /* show_glyphs */
676
    NULL, /* can_repaint_solid_pattern_surface */
713
    _cairo_paginated_surface_has_show_text_glyphs,