1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/2d/unittest/TestCairo.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.6 + */ 1.7 + 1.8 +#include "cairo.h" 1.9 + 1.10 +#include "gtest/gtest.h" 1.11 + 1.12 +namespace mozilla { 1.13 +namespace layers { 1.14 + 1.15 +void TryCircle(double centerX, double centerY, double radius) { 1.16 + printf("TestCairo:TryArcs centerY %f, radius %f\n",centerY,radius); 1.17 + 1.18 + cairo_surface_t *surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,8,21); 1.19 + ASSERT_TRUE(surf != nullptr); 1.20 + 1.21 + cairo_t *cairo = cairo_create(surf); 1.22 + ASSERT_TRUE(cairo != nullptr); 1.23 + 1.24 + cairo_set_antialias(cairo, CAIRO_ANTIALIAS_NONE); 1.25 + cairo_arc(cairo, 0.0, centerY, radius, 0.0, 6.2831853071795862); 1.26 + cairo_fill_preserve(cairo); 1.27 + 1.28 + cairo_surface_destroy(surf); 1.29 + cairo_destroy(cairo); 1.30 +} 1.31 + 1.32 +TEST(Cairo, Simple) { 1.33 + TryCircle(0.0, 0.0, 14.0); 1.34 + TryCircle(0.0, 1.0, 22.4); 1.35 + TryCircle(1.0, 0.0, 1422.4); 1.36 + TryCircle(1.0, 1.0, 3422.4); 1.37 + TryCircle(-10.0, 1.0, -2); 1.38 +} 1.39 + 1.40 +TEST(Cairo, Bug825721) { 1.41 + // OK: 1.42 + TryCircle(0.0, 0.0, 8761126469220696064.0); 1.43 + TryCircle(0.0, 1.0, 8761126469220696064.0); 1.44 + 1.45 + // OK: 1.46 + TryCircle(1.0, 0.0, 5761126469220696064.0); 1.47 + 1.48 + // This was the crash in 825721. Note that centerY has to be non-zero, 1.49 + // and radius has to be not only large, but in particular range. 1.50 + // 825721 has a band-aid fix, where the crash is inevitable, but does 1.51 + // not fix the cause. The same code crashes in cairo standalone. 1.52 + TryCircle(0.0, 1.0, 5761126469220696064.0); 1.53 +} 1.54 + 1.55 +} 1.56 +}