Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/misp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ef45d064bdbe
Choose a base ref
...
head repository: m-labs/misp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 10f9d16b1747
Choose a head ref
  • 4 commits
  • 13 files changed
  • 1 contributor

Commits on Mar 25, 2013

  1. libglue: add C++ new/delete operators

    Sebastien Bourdeauducq committed Mar 25, 2013
    Copy the full SHA
    af27064 View commit details
  2. isr: use new milkymist-ng include file

    Sebastien Bourdeauducq committed Mar 25, 2013
    Copy the full SHA
    dfa6238 View commit details
  3. libm: C++ compatibility

    Sebastien Bourdeauducq committed Mar 25, 2013
    Copy the full SHA
    facb816 View commit details
  4. Antigrain-lite test

    Sebastien Bourdeauducq committed Mar 25, 2013
    Copy the full SHA
    10f9d16 View commit details
Showing with 2,378 additions and 877 deletions.
  1. +9 −3 Makefile
  2. +141 −0 agg_test.cpp
  3. +1 −2 isr.c
  4. +22 −0 libagl/Makefile
  5. +892 −0 libagl/agg.cpp
  6. +1,270 −0 libagl/include/agg.h
  7. +0 −46 libfreetype/Makefile
  8. +0 −20 libfreetype/include/freetype/config/ftmodule.h
  9. +0 −805 libfreetype/include/freetype/config/ftoption.h
  10. +4 −1 libglue/Makefile
  11. +28 −0 libglue/cppmm.cpp
  12. +8 −0 libm/include/math.h
  13. +3 −0 main.c
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
MISPDIR=.
include $(MISPDIR)/common.mak

OBJECTS=crt0.o isr.o luainit.o main.o
OURLIBS=m mm yaffs2 glue lua lfs freetype
OBJECTS=crt0.o isr.o luainit.o agg_test.o main.o
OURLIBS=m mm yaffs2 glue lua lfs agl

CFLAGS+=-I$(MISPDIR)/libm/include -I$(MISPDIR)/libmm/include -I$(MISPDIR)/libglue/include -I$(LUADIR)/src -I$(MISPDIR)/liblfs/include
INCFLAGS=-I$(MISPDIR)/libm/include -I$(MISPDIR)/libmm/include -I$(MISPDIR)/libglue/include -I$(LUADIR)/src -I$(MISPDIR)/liblfs/include -I$(MISPDIR)/libagl/include
CFLAGS+=$(INCFLAGS)
CXXFLAGS+=$(INCFLAGS)

all: misp.bin

@@ -25,9 +27,13 @@ misp.elf: linker.ld $(OBJECTS) libs
--start-group -lbase -lcompiler-rt $(addprefix -l,$(OURLIBS)) --end-group
chmod -x $@

%.o: %.cpp
$(compilexx-dep)

%.o: %.c
$(compile-dep)


libs:
set -e; \
for lib in $(OURLIBS); do \
141 changes: 141 additions & 0 deletions agg_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <hw/csr.h>
#include "agg.h"

enum
{
width = 640,
height = 480
};


double random(double min, double max)
{
int r = (rand() << 15) | rand();
return ((r & 0xFFFFFFF) / double(0xFFFFFFF + 1)) * (max - min) + min;
}


void draw_ellipse(agg::rasterizer& ras,
double x, double y,
double rx, double ry)
{
int i;
ras.move_to_d(x + rx, y);

// Here we have a fixed number of approximation steps, namely 360
// while in reality it's supposed to be smarter.
for(i = 1; i < 360; i++)
{
double a = double(i) * 3.1415926 / 180.0;
ras.line_to_d(x + cos(a) * rx, y + sin(a) * ry);
}
}


void draw_line(agg::rasterizer& ras,
double x1, double y1,
double x2, double y2,
double width)
{

double dx = x2 - x1;
double dy = y2 - y1;
double d = sqrt(dx*dx + dy*dy);

dx = width * (y2 - y1) / d;
dy = width * (x2 - x1) / d;

ras.move_to_d(x1 - dx, y1 + dy);
ras.line_to_d(x2 - dx, y2 + dy);
ras.line_to_d(x2 + dx, y2 - dy);
ras.line_to_d(x1 + dx, y1 - dy);
}

static void start_fb(unsigned char *addr)
{
fb_base_write((unsigned int)addr);
fb_enable_write(1);
}

extern "C" void agg_test(void);
void agg_test(void)
{
// Allocate the framebuffer
unsigned char* buf = new unsigned char[width * height * 4];

start_fb(buf);

// Create the rendering buffer
agg::rendering_buffer rbuf(buf, width, height, width * 4);

// Create the renderer and the rasterizer
agg::renderer<agg::span_rgba32> ren(rbuf);
agg::rasterizer ras;

// Setup the rasterizer
ras.gamma(1.3);
ras.filling_rule(agg::fill_even_odd);

ren.clear(agg::rgba8(255, 255, 255));

int i;

// Draw random polygons
for(i = 0; i < 10; i++)
{
int n = rand() % 6 + 3;

// Make the polygon. One can call move_to() more than once.
// In this case the rasterizer behaves like Win32 API PolyPolygon().
ras.move_to_d(random(-30, rbuf.width() + 30),
random(-30, rbuf.height() + 30));

int j;
for(j = 1; j < n; j++)
{
ras.line_to_d(random(-30, rbuf.width() + 30),
random(-30, rbuf.height() + 30));
}

// Render
ras.render(ren, agg::rgba8(rand() & 0xFF,
rand() & 0xFF,
rand() & 0xFF,
rand() & 0xFF));
}

// Draw random ellipses
for(i = 0; i < 50; i++)
{
draw_ellipse(ras,
random(-30, rbuf.width() + 30),
random(-30, rbuf.height() + 30),
random(3, 50),
random(3, 50));
ras.render(ren, agg::rgba8(rand() & 0x7F,
rand() & 0x7F,
rand() & 0x7F,
(rand() & 0x7F) + 100));
}

// Draw random straight lines
for(i = 0; i < 20; i++)
{
draw_line(ras,
random(-30, rbuf.width() + 30),
random(-30, rbuf.height() + 30),
random(-30, rbuf.width() + 30),
random(-30, rbuf.height() + 30),
random(0.1, 10));

ras.render(ren, agg::rgba8(rand() & 0x7F,
rand() & 0x7F,
rand() & 0x7F));
}

delete [] buf;
}

3 changes: 1 addition & 2 deletions isr.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <hw/uart.h>
#include <interrupt.h>
#include <hw/csr.h>
#include <irq.h>
#include <uart.h>

22 changes: 22 additions & 0 deletions libagl/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MISPDIR=..
include $(MISPDIR)/common.mak

CXXFLAGS+=-I$(MISPDIR)/libagl/include -I$(MISPDIR)/libm/include
OBJECTS=agg.o

all: libagl.a

# pull in dependency info for *existing* .o files
-include $(OBJECTS:.o=.d)

libagl.a: $(OBJECTS)
$(AR) clr libagl.a $(OBJECTS)
$(RANLIB) libagl.a

%.o: %.cpp
$(compilexx-dep)

.PHONY: clean

clean:
rm -f $(OBJECTS) $(OBJECTS:.o=.d) libagl.a .*~ *~
Loading