1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Direct2D: Do image cloning on GPU when possible

Co-authored-by: Matt Gonzalez <matt@echoaudio.com>
This commit is contained in:
Oli 2025-03-18 00:22:25 +00:00 committed by Oli
parent ae784a941e
commit bf940ae42a
2 changed files with 24 additions and 7 deletions

View file

@ -537,6 +537,28 @@ private:
bool initialState = extensions.isBackupEnabled(); bool initialState = extensions.isBackupEnabled();
}; };
ImagePixelData::Ptr Direct2DPixelData::clone()
{
auto device = getMostRelevantDevice();
auto* exts = getBackupExtensions();
if (device == nullptr || exts == nullptr || exts->isBackupEnabled())
return new Direct2DPixelData { backingData->clone(), State::drawn };
Ptr clonedPixelData = new Direct2DPixelData { pixelFormat, width, height, false };
const ScopedBackupDisabler scope { *this };
const ScopedBackupDisabler clonedScope { *clonedPixelData };
copyPages (device,
*clonedPixelData,
*this,
{ 0, 0 },
{ 0, 0, width, height });
return clonedPixelData;
}
void Direct2DPixelData::moveValidatedImageSection (Point<int> destTopLeft, Rectangle<int> sourceRect) void Direct2DPixelData::moveValidatedImageSection (Point<int> destTopLeft, Rectangle<int> sourceRect)
{ {
auto device = getMostRelevantDevice(); auto device = getMostRelevantDevice();

View file

@ -138,13 +138,8 @@ public:
~Direct2DPixelData() override; ~Direct2DPixelData() override;
/* Creates new software image storage with content matching the content of this image. /* Creates new image storage with content matching the content of this image. */
Does not copy any hardware resources. ImagePixelData::Ptr clone() override;
*/
ImagePixelData::Ptr clone() override
{
return new Direct2DPixelData (backingData->clone(), State::drawn);
}
std::unique_ptr<ImageType> createType() const override std::unique_ptr<ImageType> createType() const override
{ {