line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
8055
|
use Renard::Incunabula::Common::Setup; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
2
|
|
|
|
|
|
|
package Renard::Incunabula::Page::Role::CairoRenderableFromPNG; |
3
|
|
|
|
|
|
|
# ABSTRACT: A role to use PNG data to create Cairo::ImageSurface |
4
|
|
|
|
|
|
|
$Renard::Incunabula::Page::Role::CairoRenderableFromPNG::VERSION = '0.003'; |
5
|
1
|
|
|
1
|
|
9
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
6
|
1
|
|
|
1
|
|
735
|
use Cairo; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Renard::Incunabula::Common::Types qw(Str InstanceOf Int); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has png_data => ( |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
isa => Str, |
13
|
|
|
|
|
|
|
required => 1 |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has cairo_image_surface => ( |
17
|
|
|
|
|
|
|
is => 'lazy', # _build_cairo_image_surface |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
method _build_cairo_image_surface() :ReturnType(InstanceOf['Cairo::ImageSurface']) { |
21
|
|
|
|
|
|
|
# read the PNG data in-memory |
22
|
|
|
|
|
|
|
my $img = Cairo::ImageSurface->create_from_png_stream( |
23
|
|
|
|
|
|
|
fun ((Str) $callback_data, (Int) $length) { |
24
|
|
|
|
|
|
|
state $offset = 0; |
25
|
|
|
|
|
|
|
my $data = substr $callback_data, $offset, $length; |
26
|
|
|
|
|
|
|
$offset += $length; |
27
|
|
|
|
|
|
|
$data; |
28
|
|
|
|
|
|
|
}, $self->png_data ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return $img; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
with qw( |
34
|
|
|
|
|
|
|
Renard::Incunabula::Page::Role::CairoRenderable |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=pod |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=encoding UTF-8 |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 NAME |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Renard::Incunabula::Page::Role::CairoRenderableFromPNG - A role to use PNG data to create Cairo::ImageSurface |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 VERSION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
version 0.003 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 CONSUMES |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over 4 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item * L<Renard::Incunabula::Page::Role::CairoRenderable> |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=back |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 png_data |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
A binary C<Str> which contains the PNG data that represents this page. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 AUTHOR |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Project Renard |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Project Renard. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
76
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |