Skip to content

Commit

Permalink
Remove ManagedTexture from HttpImageView
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Dec 12, 2023
1 parent 75e96df commit 4c3f82d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Common/GPU/Vulkan/thin3d_vulkan.cpp
Expand Up @@ -1685,7 +1685,7 @@ void VKContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChanne
break;
}

boundTextures_[binding].clear();
boundTextures_[binding].reset(nullptr);
boundImageView_[binding] = renderManager_.BindFramebufferAsTexture(fb->GetFB(), binding, aspect, layer);
}

Expand Down
5 changes: 3 additions & 2 deletions Common/GPU/thin3d.h
Expand Up @@ -419,11 +419,12 @@ struct AutoRef {
return ptr != nullptr;
}

void clear() {
// Takes over ownership over newItem, so we don't need to AddRef it, the number of owners didn't change.
void reset(T *newItem) {
if (ptr) {
ptr->Release();
ptr = nullptr;
}
ptr = newItem;
}

T *ptr = nullptr;
Expand Down
10 changes: 6 additions & 4 deletions UI/Store.cpp
Expand Up @@ -112,7 +112,7 @@ class HttpImageFileView : public UI::View {
std::shared_ptr<http::Request> download_;

std::string textureData_;
std::unique_ptr<ManagedTexture> texture_;
Draw::AutoRef<Draw::Texture> texture_;
bool textureFailed_ = false;
float fixedSizeW_ = 0.0f;
float fixedSizeH_ = 0.0f;
Expand Down Expand Up @@ -154,7 +154,9 @@ void HttpImageFileView::SetFilename(std::string filename) {
if (!useIconCache_ && path_ != filename) {
textureFailed_ = false;
path_ = filename;
texture_.reset(nullptr);
if (texture_) {
texture_.reset(nullptr);
}
}
}

Expand All @@ -181,7 +183,7 @@ void HttpImageFileView::Draw(UIContext &dc) {
}

if (!textureData_.empty()) {
texture_ = CreateManagedTextureFromFileData(dc.GetDrawContext(), (const uint8_t *)(textureData_.data()), (int)textureData_.size(), DETECT, false, "store_icon");
texture_ = CreateTextureFromFileData(dc.GetDrawContext(), (const uint8_t *)(textureData_.data()), (int)textureData_.size(), DETECT, false, "store_icon");
if (!texture_)
textureFailed_ = true;
textureData_.clear();
Expand All @@ -198,7 +200,7 @@ void HttpImageFileView::Draw(UIContext &dc) {
if (useIconCache_) {
texture = g_iconCache.BindIconTexture(&dc, path_);
} else {
texture = texture_->GetTexture();
texture = texture_;
}

if (texture) {
Expand Down

0 comments on commit 4c3f82d

Please sign in to comment.