Skip to content

Commit ed773f5

Browse files
DataBlobImpl: added constructor that takes vector
1 parent 44e81db commit ed773f5

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Common/interface/DataBlobImpl.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2024 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,6 +49,7 @@ class DataBlobImpl final : public Diligent::ObjectBase<IDataBlob>
4949

5050
static RefCntAutoPtr<DataBlobImpl> Create(size_t InitialSize = 0, const void* pData = nullptr);
5151
static RefCntAutoPtr<DataBlobImpl> Create(IMemoryAllocator* pAllocator, size_t InitialSize = 0, const void* pData = nullptr);
52+
static RefCntAutoPtr<DataBlobImpl> Create(std::vector<Uint8, STDAllocatorRawMem<Uint8>>&& DataBuff) noexcept;
5253
static RefCntAutoPtr<DataBlobImpl> MakeCopy(const IDataBlob* pDataBlob);
5354

5455
~DataBlobImpl() override;
@@ -88,6 +89,9 @@ class DataBlobImpl final : public Diligent::ObjectBase<IDataBlob>
8889
size_t InitialSize = 0,
8990
const void* pData = nullptr);
9091

92+
DataBlobImpl(IReferenceCounters* pRefCounters,
93+
std::vector<Uint8, STDAllocatorRawMem<Uint8>>&& DataBuff) noexcept;
94+
9195
private:
9296
std::vector<Uint8, STDAllocatorRawMem<Uint8>> m_DataBuff;
9397
};

Common/src/DataBlobImpl.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2024 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -46,6 +46,11 @@ RefCntAutoPtr<DataBlobImpl> DataBlobImpl::Create(size_t InitialSize, const void*
4646
return Create(nullptr, InitialSize, pData);
4747
}
4848

49+
RefCntAutoPtr<DataBlobImpl> DataBlobImpl::Create(std::vector<Uint8, STDAllocatorRawMem<Uint8>>&& DataBuff) noexcept
50+
{
51+
return RefCntAutoPtr<DataBlobImpl>{MakeNewRCObj<DataBlobImpl>()(std::move(DataBuff))};
52+
}
53+
4954
RefCntAutoPtr<DataBlobImpl> DataBlobImpl::MakeCopy(const IDataBlob* pDataBlob)
5055
{
5156
if (pDataBlob == nullptr)
@@ -67,6 +72,13 @@ DataBlobImpl::DataBlobImpl(IReferenceCounters* pRefCounters,
6772
}
6873
}
6974

75+
DataBlobImpl::DataBlobImpl(IReferenceCounters* pRefCounters,
76+
std::vector<Uint8, STDAllocatorRawMem<Uint8>>&& DataBuff) noexcept :
77+
TBase{pRefCounters},
78+
m_DataBuff{std::move(DataBuff)}
79+
{
80+
}
81+
7082
DataBlobImpl::~DataBlobImpl()
7183
{}
7284

0 commit comments

Comments
 (0)