~eliasnaur/gio-patches

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
8 4

[PATCH gio] Change App background to Transparent

Paulo Melo
Details
Message ID
<20210215164731.54836-1-paulo.durrer.melo@gmail.com>
DKIM signature
missing
Download raw message
Patch: +1 -1
---
 app/loop.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/loop.go b/app/loop.go
index cf00c41..0dadeac 100644
--- a/app/loop.go
+++ b/app/loop.go
@@ -86,7 +86,7 @@ func (l *renderLoop) renderLoop(ctx window.Context) error {
				l.refreshErr <- ctx.MakeCurrent()
			case frame := <-l.frames:
				ctx.Lock()
				g.Clear(color.NRGBA{A: 0xff, R: 0xff, G: 0xff, B: 0xff})
				g.Clear(color.NRGBA{A: 0x00, R: 0x00, G: 0x00, B: 0x00})
				g.Collect(frame.viewport, frame.ops)
				// Signal that we're done with the frame ops.
				l.ack <- struct{}{}
-- 
2.26.2
Details
Message ID
<C9A9DGH2DOMA.T15KEBP5ZITB@themachine>
In-Reply-To
<20210215164731.54836-1-paulo.durrer.melo@gmail.com> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
Please change your commit message to include the package name, and use
lowercase

app: change clear color to transparent

Also add a sentence or two motivating the change and sign off the change.

On Mon Feb 15, 2021 at 16:47, Paulo Melo wrote:
> ---
>  app/loop.go | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/app/loop.go b/app/loop.go
> index cf00c41..0dadeac 100644
> --- a/app/loop.go
> +++ b/app/loop.go
> @@ -86,7 +86,7 @@ func (l *renderLoop) renderLoop(ctx window.Context) error {
>  				l.refreshErr <- ctx.MakeCurrent()
>  			case frame := <-l.frames:
>  				ctx.Lock()
> -				g.Clear(color.NRGBA{A: 0xff, R: 0xff, G: 0xff, B: 0xff})
> +				g.Clear(color.NRGBA{A: 0x00, R: 0x00, G: 0x00, B: 0x00})
>  				g.Collect(frame.viewport, frame.ops)
>  				// Signal that we're done with the frame ops.
>  				l.ack <- struct{}{}
> -- 
> 2.26.2

[gio/patches] build failed

builds.sr.ht
Details
Message ID
<C9A9RS93775N.2EILU9T40057J@cirno2>
In-Reply-To
<20210215164731.54836-1-paulo.durrer.melo@gmail.com> (view parent)
DKIM signature
missing
Download raw message
gio/patches: FAILED in 22m57s

[Change App background to Transparent][0] from [Paulo Melo][1]

[0]: https://lists.sr.ht/~eliasnaur/gio-patches/patches/20282
[1]: mailto:paulo.durrer.melo@gmail.com

✓ #426936 SUCCESS gio/patches/apple.yml   https://builds.sr.ht/~eliasnaur/job/426936
✓ #426937 SUCCESS gio/patches/freebsd.yml https://builds.sr.ht/~eliasnaur/job/426937
✓ #426939 SUCCESS gio/patches/openbsd.yml https://builds.sr.ht/~eliasnaur/job/426939
✗ #426938 FAILED  gio/patches/linux.yml   https://builds.sr.ht/~eliasnaur/job/426938
Details
Message ID
<CANtNKfp=10bSS6v_PyL7j14J=961ySqt66ZT47a7uYySQuy-Uw@mail.gmail.com>
In-Reply-To
<20210215164731.54836-1-paulo.durrer.melo@gmail.com> (view parent)
DKIM signature
pass
Download raw message
One annoyance with this approach is that it requires mostly everyone
to add painting to white.

Wouldn't adding a `paint.Clear` operation be a nicer approach?
That way people can choose to override the clearing with whichever
color is suitable,
without having to change the default useful behavior.

On Mon, Feb 15, 2021 at 8:13 PM Paulo Melo <paulo.durrer.melo@gmail.com> wrote:
>
> ---
>  app/loop.go | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/app/loop.go b/app/loop.go
> index cf00c41..0dadeac 100644
> --- a/app/loop.go
> +++ b/app/loop.go
> @@ -86,7 +86,7 @@ func (l *renderLoop) renderLoop(ctx window.Context) error {
>                                 l.refreshErr <- ctx.MakeCurrent()
>                         case frame := <-l.frames:
>                                 ctx.Lock()
> -                               g.Clear(color.NRGBA{A: 0xff, R: 0xff, G: 0xff, B: 0xff})
> +                               g.Clear(color.NRGBA{A: 0x00, R: 0x00, G: 0x00, B: 0x00})
>                                 g.Collect(frame.viewport, frame.ops)
>                                 // Signal that we're done with the frame ops.
>                                 l.ack <- struct{}{}
> --
> 2.26.2
>
paulo melo
Details
Message ID
<362172C9-DAEA-48B1-98D2-7FEB2C23FAD7@gmail.com>
In-Reply-To
<CANtNKfp=10bSS6v_PyL7j14J=961ySqt66ZT47a7uYySQuy-Uw@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
The background is now either transparent or black.

This was the approach suggested by Elias Naur. 
Another solution is to leave it as it was and change the gpu/gpu.go 
file at line 1004 by removing the opacity test and at line 1011 by removing the opaque()


> On 15 Feb 2021, at 18:16, Egon Elbre <egonelbre@gmail.com> wrote:
> 
> One annoyance with this approach is that it requires mostly everyone
> to add painting to white.
> 
> Wouldn't adding a `paint.Clear` operation be a nicer approach?
> That way people can choose to override the clearing with whichever
> color is suitable,
> without having to change the default useful behavior.
> 
> On Mon, Feb 15, 2021 at 8:13 PM Paulo Melo <paulo.durrer.melo@gmail.com> wrote:
>> 
>> ---
>> app/loop.go | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/app/loop.go b/app/loop.go
>> index cf00c41..0dadeac 100644
>> --- a/app/loop.go
>> +++ b/app/loop.go
>> @@ -86,7 +86,7 @@ func (l *renderLoop) renderLoop(ctx window.Context) error {
>>                                l.refreshErr <- ctx.MakeCurrent()
>>                        case frame := <-l.frames:
>>                                ctx.Lock()
>> -                               g.Clear(color.NRGBA{A: 0xff, R: 0xff, G: 0xff, B: 0xff})
>> +                               g.Clear(color.NRGBA{A: 0x00, R: 0x00, G: 0x00, B: 0x00})
>>                                g.Collect(frame.viewport, frame.ops)
>>                                // Signal that we're done with the frame ops.
>>                                l.ack <- struct{}{}
>> --
>> 2.26.2
>> 
Details
Message ID
<CANtNKfpOmfttVThAk0Rh_Xgpoac_gJMor2kawsMNdnoM1-91CQ@mail.gmail.com>
In-Reply-To
<362172C9-DAEA-48B1-98D2-7FEB2C23FAD7@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Note, I just realized that it could also be a window option. So something like:

w := app.NewWindow(app.ClearColor(color.NRGBA{A: 0x00, R: 0x00, G:
0x00, B: 0x00}))

And potentially:

w := app.NewWindow(app.NoClear())

On Mon, Feb 15, 2021 at 8:23 PM paulo melo <paulo.durrer.melo@gmail.com> wrote:
>
> The background is now either transparent or black.
>
> This was the approach suggested by Elias Naur.
> Another solution is to leave it as it was and change the gpu/gpu.go
> file at line 1004 by removing the opacity test and at line 1011 by removing the opaque()
>
>
> > On 15 Feb 2021, at 18:16, Egon Elbre <egonelbre@gmail.com> wrote:
> >
> > One annoyance with this approach is that it requires mostly everyone
> > to add painting to white.
> >
> > Wouldn't adding a `paint.Clear` operation be a nicer approach?
> > That way people can choose to override the clearing with whichever
> > color is suitable,
> > without having to change the default useful behavior.
> >
> > On Mon, Feb 15, 2021 at 8:13 PM Paulo Melo <paulo.durrer.melo@gmail.com> wrote:
> >>
> >> ---
> >> app/loop.go | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/app/loop.go b/app/loop.go
> >> index cf00c41..0dadeac 100644
> >> --- a/app/loop.go
> >> +++ b/app/loop.go
> >> @@ -86,7 +86,7 @@ func (l *renderLoop) renderLoop(ctx window.Context) error {
> >>                                l.refreshErr <- ctx.MakeCurrent()
> >>                        case frame := <-l.frames:
> >>                                ctx.Lock()
> >> -                               g.Clear(color.NRGBA{A: 0xff, R: 0xff, G: 0xff, B: 0xff})
> >> +                               g.Clear(color.NRGBA{A: 0x00, R: 0x00, G: 0x00, B: 0x00})
> >>                                g.Collect(frame.viewport, frame.ops)
> >>                                // Signal that we're done with the frame ops.
> >>                                l.ack <- struct{}{}
> >> --
> >> 2.26.2
> >>
>
Details
Message ID
<C9ATVMZ97H41.14AC87SW5ZCDX@themachine>
In-Reply-To
<CANtNKfpOmfttVThAk0Rh_Xgpoac_gJMor2kawsMNdnoM1-91CQ@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Mon Feb 15, 2021 at 21:06, Egon Elbre wrote:
> Note, I just realized that it could also be a window option. So something like:
>
> w := app.NewWindow(app.ClearColor(color.NRGBA{A: 0x00, R: 0x00, G:
> 0x00, B: 0x00}))
>
> And potentially:
>
> w := app.NewWindow(app.NoClear())
>

I considered the window option, but preferred the Go-like zero clear
color and the explicit one-liner for setting the background; after all,
not all windows have a white background. Some may even change the
background at runtime, and I'd rather lead people to paint.Fill than an
option.

Like Egon points out, however, it's a bit unsatisfying to need
paint.Fill in almost every program. Further, the default value is subtly
different than it appears: transparent black (0, 0, 0, 0) is not the
same as black (0, 0, 0, 1).

How about we change the default color to transparent black *only* where
Gio is embedded with something else? I did a similar change for the GLFW
example[0] so it could mix custom GL with Gio. You could do the same for
webassembly, because there is always a webpage below the canvas.

Elias

[0] https://gioui.org/commit/84b586ae6ce6de
paulo melo
Details
Message ID
<47541C49-0816-4302-9DA2-B221755562E7@gmail.com>
In-Reply-To
<C9ATVMZ97H41.14AC87SW5ZCDX@themachine> (view parent)
DKIM signature
pass
Download raw message
Elias,

on my initial tests I’ve found the following using the default background as White.
I tryed to explicitly set the background to transparent and found that on the gpu.go file there was a lock to only accept opaque colors.

If we remove this opaque lock I’ve found that it works. Is there any special reason to have this lock? 

I believe that this solution should be the best. By default the background is White and if we want it to be another color or transparent we set it as needed.

Do you agree?

On 16 Feb 2021, at 08:56, Elias Naur <mail@eliasnaur.com> wrote:

On Mon Feb 15, 2021 at 21:06, Egon Elbre wrote:
> Note, I just realized that it could also be a window option. So something like:
> 
> w := app.NewWindow(app.ClearColor(color.NRGBA{A: 0x00, R: 0x00, G:
> 0x00, B: 0x00}))
> 
> And potentially:
> 
> w := app.NewWindow(app.NoClear())
> 

I considered the window option, but preferred the Go-like zero clear
color and the explicit one-liner for setting the background; after all,
not all windows have a white background. Some may even change the
background at runtime, and I'd rather lead people to paint.Fill than an
option.

Like Egon points out, however, it's a bit unsatisfying to need
paint.Fill in almost every program. Further, the default value is subtly
different than it appears: transparent black (0, 0, 0, 0) is not the
same as black (0, 0, 0, 1).

How about we change the default color to transparent black *only* where
Gio is embedded with something else? I did a similar change for the GLFW
example[0] so it could mix custom GL with Gio. You could do the same for
webassembly, because there is always a webpage below the canvas.

Elias

[0] https://gioui.org/commit/84b586ae6ce6de
Details
Message ID
<C9AWVK85PCKY.B38VMPB5PUQB@themachine>
In-Reply-To
<47541C49-0816-4302-9DA2-B221755562E7@gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Tue Feb 16, 2021 at 09:37, paulo melo wrote:
> Elias,
>
> on my initial tests I’ve found the following using the default background as White.
> I tryed to explicitly set the background to transparent and found that on the gpu.go file there was a lock to only accept opaque colors.
>
> If we remove this opaque lock I’ve found that it works. Is there any special reason to have this lock? 
>
> I believe that this solution should be the best. By default the background is White and if we want it to be another color or transparent we set it as needed.
>
> Do you agree?

What is the lock you're referring to? What did you try that didn't work?

Elias
Reply to thread Export thread (mbox)