Skip to content
Snippets Groups Projects
Commit 6330748a authored by pippin's avatar pippin
Browse files

uctx: deprecated start_group and end_group

They seem to not work as documented in the ctx protocol, in the cases where it
seemed to work it was due to side effects of global alpha, existing code should
continue working after this commit. The API might return, it is not removed
from the ctx protocol - and can still be accessed through ctx.parse().
parent 18c37862
No related branches found
No related tags found
No related merge requests found
...@@ -202,8 +202,12 @@ MP_CTX_COMMON_FUN_0(restore); ...@@ -202,8 +202,12 @@ MP_CTX_COMMON_FUN_0(restore);
MP_CTX_COMMON_FUN_0(start_frame); MP_CTX_COMMON_FUN_0(start_frame);
MP_CTX_COMMON_FUN_0(end_frame); MP_CTX_COMMON_FUN_0(end_frame);
#define UCTX_COMPOSITING_GROUPS 0
#if UCTX_COMPOSITING_GROUPS
MP_CTX_COMMON_FUN_0(start_group); MP_CTX_COMMON_FUN_0(start_group);
MP_CTX_COMMON_FUN_0(end_group); MP_CTX_COMMON_FUN_0(end_group);
#endif
MP_CTX_COMMON_FUN_0(clip); MP_CTX_COMMON_FUN_0(clip);
MP_CTX_COMMON_FUN_1F(rotate); MP_CTX_COMMON_FUN_1F(rotate);
MP_CTX_COMMON_FUN_2F(scale); MP_CTX_COMMON_FUN_2F(scale);
...@@ -804,6 +808,9 @@ STATIC void mp_ctx_attr(mp_obj_t obj, qstr attr, mp_obj_t *dest) { ...@@ -804,6 +808,9 @@ STATIC void mp_ctx_attr(mp_obj_t obj, qstr attr, mp_obj_t *dest) {
/* CTX class/type */ /* CTX class/type */
static const mp_rom_map_elem_t mp_ctx_locals_dict_table[] = { static const mp_rom_map_elem_t mp_ctx_locals_dict_table[] = {
MP_CTX_METHOD(gray),
MP_CTX_METHOD(rgb),
MP_CTX_METHOD(rgba),
MP_CTX_METHOD(line_to), MP_CTX_METHOD(line_to),
MP_CTX_METHOD(move_to), MP_CTX_METHOD(move_to),
MP_CTX_METHOD(curve_to), MP_CTX_METHOD(curve_to),
...@@ -823,6 +830,8 @@ static const mp_rom_map_elem_t mp_ctx_locals_dict_table[] = { ...@@ -823,6 +830,8 @@ static const mp_rom_map_elem_t mp_ctx_locals_dict_table[] = {
MP_CTX_METHOD(fill), MP_CTX_METHOD(fill),
MP_CTX_METHOD(stroke), MP_CTX_METHOD(stroke),
MP_CTX_METHOD(paint), MP_CTX_METHOD(paint),
MP_CTX_METHOD(save),
MP_CTX_METHOD(restore),
MP_CTX_METHOD(clip), MP_CTX_METHOD(clip),
MP_CTX_METHOD(text), MP_CTX_METHOD(text),
MP_CTX_METHOD(text_width), MP_CTX_METHOD(text_width),
...@@ -830,8 +839,13 @@ static const mp_rom_map_elem_t mp_ctx_locals_dict_table[] = { ...@@ -830,8 +839,13 @@ static const mp_rom_map_elem_t mp_ctx_locals_dict_table[] = {
MP_CTX_METHOD(scale), MP_CTX_METHOD(scale),
MP_CTX_METHOD(translate), MP_CTX_METHOD(translate),
MP_CTX_METHOD(apply_transform), MP_CTX_METHOD(apply_transform),
#if UCTX_COMPOSITING_GROUPS
MP_CTX_METHOD(start_group), MP_CTX_METHOD(start_group),
MP_CTX_METHOD(end_group), MP_CTX_METHOD(end_group),
#else
{ MP_ROM_QSTR(MP_QSTR_start_group), MP_ROM_PTR(&mp_ctx_save_obj) },
{ MP_ROM_QSTR(MP_QSTR_end_group), MP_ROM_PTR(&mp_ctx_restore_obj) },
#endif
MP_CTX_METHOD(preserve), MP_CTX_METHOD(preserve),
MP_CTX_METHOD(linear_gradient), MP_CTX_METHOD(linear_gradient),
MP_CTX_METHOD(radial_gradient), MP_CTX_METHOD(radial_gradient),
...@@ -839,15 +853,10 @@ static const mp_rom_map_elem_t mp_ctx_locals_dict_table[] = { ...@@ -839,15 +853,10 @@ static const mp_rom_map_elem_t mp_ctx_locals_dict_table[] = {
MP_CTX_METHOD(line_dash), MP_CTX_METHOD(line_dash),
MP_CTX_METHOD(texture), MP_CTX_METHOD(texture),
MP_CTX_METHOD(image), MP_CTX_METHOD(image),
MP_CTX_METHOD(save),
MP_CTX_METHOD(restore),
MP_CTX_METHOD(start_frame), MP_CTX_METHOD(start_frame),
MP_CTX_METHOD(end_frame), MP_CTX_METHOD(end_frame),
MP_CTX_METHOD(get_font_name), MP_CTX_METHOD(get_font_name),
MP_CTX_METHOD(gray),
MP_CTX_METHOD(rgb),
MP_CTX_METHOD(rgba),
#if CTX_PARSER #if CTX_PARSER
MP_CTX_METHOD(parse), MP_CTX_METHOD(parse),
#endif #endif
......
...@@ -75,17 +75,6 @@ class Context(Protocol): ...@@ -75,17 +75,6 @@ class Context(Protocol):
should be balanced. should be balanced.
""" """
pass pass
def start_group(self) -> "Context":
"""
Start a compositing group.
"""
pass
def end_group(self) -> "Context":
"""
End a compositing group, the global alpha, compositing mode and blend
mode set before this call is used to apply the group.
"""
pass
def clip(self) -> "Context": def clip(self) -> "Context":
""" """
Use the current path as a clipping mask, subsequent draw calls are Use the current path as a clipping mask, subsequent draw calls are
......
...@@ -189,7 +189,7 @@ class About(BaseView): ...@@ -189,7 +189,7 @@ class About(BaseView):
ctx.translate(-240 * offs, 0) ctx.translate(-240 * offs, 0)
# Opaque circle # Opaque circle
ctx.start_group() ctx.save()
ctx.global_alpha = 0.5 ctx.global_alpha = 0.5
ctx.rgb(0, 0, 0) ctx.rgb(0, 0, 0)
ctx.arc(0, 0, 90, 0, tau, 0) ctx.arc(0, 0, 90, 0, tau, 0)
...@@ -208,10 +208,10 @@ class About(BaseView): ...@@ -208,10 +208,10 @@ class About(BaseView):
ctx.font_size = 30 ctx.font_size = 30
ctx.text_align = ctx.MIDDLE ctx.text_align = ctx.MIDDLE
ctx.text("\ue5c8") ctx.text("\ue5c8")
ctx.end_group() ctx.restore()
# Text # Text
ctx.start_group() ctx.save()
ctx.global_alpha = 1.0 ctx.global_alpha = 1.0
ctx.gray(1) ctx.gray(1)
...@@ -219,5 +219,5 @@ class About(BaseView): ...@@ -219,5 +219,5 @@ class About(BaseView):
screen.draw(ctx) screen.draw(ctx)
ctx.end_group() ctx.restore()
ctx.restore() ctx.restore()
...@@ -259,14 +259,6 @@ class Context: ...@@ -259,14 +259,6 @@ class Context:
self._emit(f"stroke") self._emit(f"stroke")
return self return self
def start_group(self):
self._emit(f"start_group")
return self
def end_group(self):
self._emit(f"end_group")
return self
def save(self): def save(self):
self._emit(f"save") self._emit(f"save")
return self return self
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment