File Coverage

blib/lib/Renard/Curie/Model/Page/RenderedFromPNG.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1 3     3   395 use Renard::Curie::Setup;
  3         8  
  3         24  
2             package Renard::Curie::Model::Page::RenderedFromPNG;
3             # ABSTRACT: Page generated from PNG data
4             $Renard::Curie::Model::Page::RenderedFromPNG::VERSION = '0.002';
5 3     3   435 use Moo;
  3         6316  
  3         20  
6 3     3   2306 use Cairo;
  0            
  0            
7             use Function::Parameters;
8             use Renard::Curie::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::Curie::Model::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::Curie::Model::Page::RenderedFromPNG - Page generated from PNG data
48              
49             =head1 VERSION
50              
51             version 0.002
52              
53             =head1 EXTENDS
54              
55             =over 4
56              
57             =item * L<Moo::Object>
58              
59             =back
60              
61             =head1 CONSUMES
62              
63             =over 4
64              
65             =item * L<Renard::Curie::Model::Page::Role::Bounds>
66              
67             =item * L<Renard::Curie::Model::Page::Role::CairoRenderable>
68              
69             =back
70              
71             =head1 ATTRIBUTES
72              
73             =head2 png_data
74              
75             A binary C<Str> which contains the PNG data that represents this page.
76              
77             =head1 AUTHOR
78              
79             Project Renard
80              
81             =head1 COPYRIGHT AND LICENSE
82              
83             This software is copyright (c) 2016 by Project Renard.
84              
85             This is free software; you can redistribute it and/or modify it under
86             the same terms as the Perl 5 programming language system itself.
87              
88             =cut