diff options
Diffstat (limited to 'nuttx/graphics')
-rw-r--r-- | nuttx/graphics/Makefile | 98 | ||||
-rw-r--r-- | nuttx/graphics/nxfonts/Makefile.sources | 14 | ||||
-rw-r--r-- | nuttx/graphics/nxglib/Makefile.sources | 52 | ||||
-rw-r--r-- | nuttx/graphics/nxglib/nxglib_splitline.c | 389 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nx_bitmap.c | 29 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nx_block.c | 2 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nx_getrectangle.c | 30 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nxfe.h | 21 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nxmu_kbdin.c | 2 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nxmu_mouse.c | 46 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nxmu_redrawreq.c | 2 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nxmu_reportposition.c | 2 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nxmu_sendwindow.c | 44 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nxmu_server.c | 10 | ||||
-rw-r--r-- | nuttx/graphics/nxsu/nx_mousein.c | 30 | ||||
-rw-r--r-- | nuttx/graphics/nxtk/nxtk_events.c | 39 | ||||
-rw-r--r-- | nuttx/graphics/nxtk/nxtk_filltrapwindow.c | 11 | ||||
-rw-r--r-- | nuttx/graphics/nxtk/nxtk_getwindow.c | 11 | ||||
-rw-r--r-- | nuttx/graphics/nxtk/nxtk_internal.h | 5 | ||||
-rw-r--r-- | nuttx/graphics/nxtk/nxtk_subwindowmove.c | 12 |
20 files changed, 628 insertions, 221 deletions
diff --git a/nuttx/graphics/Makefile b/nuttx/graphics/Makefile index 6e549c1dd..238e14df4 100644 --- a/nuttx/graphics/Makefile +++ b/nuttx/graphics/Makefile @@ -33,7 +33,6 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs DEPPATH = --dep-path . @@ -44,34 +43,34 @@ endif include nxglib/Make.defs DEPPATH += --dep-path nxglib -CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxglib} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxglib} include nxbe/Make.defs DEPPATH += --dep-path nxbe -CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxbe} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxbe} ifeq ($(CONFIG_NX_MULTIUSER),y) include nxmu/Make.defs DEPPATH += --dep-path nxmu -CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxmu} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxmu} else include nxsu/Make.defs DEPPATH += --dep-path nxsu -CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxsu} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxsu} endif include nxtk/Make.defs DEPPATH += --dep-path nxtk -CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxtk} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxtk} include nxfonts/Make.defs DEPPATH += --dep-path nxfonts -CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxfonts} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxfonts} ifeq ($(CONFIG_NXCONSOLE),y) include nxconsole/Make.defs DEPPATH += --dep-path nxconsole -CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxconsole} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxconsole} endif ASRCS = $(NXGLIB_ASRCS) $(NXBE_ASRCS) $(NX_ASRCS) $(NXTK_ASRCS) $(NXFONTS_ASRCS) $(NXCON_ASRCS) @@ -97,84 +96,84 @@ all: mklibgraphics gen32bppsources genfontsources gen1bppsources: - @$(MAKE) -C nxglib -f Makefile.sources TOPDIR=$(TOPDIR) NXGLIB_BITSPERPIXEL=1 EXTRADEFINES=$(EXTRADEFINES) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_BITSPERPIXEL=1 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxglib -f Makefile.sources TOPDIR=$(TOPDIR) NXGLIB_BITSPERPIXEL=1 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_BITSPERPIXEL=1 EXTRADEFINES=$(EXTRADEFINES) gen2bppsource: - @$(MAKE) -C nxglib -f Makefile.sources TOPDIR=$(TOPDIR) NXGLIB_BITSPERPIXEL=2 EXTRADEFINES=$(EXTRADEFINES) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_BITSPERPIXEL=2 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxglib -f Makefile.sources TOPDIR=$(TOPDIR) NXGLIB_BITSPERPIXEL=2 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_BITSPERPIXEL=2 EXTRADEFINES=$(EXTRADEFINES) gen4bppsource: - @$(MAKE) -C nxglib -f Makefile.sources TOPDIR=$(TOPDIR) NXGLIB_BITSPERPIXEL=4 EXTRADEFINES=$(EXTRADEFINES) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_BITSPERPIXEL=4 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxglib -f Makefile.sources TOPDIR=$(TOPDIR) NXGLIB_BITSPERPIXEL=4 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_BITSPERPIXEL=4 EXTRADEFINES=$(EXTRADEFINES) gen8bppsource: - @$(MAKE) -C nxglib -f Makefile.sources TOPDIR=$(TOPDIR) NXGLIB_BITSPERPIXEL=8 EXTRADEFINES=$(EXTRADEFINES) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_BITSPERPIXEL=8 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxglib -f Makefile.sources TOPDIR=$(TOPDIR) NXGLIB_BITSPERPIXEL=8 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_BITSPERPIXEL=8 EXTRADEFINES=$(EXTRADEFINES) gen16bppsource: - @$(MAKE) -C nxglib -f Makefile.sources TOPDIR=$(TOPDIR) NXGLIB_BITSPERPIXEL=16 EXTRADEFINES=$(EXTRADEFINES) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_BITSPERPIXEL=16 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxglib -f Makefile.sources TOPDIR=$(TOPDIR) NXGLIB_BITSPERPIXEL=16 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_BITSPERPIXEL=16 EXTRADEFINES=$(EXTRADEFINES) gen24bppsource: - @$(MAKE) -C nxglib -f Makefile.sources TOPDIR=$(TOPDIR) NXGLIB_BITSPERPIXEL=24 EXTRADEFINES=$(EXTRADEFINES) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_BITSPERPIXEL=24 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxglib -f Makefile.sources TOPDIR=$(TOPDIR) NXGLIB_BITSPERPIXEL=24 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_BITSPERPIXEL=24 EXTRADEFINES=$(EXTRADEFINES) gen32bppsources: - @$(MAKE) -C nxglib -f Makefile.sources TOPDIR=$(TOPDIR) NXGLIB_BITSPERPIXEL=32 EXTRADEFINES=$(EXTRADEFINES) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_BITSPERPIXEL=32 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxglib -f Makefile.sources TOPDIR=$(TOPDIR) NXGLIB_BITSPERPIXEL=32 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_BITSPERPIXEL=32 EXTRADEFINES=$(EXTRADEFINES) genfontsources: ifeq ($(CONFIG_NXFONT_SANS23X27),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=1 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=1 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SANS22X29),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=2 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=2 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SANS28X37),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=3 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=3 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SANS39X48),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=4 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=4 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SANS17X23B),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=16 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=16 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SANS20X27B),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=17 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=17 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SANS22X29B),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=5 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=5 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SANS28X37B),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=6 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=6 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SANS40X49B),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=7 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=7 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SERIF22X29),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=8 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=8 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SERIF29X37),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=9 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=9 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SERIF38X48),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=10 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=10 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SERIF22X28B),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=11 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=11 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SERIF27X38B),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=12 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=12 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SERIF38X49B),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=13 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=13 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SANS17X22),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=14 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=14 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_SANS20X26),y) - @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=15 EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=15 EXTRADEFINES=$(EXTRADEFINES) endif gensources: gen1bppsources gen2bppsource gen4bppsource gen8bppsource gen16bppsource gen24bppsource gen32bppsources genfontsources @@ -186,30 +185,29 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) $(BIN): $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $@, $${obj}); \ - done ; ) + $(call ARCHIVE, $@, $(OBJS)) mklibgraphics: gensources $(BIN) .depend: gensources Makefile $(SRCS) - @$(MKDEP) $(DEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep - @touch $@ + $(Q) $(MKDEP) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + $(Q) touch $@ depend: .depend context: gensources clean: - @$(MAKE) -C nxglib -f Makefile.sources clean TOPDIR=$(TOPDIR) EXTRADEFINES=$(EXTRADEFINES) - @$(MAKE) -C nxfonts -f Makefile.sources clean TOPDIR=$(TOPDIR) EXTRADEFINES=$(EXTRADEFINES) - @rm -f $(BIN) *~ .*.swp + $(Q) $(MAKE) -C nxglib -f Makefile.sources clean TOPDIR=$(TOPDIR) EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources clean TOPDIR=$(TOPDIR) EXTRADEFINES=$(EXTRADEFINES) + $(call DELFILE, $(BIN)) $(call CLEAN) distclean: clean - @$(MAKE) -C nxglib -f Makefile.sources distclean TOPDIR=$(TOPDIR) EXTRADEFINES=$(EXTRADEFINES) - @$(MAKE) -C nxfonts -f Makefile.sources distclean TOPDIR=$(TOPDIR) EXTRADEFINES=$(EXTRADEFINES) - @rm -f Make.dep .depend + $(Q) $(MAKE) -C nxglib -f Makefile.sources distclean TOPDIR=$(TOPDIR) EXTRADEFINES=$(EXTRADEFINES) + $(Q) $(MAKE) -C nxfonts -f Makefile.sources distclean TOPDIR=$(TOPDIR) EXTRADEFINES=$(EXTRADEFINES) + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/nuttx/graphics/nxfonts/Makefile.sources b/nuttx/graphics/nxfonts/Makefile.sources index f2aa87caf..76a099dcb 100644 --- a/nuttx/graphics/nxfonts/Makefile.sources +++ b/nuttx/graphics/nxfonts/Makefile.sources @@ -33,7 +33,6 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs ifdef NXFONTS_BITSPERPIXEL @@ -177,13 +176,14 @@ all: $(GEN_CSRC) .PHONY : clean distclean $(GEN_CSRC) : $(DEPENDENCY) - @$(call PREPROCESS, $<, $(GEN_TMP)) - @cat $(GEN_TMP) | sed -e "/^#/d" >$@ - @rm -f $(GEN_TMP) + $(call PREPROCESS, $<, $(GEN_TMP)) + $(Q) cat $(GEN_TMP) | sed -e "/^#/d" >$@ + $(Q) rm -f $(GEN_TMP) clean: - @rm -f *~ .*.swp *.i + $(call DELFILE, *.i) + $(call CLEAN) distclean: clean - @rm -f nxfonts_convert_*bpp.c - @rm -f nxfonts_bitmaps_*.c + $(call DELFILE, nxfonts_convert_*bpp.c) + $(call DELFILE, nxfonts_bitmaps_*.c) diff --git a/nuttx/graphics/nxglib/Makefile.sources b/nuttx/graphics/nxglib/Makefile.sources index 67f8defc3..71d6e0661 100644 --- a/nuttx/graphics/nxglib/Makefile.sources +++ b/nuttx/graphics/nxglib/Makefile.sources @@ -33,7 +33,6 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs ifeq ($(NXGLIB_BITSPERPIXEL),1) @@ -123,53 +122,54 @@ all: $(GEN_CSRCS) $(SETP_CSRC) : $(BLITDIR)/nxglib_setpixel.c nxglib_bitblit.h ifneq ($(NXGLIB_BITSPERPIXEL),) - @$(call PREPROCESS, $(BLITDIR)/nxglib_setpixel.c, $(SETP_TMP)) - @cat $(SETP_TMP) | sed -e "/^#/d" >$@ - @rm -f $(SETP_TMP) + $(call PREPROCESS, $(BLITDIR)/nxglib_setpixel.c, $(SETP_TMP)) + $(Q) cat $(SETP_TMP) | sed -e "/^#/d" >$@ + $(Q) rm -f $(SETP_TMP) endif $(RFILL_CSRC) : $(BLITDIR)/nxglib_fillrectangle.c nxglib_bitblit.h ifneq ($(NXGLIB_BITSPERPIXEL),) - @$(call PREPROCESS, $(BLITDIR)/nxglib_fillrectangle.c, $(RFILL_TMP)) - @cat $(RFILL_TMP) | sed -e "/^#/d" >$@ - @rm -f $(RFILL_TMP) + $(call PREPROCESS, $(BLITDIR)/nxglib_fillrectangle.c, $(RFILL_TMP)) + $(Q) cat $(RFILL_TMP) | sed -e "/^#/d" >$@ + $(Q) rm -f $(RFILL_TMP) endif $(RGET_CSRC) : $(BLITDIR)/nxglib_getrectangle.c nxglib_bitblit.h ifneq ($(NXGLIB_BITSPERPIXEL),) - @$(call PREPROCESS, $(BLITDIR)/nxglib_getrectangle.c, $(RGET_TMP)) - @cat $(RGET_TMP) | sed -e "/^#/d" >$@ - @rm -f $(RGET_TMP) + $(call PREPROCESS, $(BLITDIR)/nxglib_getrectangle.c, $(RGET_TMP)) + $(Q) cat $(RGET_TMP) | sed -e "/^#/d" >$@ + $(Q) rm -f $(RGET_TMP) endif $(TFILL_CSRC) : $(BLITDIR)/nxglib_filltrapezoid.c nxglib_bitblit.h ifneq ($(NXGLIB_BITSPERPIXEL),) - @$(call PREPROCESS, $(BLITDIR)/nxglib_filltrapezoid.c, $(TFILL_TMP)) - @cat $(TFILL_TMP) | sed -e "/^#/d" >$@ - @rm -f $(TFILL_TMP) + $(call PREPROCESS, $(BLITDIR)/nxglib_filltrapezoid.c, $(TFILL_TMP)) + $(Q) cat $(TFILL_TMP) | sed -e "/^#/d" >$@ + $(Q) rm -f $(TFILL_TMP) endif $(RMOVE_CSRC) : $(BLITDIR)/nxglib_moverectangle.c nxglib_bitblit.h ifneq ($(NXGLIB_BITSPERPIXEL),) - @$(call PREPROCESS, $(BLITDIR)/nxglib_moverectangle.c, $(RMOVE_TMP)) - @cat $(RMOVE_TMP) | sed -e "/^#/d" >$@ - @rm -f $(RMOVE_TMP) + $(call PREPROCESS, $(BLITDIR)/nxglib_moverectangle.c, $(RMOVE_TMP)) + $(Q) cat $(RMOVE_TMP) | sed -e "/^#/d" >$@ + $(Q) rm -f $(RMOVE_TMP) endif $(RCOPY_CSRC) : $(BLITDIR)/nxglib_copyrectangle.c nxglib_bitblit.h ifneq ($(NXGLIB_BITSPERPIXEL),) - @$(call PREPROCESS, $(BLITDIR)/nxglib_copyrectangle.c, $(RCOPY_TMP)) - @cat $(RCOPY_TMP) | sed -e "/^#/d" >$@ - @rm -f $(RCOPY_TMP) + $(call PREPROCESS, $(BLITDIR)/nxglib_copyrectangle.c, $(RCOPY_TMP)) + $(Q) cat $(RCOPY_TMP) | sed -e "/^#/d" >$@ + $(Q) rm -f $(RCOPY_TMP) endif clean: - @rm -f *~ .*.swp *.i + $(call DELFILE, *.i) + $(call CLEAN) distclean: clean - @rm -f nxglib_setpixel_*bpp.c - @rm -f nxglib_fillrectangle_*bpp.c - @rm -f nxglib_getrectangle_*bpp.c - @rm -f nxglib_filltrapezoid_*bpp.c - @rm -f nxglib_moverectangle_*bpp.c - @rm -f nxglib_copyrectangle_*bpp.c + $(call DELFILE, nxglib_setpixel_*bpp.c) + $(call DELFILE, nxglib_fillrectangle_*bpp.c) + $(call DELFILE, nxglib_getrectangle_*bpp.c) + $(call DELFILE, nxglib_filltrapezoid_*bpp.c) + $(call DELFILE, nxglib_moverectangle_*bpp.c) + $(call DELFILE, nxglib_copyrectangle_*bpp.c) diff --git a/nuttx/graphics/nxglib/nxglib_splitline.c b/nuttx/graphics/nxglib/nxglib_splitline.c index 84892b67e..fa2ccc1a0 100644 --- a/nuttx/graphics/nxglib/nxglib_splitline.c +++ b/nuttx/graphics/nxglib/nxglib_splitline.c @@ -1,7 +1,7 @@ /**************************************************************************** * graphics/nxglib/nxglib_splitline.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -41,6 +41,8 @@ #include <string.h> #include <errno.h> +#include <stdlib.h> +#include <debug.h> #include <nuttx/nx/nxglib.h> @@ -48,12 +50,16 @@ * Pre-Processor Definitions ****************************************************************************/ -#define SMALL_SIN 1966 /* 1966/65536 = 0.03 */ - /**************************************************************************** * Private Types ****************************************************************************/ +struct b16point_s +{ + b16_t x; + b16_t y; +}; + /**************************************************************************** * Private Data ****************************************************************************/ @@ -66,6 +72,12 @@ * Private Functions ****************************************************************************/ +static b16_t nxgl_interpolate(b16_t x, b16_t dy, b16_t dxdy) +{ + b16_t dx = b16mulb16(dy, dxdy); + return x + dx; +} + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -116,15 +128,19 @@ int nxgl_splitline(FAR struct nxgl_vector_s *vector, struct nxgl_vector_s line; nxgl_coord_t iheight; nxgl_coord_t iwidth; - nxgl_coord_t iy; - nxgl_coord_t triheight; - nxgl_coord_t halfheight; - b16_t adjwidth; - b16_t xoffset; - b16_t halfoffset; + nxgl_coord_t iyoffset; + struct b16point_s quad[4]; + b16_t b16xoffset; + b16_t b16yoffset; + b16_t b16dxdy; b16_t angle; + b16_t cosangle; b16_t sinangle; b16_t b16x; + b16_t b16y; + + gvdbg("vector: (%d,%d)->(%d,%d) linewidth: %d\n", + vector->pt1.x, vector->pt1.y, vector->pt2.x, vector->pt2.y, linewidth); /* First, check the linewidth */ @@ -152,7 +168,7 @@ int nxgl_splitline(FAR struct nxgl_vector_s *vector, line.pt2.x = vector->pt1.x; line.pt2.y = vector->pt1.y; } - else + else /* if (vector->pt1.y == vector->pt2.y) */ { /* First degenerate case: The line is horizontal. */ @@ -173,6 +189,10 @@ int nxgl_splitline(FAR struct nxgl_vector_s *vector, rect->pt1.y = vector->pt1.y - (linewidth >> 1); rect->pt2.y = rect->pt1.y + linewidth - 1; + + gvdbg("Horizontal rect: (%d,%d),(%d,%d)\n", + rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y); + return 2; } @@ -187,14 +207,21 @@ int nxgl_splitline(FAR struct nxgl_vector_s *vector, rect->pt1.x = line.pt1.x - (linewidth >> 1); rect->pt2.x = rect->pt1.x + linewidth - 1; + + gvdbg("Vertical rect: (%d,%d),(%d,%d)\n", + rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y); + return 2; } /* The final degenerate case */ - if (linewidth == 1) + if (linewidth == 1 && + abs(line.pt2.x - line.pt1.x) < (line.pt2.y - line.pt1.y)) { - /* A line of width 1 is basically a single parallelogram of width 1 */ + /* A close to vertical line of width 1 is basically + * a single parallelogram of width 1. + */ traps[1].top.x1 = itob16(line.pt1.x); traps[1].top.x2 = traps[1].top.x1; @@ -203,6 +230,11 @@ int nxgl_splitline(FAR struct nxgl_vector_s *vector, traps[1].bot.x1 = itob16(line.pt2.x); traps[1].bot.x2 = traps[1].bot.x1; traps[1].bot.y = line.pt2.y; + + gvdbg("Vertical traps[1]: (%08x,%08x,%d),(%08x,%08x, %d)\n", + traps[1].top.x1, traps[1].top.x2, traps[1].top.y, + traps[1].bot.x1, traps[1].bot.x2, traps[1].bot.y); + return 1; } @@ -222,103 +254,260 @@ int nxgl_splitline(FAR struct nxgl_vector_s *vector, iwidth = line.pt1.x - line.pt2.x + 1; } - /* Triangle height: linewidth * cosA - * Adjusted width: triheight / sinA - * X offset : linewidth * linewidth / adjusted line width + /* Applying the line width to the line results in a rotated, rectangle. + * Get the Y offset from an end of the original thin line to a corner of the fat line. + * + * Angle of line: angle = atan2(iheight, iwidth) + * Y offset from line: b16yoffset = linewidth * cos(angle) + * + * For near verical lines, b16yoffset is be nearly zero. For near horizontal + * lines, b16yOffset is be about the same as linewidth. */ - angle = b16atan2(itob16(iheight), itob16(iwidth)); - triheight = b16toi(linewidth * b16cos(angle) + b16HALF); - halfheight = (triheight >> 1); + angle = b16atan2(itob16(iheight), itob16(iwidth)); + cosangle = b16cos(angle); + b16yoffset = (linewidth * cosangle + 1) >> 1; - /* If the sine of the angle is tiny (i.e., the line is nearly horizontal), - * then we cannot compute the adjusted width. In this case, just use - * the width of the line bounding box. + /* Get the X offset from an end of the original thin line to a corner of the fat line. + * + * For near vertical lines, b16xoffset is about the same as linewidth. For near + * horizontal lines, b16xoffset is nearly zero. */ - sinangle = b16sin(angle); - if (sinangle < SMALL_SIN) - { - adjwidth = itob16(iwidth); - xoffset = 0; - } - else - { - adjwidth = b16divb16(itob16(linewidth), sinangle); - xoffset = itob16(linewidth * linewidth); - xoffset = b16divb16(xoffset, adjwidth); - } + sinangle = b16sin(angle); + b16xoffset = (linewidth * sinangle + 1) >> 1; - halfoffset = (xoffset >> 1); + gvdbg("height: %d width: %d angle: %08x b16yoffset: %08x b16xoffset: %08x\n", + iheight, iwidth, angle, b16yoffset, b16xoffset); - /* Return the top triangle (if there is one). NOTE that the horizontal - * (z) positions are represented with 16 bits of fraction. The vertical - * (y) positions, on the other hand, are integer. - */ + /* Now we know all four points of the rotated rectangle */ - if (triheight > 0) + iyoffset = b16toi(b16yoffset + b16HALF); + if (iyoffset > 0) { + /* Get the Y positions of each point */ + + b16y = itob16(line.pt1.y); + quad[0].y = b16y - b16yoffset; + quad[1].y = b16y + b16yoffset; + + b16y = itob16(line.pt2.y); + quad[2].y = b16y - b16yoffset; + quad[3].y = b16y + b16yoffset; + if (line.pt1.x < line.pt2.x) { - /* Line is going "south east" */ - - b16x = itob16(line.pt1.x) - halfoffset; - iy = line.pt1.y + halfheight; - - traps[0].top.x1 = b16x + xoffset; - traps[0].top.x2 = traps[0].top.x1; - traps[0].top.y = iy - triheight + 1; - traps[0].bot.x1 = b16x; - traps[0].bot.x2 = b16x + adjwidth - b16ONE; - traps[0].bot.y = iy; - - b16x = itob16(line.pt2.x) + halfoffset; - iy = line.pt2.y - halfheight; - - traps[2].top.x1 = b16x - adjwidth + b16ONE; - traps[2].top.x2 = b16x; - traps[2].top.y = iy; - traps[2].bot.x1 = b16x - xoffset; - traps[2].bot.x2 = traps[2].bot.x1; - traps[2].bot.y = iy + triheight - 1; + /* Line is going "south east". Get the X positions of each point */ + + b16x = itob16(line.pt1.x); + quad[0].x = b16x + b16xoffset; + quad[1].x = b16x - b16xoffset; + + b16x = itob16(line.pt2.x); + quad[2].x = b16x + b16xoffset; + quad[3].x = b16x - b16xoffset; + + gvdbg("Southeast: quad (%08x,%08x),(%08x,%08x),(%08x,%08x),(%08x,%08x)\n", + quad[0].x, quad[0].y, quad[1].x, quad[1].y, + quad[2].x, quad[2].y, quad[3].x, quad[3].y); + + /* Now we can form the trapezoids. The top of the first trapezoid + * (triangle) is at quad[0] + */ + + traps[0].top.x1 = quad[0].x; + traps[0].top.x2 = quad[0].x; + traps[0].top.y = b16toi(quad[0].y + b16HALF); + + /* The bottom of the first trapezoid (triangle) may be either at + * quad[1] or quad[2], depending upon orientation. + */ + + if (quad[1]. y < quad[2].y) + { + /* quad[1] is at the bottom left of the triangle. Interpolate + * to get the corresponding point on the right side. + * + * Interpolation is from quad[0] along the line quad[0]->quad[2] + * which as the same slope as the line (positive) + */ + + b16dxdy = itob16(iwidth) / iheight; + + traps[0].bot.x1 = quad[1].x; + traps[0].bot.x2 = nxgl_interpolate(quad[0].x, quad[1].y - quad[0].y, b16dxdy); + traps[0].bot.y = b16toi(quad[1].y + b16HALF); + + /* quad[1] is at the top left of the second trapezoid. quad[2} is + * at the bottom right of the second trapezoid. Interpolate to get + * corresponding point on the left side. + * + * Interpolation is from quad[1] along the line quad[1]->quad[3] + * which as the same slope as the line (positive) + */ + + traps[1].top.x1 = traps[0].bot.x1; + traps[1].top.x2 = traps[0].bot.x2; + traps[1].top.y = traps[0].bot.y; + + traps[1].bot.x1 = nxgl_interpolate(traps[1].top.x1, quad[2].y - quad[1].y, b16dxdy); + traps[1].bot.x2 = quad[2].x; + traps[1].bot.y = b16toi(quad[2].y + b16HALF); + } + else + { + /* quad[2] is at the bottom right of the triangle. Interpolate + * to get the corresponding point on the left side. + * + * Interpolation is from quad[0] along the line quad[0]->quad[1] + * which orthogonal to the slope of the line (and negative) + */ + + b16dxdy = -itob16(iheight) / iwidth; + + traps[0].bot.x1 = nxgl_interpolate(quad[0].x, quad[2].y - quad[0].y, b16dxdy); + traps[0].bot.x2 = quad[2].x; + traps[0].bot.y = b16toi(quad[2].y + b16HALF); + + /* quad[2] is at the top right of the second trapezoid. quad[1} is + * at the bottom left of the second trapezoid. Interpolate to get + * corresponding point on the right side. + * + * Interpolation is from quad[2] along the line quad[2]->quad[3] + * which as the same slope as the previous interpolation. + */ + + traps[1].top.x1 = traps[0].bot.x1; + traps[1].top.x2 = traps[0].bot.x2; + traps[1].top.y = traps[0].bot.y; + + traps[1].bot.x1 = quad[1].x; + traps[1].bot.x2 = nxgl_interpolate(traps[1].top.x2, quad[1].y - quad[2].y, b16dxdy); + traps[1].bot.y = b16toi(quad[1].y + b16HALF); + } + + /* The final trapezond (triangle) at the bottom is new well defined */ + + traps[2].top.x1 = traps[1].bot.x1; + traps[2].top.x2 = traps[1].bot.x2; + traps[2].top.y = traps[1].bot.y; + + traps[2].bot.x1 = quad[3].x; + traps[2].bot.x2 = quad[3].x; + traps[2].bot.y = b16toi(quad[3].y + b16HALF); } else { - /* Line is going "south west" */ - - b16x = itob16(line.pt1.x) + halfoffset; - iy = line.pt1.y + halfheight; - - traps[0].top.x1 = b16x - xoffset; - traps[0].top.x2 = traps[0].top.x1; - traps[0].top.y = iy - triheight + 1; - traps[0].bot.x1 = b16x - adjwidth + b16ONE; - traps[0].bot.x2 = b16x; - traps[0].bot.y = iy; - - b16x = itob16(line.pt2.x) - halfoffset; - iy = line.pt2.y - halfheight; - - traps[2].top.x1 = b16x; - traps[2].top.x2 = b16x + adjwidth - b16ONE; - traps[2].top.y = iy; - traps[2].bot.x1 = b16x + xoffset; - traps[2].bot.x2 = traps[2].bot.x1; - traps[2].bot.y = iy + triheight - 1; + /* Get the X positions of each point */ + + b16x = itob16(line.pt1.x); + quad[0].x = b16x - b16xoffset; + quad[1].x = b16x + b16xoffset; + + b16x = itob16(line.pt2.x); + quad[2].x = b16x - b16xoffset; + quad[3].x = b16x + b16xoffset; + + gvdbg("Southwest: quad (%08x,%08x),(%08x,%08x),(%08x,%08x),(%08x,%08x)\n", + quad[0].x, quad[0].y, quad[1].x, quad[1].y, + quad[2].x, quad[2].y, quad[3].x, quad[3].y); + + /* Now we can form the trapezoids. The top of the first trapezoid + * (triangle) is at quad[0] + */ + + traps[0].top.x1 = quad[0].x; + traps[0].top.x2 = quad[0].x; + traps[0].top.y = b16toi(quad[0].y + b16HALF); + + /* The bottom of the first trapezoid (triangle) may be either at + * quad[1] or quad[2], depending upon orientation. + */ + + if (quad[1].y < quad[2].y) + { + /* quad[1] is at the bottom right of the triangle. Interpolate + * to get the corresponding point on the left side. + * + * Interpolation is from quad[0] along the line quad[0]->quad[2] + * which as the same slope as the line (negative) + */ + + b16dxdy = -itob16(iwidth) / iheight; + + traps[0].bot.x1 = nxgl_interpolate(traps[0].top.x1, quad[1].y - quad[0].y, b16dxdy); + traps[0].bot.x2 = quad[1].x; + traps[0].bot.y = b16toi(quad[1].y + b16HALF); + + /* quad[1] is at the top right of the second trapezoid. quad[2} is + * at the bottom left of the second trapezoid. Interpolate to get + * corresponding point on the right side. + * + * Interpolation is from quad[1] along the line quad[1]->quad[3] + * which as the same slope as the line (negative) + */ + + traps[1].top.x1 = traps[0].bot.x1; + traps[1].top.x2 = traps[0].bot.x2; + traps[1].top.y = traps[0].bot.y; + + traps[1].bot.x1 = quad[2].x; + traps[1].bot.x2 = nxgl_interpolate(traps[1].top.x2, quad[2].y - quad[1].y, b16dxdy); + traps[1].bot.y = b16toi(quad[2].y + b16HALF); + } + else + { + /* quad[2] is at the bottom left of the triangle. Interpolate + * to get the corresponding point on the right side. + * + * Interpolation is from quad[0] along the line quad[0]->quad[1] + * which orthogonal to the slope of the line (and positive) + */ + + b16dxdy = itob16(iheight) / iwidth; + + traps[0].bot.x1 = quad[2].x; + traps[0].bot.x2 = nxgl_interpolate(traps[0].top.x2, quad[2].y - quad[0].y, b16dxdy); + traps[0].bot.y = b16toi(quad[2].y + b16HALF); + + /* quad[2] is at the top left of the second trapezoid. quad[1} is + * at the bottom right of the second trapezoid. Interpolate to get + * corresponding point on the left side. + * + * Interpolation is from quad[2] along the line quad[2]->quad[3] + * which as the same slope as the previous interpolation. + */ + + traps[1].top.x1 = traps[0].bot.x1; + traps[1].top.x2 = traps[0].bot.x2; + traps[1].top.y = traps[0].bot.y; + + traps[1].bot.x1 = nxgl_interpolate(traps[1].top.x1, quad[1].y - quad[2].y, b16dxdy); + traps[1].bot.x2 = quad[1].x; + traps[1].bot.y = b16toi(quad[1].y + b16HALF); + } + + /* The final trapezond (triangle) at the bottom is new well defined */ + + traps[2].top.x1 = traps[1].bot.x1; + traps[2].top.x2 = traps[1].bot.x2; + traps[2].top.y = traps[1].bot.y; + + traps[2].bot.x1 = quad[3].x; + traps[2].bot.x2 = quad[3].x; + traps[2].bot.y = b16toi(quad[3].y + b16HALF); } - /* The center parallelogram is the horizontal edge of each triangle. - * Note the minor inefficency: that horizontal edges are drawn twice. - */ + gvdbg("traps[0]: (%08x,%08x,%d),(%08x,%08x,%d)\n", + traps[0].top.x1, traps[0].top.x2, traps[0].top.y, + traps[0].bot.x1, traps[0].bot.x2, traps[0].bot.y); + gvdbg("traps[1]: (%08x,%08x,%d),(%08x,%08x,%d)\n", + traps[1].top.x1, traps[1].top.x2, traps[1].top.y, + traps[1].bot.x1, traps[1].bot.x2, traps[1].bot.y); + gvdbg("traps[2]: (%08x,%08x,%d),(%08x,%08x,%d)\n", + traps[2].top.x1, traps[2].top.x2, traps[2].top.y, + traps[2].bot.x1, traps[2].bot.x2, traps[2].bot.y); - traps[1].top.x1 = traps[0].bot.x1; - traps[1].top.x2 = traps[0].bot.x2; - traps[1].top.y = traps[0].bot.y; - - traps[1].bot.x1 = traps[2].top.x1; - traps[1].bot.x2 = traps[2].top.x2; - traps[1].bot.y = traps[2].top.y; - return 0; } @@ -326,12 +515,18 @@ int nxgl_splitline(FAR struct nxgl_vector_s *vector, * bottom. Just return the center parallelogram. */ - traps[1].top.x1 = itob16(line.pt1.x) - halfoffset; - traps[1].top.x2 = traps[1].top.x1 + adjwidth - 1; + traps[1].top.x1 = itob16(line.pt1.x - (linewidth >> 1)); + traps[1].top.x2 = traps[1].top.x1 + itob16(linewidth - 1); traps[1].top.y = line.pt1.y; - - traps[1].bot.x1 = itob16(line.pt2.x) - halfoffset; - traps[1].bot.x2 = traps[1].bot.x1 + adjwidth - 1; + + traps[1].bot.x1 = itob16(line.pt2.x - (linewidth >> 1)); + traps[1].bot.x2 = traps[1].bot.x1 + itob16(linewidth - 1); traps[1].bot.y = line.pt2.y; + + gvdbg("Horizontal traps[1]: (%08x,%08x,%d),(%08x,%08x, %d)\n", + traps[1].top.x1, traps[1].top.x2, traps[1].top.y, + traps[1].bot.x1, traps[1].bot.x2, traps[1].bot.y); + return 1; } + diff --git a/nuttx/graphics/nxmu/nx_bitmap.c b/nuttx/graphics/nxmu/nx_bitmap.c index a86eda96a..a0bd748b0 100644 --- a/nuttx/graphics/nxmu/nx_bitmap.c +++ b/nuttx/graphics/nxmu/nx_bitmap.c @@ -100,6 +100,8 @@ int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest, FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; struct nxsvrmsg_bitmap_s outmsg; int i; + int ret; + sem_t sem_done; #ifdef CONFIG_DEBUG if (!wnd || !dest || !src || !origin) @@ -124,7 +126,32 @@ int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest, outmsg.origin.y = origin->y; nxgl_rectcopy(&outmsg.dest, dest); + + /* Create a semaphore for tracking command completion */ + + outmsg.sem_done = &sem_done; + ret = sem_init(&sem_done, 0, 0); + + if (ret != OK) + { + gdbg("sem_init failed: %d\n", errno); + return ret; + } + /* Forward the fill command to the server */ - return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_bitmap_s)); + ret = nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_bitmap_s)); + + /* Wait that the command is completed, so that caller can release the buffer. */ + + if (ret == OK) + { + ret = sem_wait(&sem_done); + } + + /* Destroy the semaphore and return. */ + + sem_destroy(&sem_done); + + return ret; } diff --git a/nuttx/graphics/nxmu/nx_block.c b/nuttx/graphics/nxmu/nx_block.c index 3a051f9d7..7b198613c 100644 --- a/nuttx/graphics/nxmu/nx_block.c +++ b/nuttx/graphics/nxmu/nx_block.c @@ -140,7 +140,7 @@ int nx_block(NXWINDOW hwnd, FAR void *arg) * that it will not be blocked. */ - ret = nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxbe_window_s)); + ret = nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxsvrmsg_blocked_s)); } return ret; diff --git a/nuttx/graphics/nxmu/nx_getrectangle.c b/nuttx/graphics/nxmu/nx_getrectangle.c index f32065129..9b7d3679c 100644 --- a/nuttx/graphics/nxmu/nx_getrectangle.c +++ b/nuttx/graphics/nxmu/nx_getrectangle.c @@ -98,7 +98,9 @@ int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, { FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; struct nxsvrmsg_getrectangle_s outmsg; - + int ret; + sem_t sem_done; + #ifdef CONFIG_DEBUG if (!hwnd || !rect || !dest) { @@ -118,7 +120,31 @@ int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, nxgl_rectcopy(&outmsg.rect, rect); + /* Create a semaphore for tracking command completion */ + + outmsg.sem_done = &sem_done; + ret = sem_init(&sem_done, 0, 0); + + if (ret != OK) + { + gdbg("sem_init failed: %d\n", errno); + return ret; + } + /* Forward the fill command to the server */ - return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_getrectangle_s)); + ret = nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_getrectangle_s)); + + /* Wait that the command is completed, so that caller can release the buffer. */ + + if (ret == OK) + { + ret = sem_wait(&sem_done); + } + + /* Destroy the semaphore and return. */ + + sem_destroy(&sem_done); + + return ret; } diff --git a/nuttx/graphics/nxmu/nxfe.h b/nuttx/graphics/nxmu/nxfe.h index 8b6a21ef4..b9e02616c 100644 --- a/nuttx/graphics/nxmu/nxfe.h +++ b/nuttx/graphics/nxmu/nxfe.h @@ -392,6 +392,7 @@ struct nxsvrmsg_getrectangle_s unsigned int plane; /* The plane number to read */ FAR uint8_t *dest; /* Memory location in which to store the graphics data */ unsigned int deststride; /* Width of the destination memory in bytes */ + sem_t *sem_done; /* Semaphore to report when command is done. */ }; /* Fill a trapezoidal region in the window with a color */ @@ -425,6 +426,7 @@ struct nxsvrmsg_bitmap_s FAR const void *src[CONFIG_NX_NPLANES]; /* The start of the source image. */ struct nxgl_point_s origin; /* Offset into the source image data */ unsigned int stride; /* The width of the full source image in pixels. */ + sem_t *sem_done; /* Semaphore to report when command is done. */ }; /* Set the color of the background */ @@ -587,6 +589,25 @@ EXTERN int nxmu_sendclient(FAR struct nxfe_conn_s *conn, FAR const void *msg, size_t msglen); /**************************************************************************** + * Name: nxmu_sendclientwindow + * + * Description: + * Send a message to the client at NX_CLIMSG_PRIO priority + * + * Input Parameters: + * wnd - A pointer to the back-end window structure + * msg - A pointer to the message to send + * msglen - The length of the message in bytes. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxmu_sendclientwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg, + size_t msglen); + +/**************************************************************************** * Name: nxmu_openwindow * * Description: diff --git a/nuttx/graphics/nxmu/nxmu_kbdin.c b/nuttx/graphics/nxmu/nxmu_kbdin.c index 2c658009b..0308c2bfa 100644 --- a/nuttx/graphics/nxmu/nxmu_kbdin.c +++ b/nuttx/graphics/nxmu/nxmu_kbdin.c @@ -108,7 +108,7 @@ void nxmu_kbdin(FAR struct nxfe_state_s *fe, uint8_t nch, FAR uint8_t *ch) outmsg->ch[i] = ch[i]; } - (void)nxmu_sendclient(fe->be.topwnd->conn, outmsg, size); + (void)nxmu_sendclientwindow(fe->be.topwnd, outmsg, size); free(outmsg); } } diff --git a/nuttx/graphics/nxmu/nxmu_mouse.c b/nuttx/graphics/nxmu/nxmu_mouse.c index 3ebe062d2..1b8f4a592 100644 --- a/nuttx/graphics/nxmu/nxmu_mouse.c +++ b/nuttx/graphics/nxmu/nxmu_mouse.c @@ -61,9 +61,10 @@ * Private Data ****************************************************************************/ -static struct nxgl_point_s g_mpos; -static struct nxgl_point_s g_mrange; -static uint8_t g_mbutton; +static struct nxgl_point_s g_mpos; +static struct nxgl_point_s g_mrange; +static uint8_t g_mbutton; +static struct nxbe_window_s *g_mwnd; /**************************************************************************** * Public Data @@ -129,7 +130,7 @@ int nxmu_mousereport(struct nxbe_window_s *wnd) outmsg.buttons = g_mbutton; nxgl_vectsubtract(&outmsg.pos, &g_mpos, &wnd->bounds.pt1); - return nxmu_sendclient(wnd->conn, &outmsg, sizeof(struct nxclimsg_mousein_s)); + return nxmu_sendclientwindow(wnd, &outmsg, sizeof(struct nxclimsg_mousein_s)); } } @@ -154,6 +155,7 @@ int nxmu_mousein(FAR struct nxfe_state_s *fe, struct nxbe_window_s *wnd; nxgl_coord_t x = pos->x; nxgl_coord_t y = pos->y; + uint8_t oldbuttons; int ret; /* Clip x and y to within the bounding rectangle */ @@ -182,20 +184,36 @@ int nxmu_mousein(FAR struct nxfe_state_s *fe, { /* Update the mouse value */ - g_mpos.x = x; - g_mpos.y = y; - g_mbutton = buttons; + oldbuttons = g_mbutton; + g_mpos.x = x; + g_mpos.y = y; + g_mbutton = buttons; - /* Pick the window to receive the mouse event. Start with - * the top window and go down. Stop with the first window - * that gets the mouse report + /* If a button is already down, regard this as part of a mouse drag + * event. Pass all the following events to the window where the drag + * started in. + */ + + if (oldbuttons && g_mwnd && g_mwnd->cb->mousein) + { + struct nxclimsg_mousein_s outmsg; + outmsg.msgid = NX_CLIMSG_MOUSEIN; + outmsg.wnd = g_mwnd; + outmsg.buttons = g_mbutton; + nxgl_vectsubtract(&outmsg.pos, &g_mpos, &g_mwnd->bounds.pt1); + + return nxmu_sendclientwindow(g_mwnd, &outmsg, sizeof(struct nxclimsg_mousein_s)); + } + + /* Pick the window to receive the mouse event. Start with the top + * window and go down. Stop with the first window that gets the mouse + * report */ for (wnd = fe->be.topwnd; wnd; wnd = wnd->below) { - /* The background window normally has no callback structure - * (unless a client has taken control of the background via - * nx_requestbkgd()). + /* The background window normally has no callback structure (unless + * a client has taken control of the background via nx_requestbkgd()). */ if (wnd->cb) @@ -207,6 +225,8 @@ int nxmu_mousein(FAR struct nxfe_state_s *fe, } } } + + g_mwnd = wnd; } return OK; diff --git a/nuttx/graphics/nxmu/nxmu_redrawreq.c b/nuttx/graphics/nxmu/nxmu_redrawreq.c index 32ca477a2..f54aa85a7 100644 --- a/nuttx/graphics/nxmu/nxmu_redrawreq.c +++ b/nuttx/graphics/nxmu/nxmu_redrawreq.c @@ -87,7 +87,7 @@ void nxfe_redrawreq(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s outmsg.more = false; nxgl_rectoffset(&outmsg.rect, rect, -wnd->bounds.pt1.x, -wnd->bounds.pt1.y); - (void)nxmu_sendclient(wnd->conn, &outmsg, sizeof(struct nxclimsg_redraw_s)); + (void)nxmu_sendclientwindow(wnd, &outmsg, sizeof(struct nxclimsg_redraw_s)); } diff --git a/nuttx/graphics/nxmu/nxmu_reportposition.c b/nuttx/graphics/nxmu/nxmu_reportposition.c index f9b5f9daf..6ffb3f4ee 100644 --- a/nuttx/graphics/nxmu/nxmu_reportposition.c +++ b/nuttx/graphics/nxmu/nxmu_reportposition.c @@ -100,7 +100,7 @@ void nxfe_reportposition(FAR struct nxbe_window_s *wnd) /* And provide this to the client */ - ret = nxmu_sendclient(wnd->conn, &outmsg, sizeof(struct nxclimsg_newposition_s)); + ret = nxmu_sendclientwindow(wnd, &outmsg, sizeof(struct nxclimsg_newposition_s)); if (ret < 0) { gdbg("nxmu_sendclient failed: %d\n", errno); diff --git a/nuttx/graphics/nxmu/nxmu_sendwindow.c b/nuttx/graphics/nxmu/nxmu_sendwindow.c index 6f64ffff2..0826a45bc 100644 --- a/nuttx/graphics/nxmu/nxmu_sendwindow.c +++ b/nuttx/graphics/nxmu/nxmu_sendwindow.c @@ -112,3 +112,47 @@ int nxmu_sendwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg, return ret; } + +/**************************************************************************** + * Name: nxmu_sendclientwindow + * + * Description: + * Send a message to the client at NX_CLIMSG_PRIO priority + * + * Input Parameters: + * wnd - A pointer to the back-end window structure + * msg - A pointer to the message to send + * msglen - The length of the message in bytes. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxmu_sendclientwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg, + size_t msglen) +{ + int ret = OK; + + /* Sanity checking */ + +#ifdef CONFIG_DEBUG + if (!wnd || !wnd->conn) + { + errno = EINVAL; + return ERROR; + } +#endif + + /* Ignore messages destined to a blocked window (no errors reported) */ + + if (!NXBE_ISBLOCKED(wnd)) + { + /* Send the message to the server */ + + ret = nxmu_sendclient(wnd->conn, msg, msglen); + } + + return ret; +} + diff --git a/nuttx/graphics/nxmu/nxmu_server.c b/nuttx/graphics/nxmu/nxmu_server.c index 2730e0ea2..cfaa5bbf5 100644 --- a/nuttx/graphics/nxmu/nxmu_server.c +++ b/nuttx/graphics/nxmu/nxmu_server.c @@ -451,6 +451,11 @@ int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev) { FAR struct nxsvrmsg_getrectangle_s *getmsg = (FAR struct nxsvrmsg_getrectangle_s *)buffer; nxbe_getrectangle(getmsg->wnd, &getmsg->rect, getmsg->plane, getmsg->dest, getmsg->deststride); + + if (getmsg->sem_done) + { + sem_post(getmsg->sem_done); + } } break; @@ -471,6 +476,11 @@ int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev) { FAR struct nxsvrmsg_bitmap_s *bmpmsg = (FAR struct nxsvrmsg_bitmap_s *)buffer; nxbe_bitmap(bmpmsg->wnd, &bmpmsg->dest, bmpmsg->src, &bmpmsg->origin, bmpmsg->stride); + + if (bmpmsg->sem_done) + { + sem_post(bmpmsg->sem_done); + } } break; diff --git a/nuttx/graphics/nxsu/nx_mousein.c b/nuttx/graphics/nxsu/nx_mousein.c index bee4a2265..5b268358b 100644 --- a/nuttx/graphics/nxsu/nx_mousein.c +++ b/nuttx/graphics/nxsu/nx_mousein.c @@ -62,9 +62,10 @@ * Private Data ****************************************************************************/ -static struct nxgl_point_s g_mpos; -static struct nxgl_point_s g_mrange; -static uint8_t g_mbutton; +static struct nxgl_point_s g_mpos; +static struct nxgl_point_s g_mrange; +static uint8_t g_mbutton; +static struct nxbe_window_s *g_mwnd; /**************************************************************************** * Public Data @@ -148,6 +149,7 @@ int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons) { FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle; struct nxbe_window_s *wnd; + uint8_t oldbuttons; int ret; /* Clip x and y to within the bounding rectangle */ @@ -176,13 +178,27 @@ int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons) { /* Update the mouse value */ + oldbuttons = g_mbutton; g_mpos.x = x; g_mpos.y = y; g_mbutton = buttons; - /* Pick the window to receive the mouse event. Start with - * the top window and go down. Step with the first window - * that gets the mouse report + /* If a button is already down, regard this as part of a mouse drag + * event. Pass all the following events to the window where the drag + * started in. + */ + + if (oldbuttons && g_mwnd && g_mwnd->cb->mousein) + { + struct nxgl_point_s relpos; + nxgl_vectsubtract(&relpos, &g_mpos, &g_mwnd->bounds.pt1); + g_mwnd->cb->mousein((NXWINDOW)g_mwnd, &relpos, g_mbutton, g_mwnd->arg); + return OK; + } + + /* Pick the window to receive the mouse event. Start with the top + * window and go down. Step with the first window that gets the mouse + * report */ for (wnd = fe->be.topwnd; wnd; wnd = wnd->below) @@ -193,6 +209,8 @@ int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons) break; } } + + g_mwnd = wnd; } return OK; } diff --git a/nuttx/graphics/nxtk/nxtk_events.c b/nuttx/graphics/nxtk/nxtk_events.c index 33c50b7f9..facf92176 100644 --- a/nuttx/graphics/nxtk/nxtk_events.c +++ b/nuttx/graphics/nxtk/nxtk_events.c @@ -76,6 +76,9 @@ static void nxtk_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, static void nxtk_kbdin(NXWINDOW hwnd, uint8_t nch, const uint8_t *ch, FAR void *arg); #endif +#ifdef CONFIG_NX_MULTIUSER +static void nxtk_blocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2); +#endif /**************************************************************************** * Private Data @@ -95,6 +98,9 @@ const struct nx_callback_s g_nxtkcb = #ifdef CONFIG_NX_KBD , nxtk_kbdin /* kbdin */ #endif +#ifdef CONFIG_NX_MULTIUSER + , nxtk_blocked +#endif }; /**************************************************************************** @@ -255,9 +261,20 @@ static void nxtk_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, nxgl_vectoradd(&abspos, pos, &fwnd->wnd.bounds.pt1); + /* In order to deliver mouse release events to the same window where the + * mouse down event happened, we store the initial mouse down location. + */ + + if (fwnd->mbutton == 0 && buttons != 0) + { + fwnd->mpos = abspos; + } + + fwnd->mbutton = buttons; + /* Is the mouse position inside of the client window region? */ - if (fwnd->fwcb->mousein && nxgl_rectinside(&fwnd->fwrect, &abspos)) + if (fwnd->fwcb->mousein && nxgl_rectinside(&fwnd->fwrect, &fwnd->mpos)) { nxgl_vectsubtract(&relpos, &abspos, &fwnd->fwrect.pt1); fwnd->fwcb->mousein((NXTKWINDOW)fwnd, &relpos, buttons, fwnd->fwarg); @@ -265,7 +282,7 @@ static void nxtk_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, /* If the mouse position inside the toobar region? */ - else if (fwnd->tbcb->mousein && nxgl_rectinside(&fwnd->tbrect, &abspos)) + else if (fwnd->tbcb->mousein && nxgl_rectinside(&fwnd->tbrect, &fwnd->mpos)) { nxgl_vectsubtract(&relpos, &abspos, &fwnd->tbrect.pt1); fwnd->tbcb->mousein((NXTKWINDOW)fwnd, &relpos, buttons, fwnd->tbarg); @@ -293,5 +310,23 @@ static void nxtk_kbdin(NXWINDOW hwnd, uint8_t nch, const uint8_t *ch, #endif /**************************************************************************** + * Name: nxtk_blocked + ****************************************************************************/ + +#ifdef CONFIG_NX_MULTIUSER +static void nxtk_blocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2) +{ + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd; + + /* Only the client window gets keyboard input */ + + if (fwnd->fwcb->blocked) + { + fwnd->fwcb->blocked((NXTKWINDOW)fwnd, fwnd->fwarg, arg2); + } +} +#endif + +/**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/nuttx/graphics/nxtk/nxtk_filltrapwindow.c b/nuttx/graphics/nxtk/nxtk_filltrapwindow.c index c1032f1e7..55c051ffd 100644 --- a/nuttx/graphics/nxtk/nxtk_filltrapwindow.c +++ b/nuttx/graphics/nxtk/nxtk_filltrapwindow.c @@ -94,6 +94,7 @@ int nxtk_filltrapwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_trapezoid_s *tra { FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; struct nxgl_rect_s relclip; + struct nxgl_trapezoid_s reltrap; #ifdef CONFIG_DEBUG if (!hfwnd || !trap || !color) @@ -103,8 +104,14 @@ int nxtk_filltrapwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_trapezoid_s *tra } #endif - /* Perform the fill, clipping to the client window */ + /* Move the trapezoid from window contents area to window area */ + nxgl_trapoffset(&reltrap, trap, + fwnd->fwrect.pt1.x - fwnd->wnd.bounds.pt1.x, + fwnd->fwrect.pt1.y - fwnd->wnd.bounds.pt1.y); + + /* Perform the fill, clipping to the client window */ nxgl_rectoffset(&relclip, &fwnd->fwrect, -fwnd->wnd.bounds.pt1.x, -fwnd->wnd.bounds.pt1.y); - return nx_filltrapezoid((NXWINDOW)hfwnd, &relclip, trap, color); + + return nx_filltrapezoid((NXWINDOW)hfwnd, &relclip, &reltrap, color); } diff --git a/nuttx/graphics/nxtk/nxtk_getwindow.c b/nuttx/graphics/nxtk/nxtk_getwindow.c index 121c7702a..c91f2d22f 100644 --- a/nuttx/graphics/nxtk/nxtk_getwindow.c +++ b/nuttx/graphics/nxtk/nxtk_getwindow.c @@ -110,12 +110,15 @@ int nxtk_getwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, } #endif - /* Clip the rectangle so that it lies within the sub-window bounds - * then move the rectangle to that it is relative to the containing - * window. + /* Move the rectangle to that it is relative to the containing + * window. If part of the rectangle lies outside the window, + * it will contain garbage data, but the contained area will be + * valid. */ - nxtk_subwindowclip(fwnd, &getrect, rect, &fwnd->fwrect); + nxgl_rectoffset(&getrect, rect, + fwnd->fwrect.pt1.x - fwnd->wnd.bounds.pt1.x, + fwnd->fwrect.pt1.y - fwnd->wnd.bounds.pt1.y); /* Then get it */ diff --git a/nuttx/graphics/nxtk/nxtk_internal.h b/nuttx/graphics/nxtk/nxtk_internal.h index 87a098845..3a31215d8 100644 --- a/nuttx/graphics/nxtk/nxtk_internal.h +++ b/nuttx/graphics/nxtk/nxtk_internal.h @@ -72,6 +72,11 @@ struct nxtk_framedwindow_s struct nxgl_rect_s fwrect; FAR const struct nx_callback_s *fwcb; FAR void *fwarg; + + /* Initial mouse down location */ + + uint8_t mbutton; + struct nxgl_point_s mpos; }; /**************************************************************************** diff --git a/nuttx/graphics/nxtk/nxtk_subwindowmove.c b/nuttx/graphics/nxtk/nxtk_subwindowmove.c index a6fd9f5dd..3c2bb7f37 100644 --- a/nuttx/graphics/nxtk/nxtk_subwindowmove.c +++ b/nuttx/graphics/nxtk/nxtk_subwindowmove.c @@ -112,21 +112,19 @@ void nxtk_subwindowmove(FAR struct nxtk_framedwindow_s *fwnd, nxgl_rectintersect(&abssrc, &abssrc, &fwnd->fwrect); - /* Clip the offset so that the source rectangle does not move out of the - * the client sub-window. - */ + /* Clip the source rectangle so that destination area is within the window. */ destoffset->x = srcoffset->x; if (destoffset->x < 0) { if (abssrc.pt1.x + destoffset->x < bounds->pt1.x) { - destoffset->x = bounds->pt1.x - abssrc.pt1.x; + abssrc.pt1.x = bounds->pt1.x - destoffset->x; } } else if (abssrc.pt2.x + destoffset->x > bounds->pt2.x) { - destoffset->x = bounds->pt2.x - abssrc.pt2.x; + abssrc.pt2.x = bounds->pt2.x - destoffset->x; } destoffset->y = srcoffset->y; @@ -134,12 +132,12 @@ void nxtk_subwindowmove(FAR struct nxtk_framedwindow_s *fwnd, { if (abssrc.pt1.y + destoffset->y < bounds->pt1.y) { - destoffset->y = bounds->pt1.y - abssrc.pt1.y; + abssrc.pt1.y = bounds->pt1.y - destoffset->y; } } else if (abssrc.pt2.y + destoffset->y > bounds->pt2.y) { - destoffset->y = bounds->pt2.y - abssrc.pt2.y; + abssrc.pt2.y = bounds->pt2.y - destoffset->y; } |