Blender V4.3
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
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#ifdef WITH_CXX_GUARDEDALLOC
24# include "MEM_guardedalloc.h"
25#endif
26
27namespace Freestyle {
28
29/**********************************/
30/* */
31/* */
32/* TextureManager */
33/* */
34/* */
35/**********************************/
36
39 public:
41 virtual ~TextureManager();
42
44 {
45 return _pInstance;
46 }
47
48 void load();
50
51 inline bool hasLoaded() const
52 {
53 return _hasLoadedTextures;
54 }
55
57 {
58 return _defaultTextureId;
59 }
60
61 struct Options {
62 static void setPatternsPath(const string &path);
63 static string getPatternsPath();
64
65 static void setBrushesPath(const string &path);
66 static string getBrushesPath();
67 };
68
69 protected:
70 virtual void loadStandardBrushes() = 0;
71 virtual uint loadBrush(string fileName, Stroke::MediumType = Stroke::OPAQUE_MEDIUM) = 0;
72
73 typedef std::pair<string, Stroke::MediumType> BrushTexture;
75 bool operator()(const BrushTexture &bt1, const BrushTexture &bt2) const
76 {
77 int r = strcmp(bt1.first.c_str(), bt2.first.c_str());
78 if (r != 0) {
79 return (r < 0);
80 }
81 else {
82 return (bt1.second < bt2.second);
83 }
84 }
85 };
86 typedef std::map<BrushTexture, uint, cmpBrushTexture> brushesMap;
87
91 static string _patterns_path;
92 static string _brushes_path;
94
95#ifdef WITH_CXX_GUARDEDALLOC
96 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:TextureManager")
97#endif
98};
99
100/**********************************/
101/* */
102/* */
103/* StrokeRenderer */
104/* */
105/* */
106/**********************************/
107
111 public:
113
115 virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const = 0;
116 virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const = 0;
117
118 // initializes the texture manager
119 // lazy, checks if it has already been done
120 static bool loadTextures();
121
122 // static uint getTextureIndex(uint index);
124
125#ifdef WITH_CXX_GUARDEDALLOC
126 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StrokeRenderer")
127#endif
128};
129
130} /* 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
static void setPatternsPath(const string &path)
static void setBrushesPath(const string &path)
bool operator()(const BrushTexture &bt1, const BrushTexture &bt2) const