X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fview.h;h=5e30ef7f97aa8e7ba12ec64f24fff7b1fcf50183;hp=ee0fdcdb9adab8409609be79fa60cd727e1bbe6b;hb=836513d7874d20bec7247c6dfa8b3d2c426a71d4;hpb=f8ef964f021d1d6da6ea46bbb1fe8f0250a5be8c diff --git a/src/view.h b/src/view.h index ee0fdcd..5e30ef7 100644 --- a/src/view.h +++ b/src/view.h @@ -11,6 +11,7 @@ namespace IPDF { + class Screen; /** * The View class manages a rectangular view into the document. * It is responsible for coordinate transforms and rendering the document. @@ -19,7 +20,7 @@ namespace IPDF class View { public: - View(Document & document, const Rect & bounds = Rect(0,0,1,1), const Colour & colour = Colour(0.f,0.f,0.f,1.f)); + View(Document & document, Screen & screen, const Rect & bounds = Rect(0,0,1,1), const Colour & colour = Colour(0.f,0.f,0.f,1.f)); virtual ~View(); void Render(int width = 0, int height = 0); @@ -35,7 +36,13 @@ namespace IPDF const bool UsingGPURendering() const { return m_use_gpu_rendering; } // whether GPU shaders are used or CPU rendering void ToggleGPUTransform() { m_use_gpu_transform = (!m_use_gpu_transform); m_bounds_dirty = true; m_buffer_dirty = true; } void ToggleGPURendering() { m_use_gpu_rendering = (!m_use_gpu_rendering); m_bounds_dirty = true; m_buffer_dirty = true; } - + + + void ForceBoundsDirty() {m_bounds_dirty = true;} + void ForceBufferDirty() {m_buffer_dirty = true;} + void ForceRenderDirty() {m_render_dirty = true;} + + private: struct GPUObjBounds { @@ -46,12 +53,15 @@ namespace IPDF void PrepareRender(); // call when m_render_dirty is true void UpdateObjBoundsVBO(); // call when m_buffer_dirty is true + void RenderRange(int width, int height, unsigned first_obj, unsigned last_obj); + bool m_use_gpu_transform; bool m_use_gpu_rendering; bool m_bounds_dirty; // the view bounds has changed (occurs when changing view) bool m_buffer_dirty; // the object bounds have changed (also occurs when changing view, but only when not using GPU transforms) bool m_render_dirty; // the document has changed (occurs when document first loaded) Document & m_document; + Screen & m_screen; FrameBuffer m_cached_display; Rect m_bounds; Colour m_colour; @@ -64,7 +74,14 @@ namespace IPDF // ObjectRenderers to be initialised in constructor // Trust me it will be easier to generalise things this way. Even though there are pointers. std::vector m_object_renderers; - + uint8_t * m_cpu_rendering_pixels; // pixels to be used for CPU rendering + +#ifndef QUADTREE_DISABLED + QuadTreeIndex m_current_quadtree_node; // The highest node we will traverse. + int m_quadtree_max_depth; // The maximum quadtree depth. + void RenderQuadtreeNode(int width, int height, QuadTreeIndex node, int remaining_depth); + +#endif }; }