Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
fwatch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
8
Issues
8
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
fwatch
Commits
3dfde748
Commit
3dfde748
authored
Aug 26, 2014
by
Projects
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gfx: Merged bitmap drawing routines.
parent
b8b9382e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
6 deletions
+35
-6
gfx.c
sw/common/gfx/gfx.c
+27
-1
gfx.h
sw/common/gfx/gfx.h
+8
-5
No files found.
sw/common/gfx/gfx.c
View file @
3dfde748
/*
* Copyright (C) 2014 Julian Lewis
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Matthieu Cattin <matthieu.cattin@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
...
...
@@ -39,7 +40,7 @@ void *gfx_alloc(int count)
count
/=
4
;
// align to 32 bits
if
(
count
+
gfx_pool_pos
>=
GFX_POOL_SIZE
)
return
NULL
;
return
NULL
;
void
*
p
=
gfx_pool_mem
+
gfx_pool_pos
;
gfx_pool_pos
+=
count
;
...
...
@@ -232,3 +233,28 @@ void gfx_round_box(struct surface *surf, int x0, int y0, int x1, int y1,
gfx_fill_circle
(
surf
,
x1
-
radius
,
y1
-
radius
,
radius
,
value
);
gfx_fill_circle
(
surf
,
x0
+
radius
,
y1
-
radius
,
radius
,
value
);
}
void
gfx_draw_bitmap
(
struct
surface
*
surf
,
int
x0
,
int
y0
,
const
struct
rle_bitmap
*
b
)
{
int
x
=
0
,
y
=
0
;
uint8_t
*
d
=
b
->
data
;
while
(
y
!=
b
->
h
)
{
int
pix
=
(
*
d
)
&
0x80
?
1
:
0
;
int
rep
=
((
*
d
)
&
0x7f
)
+
1
;
d
++
;
while
(
rep
--
)
{
if
(
pix
)
gfx_set_pixel
(
surf
,
x0
+
x
,
y0
+
y
,
COLOR_BLACK
);
x
++
;
if
(
x
==
b
->
w
)
{
x
=
0
;
y
++
;
}
}
}
}
sw/common/gfx/gfx.h
View file @
3dfde748
/*
* Copyright (C) 2014 Julian Lewis
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Matthieu Cattin <matthieu.cattin@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
...
...
@@ -24,6 +25,7 @@
#define __GFX_H
#include "font.h"
#include "bitmaps.h"
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
...
...
@@ -44,16 +46,16 @@ struct surface
void
*
data
;
};
static
inline
void
gfx_set_pixel
(
struct
surface
*
surf
,
int
x
,
int
y
,
int
value
)
static
inline
void
gfx_set_pixel
(
struct
surface
*
surf
,
int
x
,
int
y
,
int
value
)
{
if
(
x
<
surf
->
clip
.
x0
||
x
>
surf
->
clip
.
x1
||
if
(
x
<
surf
->
clip
.
x0
||
x
>
surf
->
clip
.
x1
||
y
<
surf
->
clip
.
y0
||
y
>
surf
->
clip
.
y1
)
return
;
x
+=
surf
->
client_x
;
y
+=
surf
->
client_y
;
uint8_t
mask
=
1
<<
(
x
&
0x07
);
uint8_t
mask
=
1
<<
(
x
&
0x07
);
uint8_t
*
p
=
surf
->
data
+
(
y
*
surf
->
stride
)
+
(
x
>>
3
);
if
(
value
==
COLOR_BLACK
)
...
...
@@ -75,6 +77,7 @@ void gfx_set_clip(struct surface *surf, int x0, int y0, int x1, int y1);
void
gfx_reset_clip
(
struct
surface
*
surf
);
void
gfx_fill_circle
(
struct
surface
*
surf
,
int
x0
,
int
y0
,
int
radius
,
int
value
);
void
gfx_round_box
(
struct
surface
*
surf
,
int
x0
,
int
y0
,
int
x1
,
int
y1
,
int
radius
,
int
value
);
void
gfx_draw_bitmap
(
struct
surface
*
surf
,
int
x0
,
int
y0
,
const
struct
rle_bitmap
*
b
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment