#include <EditorGradientPreviewRenderer.h>
Inherits AZ::Job.
Public Types | |
using | SampleFilterFunc = AZStd::function< float(float, const GradientSampleParams &)> |
Public Member Functions | |
AZ_CLASS_ALLOCATOR (EditorGradientPreviewUpdateJob, AZ::ThreadPoolAllocator) | |
EditorGradientPreviewUpdateJob (AZ::JobContext *context=nullptr) | |
bool | CancelAndWait () |
void | Wait () |
bool | ShouldRefreshUI () |
void | RefreshPreview (GradientSampler sampler, SampleFilterFunc filterFunc, QSize imageResolution, QImage *previewImage) |
Perform any main-thread and one-time setup needed to refresh the preview, then kick off the job. | |
void | Process () override |
Process runs exactly once for each time Start() is called on a Job, and processes on a Job worker thread. | |
EditorGradientPreviewUpdateJob offloads the creation of a gradient preview image to another thread. This is necessary for Editor responsiveness. With complex gradient hierarchies, large previews, and/or multiple gradient previews visible at the same time (like in Landscape Canvas), it's possible for the preview generation to take multiple seconds, or even minutes in degenerate data cases.
In offloading the work, we also incrementally update the preview via an adaptive interlacing scheme, similar to GIF or PNG interlacing, so that it becomes visible and usable even before the work has completed.
Implementation notes:
|
inline |
This enables our widget to know whenever the preview image has changed. We also clear the refreshUI flag here on polling, so that we only detect changes since the last time we asked. We don't rely on watching for the thread to be running, since it's possible for the thread to run and finish before we ever poll for the first time.