You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rnx #rb none #ROBOMERGE-OWNER: ryan.durand #ROBOMERGE-AUTHOR: ryan.durand #ROBOMERGE-SOURCE: CL 10869210 via CL 10869511 via CL 10869900 #ROBOMERGE-BOT: (v613-10869866) [CL 10870549 by ryan durand in Main branch]
93 lines
2.3 KiB
C++
93 lines
2.3 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "Misc/CoreDefines.h"
|
|
#include "HAL/CriticalSection.h"
|
|
#include "Templates/UniquePtr.h"
|
|
#include "Containers/ArrayView.h"
|
|
#include "ImagePixelData.h"
|
|
|
|
struct FImageStreamEndpoint;
|
|
|
|
/**
|
|
* A pipe that receives image data and forwards it onto 0 or more end points, copying the buffer as few times as possible
|
|
*/
|
|
struct IMAGEWRITEQUEUE_API FImagePixelPipe
|
|
{
|
|
/**
|
|
* Default constructor (an empty pipe)
|
|
*/
|
|
FImagePixelPipe()
|
|
{}
|
|
|
|
/**
|
|
* Define a new pipe with a single initial endpoint
|
|
*/
|
|
FImagePixelPipe(const TFunction<void(TUniquePtr<FImagePixelData>&&)>& InEndpoint)
|
|
{
|
|
AddEndpoint(InEndpoint);
|
|
}
|
|
|
|
/**
|
|
* Push the specified pixel data onto this pipe
|
|
*
|
|
* @param InImagePixelData The data to push through this pipe
|
|
*/
|
|
void Push(TUniquePtr<FImagePixelData>&& InImagePixelData);
|
|
|
|
/**
|
|
* Add a new end point handler to this pipe.
|
|
*
|
|
* @param InEndpoint The new endpoint to add. Potentially used on any thread.
|
|
*/
|
|
void AddEndpoint(TUniquePtr<FImageStreamEndpoint>&& InEndpoint);
|
|
|
|
/**
|
|
* Add a new end point handler to this pipe as a functor.
|
|
*
|
|
* @param InHandler A handler function implemented as an anonymous functor. Potentially called on any thread.
|
|
*/
|
|
void AddEndpoint(const TFunction<void(TUniquePtr<FImagePixelData>&& )>& InHandler);
|
|
|
|
/**
|
|
* Access this pipe's current set of end points.
|
|
* Warning: Not thread-safe - should only be called where no other modification to the end points can be happening.
|
|
*/
|
|
TArrayView<const TUniquePtr<FImageStreamEndpoint>> GetEndPoints() const
|
|
{
|
|
return EndPoints;
|
|
}
|
|
|
|
private:
|
|
|
|
/** A lock to protect the end points array */
|
|
FCriticalSection EndPointLock;
|
|
|
|
/** array of endpoints to be called in order */
|
|
TArray<TUniquePtr<FImageStreamEndpoint>> EndPoints;
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
* Stream end-point that receives a copy of image data from a thread
|
|
*/
|
|
struct IMAGEWRITEQUEUE_API FImageStreamEndpoint
|
|
{
|
|
virtual ~FImageStreamEndpoint(){}
|
|
|
|
/**
|
|
* Pipe the specified image data onto this end point
|
|
*
|
|
* @param InOwnedImage Image data to pass through this end point.
|
|
*/
|
|
void PipeImage(TUniquePtr<FImagePixelData>&& InOwnedImage);
|
|
|
|
private:
|
|
|
|
/**
|
|
* Implemented in derived classes to handle image data being received
|
|
*/
|
|
virtual void OnImageReceived(TUniquePtr<FImagePixelData>&& InOwnedImage) {}
|
|
}; |