-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFractalContext.h
97 lines (77 loc) · 2.6 KB
/
FractalContext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef _FRACTAL_CONTEXT_H_
#define _FRACTAL_CONTEXT_H_
#include "Evaluator.h"
#include "FractalContext.h"
#include <thread>
#include <condition_variable>
#include <shared_mutex>
class FractalContext {
public:
RelLocation CurrentLocation;
size_t ImageWidth, ImageHeight;
bool Zooming = false;
RelLocation RenderLocation;
double RemainingZoomTime;
size_t ThreadCount;
Evaluator *evaluator;
FractalTypeEnum CurrentFractalType = FractalTypeEnum::Mandelbrot;
bool UsingDE = true;
bool UsingLA = true;
#ifdef USE_BASIC_PIXEL_MANAGER
BasicPixelManager pixelManager;
#else
StandardPixelManager pixelManager;
#endif
bool ComputePixel = true, CenterChanged = true, EvaluationPending = true, LocationChanged = true;
bool RecomputeReference, ParameterChanged;
bool NeedReference = false;
Reference *reference = nullptr;
Evaluator *TaskEvaluator;
PixelManager *TaskRasterizer;
Reference *TaskReference;
std::shared_mutex TaskMutex;
std::condition_variable_any TaskConditionVariable;
bool TaskValid = false;
std::thread *worker = nullptr;
Coordinate CenterCoordinate;
std::thread ReferenceWorker;
Evaluator::ReferenceTask *ReferenceTask = nullptr;
ExecutionContext *ReferenceTaskContext = nullptr;
Task *EvaluationTask = nullptr;
ExecutionContext *EvaluationTaskContext = nullptr;
RelLocation PredictedCenter;
bool HasPredictedCenter = false;
Evaluator::Feature *Feature = nullptr;
SRReal Attraction;
RelLocation EvalLocation;
bool LockReference = false;
void UpdateRelativeCoordinate(HRReal OffsetX, HRReal OffsetY);
void FindFeature(SRReal CenterX, SRReal CenterY);
void ZoomIn(SRReal CenterX, SRReal CenterY);
void ZoomOut(HRReal CenterX, HRReal CenterY);
void Move(HRReal X, HRReal Y);
void ChangeLocation(RelLocation NewLocation);
void ZoomToAnimated(Coordinate newCenterCoordinate, size_t precision, HRReal halfH);
void SetLocation(Coordinate newCenterCoordinate, size_t precision, HRReal halfH);
void ChangeCenter();
void AsyncEvaluate(Evaluator *e, PixelManager *rasterizer, Reference *Reference);
bool IsIdle();
void CancelReferenceComputation();
void CancelPixelComputation();
void CancelAll();
FractalContext();
void Update();
void GetTextures(TextureDescription *TD, size_t NumDesired, size_t &NumObtained);
void PredictCenter(RelLocation NewCenter) {
PredictedCenter = NewCenter;
HasPredictedCenter = true;
}
void InvalidatePixel();
void InvalidateAll();
void SetResolution(int32_t width, int32_t height);
void ChangeFractalType(FractalTypeEnum FractalType, bool UseLinearApproximation);
void SetUseDE(bool UseDE);
void ResetLocation();
void InvalidateReference();
};
#endif