vfs: check userland buffers before reading them.
[haiku.git] / src / apps / mandelbrot / FractalEngine.h
blob526987451e92f9f1504860f932a47ecbd00b2a8b
1 /*
2 * Copyright 2016, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT license.
5 * Authors:
6 * Augustin Cavalier <waddlesplash>
7 * kerwizzy
8 */
9 #ifndef FRACTALENGINE_H
10 #define FRACTALENGINE_H
12 #include <SupportDefs.h>
13 #include <Looper.h>
14 #include <Messenger.h>
16 class BBitmap;
19 class FractalEngine : public BLooper {
20 public:
21 enum {
22 MSG_CHANGE_SET = 'Frct',
23 MSG_SET_PALETTE,
24 MSG_SET_ITERATIONS,
25 MSG_RESIZE,
26 MSG_RENDER,
27 MSG_RENDER_COMPLETE,
30 FractalEngine(BHandler* parent, BLooper* looper);
31 ~FractalEngine();
33 virtual void MessageReceived(BMessage* msg);
35 private:
36 BMessenger fMessenger;
37 BBitmap* fBitmapStandby;
38 BBitmap* fBitmapDisplay;
40 uint8 fThreadCount;
41 thread_id fRenderThreads[4];
42 sem_id fRenderSem;
43 sem_id fRenderFinishedSem;
45 double fLocationX;
46 double fLocationY;
47 double fSize;
49 uint16 fIterations;
50 uint16 fWidth;
51 uint16 fHeight;
53 uint8* fRenderBuffer;
54 uint32 fRenderBufferLen;
56 const uint8* fColorset;
58 int32 (FractalEngine::*fDoSet)(double real, double imaginary);
60 void Render(double locationX, double locationY, double size);
61 static status_t RenderThread(void* data);
62 void RenderPixel(uint32 x, uint32 y, double real, double imaginary);
64 int32 DoSet_Mandelbrot(double real, double imaginary);
65 int32 DoSet_BurningShip(double real, double imaginary);
66 int32 DoSet_Tricorn(double real, double imaginary);
67 int32 DoSet_Julia(double real, double imaginary);
68 int32 DoSet_OrbitTrap(double real, double imaginary);
69 int32 DoSet_Multibrot(double real, double imaginary);
73 #endif /* FRACTALENGINE_H */