Blender V5.0
StrokeRenderer.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
11
12#include <algorithm>
13#include <map>
14#include <string.h>
15#include <utility>
16#include <vector>
17
18#include "Stroke.h"
19#include "StrokeRep.h"
20
22
23#include "MEM_guardedalloc.h"
24
25namespace Freestyle {
26
27/**********************************/
28/* */
29/* */
30/* TextureManager */
31/* */
32/* */
33/**********************************/
34
37 public:
39 virtual ~TextureManager();
40
42 {
43 return _pInstance;
44 }
45
46 void load();
48
49 inline bool hasLoaded() const
50 {
51 return _hasLoadedTextures;
52 }
53
55 {
56 return _defaultTextureId;
57 }
58
59 struct Options {
60 static void setPatternsPath(const string &path);
61 static string getPatternsPath();
62
63 static void setBrushesPath(const string &path);
64 static string getBrushesPath();
65 };
66
67 protected:
68 virtual void loadStandardBrushes() = 0;
69 virtual uint loadBrush(string fileName, Stroke::MediumType = Stroke::OPAQUE_MEDIUM) = 0;
70
71 typedef std::pair<string, Stroke::MediumType> BrushTexture;
73 bool operator()(const BrushTexture &bt1, const BrushTexture &bt2) const
74 {
75 int r = strcmp(bt1.first.c_str(), bt2.first.c_str());
76 if (r != 0) {
77 return (r < 0);
78 }
79 else {
80 return (bt1.second < bt2.second);
81 }
82 }
83 };
84 typedef std::map<BrushTexture, uint, cmpBrushTexture> brushesMap;
85
89 static string _patterns_path;
90 static string _brushes_path;
92
93 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:TextureManager")
94};
95
96/**********************************/
97/* */
98/* */
99/* StrokeRenderer */
100/* */
101/* */
102/**********************************/
103
107 public:
109
111 virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const = 0;
112 virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const = 0;
113
114 // initializes the texture manager
115 // lazy, checks if it has already been done
116 static bool loadTextures();
117
118 // static uint getTextureIndex(uint index);
120
121 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StrokeRenderer")
122};
123
124} /* namespace Freestyle */
unsigned int uint
Configuration definitions.
Read Guarded memory(de)allocation.
Class to define the representation of a stroke (for display purpose).
Classes to define a stroke.
static TextureManager * _textureManager
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const =0
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const =0
static TextureManager * getInstance()
std::map< BrushTexture, uint, cmpBrushTexture > brushesMap
virtual uint loadBrush(string fileName, Stroke::MediumType=Stroke::OPAQUE_MEDIUM)=0
virtual void loadStandardBrushes()=0
static TextureManager * _pInstance
uint getBrushTextureIndex(string name, Stroke::MediumType iType=Stroke::OPAQUE_MEDIUM)
std::pair< string, Stroke::MediumType > BrushTexture
inherits from class Rep
Definition AppCanvas.cpp:20
const char * name
static void setPatternsPath(const string &path)
static void setBrushesPath(const string &path)
bool operator()(const BrushTexture &bt1, const BrushTexture &bt2) const