This file is indexed.

/usr/sbin/dizzy-render is in dizzy 0.3-3.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
#!/usr/bin/perl
use strict;
use warnings;

use B::Deparse;
use Digest::SHA qw(sha1_hex);
use File::Path qw(make_path);

use Time::HiRes qw(time);


use Dizzy::Textures;

use Getopt::Long qw(:config no_ignore_case bundling);
use Pod::Usage;
my %options = (
	help => 0, man => 0,
	resolution => 256,
	output_path => "/var/cache/dizzy/textures",
);
GetOptions(\%options,
	'help|?',
	'man',
	'resolution|r=i',
	'output_path|output-path|o=s',
) or pod2usage(2);
pod2usage(1) if $options{help};
pod2usage(-exitstatus => 0, -verbose => 2) if $options{man};

my @textures = Dizzy::Textures::textures();
my @tbr = @ARGV;

# create the path first
print STDERR "seeding texture cache in $options{output_path}\n";
make_path($options{output_path});

# render all textures or the ones specified
foreach my $texture (@textures) {
	next if (@tbr and not grep { $_ eq $texture->{name} } @tbr);
	my $hash = sha1_hex(B::Deparse->new()->coderef2text($texture->{function}));
	my $fn = "$hash-$texture->{name}-$options{resolution}";
	print STDERR "rendering $fn " . " " x (16 + 70 - length($fn));
	open(my $outfile, ">", "$options{output_path}/$fn");
	my ($t_s, $t_e);
	$t_s = time();
	for (my $y = 0; $y < $options{resolution}; $y++) {
		print STDERR sprintf("%s(line %4d/%4d)", "\b" x 16, $y, $options{resolution}) if (!($y % 16));
		my $val;
		for (my $x = 0; $x < $options{resolution}; $x++) {
			$val = $texture->{function}->($x / $options{resolution} - 0.5, $y / $options{resolution} - 0.5);
			print $outfile pack("f", $val);
		}
	}
	$t_e = time();
	print STDERR sprintf("%s(line %4d/%2\$4d) in %.2fs\n", "\b" x 16, $options{resolution}, $t_e - $t_s);
	close($outfile);
}

__END__

=head1 NAME

B<dizzy-render> - seed a directory with cached texture files

=head1 SYNOPSIS

B<dizzy-render> B<-o> I<output-dir> B<-r> I<resolution> [I<names...>]

=head1 DESCRIPTION

B<dizzy-render> can be used to preseed a directory with cached textures.
Why an extra tool, if Dizzy can do this itself? Well, people might want to
generate textures in the installation script of a distro package, where it's
unlikely or at least unwanted that an X11 program spawns to render textures.

=head1 OPTIONS

=over

=item B<-o> I<output-dir>

=item B<--output-path> I<output-dir>

Dump the textures to this directory. The directory will be created if it does
not exist. The default value is F</var/cache/dizzy/textures>.

=item B<-r> I<resolution>

=item B<--resolution> I<resolution>

Sets the resolution at which the textures will be rendered. The default value
is 256, just like Dizzy's default resolution.

=back

The options can be followed by a list of I<names>. If there are any such
I<names> specified, only textures with these names will be rendered.

=head1 CAVEATS

This tool cannot make use of GLSL shaders to speed up rendering. But on the
other hand, the cache files are not portable, and there is no need to generate
them on a GLSL supporting machine.

This is not even recommended, as performance tests have shown GLSL rendering
to be much faster than loading the textures from disk for high resolutions.

=cut