Use "Real" in CPU renderer for filled circles
authorSam Moore <[email protected]>
Tue, 29 Jul 2014 14:12:16 +0000 (22:12 +0800)
committerSam Moore <[email protected]>
Tue, 29 Jul 2014 14:12:16 +0000 (22:12 +0800)
src/objectrenderer.cpp
src/tests/arbint_vs_gmpint.cpp

index a5cd625..0770e46 100644 (file)
@@ -179,17 +179,16 @@ void CircleFilledRenderer::RenderUsingCPU(const Objects & objects, const View &
                {
                        for (int64_t y = max(0L, bounds.y); y <= min(bounds.y + bounds.h, target.h-1); ++y)
                        {
-                               double dx = 2.0*(double)(x - centre_x)/(double)(bounds.w);
-                               double dy = 2.0*(double)(y - centre_y)/(double)(bounds.h);
+                               Real dx(2); dx *= Real(x - centre_x)/Real(bounds.w);
+                               Real dy(2); dy *= Real(y - centre_y)/Real(bounds.h);
                                int64_t index = (x+target.w*y)*4;
                                
-                               if (dx*dx + dy*dy <= 1.0)
+                               if (dx*dx + dy*dy <= Real(1))
                                {
                                        target.pixels[index+0] = 0;
                                        target.pixels[index+1] = 0;
                                        target.pixels[index+2] = 0;
                                        target.pixels[index+3] = 255;
-
                                }
                        }
                }
index 306bbb7..a30758c 100644 (file)
@@ -7,13 +7,14 @@
 #include "gmpint.h"
 #include "arbint.h"
 
-#define TEST_CASES 100
+
 
 using namespace IPDF;
 
 int main(int argc, char ** argv)
 {
-       for (unsigned i = 0; i < TEST_CASES; ++i)
+       unsigned test_cases = (argc > 1) ? atoi(argv[1]) : 100;
+       for (unsigned i = 0; i < test_cases; ++i)
        {
                uint64_t a = rand();
        
@@ -28,6 +29,13 @@ int main(int argc, char ** argv)
                        gmp_a *= b;
                }
                
+               
+               for (unsigned j = 0; j < 5; ++j)
+               {
+                       arb_a += b;
+                       gmp_a += b;
+               }
+               
                for (unsigned j = 0; j < 5; ++j)
                {
                        arb_a /= b;
@@ -35,6 +43,11 @@ int main(int argc, char ** argv)
                }
                
                
+               for (unsigned j = 0; j < 5; ++j)
+               {
+                       arb_a -= b;
+                       gmp_a -= b;
+               }               
        }
        return 0;
 }

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