Luanti 5.15.0-dev
 
Loading...
Searching...
No Matches
imagesource.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include <IImage.h>
8#include <unordered_map>
9#include <set>
10#include <string>
11
12
13// This file is only used for internal generation of images.
14// Use texturesource.h to handle textures.
15
16// A cache used for storing source images.
17// (A "source image" is an unmodified image directly taken from the filesystem.)
18// Does not contain modified images.
20public:
22
23 void insert(const std::string &name, video::IImage *img, bool prefer_local);
24
25 video::IImage* get(const std::string &name);
26
27 // Primarily fetches from cache, secondarily tries to read from filesystem.
28 video::IImage *getOrLoad(const std::string &name);
29private:
30 std::unordered_map<std::string, video::IImage*> m_images;
31};
32
33// Generates images using texture modifiers, and caches source images.
36
42 video::IImage* generateImage(std::string_view name, std::set<std::string> &source_image_names);
43
44 // Insert a source image into the cache without touching the filesystem.
45 void insertSourceImage(const std::string &name, video::IImage *img, bool prefer_local);
46
47 // This was picked so that the image buffer size fits in an s32 (assuming 32bpp).
48 // The exact value is 23170 but this provides some leeway.
49 // In theory something like 33333x123 could be allowed, but there is no strong
50 // need or argument. Irrlicht also has the same limit.
51 static constexpr int MAX_IMAGE_DIMENSION = 23000;
52
53private:
54
55 // Generate image based on a string like "stone.png" or "[crack:1:0".
56 // If baseimg is NULL, it is created. Otherwise stuff is made on it.
57 // source_image_names is important to determine when to flush the image from a cache (dynamic media).
58 bool generateImagePart(std::string_view part_of_name, video::IImage *& baseimg,
59 std::set<std::string> &source_image_names);
60
61 // Cached settings needed for making textures from meshes
66
67 // Cache of source images
69};
Definition imagesource.h:19
video::IImage * get(const std::string &name)
Definition imagesource.cpp:64
void insert(const std::string &name, video::IImage *img, bool prefer_local)
Definition imagesource.cpp:31
video::IImage * getOrLoad(const std::string &name)
Definition imagesource.cpp:73
~SourceImageCache()
Definition imagesource.cpp:24
std::unordered_map< std::string, video::IImage * > m_images
Definition imagesource.h:30
Definition imagesource.h:34
bool m_setting_mipmap
Definition imagesource.h:62
bool m_setting_anisotropic_filter
Definition imagesource.h:65
bool generateImagePart(std::string_view part_of_name, video::IImage *&baseimg, std::set< std::string > &source_image_names)
Definition imagesource.cpp:981
video::IImage * generateImage(std::string_view name, std::set< std::string > &source_image_names)
Definition imagesource.cpp:1808
ImageSource()
Definition imagesource.cpp:1801
static constexpr int MAX_IMAGE_DIMENSION
Definition imagesource.h:51
SourceImageCache m_sourcecache
Definition imagesource.h:68
bool m_setting_bilinear_filter
Definition imagesource.h:64
void insertSourceImage(const std::string &name, video::IImage *img, bool prefer_local)
Definition imagesource.cpp:1921
bool m_setting_trilinear_filter
Definition imagesource.h:63