<commit_before>#include "Texture.h"
#include <cstdlib>

#include "SharedTextureCache.h"

namespace mural
{

Texture::Texture():
    textureStorage(nullptr),
    callback(nullptr),
    dimensionsKnown(false),
    width(0), height(0),
    fullPath(""),
    contentScale(1.0f),
    textureId(0)
{}

Texture::~Texture() {}

Texture *Texture::cachedTextureWithPath(String path, MuOperationQueue& queue, MuOperation callback)
{
    Texture *texture = nullptr;
    auto it = theTextureCache.textures.find(path);
    if (it != theTextureCache.textures.end()) {
        texture = it->second;
    }

    if (texture) {
        MuOperationQueue::defaultQueue().addBlockOperation(callback);
    }
    else {
        texture = new Texture();
        texture->initWithPath(path, queue, callback);
    }

    return texture;
}

Texture *Texture::initWithPath(String path, MuOperationQueue& queue, MuOperation initCallback)
{
    this->fullPath = path;
    this->loadCompleteCallback = initCallback;
    this->callback = [&] {
        bool result = this->loadPixelsFromPath(this->fullPath, this->data, this->width, this->height, false);

        std::this_thread::sleep_for(std::chrono::milliseconds(1000));

        if (result) {
            queue.addBlockOperation([&] {
                // printf("IMAGE: %s load completed\n", this->fullPath.c_str());
                this->dimensionsKnown = true;
                this->createWithPixels(this->data, GL_RGBA);<commit_msg>Disable manually delay of texture loading, which is for test only but not required any more<commit_after>#include "Texture.h"
#include <cstdlib>

#include "SharedTextureCache.h"

namespace mural
{

Texture::Texture():
    textureStorage(nullptr),
    callback(nullptr),
    dimensionsKnown(false),
    width(0), height(0),
    fullPath(""),
    contentScale(1.0f),
    textureId(0)
{}

Texture::~Texture() {}

Texture *Texture::cachedTextureWithPath(String path, MuOperationQueue& queue, MuOperation callback)
{
    Texture *texture = nullptr;
    auto it = theTextureCache.textures.find(path);
    if (it != theTextureCache.textures.end()) {
        texture = it->second;
    }

    if (texture) {
        MuOperationQueue::defaultQueue().addBlockOperation(callback);
    }
    else {
        texture = new Texture();
        texture->initWithPath(path, queue, callback);
    }

    return texture;
}

Texture *Texture::initWithPath(String path, MuOperationQueue& queue, MuOperation initCallback)
{
    this->fullPath = path;
    this->loadCompleteCallback = initCallback;
    this->callback = [&] {
        bool result = this->loadPixelsFromPath(this->fullPath, this->data, this->width, this->height, false);

        // std::this_thread::sleep_for(std::chrono::milliseconds(1000));

        if (result) {
            queue.addBlockOperation([&] {
                // printf("IMAGE: %s load completed\n", this->fullPath.c_str());
                this->dimensionsKnown = true;
                this->createWithPixels(this->data, GL_RGBA);
{'fraction_non_alphanumeric': 0.138656866020715, 'fraction_numerical': 0.006014032743067156, 'mean_word_length': 3.3454281567489113, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3715853', 'n_tokens_mistral': 896, 'n_tokens_neox': 875, 'n_words': 174}