Reuse image data instead of fetching it every time off the GPU
This commit is contained in:
@@ -5,8 +5,9 @@
|
||||
#include "graphics/core/Texture.hpp"
|
||||
|
||||
gui::Canvas::Canvas(ImageFormat inFormat, glm::uvec2 inSize) : UINode(inSize) {
|
||||
ImageData data {inFormat, inSize.x, inSize.y};
|
||||
mTexture = Texture::from(&data);
|
||||
auto data = std::make_shared<ImageData>(inFormat, inSize.x, inSize.y);
|
||||
mTexture = Texture::from(data.get());
|
||||
mData = std::move(data);
|
||||
}
|
||||
|
||||
void gui::Canvas::draw(const DrawContext& pctx, const Assets& assets) {
|
||||
|
||||
@@ -15,11 +15,15 @@ namespace gui {
|
||||
|
||||
void draw(const DrawContext& pctx, const Assets& assets) override;
|
||||
|
||||
[[nodiscard]] std::shared_ptr<::Texture> texture() const {
|
||||
[[nodiscard]] auto texture() const {
|
||||
return mTexture;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto data() const {
|
||||
return mData;
|
||||
}
|
||||
private:
|
||||
std::shared_ptr<::Texture> mTexture;
|
||||
std::unique_ptr<ImageData> mData;
|
||||
std::shared_ptr<ImageData> mData;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user