Add unsigned char buffer to BLF_draw_buffer and update makefiles for lzo and lzma.
authorDiego Borghetti <bdiego@gmail.com>
Thu, 20 Aug 2009 18:34:14 +0000 (18:34 +0000)
committerDiego Borghetti <bdiego@gmail.com>
Thu, 20 Aug 2009 18:34:14 +0000 (18:34 +0000)
I rename the original makefile of lzo (Makefile.bak) and a new one.
Also four new option for user-def.mk:
WITH_LZO, default true
WITH_LZMA, default true
NAN_LZO, default extern/lzo
NAN_LZMA, default extern/lzma

It's easy add support for system libs (using lzo and lzma from OS) but I don't
know if it have much sense.

Note that I can't test the "unsigned char" buffer because the OGL animation
is not working (right ?), but is the same code that for float also the new
Makefile work fine here (Linux), but maybe need some tweak on other OS.

extern/Makefile
extern/lzma/Makefile [new file with mode: 0644]
extern/lzo/minilzo/Makefile
source/Makefile
source/blender/blenfont/intern/blf_font.c
source/blender/blenkernel/intern/Makefile
source/nan_definitions.mk

index 61499da8743579383798fbf498d08581bbcce241..1bebf1e1994d1d535ef4ef4b9b724160b7ea1ea0 100644 (file)
@@ -54,6 +54,14 @@ ifeq ($(WITH_OPENJPEG), true)
     DIRS += libopenjpeg
 endif
 
+ifeq ($(WITH_LZO), true)
+    DIRS += lzo/minilzo
+endif
+
+ifeq ($(WITH_LZMA), true)
+    DIRS += lzma
+endif
+
 TARGET = solid
 
 all::
diff --git a/extern/lzma/Makefile b/extern/lzma/Makefile
new file mode 100644 (file)
index 0000000..11d70dc
--- /dev/null
@@ -0,0 +1,46 @@
+#
+# $Id$
+#
+# ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version. The Blender
+# Foundation also sells licenses for use in proprietary software under
+# the Blender License.  See http://www.blender.org/BL/ for information
+# about this.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# 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.
+#
+# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s):
+#
+# ***** END GPL/BL DUAL LICENSE BLOCK *****
+#
+#
+
+LIBNAME = lzma
+DIR = $(OCGDIR)/extern/$(LIBNAME)
+
+include nan_compile.mk 
+
+install: $(ALL_OR_DEBUG)
+       @[ -d $(NAN_LZMA) ] || mkdir -p $(NAN_LZMA)
+       @[ -d $(NAN_LZMA)/lib/$(DEBUG_DIR) ] || mkdir -p $(NAN_LZMA)/lib/$(DEBUG_DIR)
+       @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)lib$(LIBNAME).a $(NAN_LZMA)/lib/$(DEBUG_DIR)
+ifeq ($(OS),darwin)
+       ranlib $(NAN_LZMA)/lib/$(DEBUG_DIR)lib$(LIBNAME).a
+endif
+       @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh *.h $(NAN_LZMA)
index a6ee373e8bc11ee94dbce87c2596f3a5772393e5..8f3d5042579508bbe65e2310e12899d80bc7ebab 100644 (file)
 #
-# a very simple Makefile for miniLZO
+# $Id:
 #
-# Copyright (C) 1996-2008 Markus F.X.J. Oberhumer
+# ***** BEGIN GPL LICENSE BLOCK *****
 #
-
-PROGRAM = testmini
-SOURCES = testmini.c minilzo.c
-
-default:
-       @echo "Please choose one of the following targets:"
-       @echo "    gcc:   gcc"
-       @echo "    unix:  hpux hpux9"
-       @echo "    win32: win32-bc win32-cygwin win32-dm win32-lccwin32"
-       @echo "           win32-intelc win32-mingw win32-vc win32-watcomc"
-       @echo "    dos16: dos16-bc dos16-mc dos16-wc"
-       @echo "    dos32: dos32-djgpp2 dos32-wc"
-
-
-# Make sure that minilzo.h, lzoconf.h and lzodefs.h are in the
-# current dircectory. Otherwise you may want to adjust CPPFLAGS.
-##CPPFLAGS = -I../include/lzo -I.
-
-GCC_CFLAGS = -s -Wall -O2 -fomit-frame-pointer
-
-
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
 #
-# gcc (generic)
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
 #
-
-gcc:
-       gcc $(CPPFLAGS) $(GCC_CFLAGS) -o $(PROGRAM) $(SOURCES)
-
-cc:
-       cc $(CPPFLAGS) -o $(PROGRAM) $(SOURCES)
-
-
+# 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.
 #
-# UNIX
-#
-
-hpux:
-       cc -Ae $(CPPFLAGS) -o $(PROGRAM) $(SOURCES)
-
-hpux9:
-       cc -Aa -D_HPUX_SOURCE $(CPPFLAGS) -o $(PROGRAM) $(SOURCES)
-
-
-#
-# Windows (32-bit)
-#
-
-win32-borlandc win32-bc:
-       bcc32 -O2 -d -w -w-aus $(CPPFLAGS) $(SOURCES)
-
-win32-cygwin32 win32-cygwin:
-       gcc -mcygwin $(CPPFLAGS) $(GCC_CFLAGS) -o $(PROGRAM).exe $(SOURCES)
-
-win32-digitalmars win32-dm:
-       dmc -mn -o -w- $(CPPFLAGS) $(SOURCES)
-
-win32-intelc win32-ic:
-       icl -nologo -MD -W3 -O2 -GF $(CPPFLAGS) $(SOURCES)
-
-win32-lccwin32:
-       @echo "NOTE: need lcc 2002-07-25 or newer, older versions have bugs"
-       lc -A -unused -O $(CPPFLAGS) $(SOURCES)
-
-win32-mingw32 win32-mingw:
-       gcc -mno-cygwin $(CPPFLAGS) $(GCC_CFLAGS) -o $(PROGRAM).exe $(SOURCES)
-
-win32-visualc win32-vc:
-       cl -nologo -MD -W3 -O2 -GF $(CPPFLAGS) $(SOURCES)
-
-win32-watcomc win32-wc:
-       wcl386 -bt=nt -zq -mf -5r -zc -w5 -oneatx $(CPPFLAGS) $(SOURCES)
-
-
-#
-# DOS (16-bit)
-#
-
-dos16-borlandc dos16-bc:
-       bcc -ml -w -d -O -4 $(CPPFLAGS) $(SOURCES)
-
-dos16-microsoftc dos16-msc dos16-mc:
-       cl -nologo -f- -AL -O -G2 -W3 $(CPPFLAGS) $(SOURCES)
-
-dos16-watcomc dos16-wc:
-       wcl -zq -ml -bt=dos -l=dos -ox -w5 $(CPPFLAGS) $(SOURCES)
-
-
-#
-# DOS (32-bit)
-#
-
-dos32-djgpp2 dos32-dj2:
-       gcc $(CPPFLAGS) $(GCC_CFLAGS) -o $(PROGRAM).exe $(SOURCES)
-
-dos32-watcomc dos32-wc:
-       wcl386 -zq -mf -bt=dos -l=dos4g -5r -ox -zc $(CPPFLAGS) $(SOURCES)
-
-
+# The Original Code is Copyright (C) 2009 Blender Foundation
+# All rights reserved.
 #
-# other targets
+# Contributor(s): none yet.
 #
+# ***** END GPL LICENSE BLOCK *****
 
-clean:
-       rm -f $(PROGRAM) $(PROGRAM).exe $(PROGRAM).map $(PROGRAM).tds
-       rm -f *.err *.o *.obj
+LIBNAME = minilzo
+DIR = $(OCGDIR)/extern/$(LIBNAME)
 
-.PHONY: default clean
+include nan_compile.mk
 
+install: $(ALL_OR_DEBUG)
+       @[ -d $(NAN_LZO) ] || mkdir -p $(NAN_LZO)
+       @[ -d $(NAN_LZO)/minilzo ] || mkdir -p $(NAN_LZO)/minilzo
+       @[ -d $(NAN_LZO)/lib/$(DEBUG_DIR) ] || mkdir -p $(NAN_LZO)/lib/$(DEBUG_DIR)
+       @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)lib$(LIBNAME).a $(NAN_LZO)/lib/$(DEBUG_DIR)
+ifeq ($(OS),darwin)
+       ranlib $(NAN_LZO)/lib/$(DEBUG_DIR)lib$(LIBNAME).a
+endif
+       @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh *.h $(NAN_LZO)/minilzo
index cd2e7cf75baf8ed5652753971ddc95a2d0995fd0..8e9f66bbe42b55ae8727a4ac518cbc393809ec25 100644 (file)
@@ -110,6 +110,9 @@ COMLIB += $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaudaspace.a
 COMLIB += $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_src.a
 COMLIB += $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_fx.a
 COMLIB += $(NAN_SAMPLERATE)/lib/$(DEBUG_DIR)libsamplerate.a
+COMLIB += $(NAN_LZO)/lib/$(DEBUG_DIR)libminilzo.a
+COMLIB += $(NAN_LZMA)/lib/$(DEBUG_DIR)liblzma.a
+COMLIB += $(NAN_SMOKE)/lib/$(DEBUG_DIR)/libsmoke.a 
 
 ifneq ($(NAN_NO_KETSJI),true)
     COMLIB += $(OCGDIR)/gameengine/bloutines/$(DEBUG_DIR)libbloutines.a
index 432c3b5f854d101f5f427257e268d35d2cc01be9..2cd72809579d64221631618be898732b65fe2586 100644 (file)
@@ -151,7 +151,7 @@ void blf_font_draw(FontBLF *font, char *str)
 
 void blf_font_buffer(FontBLF *font, char *str)
 {
-       unsigned char *data;
+       unsigned char *data, *cbuf;
        unsigned int c;
        GlyphBLF *g, *g_prev;
        FT_Vector delta;
@@ -197,30 +197,27 @@ void blf_font_buffer(FontBLF *font, char *str)
                                pen_x += delta.x >> 6;
                }
 
-               if (font->b_fbuf) {
-                       chx= pen_x + ((int)g->pos_x);
-
-                       diff= g->height - ((int)g->pos_y);
-
-                       if (diff > 0) {
-                               if (g->pitch < 0)
-                                       pen_y += diff;
-                               else
-                                       pen_y -= diff;
-                       }
-                       else if (diff < 0) {
-                               if (g->pitch < 0)
-                                       pen_y -= diff;
-                               else
-                                       pen_y += diff;
-                       }
-
-
+               chx= pen_x + ((int)g->pos_x);
+               diff= g->height - ((int)g->pos_y);
+               if (diff > 0) {
                        if (g->pitch < 0)
-                               chy= pen_y - ((int)g->pos_y);
+                               pen_y += diff;
                        else
-                               chy= pen_y + ((int)g->pos_y);
+                               pen_y -= diff;
+               }
+               else if (diff < 0) {
+                       if (g->pitch < 0)
+                               pen_y -= diff;
+                       else
+                               pen_y += diff;
+               }
 
+               if (g->pitch < 0)
+                       chy= pen_y - ((int)g->pos_y);
+               else
+                       chy= pen_y + ((int)g->pos_y);
+
+               if (font->b_fbuf) {
                        if (chx >= 0 && chx < font->bw && pen_y >= 0 && pen_y < font->bh) {
                                if (g->pitch < 0)
                                        yb= 0;
@@ -251,20 +248,52 @@ void blf_font_buffer(FontBLF *font, char *str)
                                                yb--;
                                }
                        }
+               }
 
-                       if (diff > 0) {
-                               if (g->pitch < 0)
-                                       pen_x -= diff;
-                               else
-                                       pen_y += diff;
-                       }
-                       else if (diff < 0) {
+               if (font->b_cbuf) {
+                       if (chx >= 0 && chx < font->bw && pen_y >= 0 && pen_y < font->bh) {
                                if (g->pitch < 0)
-                                       pen_x += diff;
+                                       yb= 0;
                                else
-                                       pen_y -= diff;
+                                       yb= g->height-1;
+
+                               for (y= 0; y < g->height; y++) {
+                                       for (x= 0; x < g->width; x++) {
+                                               cbuf= font->b_cbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw));
+                                               data= g->bitmap + x + (yb * g->pitch);
+                                               a= data[0];
+
+                                               if (a == 256) {
+                                                       cbuf[0]= font->b_col[0];
+                                                       cbuf[1]= font->b_col[1];
+                                                       cbuf[2]= font->b_col[2];
+                                               }
+                                               else {
+                                                       cbuf[0]= (font->b_col[0]*a) + (cbuf[0] * (256-a));
+                                                       cbuf[1]= (font->b_col[1]*a) + (cbuf[1] * (256-a));
+                                                       cbuf[2]= (font->b_col[2]*a) + (cbuf[2] * (256-a));
+                                               }
+                                       }
+
+                                       if (g->pitch < 0)
+                                               yb++;
+                                       else
+                                               yb--;
+                               }
                        }
+               }
 
+               if (diff > 0) {
+                       if (g->pitch < 0)
+                               pen_x -= diff;
+                       else
+                               pen_y += diff;
+               }
+               else if (diff < 0) {
+                       if (g->pitch < 0)
+                               pen_x += diff;
+                       else
+                               pen_y -= diff;
                }
 
                pen_x += g->advance;
index d6d41d6579ea4f8734461705b72eff3eff85062f..6c2edc9e25f9d746513f560ea56c5840037b71e7 100644 (file)
@@ -90,6 +90,10 @@ CPPFLAGS += -I$(NAN_BULLET2)/include
 CPPFLAGS += -I$(NAN_FREETYPE)/include
 CPPFLAGS += -I$(NAN_FREETYPE)/include/freetype2
 
+# lzo and lzma, for pointcache
+CPPFLAGS += -I$(NAN_LZO)/minilzo
+CPPFLAGS += -I$(NAN_LZMA)
+
 ifeq ($(WITH_FFMPEG),true)
     CPPFLAGS += -DWITH_FFMPEG
     CPPFLAGS += $(NAN_FFMPEGCFLAGS)
@@ -111,3 +115,4 @@ ifeq ($(WITH_QUICKTIME), true)
        CPPFLAGS += -I../../quicktime
        CPPFLAGS += -DWITH_QUICKTIME
 endif
+
index b3f36dd3b5c256c14f122c313791b3520e426d8a..7fab61d524719705bb5bba28a8cac559f796dfbc 100644 (file)
@@ -113,7 +113,10 @@ ifndef CONFIG_GUESS
     export WITH_OPENEXR ?= true
     export WITH_DDS ?= true
     export WITH_OPENJPEG ?= true
-
+    export WITH_LZO ?= true
+    export WITH_LZMA ?= true
+    export NAN_LZO ?= $(LCGDIR)/lzo
+    export NAN_LZMA ?= $(LCGDIR)/lzma
 
   ifeq ($(NAN_USE_FFMPEG_CONFIG), true)
     export NAN_FFMPEG ?= $(shell ffmpeg-config --prefix)