summaryrefslogtreecommitdiffstats
path: root/src/display/sp-canvas-util.cpp
diff options
context:
space:
mode:
authorPeter Moulder <peter.moulder@monash.edu>2007-09-29 12:54:44 +0000
committerpjrm <pjrm@users.sourceforge.net>2007-09-29 12:54:44 +0000
commit25a23dfa303b3874b468b19edbb5a7e8516416f2 (patch)
tree4968f0bdfbb909a397540d0fcddbc5f240d21dc9 /src/display/sp-canvas-util.cpp
parentnoop: CodingStyle: const placement (diff)
downloadinkscape-25a23dfa303b3874b468b19edbb5a7e8516416f2.tar.gz
inkscape-25a23dfa303b3874b468b19edbb5a7e8516416f2.zip
noop: CodingStyle: re-indent a few files that had mixtures of spaces & tabs for indentation.
(bzr r3816)
Diffstat (limited to 'src/display/sp-canvas-util.cpp')
-rw-r--r--src/display/sp-canvas-util.cpp170
1 files changed, 91 insertions, 79 deletions
diff --git a/src/display/sp-canvas-util.cpp b/src/display/sp-canvas-util.cpp
index a0c74b2c3..9b3e53f20 100644
--- a/src/display/sp-canvas-util.cpp
+++ b/src/display/sp-canvas-util.cpp
@@ -24,112 +24,112 @@
void
sp_canvas_update_bbox (SPCanvasItem *item, int x1, int y1, int x2, int y2)
{
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
- item->x1 = x1;
- item->y1 = y1;
- item->x2 = x2;
- item->y2 = y2;
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->x1 = x1;
+ item->y1 = y1;
+ item->x2 = x2;
+ item->y2 = y2;
+ sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
}
void
sp_canvas_item_reset_bounds (SPCanvasItem *item)
{
- item->x1 = 0.0;
- item->y1 = 0.0;
- item->x2 = 0.0;
- item->y2 = 0.0;
+ item->x1 = 0.0;
+ item->y1 = 0.0;
+ item->x2 = 0.0;
+ item->y2 = 0.0;
}
void
sp_canvas_prepare_buffer (SPCanvasBuf *buf)
{
- if (buf->is_empty) {
- sp_canvas_clear_buffer(buf);
- buf->is_empty = false;
- }
+ if (buf->is_empty) {
+ sp_canvas_clear_buffer(buf);
+ buf->is_empty = false;
+ }
}
void
sp_canvas_clear_buffer (SPCanvasBuf *buf)
{
- unsigned char r, g, b;
-
- r = (buf->bg_color >> 16) & 0xff;
- g = (buf->bg_color >> 8) & 0xff;
- b = buf->bg_color & 0xff;
-
- if ((r != g) || (r != b)) {
- int x, y;
- for (y = buf->rect.y0; y < buf->rect.y1; y++) {
- unsigned char *p;
- p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride;
- for (x = buf->rect.x0; x < buf->rect.x1; x++) {
- *p++ = r;
- *p++ = g;
- *p++ = b;
- }
- }
- } else {
- int y;
- for (y = buf->rect.y0; y < buf->rect.y1; y++) {
- memset (buf->buf + (y - buf->rect.y0) * buf->buf_rowstride, r, 3 * (buf->rect.x1 - buf->rect.x0)); // CAIRO FIXME: for cairo output we need 32bpp, so it will be 4 * ...
- }
- }
+ unsigned char r, g, b;
+
+ r = (buf->bg_color >> 16) & 0xff;
+ g = (buf->bg_color >> 8) & 0xff;
+ b = buf->bg_color & 0xff;
+
+ if ((r != g) || (r != b)) {
+ int x, y;
+ for (y = buf->rect.y0; y < buf->rect.y1; y++) {
+ unsigned char *p;
+ p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride;
+ for (x = buf->rect.x0; x < buf->rect.x1; x++) {
+ *p++ = r;
+ *p++ = g;
+ *p++ = b;
+ }
+ }
+ } else {
+ int y;
+ for (y = buf->rect.y0; y < buf->rect.y1; y++) {
+ memset (buf->buf + (y - buf->rect.y0) * buf->buf_rowstride, r, 3 * (buf->rect.x1 - buf->rect.x0)); // CAIRO FIXME: for cairo output we need 32bpp, so it will be 4 * ...
+ }
+ }
}
NR::Matrix sp_canvas_item_i2p_affine (SPCanvasItem * item)
{
- g_assert (item != NULL); // this may be overly zealous - it is
- // plausible that this gets called
- // with item == 0
-
- return item->xform;
+ g_assert (item != NULL); /* this may be overly zealous - it is
+ * plausible that this gets called
+ * with item == 0. */
+
+ return item->xform;
}
NR::Matrix sp_canvas_item_i2i_affine (SPCanvasItem * from, SPCanvasItem * to)
{
- g_assert (from != NULL);
- g_assert (to != NULL);
+ g_assert (from != NULL);
+ g_assert (to != NULL);
- return sp_canvas_item_i2w_affine(from) / sp_canvas_item_i2w_affine(to);
+ return sp_canvas_item_i2w_affine(from) / sp_canvas_item_i2w_affine(to);
}
void sp_canvas_item_set_i2w_affine (SPCanvasItem * item, NR::Matrix const &i2w)
{
- g_assert (item != NULL);
+ g_assert (item != NULL);
- sp_canvas_item_affine_absolute(item, i2w / sp_canvas_item_i2w_affine(item->parent));
+ sp_canvas_item_affine_absolute(item, i2w / sp_canvas_item_i2w_affine(item->parent));
}
void sp_canvas_item_move_to_z (SPCanvasItem * item, gint z)
{
- g_assert (item != NULL);
+ g_assert (item != NULL);
- gint current_z = sp_canvas_item_order (item);
+ gint current_z = sp_canvas_item_order (item);
- if (current_z == -1) // not found in its parent
- return;
+ if (current_z == -1) // not found in its parent
+ return;
- if (z == current_z)
- return;
+ if (z == current_z)
+ return;
- if (z > current_z)
- sp_canvas_item_raise (item, z - current_z);
+ if (z > current_z)
+ sp_canvas_item_raise (item, z - current_z);
- sp_canvas_item_lower (item, current_z - z);
+ sp_canvas_item_lower (item, current_z - z);
}
gint
sp_canvas_item_compare_z (SPCanvasItem * a, SPCanvasItem * b)
{
- gint const o_a = sp_canvas_item_order (a);
- gint const o_b = sp_canvas_item_order (b);
+ gint const o_a = sp_canvas_item_order (a);
+ gint const o_b = sp_canvas_item_order (b);
- if (o_a > o_b) return -1;
- if (o_a < o_b) return 1;
+ if (o_a > o_b) return -1;
+ if (o_a < o_b) return 1;
- return 0;
+ return 0;
}
// These two functions are used by canvasitems that use livarot (currently ctrlline and ctrlquadr)
@@ -143,17 +143,17 @@ ctrl_run_A8_OR (raster_info &dest,void *data,int st,float vst,int en,float ven)
} tempCol;
if ( st >= en ) return;
tempCol.col=*(uint32_t*)data;
-
+
unsigned int r, g, b, a;
r = NR_RGBA32_R (tempCol.col);
g = NR_RGBA32_G (tempCol.col);
b = NR_RGBA32_B (tempCol.col);
a = NR_RGBA32_A (tempCol.col);
if (a == 0) return;
-
+
vst*=a;
ven*=a;
-
+
if ( vst < 0 ) vst=0;
if ( vst > 255 ) vst=255;
if ( ven < 0 ) ven=0;
@@ -162,7 +162,7 @@ ctrl_run_A8_OR (raster_info &dest,void *data,int st,float vst,int en,float ven)
float dv=ven-vst;
int len=en-st;
uint8_t* d=(uint8_t*)dest.buffer;
-
+
d+=3*(st-dest.startPix);
if ( fabs(dv) < 0.001 ) {
if ( sv > 249.999 ) {
@@ -219,7 +219,7 @@ ctrl_run_A8_OR (raster_info &dest,void *data,int st,float vst,int en,float ven)
void nr_pixblock_render_ctrl_rgba (Shape* theS,uint32_t color,NRRectL &area,char* destBuf,int stride)
{
-
+
theS->CalcBBox();
float l=theS->leftX,r=theS->rightX,t=theS->topY,b=theS->bottomY;
int il,ir,it,ib;
@@ -227,25 +227,25 @@ void nr_pixblock_render_ctrl_rgba (Shape* theS,uint32_t color,NRRectL &area,char
ir=(int)ceil(r);
it=(int)floor(t);
ib=(int)ceil(b);
-
+
// printf("bbox %i %i %i %i render %i %i %i %i\n",il,it,ir,ib,area.x0,area.y0,area.x1,area.y1);
-
+
if ( il >= area.x1 || ir <= area.x0 || it >= area.y1 || ib <= area.y0 ) return;
if ( il < area.x0 ) il=area.x0;
if ( it < area.y0 ) it=area.y0;
if ( ir > area.x1 ) ir=area.x1;
if ( ib > area.y1 ) ib=area.y1;
-
+
/* // version par FloatLigne
int curPt;
float curY;
theS->BeginRaster(curY,curPt,1.0);
-
+
FloatLigne* theI=new FloatLigne();
IntLigne* theIL=new IntLigne();
-
+
theS->Scan(curY,curPt,(float)(it),1.0);
-
+
char* mdata=(char*)destBuf;
uint32_t* ligStart=((uint32_t*)(mdata+(3*(il-area.x0)+stride*(it-area.y0))));
for (int y=it;y<ib;y++) {
@@ -257,7 +257,7 @@ void nr_pixblock_render_ctrl_rgba (Shape* theS,uint32_t color,NRRectL &area,char
}
theI->Flatten();
theIL->Copy(theI);
-
+
raster_info dest;
dest.startPix=il;
dest.endPix=ir;
@@ -270,18 +270,18 @@ void nr_pixblock_render_ctrl_rgba (Shape* theS,uint32_t color,NRRectL &area,char
theS->EndRaster();
delete theI;
delete theIL; */
-
+
// version par BitLigne directe
int curPt;
float curY;
theS->BeginQuickRaster(curY, curPt);
-
+
BitLigne* theI[4];
for (int i=0;i<4;i++) theI[i]=new BitLigne(il,ir);
IntLigne* theIL=new IntLigne();
-
+
theS->QuickScan(curY,curPt,(float)(it),true,0.25);
-
+
char* mdata=(char*)destBuf;
uint32_t* ligStart=((uint32_t*)(mdata+(3*(il-area.x0)+stride*(it-area.y0))));
for (int y=it;y<ib;y++) {
@@ -291,7 +291,7 @@ void nr_pixblock_render_ctrl_rgba (Shape* theS,uint32_t color,NRRectL &area,char
theS->QuickScan(curY,curPt,((float)(y+0.75)),fill_oddEven,theI[2],0.25);
theS->QuickScan(curY,curPt,((float)(y+1.0)),fill_oddEven,theI[3],0.25);
theIL->Copy(4,theI);
-
+
raster_info dest;
dest.startPix=il;
dest.endPix=ir;
@@ -303,5 +303,17 @@ void nr_pixblock_render_ctrl_rgba (Shape* theS,uint32_t color,NRRectL &area,char
}
theS->EndQuickRaster();
for (int i=0;i<4;i++) delete theI[i];
- delete theIL;
+ delete theIL;
}
+
+
+/*
+ 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:encoding=utf-8:textwidth=99 :