Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Software Driver #4811

Draft
wants to merge 19 commits into
base: develop
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fyne-cross

### JetBrains
.idea
*.iml

### VSCode
.vscode
Expand Down
2 changes: 1 addition & 1 deletion app/app_darwin.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && !wasm && !test_web_driver
//go:build !ci && !software && !wasm && !test_web_driver

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_darwin.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci
//go:build !ci && !software

#import <Foundation/Foundation.h>
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
Expand Down
2 changes: 1 addition & 1 deletion app/app_darwin_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && !ios
//go:build !ci && !software && !ios

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_desktop_darwin.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && !ios && !wasm && !test_web_driver
//go:build !ci && !software && !ios && !wasm && !test_web_driver

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_desktop_darwin.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && !ios
//go:build !ci && !software && !ios

extern void themeChanged();

Expand Down
2 changes: 1 addition & 1 deletion app/app_gl.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && !android && !ios && !mobile
//go:build !ci && !software && !android && !ios && !mobile

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_goxjs.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && (!android || !ios || !mobile) && (wasm || test_web_driver)
//go:build !ci && !software && (!android || !ios || !mobile) && (wasm || test_web_driver)

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_mobile.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && (android || ios || mobile)
//go:build !ci && !software && (android || ios || mobile)

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_mobile_and.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && android
//go:build !ci && !software && android

#include <android/log.h>
#include <jni.h>
Expand Down
2 changes: 1 addition & 1 deletion app/app_mobile_and.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && android
//go:build !ci && !software && android

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_mobile_and_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && android
//go:build !ci && !software && android

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_mobile_ios.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && ios
//go:build !ci && !software && ios

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_mobile_ios.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && ios
//go:build !ci && !software && ios

#import <UIKit/UIKit.h>

Expand Down
2 changes: 1 addition & 1 deletion app/app_notlegacy_darwin.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && !legacy && !wasm && !test_web_driver
//go:build !ci && !software && !legacy && !wasm && !test_web_driver

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_openurl_wasm.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && wasm
//go:build !ci && !software && wasm

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_openurl_web.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && !wasm && test_web_driver
//go:build !ci && !software && !wasm && test_web_driver

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_other.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build ci || (!linux && !darwin && !windows && !freebsd && !openbsd && !netbsd && !wasm && !test_web_driver)
//go:build ci || software || (!linux && !darwin && !windows && !freebsd && !openbsd && !netbsd && !wasm && !test_web_driver)

package app

Expand Down
16 changes: 12 additions & 4 deletions app/app_software.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
//go:build ci
//go:build ci || software

package app

import (
"image"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/internal/painter/software"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/internal/driver/software"
painter "fyne.io/fyne/v2/internal/painter/software"
)

// NewWithID returns a new app instance using the test (headless) driver.
// The ID string should be globally unique to this app.
func NewWithID(id string) fyne.App {
return newAppWithDriver(test.NewDriverWithPainter(software.NewPainter()), id)
return newAppWithDriver(software.NewDriverWithPainter(painter.NewPainter()), id)
}

// NewWithSoftwareDriver returns a new app instance using the Software (custom) driver.
// The ID string should be globally unique to this app.
func NewWithSoftwareDriver(id string, painter func(image.Image), events chan any, transparent bool) fyne.App {
return newAppWithDriver(software.NewDriver(painter, events, transparent), id)
}
2 changes: 1 addition & 1 deletion app/app_theme_wasm.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && wasm
//go:build !ci && !software && wasm

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_theme_web.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && !wasm && test_web_driver
//go:build !ci && !software && !wasm && test_web_driver

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_windows.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && !android && !ios && !wasm && !test_web_driver
//go:build !ci && !software && !android && !ios && !wasm && !test_web_driver

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_windows_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && !android && !ios
//go:build !ci && !software && !android && !ios

package app

Expand Down
2 changes: 1 addition & 1 deletion app/app_xdg.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ci && !wasm && !test_web_driver && (linux || openbsd || freebsd || netbsd) && !android
//go:build !ci && !software && !wasm && !test_web_driver && (linux || openbsd || freebsd || netbsd) && !android

package app

Expand Down
7 changes: 5 additions & 2 deletions canvas/rectangle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/driver/software"
"fyne.io/fyne/v2/internal/cache"
canvas2 "fyne.io/fyne/v2/internal/driver/software"
painter "fyne.io/fyne/v2/internal/painter/software"
"fyne.io/fyne/v2/test"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -37,11 +39,12 @@ func TestRectangle_Radius(t *testing.T) {
rect.Resize(fyne.NewSize(50, 50))
test.AssertObjectRendersToMarkup(t, "rounded_rect.xml", rect)

c := software.NewCanvas()
c := canvas2.NewCanvasWithPainter(painter.NewPainter())
c.SetContent(rect)
c.Resize(fyne.NewSize(60, 60))
test.AssertRendersToImage(t, "rounded_rect_stroke.png", c)

rect.StrokeWidth = 0
cache.DeleteTexture(rect)
test.AssertRendersToImage(t, "rounded_rect.png", c)
}
5 changes: 3 additions & 2 deletions container/apptabs_desktop_flakey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/internal/driver/software"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/widget"
)
Expand All @@ -15,7 +16,7 @@ func TestAppTabs_ApplyTheme(t *testing.T) {
test.NewApp()
defer test.NewApp()

w := test.NewWindow(
w := software.NewWindow(
container.NewAppTabs(&container.TabItem{Text: "Test", Content: widget.NewLabel("Text")}),
)
defer w.Close()
Expand All @@ -36,7 +37,7 @@ func TestAppTabs_ChangeItemContent(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand Down
15 changes: 8 additions & 7 deletions container/apptabs_desktop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/internal/driver/software"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
Expand All @@ -23,7 +24,7 @@ func TestAppTabs_ChangeItemIcon(t *testing.T) {
item1 := &container.TabItem{Icon: theme.CancelIcon(), Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Icon: theme.ConfirmIcon(), Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -47,7 +48,7 @@ func TestAppTabs_ChangeItemText(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -70,7 +71,7 @@ func TestAppTabs_DynamicTabs(t *testing.T) {

item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text 1")}
tabs := container.NewAppTabs(item1)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(300, 150))
Expand Down Expand Up @@ -123,7 +124,7 @@ func TestAppTabs_HoverButtons(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand Down Expand Up @@ -151,7 +152,7 @@ func TestAppTabs_Layout(t *testing.T) {
test.NewApp()
defer test.NewApp()

w := test.NewWindow(nil)
w := software.NewWindow(nil)
defer w.Close()
w.SetPadded(false)
c := w.Canvas()
Expand Down Expand Up @@ -255,7 +256,7 @@ func TestAppTabs_SetTabLocation(t *testing.T) {
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text 2")}
item3 := &container.TabItem{Text: "Test3", Content: widget.NewLabel("Text 3")}
tabs := container.NewAppTabs(item1, item2, item3)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
c := w.Canvas()
Expand Down Expand Up @@ -288,7 +289,7 @@ func TestAppTabs_Tapped(t *testing.T) {
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text 2")}
item3 := &container.TabItem{Text: "Test3", Content: widget.NewLabel("Text 3")}
tabs := container.NewAppTabs(item1, item2, item3)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(200, 100))
Expand Down
5 changes: 3 additions & 2 deletions container/apptabs_mobile_flakey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/internal/driver/software"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/widget"
)
Expand All @@ -15,7 +16,7 @@ func TestAppTabs_ApplyTheme(t *testing.T) {
test.NewApp()
defer test.NewApp()

w := test.NewWindow(
w := software.NewWindow(
container.NewAppTabs(&container.TabItem{Text: "Test", Content: widget.NewLabel("Text")}),
)
defer w.Close()
Expand All @@ -36,7 +37,7 @@ func TestAppTabs_ChangeItemContent(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand Down
15 changes: 8 additions & 7 deletions container/apptabs_mobile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/internal/driver/software"
internalTest "fyne.io/fyne/v2/internal/test"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/theme"
Expand All @@ -24,7 +25,7 @@ func TestAppTabs_ChangeItemIcon(t *testing.T) {
item1 := &container.TabItem{Icon: theme.CancelIcon(), Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Icon: theme.ConfirmIcon(), Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -48,7 +49,7 @@ func TestAppTabs_ChangeItemText(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -71,7 +72,7 @@ func TestAppTabs_DynamicTabs(t *testing.T) {

item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text 1")}
tabs := container.NewAppTabs(item1)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(300, 150))
Expand Down Expand Up @@ -125,7 +126,7 @@ func TestAppTabs_HoverButtons(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -147,7 +148,7 @@ func TestAppTabs_Layout(t *testing.T) {
test.NewApp()
defer test.NewApp()

w := test.NewWindow(nil)
w := software.NewWindow(nil)
defer w.Close()
w.SetPadded(false)
c := w.Canvas()
Expand Down Expand Up @@ -251,7 +252,7 @@ func TestAppTabs_SetTabLocation(t *testing.T) {
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text 2")}
item3 := &container.TabItem{Text: "Test3", Content: widget.NewLabel("Text 3")}
tabs := container.NewAppTabs(item1, item2, item3)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
c := w.Canvas()
Expand Down Expand Up @@ -284,7 +285,7 @@ func TestAppTabs_Tapped(t *testing.T) {
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text 2")}
item3 := &container.TabItem{Text: "Test3", Content: widget.NewLabel("Text 3")}
tabs := container.NewAppTabs(item1, item2, item3)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(200, 100))
Expand Down
Loading
Loading