Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions canvas/blur.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package canvas

import "fyne.io/fyne/v2"

// Declare conformity with CanvasObject interface
var _ fyne.CanvasObject = (*Blur)(nil)

// Blur creates a rectangular blur region on the output.
// All objects drawn under this will be blurred, any above will not be affected.
//
// Since: 2.7
type Blur struct {
baseObject

// Radius refers to how far from a pixel should be used to calculate the blur.
// It must be greater than 0 but no more than 50.
Radius float32
}

// Hide will set this blur to not be visible
func (b *Blur) Hide() {
b.baseObject.Hide()

repaint(b)
}

// Move the blur to a new position, relative to its parent / canvas
func (b *Blur) Move(pos fyne.Position) {
if b.Position() == pos {
return
}
b.baseObject.Move(pos)

repaint(b)
}

// Refresh causes this blur to be redrawn with its configured state.
func (b *Blur) Refresh() {
Refresh(b)
}

// Resize on a blur updates the new size of this object.
func (b *Blur) Resize(s fyne.Size) {
if s == b.Size() {
return
}

b.baseObject.Resize(s)
}

// NewBlur returns a new Blur instance
func NewBlur(radius float32) *Blur {
return &Blur{
Radius: radius,
}
}
26 changes: 26 additions & 0 deletions canvas/blur_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package canvas_test

import (
"testing"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/test"
)

func TestBlur(t *testing.T) {
test.NewTempApp(t)
bg := canvas.NewImageFromFile("testdata/Utah_teapot.png")
b1 := canvas.NewBlur(35)
w := test.NewTempWindow(t, container.NewWithoutLayout(bg, b1))
w.SetPadded(false)
size := fyne.NewSize(300, 243)
bg.Resize(size)
w.Resize(size)

b1.Move(fyne.NewPos(120, 110))
b1.Resize(fyne.NewSize(140, 100))

test.AssertRendersToImage(t, "blur.png", w.Canvas())
}
Binary file added canvas/testdata/Utah_teapot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added canvas/testdata/blur.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions dialog/confirm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dialog

import (
"image/color"
"os"
"testing"

"fyne.io/fyne/v2"
Expand Down Expand Up @@ -129,3 +130,19 @@ func TestConfirm_Importance(t *testing.T) {
d.Show()
test.AssertRendersToImage(t, "dialog-confirm-importance.png", w.Canvas())
}

func TestConfirm_Importance_Blur(t *testing.T) {
test.NewTempApp(t)
code := widget.NewEntry()
data, _ := os.ReadFile("./testdata/Capitalised.txt")
code.SetText(string(data))
w := test.NewTempWindow(t, code)
size := fyne.NewSize(480, 320)
w.Resize(size)

d := NewConfirm("Delete me?", "This is dangerous!", nil, w)
d.SetConfirmImportance(widget.DangerImportance)

d.Show()
test.AssertRendersToImage(t, "dialog-confirm-blur.png", w.Canvas())
}
4 changes: 2 additions & 2 deletions dialog/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func TestFileFilters(t *testing.T) {
}

// NOTE: This count needs to be updated when more test images are added.
assert.Equal(t, 10, count)
assert.Equal(t, 11, count)

f.SetFilter(storage.NewMimeTypeFileFilter([]string{"image/jpeg"}))

Expand Down Expand Up @@ -468,7 +468,7 @@ func TestFileFilters(t *testing.T) {
}

// NOTE: This count needs to be updated when more test images are added.
assert.Equal(t, 11, count)
assert.Equal(t, 12, count)
}

func TestFileSort(t *testing.T) {
Expand Down
Binary file added dialog/testdata/dialog-confirm-blur.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions dialog/testdata/dialog-custom-custom-buttons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
</content>
<overlay>
<widget size="200x300" type="*widget.PopUp">
<blur radius="1.5" size="200x300"/>
<widget pos="19,74" size="161x150" type="*widget.Shadow">
<radialGradient centerOffset="0.5,0.5" pos="-19,-14" size="24x24" startColor="shadow"/>
<linearGradient endColor="shadow" pos="4,-14" size="152x24"/>
Expand Down
1 change: 1 addition & 0 deletions dialog/testdata/dialog-custom-no-buttons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
</content>
<overlay>
<widget size="200x300" type="*widget.PopUp">
<blur radius="1.5" size="200x300"/>
<widget pos="19,92" size="161x114" type="*widget.Shadow">
<radialGradient centerOffset="0.5,0.5" pos="-19,-14" size="24x24" startColor="shadow"/>
<linearGradient endColor="shadow" pos="4,-14" size="152x24"/>
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.19
require (
fyne.io/systray v1.11.1-0.20250603113521-ca66a66d8b58
github.com/BurntSushi/toml v1.5.0
github.com/anthonynsimon/bild v0.13.0
github.com/fogleman/gg v1.3.0
github.com/fredbi/uri v1.1.0
github.com/fsnotify/fsnotify v1.9.0
Expand Down
28 changes: 28 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw=
github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/anthonynsimon/bild v0.13.0 h1:mN3tMaNds1wBWi1BrJq0ipDBhpkooYfu7ZFSMhXt1C8=
github.com/anthonynsimon/bild v0.13.0/go.mod h1:tpzzp0aYkAsMi1zmfhimaDyX1xjn2OUc1AJZK/TF0AE=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -15,6 +22,7 @@ github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/fredbi/uri v1.1.0 h1:OqLpTXtyRg9ABReqvDGdJPqZUxs8cyBDOMXBbskCaB8=
github.com/fredbi/uri v1.1.0/go.mod h1:aYTUoAXBOq7BLfVJ8GnKmfcuURosB1xyHDIfWeC/iW4=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/fyne-io/gl-js v0.1.0 h1:8luJzNs0ntEAJo+8x8kfUOXujUlP8gB3QMOxO2mUdpM=
Expand Down Expand Up @@ -45,6 +53,8 @@ github.com/hack-pad/go-indexeddb v0.3.2 h1:DTqeJJYc1usa45Q5r52t01KhvlSN02+Oq+tQb
github.com/hack-pad/go-indexeddb v0.3.2/go.mod h1:QvfTevpDVlkfomY498LhstjwbPW6QC4VC/lxYb0Kom0=
github.com/hack-pad/safejs v0.1.0 h1:qPS6vjreAqh2amUqj4WNG1zIw7qlRQJ9K10eDKMCnE8=
github.com/hack-pad/safejs v0.1.0/go.mod h1:HdS+bKF1NrE72VoXZeWzxFOVQVUSqZJAG0xNCnb+Tio=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jackmordaunt/icns/v2 v2.2.6 h1:M7kg6pWRmB+SyCvM058cV2BlAz3MedOHy4e3j2i7FQg=
github.com/jackmordaunt/icns/v2 v2.2.6/go.mod h1:DqlVnR5iafSphrId7aSD06r3jg0KRC9V6lEBBp504ZQ=
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade h1:FmusiCI1wHw+XQbvL9M+1r/C3SPqKrmBaIOYwVfQoDE=
Expand All @@ -58,8 +68,11 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lucor/goinfo v0.9.0 h1:EdsMzmY5TZujA4xb9xMLIdlp2+zvF7miNYkVXvqqgOQ=
github.com/lucor/goinfo v0.9.0/go.mod h1:L6m6tN5Rlova5Z83h1ZaKsMP1iiaoZ9vGTNzu5QKOD4=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2 h1:YocNLcTBdEdvY3iDK6jfWXvEaM5OCKkjxPKoJRdB3Gg=
github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2/go.mod h1:76rfSfYPWj01Z85hUf/ituArm797mNKcvINh1OlsZKo=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A=
github.com/natefinch/atomic v1.0.1/go.mod h1:N/D/ELrljoqDyT3rZrsUmtsuzvHkeB/wWjHV22AZRbM=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
Expand All @@ -68,27 +81,40 @@ github.com/nicksnyder/go-i18n/v2 v2.5.1 h1:IxtPxYsR9Gp60cGXjfuR/llTqV8aYMsC472zD
github.com/nicksnyder/go-i18n/v2 v2.5.1/go.mod h1:DrhgsSDZxoAfvVrBVLXoxZn/pN5TXqaDbq7ju94viiQ=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/rymdport/portal v0.4.1 h1:2dnZhjf5uEaeDjeF/yBIeeRo6pNI2QAKm7kq1w/kbnA=
github.com/rymdport/portal v0.4.1/go.mod h1:kFF4jslnJ8pD5uCi17brj/ODlfIidOxlgUDTO5ncnC4=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c h1:km8GpoQut05eY3GiYWEedbTT0qnSxrCjsVbb7yKY1KE=
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c/go.mod h1:cNQ3dwVJtS5Hmnjxy6AgTPd0Inb3pW05ftPSX7NZO7Q=
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef h1:Ch6Q+AZUxDBCVqdkI8FSpFyZDtCVBc2VmejdNrm5rRQ=
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef/go.mod h1:nXTWP6+gD5+LUJ8krVhhoeHjvHTutPxMYl5SvkcnJNE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/urfave/cli/v2 v2.4.0 h1:m2pxjjDFgDxSPtO8WSdbndj17Wu2y8vOT86wE/tjr+I=
github.com/urfave/cli/v2 v2.4.0/go.mod h1:NX9W0zmTvedE5oDoOMs2RTC8RvdK98NTYZE5LbaEYPg=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ=
golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
Expand All @@ -101,6 +127,7 @@ golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -120,6 +147,7 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
1 change: 1 addition & 0 deletions internal/driver/mobile/gl/fn.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const (
glfnTexImage2D
glfnTexParameteri
glfnUniform1f
glfnUniform1fv
glfnUniform2f
glfnUniform4f
glfnUniform4fv
Expand Down
12 changes: 12 additions & 0 deletions internal/driver/mobile/gl/gl.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,18 @@ func (ctx *context) Uniform1f(dst Uniform, v float32) {
})
}

func (ctx *context) Uniform1fv(dst Uniform, src []float32) {
ctx.enqueue(call{
args: fnargs{
fn: glfnUniform1fv,
a0: dst.c(),
a1: uintptr(len(src)),
},
parg: unsafe.Pointer(&src[0]),
blocking: true,
})
}

func (ctx *context) Uniform2f(dst Uniform, v0, v1 float32) {
ctx.enqueue(call{
args: fnargs{
Expand Down
5 changes: 5 additions & 0 deletions internal/driver/mobile/gl/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ type Context interface {
// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
Uniform1f(dst Uniform, v float32)

// Uniform1fv writes a float array uniform variable.
//
// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
Uniform1fv(dst Uniform, v []float32)

// Uniform2f writes a vec2 uniform variable.
//
// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
Expand Down
3 changes: 3 additions & 0 deletions internal/driver/mobile/gl/work.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ uintptr_t processFn(struct fnargs* args, char* parg) {
case glfnUniform1f:
glUniform1f((GLint)args->a0, *(GLfloat*)&args->a1);
break;
case glfnUniform1fv:
glUniform1fv((GLint)args->a0, (GLsizeiptr)args->a1, (GLvoid*)parg);
break;
case glfnUniform2f:
glUniform2f((GLint)args->a0, *(GLfloat*)&args->a1, *(GLfloat*)&args->a2);
break;
Expand Down
1 change: 1 addition & 0 deletions internal/driver/mobile/gl/work.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ typedef enum {
glfnTexImage2D,
glfnTexParameteri,
glfnUniform1f,
glfnUniform1fv,
glfnUniform2f,
glfnUniform4f,
glfnUniform4fv,
Expand Down
5 changes: 5 additions & 0 deletions internal/driver/mobile/gl/work_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ var glfnMap = map[glfn]func(c call) (ret uintptr){
syscall.Syscall6(glUniform1f.Addr(), 2, c.args.a0, c.args.a1, c.args.a2, c.args.a3, c.args.a4, c.args.a5)
return
},
glfnUniform1fv: func(c call) (ret uintptr) {
syscall.Syscall(glUniform1fv.Addr(), 3, c.args.a0, c.args.a1, uintptr(c.parg))
return
},
glfnUniform2f: func(c call) (ret uintptr) {
syscall.Syscall6(glUniform2f.Addr(), 3, c.args.a0, c.args.a1, c.args.a2, c.args.a3, c.args.a4, c.args.a5)
return
Expand Down Expand Up @@ -335,6 +339,7 @@ var (
glTexImage2D = libGLESv2.NewProc("glTexImage2D")
glTexParameteri = libGLESv2.NewProc("glTexParameteri")
glUniform1f = libGLESv2.NewProc("glUniform1f")
glUniform1fv = libGLESv2.NewProc("glUniform1fv")
glUniform2f = libGLESv2.NewProc("glUniform2f")
glUniform4f = libGLESv2.NewProc("glUniform4f")
glUniform4fv = libGLESv2.NewProc("glUniform4fv")
Expand Down
17 changes: 16 additions & 1 deletion internal/painter/gl/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,29 @@ import (
type captureImage struct {
pix []uint8
width, height int

leftPad, rightPad, topPad, bottomPad int
}

func (c *captureImage) SubImage(inner image.Rectangle) *captureImage {
return &captureImage{
pix: c.pix,
width: c.width,
height: c.height,

leftPad: inner.Min.X,
topPad: inner.Min.Y,
rightPad: c.width - inner.Max.X,
bottomPad: c.height - inner.Max.Y,
}
}

func (c *captureImage) ColorModel() color.Model {
return color.RGBAModel
}

func (c *captureImage) Bounds() image.Rectangle {
return image.Rect(0, 0, c.width, c.height)
return image.Rect(c.leftPad, c.topPad, c.width-c.rightPad, c.height-c.bottomPad)
}

func (c *captureImage) At(x, y int) color.Color {
Expand Down
1 change: 1 addition & 0 deletions internal/painter/gl/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type context interface {
TexImage2D(target uint32, level, width, height int, colorFormat, typ uint32, data []uint8)
TexParameteri(target, param uint32, value int32)
Uniform1f(uniform Uniform, v float32)
Uniform1fv(uniform Uniform, v []float32)
Uniform2f(uniform Uniform, v0, v1 float32)
Uniform4f(uniform Uniform, v0, v1, v2, v3 float32)
UseProgram(program Program)
Expand Down
Loading
Loading