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

feat!: Make resource creation be on demand to enable testing #3411

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

luanpotter
Copy link
Member

Description

Make resource creation be on demand to enable testing.

Basically changes how the Resource class work:

  • resources are lazily loaded
  • the Resource class is responsible for re-creating resources when needed
  • children just provide the recreateResource boolean

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

@@ -10,6 +10,8 @@ import 'package:flutter_gpu/gpu.dart' as gpu;
///
/// {@endtemplate}
class ShaderResource extends Resource<gpu.Shader> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the new Resource design there is no longer a need to separate ShaderResource and Shader for testing purposes

one would be able to create a "Shader" in tests no problem as long as they don't call the .resource getter

if this new pattern is accepted, I can followup with updating this to be simpler as it was before

@luanpotter luanpotter changed the title feat!: Make resource creation be on demand to enable testing feat!: Make resource creation be on demand to enable testing [PROPOSAL] Dec 15, 2024
@luanpotter luanpotter force-pushed the luan.flame-3d-delayed-resources branch from 2447f54 to 4c5f726 Compare December 15, 2024 15:36
Copy link
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposal looks good to me!

@luanpotter luanpotter changed the title feat!: Make resource creation be on demand to enable testing [PROPOSAL] feat!: Make resource creation be on demand to enable testing Jan 7, 2025
@luanpotter luanpotter marked this pull request as ready for review January 7, 2025 20:06
Copy link
Contributor

github-actions bot commented Jan 7, 2025

Benchmark Results

Package flame:

  • Current Branch [luan.flame-3d-delayed-resources]: 2681.906 μs
  • Base Branch [main]: 2605.297 μs
  • Diff: 🔴 +2.941 %

Benchmarks provided with 💙 by Dart Benchmark Action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants