summaryrefslogtreecommitdiffstats
path: root/mktablec.pl
diff options
context:
space:
mode:
Diffstat (limited to 'mktablec.pl')
-rw-r--r--mktablec.pl40
1 files changed, 29 insertions, 11 deletions
diff --git a/mktablec.pl b/mktablec.pl
index 32bb0d0..6467af0 100644
--- a/mktablec.pl
+++ b/mktablec.pl
@@ -13,7 +13,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
use strict ; use warnings ;
@@ -35,19 +35,37 @@ sub shipsubarray (@) {
print "\n" ;
}
+my $precompute_it = 1 ;
+if( open CONFIGH, "<", "config.h" ) {
+ $precompute_it = 0 ;
+ while( <CONFIGH> ) {
+ if( /\#\s*define\s+PRECOMPUTED_SCALETABLE/ ) {
+ $precompute_it = 1 ;
+ last ;
+ }
+ }
+ close CONFIGH ;
+}
+
print "/* Autogenerated by $0 */\n" ;
print "#include \"pixels.h\"\n" ;
-print "const uint8_t scaletable[256][256] = {\n" ;
-for my $p ( 0..255 ) {
- shipsubarray( map { int(($p*$_+127)/255) } ( 0 .. 255 ) );
- # This formula has the property that
- # scaletable[p][q] + scaletable[255-p][q] == q
- # for all uint8_t values of p and q.
- # This is important in order that a partially transparent
- # pixel does not change the color of the underlying pixel
- # unless the two pixels have different colors.
+print "#ifdef PRECOMPUTED_SCALETABLE\n" ;
+if( $precompute_it ) {
+ print "const uint8_t scaletable[256][256] = {\n" ;
+ for my $p ( 0..255 ) {
+ shipsubarray( map { int(($p*$_+127)/255) } ( 0 .. 255 ) );
+ # This formula has the property that
+ # scaletable[p][q] + scaletable[255-p][q] == q
+ # for all uint8_t values of p and q.
+ # This is important in order that a partially transparent
+ # pixel does not change the color of the underlying pixel
+ # unless the two pixels have different colors.
+ }
+ print "};\n" ;
+} else {
+ print "#error PRECOMPUTED_SCALETABLE was not defined at generation time\n";
}
-print "};\n" ;
+print "#endif\n" ;
if(0) {