9e3017cc4033d159801923de87f04a375238a3f9
[ipdf/code.git] / src / view.h
1 #ifndef _VIEW_H
2 #define _VIEW_H
3
4 #include "ipdf.h"
5 #include "document.h"
6 #include "graphicsbuffer.h"
7 #include "framebuffer.h"
8 #include "shaderprogram.h"
9
10 namespace IPDF
11 {
12         class View
13         {
14                 public:
15                         View(Document & document, const Rect & bounds = Rect(0,0,1,1), const Colour & colour = Colour(0.f,0.f,0.f,1.f)) 
16                                 : m_use_gpu_transform(false), m_bounds_dirty(true), m_buffer_dirty(true), m_render_inited(false), m_document(document), m_bounds(bounds), m_colour(colour) 
17                         {
18                                 Debug("View Created - Bounds => {%s}", m_bounds.Str().c_str());
19                         }
20                         virtual ~View() {}
21
22                         void Render(int width = 0, int height = 0);
23                         
24                         void Translate(Real x, Real y);
25                         void ScaleAroundPoint(Real x, Real y, Real scaleAmt);
26                         
27                         Rect TransformToViewCoords(const Rect& inp) const;
28                         
29                         const Rect& GetBounds() const { return m_bounds; }
30                         
31                         const bool UsingGPUTransform() const { return m_use_gpu_transform; }
32                         void ToggleGPUTransform() { m_use_gpu_transform = (!m_use_gpu_transform); m_bounds_dirty = true; m_buffer_dirty = true; }
33                 
34                 private:
35                         void PrepareRender();
36                         void UpdateObjBoundsVBO();
37                         void DrawGrid();
38                         bool m_use_gpu_transform;
39                         bool m_bounds_dirty;
40                         bool m_buffer_dirty;
41                         bool m_render_inited;
42                         ShaderProgram m_rect_outline_shader;
43                         ShaderProgram m_rect_filled_shader;
44                         ShaderProgram m_circle_filled_shader;
45                         // Stores the view bounds.
46                         GraphicsBuffer m_bounds_ubo;
47                         // Stores the bounds for _all_ objects.
48                         GraphicsBuffer m_objbounds_vbo;
49                         // Stores indices into the objbounds vbo for each type of object.
50                         GraphicsBuffer m_outline_ibo;   // Rectangle outline
51                         GraphicsBuffer m_filled_ibo;    // Filled rectangle
52                         GraphicsBuffer m_circle_ibo;    // Filled circle
53                         FrameBuffer m_cached_display;
54                         Document & m_document;
55                         Rect m_bounds;
56                         Colour m_colour;
57                         uint32_t m_rendered_filled;
58                         uint32_t m_rendered_outline;
59                         uint32_t m_rendered_circle;
60         };
61 }
62
63 #endif //_VIEW_H

UCC git Repository :: git.ucc.asn.au