X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fview.h;h=cd9442020be07a3dafd71efa2b81ec18df24f444;hp=d99db6e7cfe1ca62f361a98230deb9099d1ef9cf;hb=ec45b44e3a44e12463c63ec09d63c648602ce866;hpb=e7066887c0d142ddef87ec9ae07ef08ff31573dc diff --git a/src/view.h b/src/view.h index d99db6e..cd94420 100644 --- a/src/view.h +++ b/src/view.h @@ -5,13 +5,27 @@ #include "document.h" #include "framebuffer.h" #include "objectrenderer.h" +#include "path.h" +#include "transformationtype.h" #define USE_GPU_TRANSFORM true #define USE_GPU_RENDERING true #define USE_SHADING !(USE_GPU_RENDERING) && true +#ifdef TRANSFORM_BEZIERS_TO_PATH +#include "gmprat.h" +#endif + namespace IPDF { + #ifdef TRANSFORM_BEZIERS_TO_PATH + #pragma message "View using Gmprat for bounds" + typedef Gmprat VReal; + #else + typedef Real VReal; + #endif + typedef TRect VRect; + class Screen; /** * The View class manages a rectangular view into the document. @@ -21,7 +35,7 @@ namespace IPDF class View { public: - 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)); + View(Document & document, Screen & screen, const VRect & bounds = VRect(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); @@ -32,13 +46,14 @@ namespace IPDF Rect TransformToViewCoords(const Rect& inp) const; - const Rect& GetBounds() const { return m_bounds; } + const VRect& GetBounds() const { return m_bounds; } const bool UsingGPUTransform() const { return m_use_gpu_transform; } // whether view transform calculated on CPU or GPU 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 SetGPUTransform(bool state) {m_use_gpu_transform = state; m_bounds_dirty = true; m_buffer_dirty = true;} void SetGPURendering(bool state) {m_use_gpu_rendering = state; m_bounds_dirty = true; m_buffer_dirty = true;} @@ -57,6 +72,16 @@ namespace IPDF void ForceBoundsDirty() {m_bounds_dirty = true;} void ForceBufferDirty() {m_buffer_dirty = true;} void ForceRenderDirty() {m_render_dirty = true;} + + void SetLazyRendering(bool state = true) {m_lazy_rendering = state;} + bool UsingLazyRendering() const {return m_lazy_rendering;} + + void SaveBMP(const char * filename) {if (UsingGPURendering()) SaveGPUBMP(filename); else SaveCPUBMP(filename);} + + void SaveCPUBMP(const char * filename); + void SaveGPUBMP(const char * filename); + + Document & Doc() {return m_document;} private: struct GPUObjBounds @@ -78,7 +103,7 @@ namespace IPDF Document & m_document; Screen & m_screen; FrameBuffer m_cached_display; - Rect m_bounds; + VRect m_bounds; Colour m_colour; // Stores the view bounds. @@ -100,6 +125,8 @@ namespace IPDF bool m_show_bezier_type; bool m_show_fill_points; bool m_show_fill_bounds; + + bool m_lazy_rendering;// don't redraw frames unless we need to #ifndef QUADTREE_DISABLED