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
Implement toGpuImage, a synchronous, GPU-resident version of #33736
Changes from 16 commits
67325b1
13a25bf
76b7e8e
86f9f1f
3bf1247
711479f
169de25
7aa625a
f727e50
0f0cf9f
e4fbe83
50793f3
edaaeb8
2864649
ea4d54d
ad9225c
f307e6f
b42bad6
c6e7abf
085b43e
a6389a2
dedd872
7c331a1
db97f79
6fe3223
7e6e3be
fbc66d9
1e22e7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,20 @@ class Scene extends NativeFieldWrapperClass1 { | |
@pragma('vm:entry-point') | ||
Scene._(); | ||
|
||
/// Creates a GPU resident image from this scene. | ||
/// | ||
/// {@macro dart.ui.painting.Picture.toGpuImage} | ||
Image toGpuImage(int width, int height) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not very sure how shall we use this new API to reuse expensive drawings across frames. Is there an example? Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, that would probably come at a higher level in the framework or in a package. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. I can contribute once I understand it. |
||
if (width <= 0 || height <= 0) { | ||
throw Exception('Invalid image dimensions.'); | ||
} | ||
|
||
final _Image image = _Image._(); | ||
_toGpuImage(width, height, image); | ||
return Image._(image, image.width, image.height); | ||
} | ||
void _toGpuImage(int width, int height, _Image outImage) native 'Scene_toGpuImage'; | ||
|
||
/// Creates a raster image representation of the current state of the scene. | ||
/// This is a slow operation that is performed on a background thread. | ||
/// | ||
|
@@ -35,7 +49,7 @@ class Scene extends NativeFieldWrapperClass1 { | |
if (image == null) { | ||
callback(null); | ||
} else { | ||
callback(Image._(image)); | ||
callback(Image._(image, image.width, image.height)); | ||
} | ||
}), | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The owning context of this image, not really whether. the owning context describes where this image is safe to use. though maybe that last part could be more defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done