/**
* \file livarot/int-line.cpp
*
* Implementation of coverage with integer boundaries.
*
* \author Fred
*
* public domain
*
*/
#include <glib.h>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
#include "livarot/int-line.h"
#include "livarot/float-line.h"
#include "livarot/BitLigne.h"
{
}
{
if ( maxBord > 0 ) {
}
if ( maxRun > 0 ) {
}
}
{
nbBord = 0;
nbRun = 0;
}
{
}
int n = nbBord++;
n = nbBord++;
return n - 1;
}
{
float sum = 0;
while ( no >= 0 ) {
}
return sum;
}
{
if ( nbBord <= 1 ) {
Reset();
return;
}
nbRun = 0;
for (int i = 0; i < nbBord; i++) {
}
for (int i = 0; i < nbBord; i++) {
}
for (int i = 0; i < nbBord; i++) {
}
int lastStart = 0;
float lastVal = 0;
bool startExists = false;
for (int i = 0; i < nbBord; ) {
float leftV = 0;
float rightV = 0;
float midV = 0;
Dequeue(i);
i++;
}
i++;
}
if ( startExists ) {
}
if ( firstAc >= 0 ) {
startExists = true;
} else {
startExists = false;
}
}
}
{
for (int i = 0; i < nbRun;i++) {
}
printf("\n");
}
{
return -1;
}
}
int n = nbRun++;
return n;
}
{
Reset();
return;
}
if ( a->nbRun <= 0 ) {
Copy(b);
}
return;
}
if ( b->nbRun <= 0 ) {
Copy(a);
}
return;
}
int curA = 0;
int curB = 0;
float valA = 0;
float valB = 0;
}
}
bool startA = false;
bool startB = false;
bool endA = false;
bool endB = false;
}
} else {
}
} else {
} else {
}
}
if ( mod == bool_op_union ) {
}
} else if ( mod == bool_op_inters ) {
}
} else if ( mod == bool_op_diff ) {
if ( inA ) {
}
} else if ( mod == bool_op_symdiff ) {
}
}
}
if ( startA ) {
// inA=true; these are never used
}
if ( startB ) {
//inB=true;
}
if ( endA ) {
//inA=false;
valA = 0;
curA++;
}
}
if ( endB ) {
//inB=false;
valB = 0;
curB++;
}
}
}
const bool inB = false;
bool startA = false;
bool endA = false;
startA = true;
endA = true;
}
valB = 0;
if ( mod == bool_op_union ) {
}
} else if ( mod == bool_op_inters ) {
}
} else if ( mod == bool_op_diff ) {
if ( inA ) {
}
} else if ( mod == bool_op_symdiff ) {
}
}
}
if ( startA ) {
//inA=true;
}
if ( endA ) {
//inA=false;
valA = 0;
curA++;
}
}
}
const bool inA = false;
bool startB = false;
bool endB = false;
startB = true;
endB = true;
}
valA = 0;
if ( mod == bool_op_union ) {
}
} else if ( mod == bool_op_inters ) {
}
} else if ( mod == bool_op_diff ) {
if ( inA ) {
}
} else if ( mod == bool_op_symdiff ) {
}
}
}
if ( startB ) {
//inB=true;
}
if ( endB ) {
//inB=false;
valB = 0;
curB++;
}
}
}
}
/**
* Transform a line of bits into pixel coverage values.
*
* This is where you go from supersampled data to alpha values.
* \see IntLigne::Copy(int nbSub,BitLigne* *a).
*/
{
Reset();
return;
}
}
Reset();
return;
}
Reset();
return;
}
}
nbBord = 0;
nbRun = 0;
int lastVal = 0;
int lastStart = 0;
bool startExists = false;
if ( nbBit > 0 ) {
if ( startExists ) {
// on continue le run
} else {
lastStart = i;
}
} else {
lastStart = i;
startExists = true;
}
} else {
if ( startExists ) {
}
startExists = false;
}
if ( chg == 0 ) {
} else {
c_full <<= 4;
c_part <<= 4;
}
}
if ( startExists ) {
}
}
/**
* Transform a line of bits into pixel coverage values.
*
* Alpha values are computed from supersampled data, so we have to scan the
* BitLigne left to right, summing the bits in each pixel. The alpha value
* is then "number of bits"/(nbSub*nbSub)". Full bits and partial bits are
* treated as equals because the method produces ugly results otherwise.
*
* \param nbSub Number of BitLigne in the array "a".
*/
{
if ( nbSub <= 0 ) {
Reset();
return;
}
if ( nbSub == 1 ) {
return;
}
// compute the min-max of the pixels to be rasterized from the min-max of the inpur bitlignes
for (int i = 1; i < nbSub; i++) {
}
}
}
}
}
Reset();
return;
}
nbBord = 0;
nbRun = 0;
int lastVal = 0;
int lastStart = 0;
bool startExists = false;
float spA;
if ( nbSub == 4 ) {
// special case for 4*4 supersampling, to avoid a few loops
int nbBit = 0;
if ( startExists ) {
}
startExists = false;
if ( startExists ) {
} else {
lastStart = i;
}
} else {
lastStart = i;
}
startExists = true;
} else {
if ( nbBit > 0 ) {
if ( startExists ) {
// on continue le run
} else {
lastStart = i;
}
} else {
lastStart = i;
startExists = true;
}
} else {
if ( startExists ) {
}
startExists = false;
}
}
if ( chg == 0 ) {
if ( i < curMax ) {
} else {
// end of line. byebye
}
} else {
c_full[0] <<= 4;
}
}
} else {
uint32_t c_full[16]; // we take nbSub < 16, since 16*16 supersampling makes a 1/256 precision in alpha values
// and that's the max of what 32bit argb can represent
// in fact, we'll treat it as 4*nbSub supersampling, so that's a half truth and a full lazyness from me
// uint32_t c_part[16];
// start by putting the bits of the nbSub BitLignes in as[] in their respective c_full
for (int i = 0; i < nbSub; i++) {
// fullB and partB treated equally
/* c_part[i]=as[i]->partB[(curMin-theSt)>>3];
c_part[i]<<=4*((curMin-theSt)&7);*/
}
spA = 1.0 / (4 * nbSub); // contribution to the alpha value of a single bit of the supersampled data
int nbBit = 0;
// int nbPartBit=0;
// a little acceleration: if the lines only contain full or empty bits, we can flush
// what's remaining in the c_full at best we flush an entire c_full, ie 32 bits, or 32/4=8 pixels
bool allEmpty = true;
bool allFull = true;
for (int j = 0; j < nbSub; j++) {
if ( c_full[j] != 0 /*|| c_part[j] != 0*/ ) {
allEmpty=false;
break;
}
}
if ( allEmpty ) {
// the remaining bits in c_full[] are empty: flush
if ( startExists ) {
}
startExists = false;
} else {
for (int j = 0; j < nbSub; j++) {
if ( c_full[j] != 0xFFFFFFFF ) {
allFull=false;
break;
}
}
if ( allFull ) {
// the remaining bits in c_full[] are empty: flush
if ( startExists ) {
} else {
lastStart = i;
}
} else {
lastStart = i;
}
startExists = true;
} else {
// alpha values will be between 0 and 1, so we have more work to do
// compute how many bit this pixel holds
for (int j = 0; j < nbSub; j++) {
// nbPartBit+=masks[c_part[j]>>28];
}
// and add a single-pixel run if needed, or extend the current run if the alpha value hasn't changed
if ( nbBit > 0 ) {
if ( startExists ) {
// alpha value hasn't changed: we continue
} else {
// alpha value did change: put the run that was being done,...
// ... and start a new one
lastStart = i;
}
} else {
// alpha value was 0, so we "create" a new run with alpha nbBit
lastStart = i;
startExists = true;
}
} else {
if ( startExists ) {
}
startExists = false;
}
}
}
// move to the right: shift bits in the c_full[], and if we shifted everything, load the next c_full[]
if ( chg == 0 ) {
if ( i < curMax ) {
for (int j = 0; j < nbSub; j++) {
// c_part[j]=as[j]->partB[(i+1-theSt)>>3];
}
} else {
// end of line. byebye
}
} else {
for (int j = 0; j < nbSub; j++) {
c_full[j]<<=4;
// c_part[j]<<=4;
}
}
}
}
if ( startExists ) {
}
}
/// Copy another IntLigne
{
if ( a->nbRun <= 0 ) {
Reset();
return;
}
nbBord = 0;
}
}
/**
* Copy a FloatLigne's runs.
*
* Compute non-overlapping runs with integer boundaries from a set of runs
* with floating-point boundaries. This involves replacing floating-point
* boundaries that are not integer by single-pixel runs, so this function
* contains plenty of rounding and float->integer conversion (read:
* time-consuming).
*
* \todo
* Optimization Questions: Why is this called so often compared with the
* other Copy() routines? How does AddRun() look for optimization potential?
*/
{
Reset();
return;
}
/* if ( showCopy ) {
printf("\nfloatligne:\n");
a->Affiche();
}*/
nbBord = 0;
nbRun = 0;
bool pixExists = false;
float lastSurf = 0;
// we take each run of the FloatLigne in sequence and make single-pixel runs of its boundaries as needed
// since the float_ligne_runs are non-overlapping, when a single-pixel run intersects with another runs,
// it must intersect with the single-pixel run created for the end of that run. so instead of creating a new
// int_ligne_run, we just add the coverage to that run.
// stEx: start boundary is not integer -> create single-pixel run for it
// enEx: end boundary is not integer -> create single-pixel run for it
// miEx: the runs minus the eventual single-pixel runs is not empty
bool stEx = true;
bool miEx = true;
bool enEx = true;
float msv;
float mev;
enEx = false;
}
// msv and mev are the start and end value of the middle section of the run, that is the run minus the
// single-pixel runs creaed for its boundaries
stEx = false;
} else {
miSt += 1;
miStF += 1.0;
} else {
// msv=a->ValAt(miSt,runA.st,runA.en,runA.vst,runA.ven);
}
}
miEx = false;
}
} else if ( enEx == false /*curEn == runA.en*/ ) {
} else {
// mev=a->ValAt(curEn,runA.st,runA.en,runA.vst,runA.ven);
}
// check the different cases
// stEx && enEx
if ( pixExists ) {
} else {
}
pixExists=false;
} else {
}
} else if ( pixExists ) {
} else {
}
} else {
pixExists=true;
}
} else if ( pixExists ) {
} else {
}
pixExists=false;
} else {
}
if ( miEx ) {
}
pixExists=false;
}
if ( enEx ) {
pixExists=true;
} else if ( ! stEx ) {
if ( pixExists ) {
}
pixExists=true;
}
}
}
if ( pixExists ) {
}
/* if ( showCopy ) {
printf("-> intligne:\n");
Affiche();
}*/
}
{
if ( firstAc < 0 ) {
} else {
}
}
{
} else {
}
} else {
}
}
}
}
/**
* Rasterization.
*
* The parameters have the same meaning as in the AlphaLigne class.
*/
{
if ( nbRun <= 0 ) {
return;
}
return;
}
break;
}
}
return;
}
} else {
return;
}
curRun++;
}
//Buffer::RasterRun(*dest,color,runs[curRun].st,runs[curRun].vst,runs[curRun].en,runs[curRun].ven);
}
return;
}
curRun++;
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :