X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fview.h;h=3d94a876f9609c7a66ee5ac290881c7ac1706673;hp=9a519b0317ec7f543179b81e87ed7066c6259536;hb=a851cf197844a2eb15fd5ee2c350ee296e415dca;hpb=b006386ab52e8a2c47c20bc21591d01c314d4d8e;ds=sidebyside diff --git a/src/view.h b/src/view.h index 9a519b0..3d94a87 100644 --- a/src/view.h +++ b/src/view.h @@ -3,20 +3,50 @@ #include "ipdf.h" #include "document.h" +#include "graphicsbuffer.h" +#include "framebuffer.h" +#include "shaderprogram.h" namespace IPDF { class View { public: - View(Document & document) : m_document(document), m_bounds(0,0,1,1) {} + View(Document & document, const Rect & bounds = Rect(0,0,1,1), const Colour & colour = Colour(0.f,0.f,0.f,1.f)) + : m_colour(colour), m_use_gpu_transform(false), m_bounds_dirty(true), m_buffer_dirty(true), m_document(document), m_bounds(bounds) + { + Debug("View Created - Bounds => {%s}", m_bounds.Str().c_str()); + } virtual ~View() {} - void Render(); + void Render(int width = 0, int height = 0); + + void Translate(Real x, Real y); + void ScaleAroundPoint(Real x, Real y, Real scaleAmt); + + Rect TransformToViewCoords(const Rect& inp) const; + + const Rect& GetBounds() const { return m_bounds; } + + const bool UsingGPUTransform() const { return m_use_gpu_transform; } + void ToggleGPUTransform() { m_use_gpu_transform = (!m_use_gpu_transform); m_bounds_dirty = true; m_buffer_dirty = true; } private: + void ReRender(); + void DrawGrid(); + bool m_use_gpu_transform; + bool m_bounds_dirty; + bool m_buffer_dirty; + ShaderProgram m_rect_shader; + GraphicsBuffer m_bounds_ubo; + GraphicsBuffer m_vertex_buffer; + GraphicsBuffer m_index_buffer; + FrameBuffer m_cached_display; Document & m_document; Rect m_bounds; + Colour m_colour; + uint32_t m_rendered_filled; + uint32_t m_rendered_outline; }; }