From 836513d7874d20bec7247c6dfa8b3d2c426a71d4 Mon Sep 17 00:00:00 2001 From: David Gow Date: Mon, 14 Jul 2014 09:24:00 +0800 Subject: [PATCH] Quadtree transforms --- src/Makefile | 2 +- src/quadtree.h | 4 ++++ src/view.cpp | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 64408ed..ce6ac42 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,7 +3,7 @@ ARCH := $(shell uname -m) # TODO: stb_truetype doesn't compile with some of these warnings. CXX = g++ -std=gnu++0x -g -Wall -Werror -Wshadow -pedantic -rdynamic MAIN = main.o -OBJ = log.o real.o bezier.o document.o objectrenderer.o view.o screen.o vfpu.o graphicsbuffer.o framebuffer.o shaderprogram.o stb_truetype.o gl_core44.o add_digits_asm.o sub_digits_asm.o mul_digits_asm.o div_digits_asm.o arbint.o +OBJ = log.o real.o bezier.o document.o objectrenderer.o view.o screen.o vfpu.o quadtree.o graphicsbuffer.o framebuffer.o shaderprogram.o stb_truetype.o gl_core44.o add_digits_asm.o sub_digits_asm.o mul_digits_asm.o div_digits_asm.o arbint.o LIB_x86_64 = ../contrib/lib/libSDL2-2.0.so.0 -lGL -lgmp LIB_i386 = ../contrib/lib32/libSDL2-2.0.so.0 -lGL -lgmp diff --git a/src/quadtree.h b/src/quadtree.h index d5eddd8..29d60ba 100644 --- a/src/quadtree.h +++ b/src/quadtree.h @@ -6,6 +6,7 @@ #include "common.h" +#include "ipdf.h" namespace IPDF { @@ -46,6 +47,9 @@ namespace IPDF QuadTreeIndex root_id; std::vector nodes; }; + + Rect TransformToQuadChild(const Rect& src, QuadTreeNodeChildren child_type); + Rect TransformFromQuadChild(const Rect& src, QuadTreeNodeChildren child_type); } #else diff --git a/src/view.cpp b/src/view.cpp index 02859c5..aaf7aae 100644 --- a/src/view.cpp +++ b/src/view.cpp @@ -135,13 +135,20 @@ void View::Render(int width, int height) #ifndef QUADTREE_DISABLED void View::RenderQuadtreeNode(int width, int height, QuadTreeIndex node, int remaining_depth) { + Rect old_bounds = m_bounds; if (node == QUADTREE_EMPTY) return; if (!remaining_depth) return; RenderRange(width, height, m_document.GetQuadTree().nodes[node].object_begin, m_document.GetQuadTree().nodes[node].object_end); + + m_bounds = TransformToQuadChild(old_bounds, QTC_TOP_LEFT); RenderQuadtreeNode(width, height, m_document.GetQuadTree().nodes[node].top_left, remaining_depth-1); + m_bounds = TransformToQuadChild(old_bounds, QTC_TOP_RIGHT); RenderQuadtreeNode(width, height, m_document.GetQuadTree().nodes[node].top_right, remaining_depth-1); + m_bounds = TransformToQuadChild(old_bounds, QTC_BOTTOM_LEFT); RenderQuadtreeNode(width, height, m_document.GetQuadTree().nodes[node].bottom_left, remaining_depth-1); + m_bounds = TransformToQuadChild(old_bounds, QTC_BOTTOM_RIGHT); RenderQuadtreeNode(width, height, m_document.GetQuadTree().nodes[node].bottom_right, remaining_depth-1); + m_bounds = old_bounds; } #endif -- 2.20.1