mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice-common
synced 2025-12-26 14:18:36 +00:00
Simplify SpiceLineAttr by removing unsed stuff
Also in new protocol don't send style data if not needed.
This commit is contained in:
parent
fcb5eb4629
commit
bef8a0cf19
@ -1593,34 +1593,6 @@ static void gdi_canvas_draw_text(SpiceCanvas *spice_canvas, SpiceRect *bbox, Spi
|
||||
}
|
||||
}
|
||||
|
||||
static int get_join_style(uint8_t join_style)
|
||||
{
|
||||
switch (join_style) {
|
||||
case SPICE_LINE_JOIN_ROUND:
|
||||
return PS_JOIN_ROUND;
|
||||
case SPICE_LINE_JOIN_BEVEL:
|
||||
return PS_JOIN_BEVEL;
|
||||
case SPICE_LINE_JOIN_MITER:
|
||||
return PS_JOIN_MITER;
|
||||
default:
|
||||
CANVAS_ERROR("bad join style %d", join_style);
|
||||
}
|
||||
}
|
||||
|
||||
static int get_cap(int end_style)
|
||||
{
|
||||
switch (end_style) {
|
||||
case SPICE_LINE_CAP_ROUND:
|
||||
return PS_ENDCAP_ROUND;
|
||||
case SPICE_LINE_CAP_SQUARE:
|
||||
return PS_ENDCAP_SQUARE;
|
||||
case SPICE_LINE_CAP_BUTT:
|
||||
return PS_ENDCAP_FLAT;
|
||||
default:
|
||||
CANVAS_ERROR("bad end style %d", end_style);
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t *gdi_get_userstyle(GdiCanvas *canvas, uint8_t nseg, SPICE_ADDRESS addr, int start_is_gap)
|
||||
{
|
||||
SPICE_FIXED28_4* style = (SPICE_FIXED28_4*)SPICE_GET_ADDRESS(addr);
|
||||
@ -1656,8 +1628,6 @@ static void gdi_canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox, S
|
||||
HPEN hpen;
|
||||
HPEN prev_hpen;
|
||||
LOGBRUSH logbrush;
|
||||
int ps_join = 0;
|
||||
int line_cap = 0;
|
||||
uint32_t *user_style = NULL;
|
||||
pixman_image_t *surface = NULL;
|
||||
|
||||
@ -1775,23 +1745,16 @@ static void gdi_canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox, S
|
||||
pixman_image_unref(surface);
|
||||
}
|
||||
|
||||
#if 0
|
||||
ps_join = get_join_style(stroke->attr.join_style);
|
||||
line_cap = get_cap(stroke->attr.end_style);
|
||||
|
||||
SetMiterLimit(canvas->dc, (FLOAT)fix_to_double(stroke->attr.miter_limit), &old_miter);
|
||||
#endif
|
||||
|
||||
if (stroke->attr.flags & SPICE_LINE_FLAGS_STYLED) {
|
||||
user_style = gdi_get_userstyle(canvas, stroke->attr.style_nseg,
|
||||
stroke->attr.style,
|
||||
!!(stroke->attr.flags & SPICE_LINE_FLAGS_START_WITH_GAP));
|
||||
hpen = ExtCreatePen(PS_GEOMETRIC | ps_join | line_cap | PS_USERSTYLE,
|
||||
(uint32_t)fix_to_double(stroke->attr.width),
|
||||
hpen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE,
|
||||
1.0,
|
||||
&logbrush, stroke->attr.style_nseg, (DWORD *)user_style);
|
||||
} else {
|
||||
hpen = ExtCreatePen(PS_GEOMETRIC | ps_join | line_cap,
|
||||
(uint32_t)fix_to_double(stroke->attr.width),
|
||||
hpen = ExtCreatePen(PS_GEOMETRIC,
|
||||
1.0,
|
||||
&logbrush, 0, NULL);
|
||||
}
|
||||
prev_hpen = (HPEN)SelectObject(canvas->dc, hpen);
|
||||
|
||||
@ -617,7 +617,7 @@ static void gl_canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox, Sp
|
||||
if (stroke->attr.flags & SPICE_LINE_FLAGS_STYLED) {
|
||||
WARN("SPICE_LINE_FLAGS_STYLED");
|
||||
}
|
||||
glc_set_line_width(canvas->glc, fix_to_double(stroke->attr.width));
|
||||
glc_set_line_width(canvas->glc, 1.0);
|
||||
|
||||
path = get_path(canvas, stroke->path);
|
||||
glc_stroke_path(canvas->glc, path);
|
||||
|
||||
@ -62,7 +62,8 @@ def write_read_primitive(writer, start, container, name, scope):
|
||||
writer.error_check("pos + %s > message_end" % m.member_type.get_fixed_nw_size())
|
||||
|
||||
var = "%s__value" % (name)
|
||||
scope.variable_def(m.member_type.c_type(), var)
|
||||
if not scope.variable_defined(var):
|
||||
scope.variable_def(m.member_type.c_type(), var)
|
||||
writer.assign(var, "read_%s(pos)" % (m.member_type.primitive_type()))
|
||||
return var
|
||||
|
||||
@ -639,7 +640,9 @@ def write_switch_parser(writer, container, switch, dest, scope):
|
||||
elif t.is_pointer():
|
||||
write_parse_pointer(writer, t, False, m.has_attr("c_ptr"), dest2, m.name, block)
|
||||
elif t.is_primitive():
|
||||
if not m.has_attr("zero"):
|
||||
if m.has_attr("zero"):
|
||||
writer.statement("consume_%s(&in)" % (t.primitive_type()))
|
||||
else:
|
||||
writer.assign(dest2.get_ref(m.name), "consume_%s(&in)" % (t.primitive_type()))
|
||||
#TODO validate e.g. flags and enums
|
||||
elif t.is_array():
|
||||
@ -768,8 +771,8 @@ def write_member_parser(writer, container, member, dest, scope):
|
||||
write_parse_pointer(writer, t, member.has_end_attr(), member.has_attr("c_ptr"), dest, member.name, scope)
|
||||
elif t.is_primitive():
|
||||
if member.has_attr("zero"):
|
||||
pass
|
||||
if member.has_end_attr():
|
||||
writer.statement("consume_%s(&in)" % t.primitive_type())
|
||||
elif member.has_end_attr():
|
||||
writer.statement("*(%s *)end = consume_%s(&in)" % (t.c_type(), t.primitive_type()))
|
||||
writer.increment("end", t.sizeof())
|
||||
else:
|
||||
|
||||
@ -610,6 +610,12 @@ class Switch(Containee):
|
||||
def is_switch(self):
|
||||
return True
|
||||
|
||||
def lookup_case_member(self, name):
|
||||
for c in self.cases:
|
||||
if c.member.name == name:
|
||||
return c.member
|
||||
return None
|
||||
|
||||
def has_switch_member(self, member):
|
||||
for c in self.cases:
|
||||
if c.member == member:
|
||||
@ -767,7 +773,14 @@ class ContainerType(Type):
|
||||
return str(fixed)
|
||||
|
||||
def lookup_member(self, name):
|
||||
return self.members_by_name[name]
|
||||
if self.members_by_name.has_key(name):
|
||||
return self.members_by_name[name]
|
||||
for m in self.members:
|
||||
if m.is_switch():
|
||||
member = m.lookup_case_member(name)
|
||||
if member:
|
||||
return member
|
||||
raise Exception, "No member called %s found" % name
|
||||
|
||||
class StructType(ContainerType):
|
||||
def __init__(self, name, members, attribute_list):
|
||||
|
||||
28
spice.proto
28
spice.proto
@ -131,7 +131,7 @@ channel BaseChannel {
|
||||
uint32 what; /* error_code/warn_code/info_code */
|
||||
uint32 message_len;
|
||||
uint8 message[message_len] @end @nomarshal;
|
||||
uint8 zero @end @ctype(uint8_t) @zero @nomarshal;
|
||||
uint8 zero @end @ctype(uint8_t) @nomarshal;
|
||||
} notify;
|
||||
|
||||
client:
|
||||
@ -349,18 +349,6 @@ flags8 line_flags {
|
||||
START_WITH_GAP = 2,
|
||||
};
|
||||
|
||||
enum8 line_cap {
|
||||
ROUND,
|
||||
SQUARE,
|
||||
BUTT,
|
||||
};
|
||||
|
||||
enum8 line_join {
|
||||
ROUND,
|
||||
BEVEL,
|
||||
MITER,
|
||||
};
|
||||
|
||||
flags8 string_flags {
|
||||
RASTER_A1,
|
||||
RASTER_A4,
|
||||
@ -537,12 +525,14 @@ struct QMask {
|
||||
|
||||
struct LineAttr {
|
||||
line_flags flags;
|
||||
line_join join_style;
|
||||
line_cap end_style;
|
||||
uint8 style_nseg;
|
||||
fixed28_4 width;
|
||||
fixed28_4 miter_limit;
|
||||
fixed28_4 *style[style_nseg];
|
||||
switch (flags) {
|
||||
case STYLED:
|
||||
uint8 style_nseg;
|
||||
} u1 @anon;
|
||||
switch (flags) {
|
||||
case STYLED:
|
||||
fixed28_4 *style[style_nseg];
|
||||
} u2 @anon;
|
||||
};
|
||||
|
||||
struct RasterGlyphA1 {
|
||||
|
||||
10
spice1.proto
10
spice1.proto
@ -131,7 +131,7 @@ channel BaseChannel {
|
||||
uint32 what; /* error_code/warn_code/info_code */
|
||||
uint32 message_len;
|
||||
uint8 message[message_len] @end @nomarshal;
|
||||
uint8 zero @end @ctype(uint8_t) @zero @nomarshal;
|
||||
uint8 zero @end @ctype(uint8_t) @nomarshal;
|
||||
} notify;
|
||||
|
||||
client:
|
||||
@ -485,11 +485,11 @@ struct QMask {
|
||||
|
||||
struct LineAttr {
|
||||
line_flags flags;
|
||||
line_join join_style;
|
||||
line_cap end_style;
|
||||
line_join join_style @zero;
|
||||
line_cap end_style @zero;
|
||||
uint8 style_nseg;
|
||||
fixed28_4 width;
|
||||
fixed28_4 miter_limit;
|
||||
fixed28_4 width @zero;
|
||||
fixed28_4 miter_limit @zero;
|
||||
fixed28_4 *style[style_nseg];
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user