MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ to_image() [1/2]

std::shared_ptr< Core::VKImage > MayaFlux::Kakshya::WindowContainer::to_image ( ) const

Upload the full surface readback to a new VKImage.

Requires at least one completed readback (processed_data[0] non-empty and of type vector<uint8_t>). A fresh VKImage is created and uploaded on each call via TextureLoom; callers driving a per-frame path should prefer the staging-buffer overload to avoid per-call VkBuffer churn.

Returns
Newly created VKImage, or nullptr on failure.

Definition at line 177 of file WindowContainer.cpp.

178{
179 std::shared_lock lock(m_data_mutex);
180
181 if (m_processed_data.empty()) {
183 "WindowContainer::to_image : no readback data available for '{}'",
184 m_window->get_create_info().title);
185 return nullptr;
186 }
187
188 const auto* pixels = std::get_if<std::vector<uint8_t>>(&m_processed_data[0]);
189 if (!pixels || pixels->empty()) {
191 "WindowContainer::to_image : processed_data[0] is not uint8_t or is empty for '{}'",
192 m_window->get_create_info().title);
193 return nullptr;
194 }
195
196 const auto fmt = query_surface_format(m_window);
197 const auto img_fmt = surface_format_to_image_format(fmt);
198 const uint32_t w = m_structure.get_width();
199 const uint32_t h = m_structure.get_height();
200
202 w, h, img_fmt, pixels->data());
203
204 if (!img) {
206 "WindowContainer::to_image : TextureLoom::create_2d failed for '{}'",
207 m_window->get_create_info().title);
208 }
209
210 return img;
211}
#define MF_RT_WARN(comp, ctx,...)
#define MF_RT_ERROR(comp, ctx,...)
const std::vector< float > * pixels
Definition Decoder.cpp:58
uint32_t h
Definition InkPress.cpp:28
std::shared_ptr< Core::Window > m_window
void lock() override
Acquire a lock for thread-safe access.
std::vector< DataVariant > m_processed_data
std::shared_ptr< Core::VKImage > create_2d(uint32_t width, uint32_t height, ImageFormat format=ImageFormat::RGBA8, const void *data=nullptr, uint32_t mip_levels=1)
Create a 2D texture.
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
Core::GraphicsSurfaceInfo::SurfaceFormat query_surface_format(const std::shared_ptr< Core::Window > &window)
Query the actual vk::Format in use by the window's live swapchain, translated back to the MayaFlux su...
static uint64_t get_height(const std::vector< DataDimension > &dimensions)
Extract height from image/video dimensions.
static uint64_t get_width(const std::vector< DataDimension > &dimensions)
Extract width from image/video dimensions.

References MayaFlux::Journal::ContainerProcessing, MayaFlux::Portal::Graphics::TextureLoom::create_2d(), MayaFlux::Kakshya::ContainerDataStructure::get_height(), MayaFlux::Kakshya::ContainerDataStructure::get_width(), h, MayaFlux::Portal::Graphics::TextureLoom::instance(), MayaFlux::Journal::Kakshya, lock(), m_data_mutex, m_processed_data, m_structure, m_window, MF_RT_ERROR, MF_RT_WARN, pixels, and MayaFlux::Kakshya::query_surface_format().

+ Here is the call graph for this function: