dslinux/user/pixil/packages/dvdview/dvdview/libvideogfx/libvideogfx/graphics/datatypes Makefile.am Makefile.in motionfield.cc motionfield.hh primitives.hh region.cc region.hh
amadeus
dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:25:40 CEST 2006
Update of /cvsroot/dslinux/dslinux/user/pixil/packages/dvdview/dvdview/libvideogfx/libvideogfx/graphics/datatypes
In directory antilope:/tmp/cvs-serv11916/packages/dvdview/dvdview/libvideogfx/libvideogfx/graphics/datatypes
Added Files:
Makefile.am Makefile.in motionfield.cc motionfield.hh
primitives.hh region.cc region.hh
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it
--- NEW FILE: Makefile.am ---
## Makefile.am for libvideogfx/libvideogfx/graphics/datatypes
noinst_LTLIBRARIES = libvideogfx-graphics-datatypes.la
libvideogfx_graphics_datatypes_la_SOURCES = \
motionfield.cc \
motionfield.hh \
primitives.hh \
region.cc \
region.hh
INCLUDES = \
-I$(top_srcdir)
.PHONY: files
files:
@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
echo $$p; \
done
--- NEW FILE: region.hh ---
/*********************************************************************
libvideogfx/graphics/datatypes/region.hh
purpose:
notes:
to do:
author(s):
- Dirk Farin, farin at ti.uni-mannheim.de
University Mannheim, Dept. Circuitry and Simulation
B 6,26 EG, room 0.10 / D-68131 Mannheim / Germany
modifications:
17/Nov/1999 - Dirk Farin - first revision
*********************************************************************/
#ifndef LIBVIDEOGFX_GRAPHICS_DATATYPES_REGION_HH
#define LIBVIDEOGFX_GRAPHICS_DATATYPES_REGION_HH
#include "libvideogfx/graphics/basic/bitmap.hh"
class RegionStripe
{
public:
int x,y;
int xrun;
bool operator==(const RegionStripe& s) const { return x==s.x && y==s.y && xrun==s.xrun; }
};
class RegionStripeIterator
{
friend class Region;
public:
RegionStripe Get();
bool NoMoreStripes();
private:
RegionStripeIterator(bool sglpixel,const class Region*);
const class Region* d_region;
bool d_sglPixel;
int d_nextIdx;
int d_currRun;
};
class Region
{
friend class RegionStripeIterator;
public:
Region();
Region(const Region&);
~Region();
const Region& operator=(const Region&);
void AddPixel(int x,int y) { AddHRun(x,y,1); }
void AddHRun(int x,int y,int xrun);
void AddStripe(const RegionStripe& s) { AddHRun(s.x,s.y,s.xrun); }
void RemovePixel(int x,int y);
RegionStripeIterator GetStripeIterator(bool sglpixel=true) const;
bool ContainsPixel(int x,int y) const;
//void GetPixelList(Point2D<int>*);
void Shift(int x,int y); // Shift region x (y) pixels right (down).
void Union(const Region&);
void Cut (const Region&);
Region Intersection(const Region&);
bool operator<=(const Region&) const;
bool operator>=(const Region& r) const { return r <= *this; }
bool operator==(const Region& r) const { return (r <= *this) && (*this <= r); }
private:
RegionStripe* d_stripes;
int d_nStripes;
int d_nSize;
};
/* String example:
" X \n"
" X0XX\n" // Use '.' for '0', when the pixel is not included in the mask.
" X \n";
*/
Region RegionFromString(const char*);
template <class T> void DrawRegion(Bitmap<T>&,const Region&,T color);
#endif
--- NEW FILE: primitives.hh ---
/********************************************************************************
libvideogfx/graphics/datatypes/primitives.hh
purpose:
Very basic data types.
notes:
to do:
author(s):
- Dirk Farin, farin at ti.uni-mannheim.de
modifications:
17/Nov/1999 - Dirk Farin - first revision
********************************************************************************
Copyright (C) 1999 Dirk Farin
This program is distributed under GNU Public License (GPL) as
outlined in the COPYING file that comes with the source distribution.
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.
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
********************************************************************************/
#ifndef LIBVIDEOGFX_GRAPHICS_DATATYPES_PRIMITIVES_HH
#define LIBVIDEOGFX_GRAPHICS_DATATYPES_PRIMITIVES_HH
template <class T> struct Point2D
{
T x,y;
};
template <class T> struct Rect2D
{
Point2D<T> upperleft;
Point2D<T> lowerright;
};
#endif
--- NEW FILE: motionfield.hh ---
/*********************************************************************
libvideogfx/graphics/datatypes/motionfield.hh
purpose:
notes:
to do:
author(s):
- Dirk Farin, farin at ti.uni-mannheim.de
University Mannheim, Dept. Circuitry and Simulation
B 6,26 EG, room 0.10 / D-68131 Mannheim / Germany
modifications:
1999/Oct/19 - Dirk Farin - integration into CVS, mostly rewritten
*********************************************************************/
#ifndef LIBVIDEOGFX_GRAPHICS_DATATYPES_MOTIONFIELD_HH
#define LIBVIDEOGFX_GRAPHICS_DATATYPES_MOTIONFIELD_HH
#include "libvideogfx/graphics/basic/bitmap.hh"
struct MotionVector
{
double h,v;
};
struct MotionVectorField
{
MotionVectorField(int p_nblks_h,
int p_nblks_v,
int p_blksize_h = 16,
int p_blksize_v = 16)
{
blksize_h = p_blksize_h;
blksize_v = p_blksize_v;
nblks_h = p_nblks_h;
nblks_v = p_nblks_v;
mv.Create(nblks_h, nblks_v);
}
Bitmap<MotionVector> mv;
int blksize_h,blksize_v;
int nblks_h ,nblks_v;
};
#endif
--- NEW FILE: Makefile.in ---
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../../..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_alias = @build_alias@
build_triplet = @build@
host_alias = @host_alias@
host_triplet = @host@
target_alias = @target_alias@
target_triplet = @target@
AS = @AS@
CC = @CC@
CXX = @CXX@
DLLTOOL = @DLLTOOL@
LIBTOOL = @LIBTOOL@
LIBVIDEOGFX_BINARY_AGE = @LIBVIDEOGFX_BINARY_AGE@
LIBVIDEOGFX_INTERFACE_AGE = @LIBVIDEOGFX_INTERFACE_AGE@
LIBVIDEOGFX_MAJOR_VERSION = @LIBVIDEOGFX_MAJOR_VERSION@
LIBVIDEOGFX_MICRO_VERSION = @LIBVIDEOGFX_MICRO_VERSION@
LIBVIDEOGFX_MINOR_VERSION = @LIBVIDEOGFX_MINOR_VERSION@
LIBVIDEOGFX_VERSION = @LIBVIDEOGFX_VERSION@
LN_S = @LN_S@
LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
LT_RELEASE = @LT_RELEASE@
LT_REVISION = @LT_REVISION@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
VERSION = @VERSION@
X_LDFLAGS = @X_LDFLAGS@
noinst_LTLIBRARIES = libvideogfx-graphics-datatypes.la
libvideogfx_graphics_datatypes_la_SOURCES = motionfield.cc motionfield.hh primitives.hh region.cc region.hh
INCLUDES = -I$(top_srcdir)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../../config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
DEFS = @DEFS@ -I. -I$(srcdir) -I../../..
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
X_CFLAGS = @X_CFLAGS@
X_LIBS = @X_LIBS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
libvideogfx_graphics_datatypes_la_LDFLAGS =
libvideogfx_graphics_datatypes_la_LIBADD =
libvideogfx_graphics_datatypes_la_OBJECTS = motionfield.lo region.lo
CXXFLAGS = @CXXFLAGS@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
DEP_FILES = .deps/motionfield.P .deps/region.P
SOURCES = $(libvideogfx_graphics_datatypes_la_SOURCES)
OBJECTS = $(libvideogfx_graphics_datatypes_la_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .cc .lo .o .s
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu libvideogfx/graphics/datatypes/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-noinstLTLIBRARIES:
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
distclean-noinstLTLIBRARIES:
maintainer-clean-noinstLTLIBRARIES:
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
.s.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.S.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
maintainer-clean-libtool:
libvideogfx-graphics-datatypes.la: $(libvideogfx_graphics_datatypes_la_OBJECTS) $(libvideogfx_graphics_datatypes_la_DEPENDENCIES)
$(CXXLINK) $(libvideogfx_graphics_datatypes_la_LDFLAGS) $(libvideogfx_graphics_datatypes_la_OBJECTS) $(libvideogfx_graphics_datatypes_la_LIBADD) $(LIBS)
.cc.o:
$(CXXCOMPILE) -c $<
.cc.lo:
$(LTCXXCOMPILE) -c $<
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = libvideogfx/graphics/datatypes
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu libvideogfx/graphics/datatypes/Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
-include $(DEP_FILES)
mostlyclean-depend:
clean-depend:
distclean-depend:
-rm -rf .deps
maintainer-clean-depend:
%.o: %.c
@echo '$(COMPILE) -c $<'; \
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-cp .deps/$(*F).pp .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm .deps/$(*F).pp
%.lo: %.c
@echo '$(LTCOMPILE) -c $<'; \
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
< .deps/$(*F).pp > .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm -f .deps/$(*F).pp
%.o: %.cc
@echo '$(CXXCOMPILE) -c $<'; \
$(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-cp .deps/$(*F).pp .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm .deps/$(*F).pp
%.lo: %.cc
@echo '$(LTCXXCOMPILE) -c $<'; \
$(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
< .deps/$(*F).pp > .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm -f .deps/$(*F).pp
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am
install-data-am:
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am:
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-noinstLTLIBRARIES mostlyclean-compile \
mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-noinstLTLIBRARIES clean-compile clean-libtool \
clean-tags clean-depend clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-noinstLTLIBRARIES distclean-compile \
distclean-libtool distclean-tags distclean-depend \
distclean-generic clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-noinstLTLIBRARIES \
maintainer-clean-compile maintainer-clean-libtool \
maintainer-clean-tags maintainer-clean-depend \
maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-noinstLTLIBRARIES distclean-noinstLTLIBRARIES \
clean-noinstLTLIBRARIES maintainer-clean-noinstLTLIBRARIES \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir \
mostlyclean-depend distclean-depend clean-depend \
maintainer-clean-depend info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
.PHONY: files
files:
@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
echo $$p; \
done
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
--- NEW FILE: motionfield.cc ---
/*
* motionfield.cc
*/
#include "motionfield.hh"
template class Bitmap<MotionVector>;
#include "libvideogfx/graphics/basic/bitmap.cc"
--- NEW FILE: region.cc ---
/*
* region.cc
*/
#include "region.hh"
RegionStripeIterator::RegionStripeIterator(bool sglpixel,const class Region* region)
: d_region(region),
d_sglPixel(sglpixel),
d_nextIdx(0),
d_currRun(0)
{
}
RegionStripe RegionStripeIterator::Get()
{
if (d_sglPixel)
{
RegionStripe s = d_region->d_stripes[d_nextIdx];
s.x += d_currRun;
s.xrun = 1;
d_currRun++;
if (d_currRun == d_region->d_stripes[d_nextIdx].xrun)
{
d_currRun=0;
d_nextIdx++;
}
return s;
}
else
{
return d_region->d_stripes[d_nextIdx++];
}
}
bool RegionStripeIterator::NoMoreStripes()
{
return d_nextIdx == d_region->d_nStripes;
}
Region::Region()
{
d_stripes = new RegionStripe[1000];
d_nStripes = 0;
d_nSize = 1000;
}
Region::~Region()
{
delete[] d_stripes;
}
Region::Region(const Region& r)
{
d_nSize = max(r.d_nStripes,10);
d_stripes = new RegionStripe[d_nSize];
d_nStripes = r.d_nStripes;
for (int i=0;i<d_nStripes;i++)
d_stripes[i] = r.d_stripes[i];
}
const Region& Region::operator=(const Region& r)
{
delete[] d_stripes;
d_nSize = max(r.d_nStripes,10);
d_stripes = new RegionStripe[d_nSize];
d_nStripes = r.d_nStripes;
for (int i=0;i<d_nStripes;i++)
d_stripes[i] = r.d_stripes[i];
}
void Region::AddHRun(int newx,int newy,int newxrun)
{
for(int i=0;i<newxrun;i++)
{
if (d_nStripes == d_nSize)
{
RegionStripe* s = new RegionStripe[d_nSize*2];
for (int n=0;n<d_nSize;n++)
s[n]=d_stripes[n];
delete[] d_stripes;
d_stripes=s;
d_nSize *= 2;
}
RegionStripe s;
s.x = newx+i;
s.y = newy;
s.xrun = 1;
bool alreadycontained=false;
for (int n=0;n<d_nStripes && !alreadycontained;n++)
{
if (d_stripes[n] == s)
{ alreadycontained=true; }
}
if (!alreadycontained)
{
d_stripes[d_nStripes] = s;
d_nStripes++;
}
}
#if 0
// Check if we can append the new stripe to an existing one.
for (int i=d_nStripes-1;i>=0 && d_stripes[i].y>=newy ;i--)
{
if (d_stripes[i].y == newy)
{
RegionStripe& s = d_stripes[i];
// 3 combination cases: new stripe connects to the front, to the end or is in the middle
if (newx < s.x && newx+newxrun>=s.x)
{
int newend = max(s.x+s.xrun , newx+xrun);
s.x = newx;
s.xrun = newend-s.x;
}
// Handle this case:
// XXXXXXXXXXXXXX <- new
// AAAAAAAA BBBBBBBBBBBBBB
}
}
#endif
}
void Region::RemovePixel(int x,int y)
{
for (int i=0;i<d_nStripes;i++)
{
if (d_stripes[i].y == y &&
d_stripes[i].x == x)
{
assert(d_stripes[i].xrun==1);
d_nStripes--;
d_stripes[i]=d_stripes[d_nStripes];
return;
}
}
}
bool Region::ContainsPixel(int x,int y) const
{
for (int i=0;i<d_nStripes;i++)
if (d_stripes[i].y == y &&
d_stripes[i].x <= x &&
d_stripes[i].x+d_stripes[i].xrun-1 >= x)
return true;
return false;
}
void Region::Shift(int x,int y) // Shift region x,y pixels right,down.
{
for (int i=0;i<d_nStripes;i++)
{
d_stripes[i].x += x;
d_stripes[i].y += y;
}
}
void Region::Union(const Region& r)
{
RegionStripeIterator iter=r.GetStripeIterator(false);
while (!iter.NoMoreStripes())
{
AddStripe(iter.Get());
}
}
void Region::Cut(const Region& r)
{
RegionStripeIterator iter=r.GetStripeIterator(false);
while (!iter.NoMoreStripes())
{
RegionStripe s = iter.Get();
RemovePixel(s.x,s.y);
}
}
Region Region::Intersection(const Region& r)
{
Region newreg;
RegionStripeIterator iter=r.GetStripeIterator(true);
while (!iter.NoMoreStripes())
{
RegionStripe s = iter.Get();
if (ContainsPixel(s.x,s.y))
newreg.AddPixel(s.x,s.y);
}
return newreg;
}
bool Region::operator<=(const Region& r) const
{
RegionStripeIterator iter=GetStripeIterator(true);
while (!iter.NoMoreStripes())
{
RegionStripe s=iter.Get();
if (!r.ContainsPixel(s.x,s.y))
return false;
}
return true;
}
RegionStripeIterator Region::GetStripeIterator(bool sglpixel) const
{
return RegionStripeIterator(sglpixel,this);
}
Region RegionFromString(const char* str)
{
// Find zero point.
int x0=0,y0=0;
for (const char* p=str;*p!='0' && *p!='.';p++,x0++)
{
if (*p=='\n') { x0=-1; y0++; }
}
int x=0,y=0;
Region r;
for (const char* p=str;*p!=0;p++,x++)
{
if (*p=='X' || *p=='0') { r.AddPixel(x-x0,y-y0); }
if (*p=='\n') { x=-1; y++; }
}
return r;
}
template <class T> void DrawRegion(Bitmap<T>& bm,const Region& r,T color)
{
RegionStripeIterator iter=r.GetStripeIterator(false);
T*const* p = bm.AskFrame();
while (!iter.NoMoreStripes())
{
RegionStripe s = iter.Get();
for (int x=0;x<s.xrun;x++)
p[s.y][s.x+x]=color;
}
}
template void DrawRegion(Bitmap<bool>& ,const Region&,bool);
template void DrawRegion(Bitmap<Pixel>&,const Region&,Pixel);
More information about the dslinux-commit
mailing list