gfx/2d/unittest/TestCairo.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/
     3  */
     5 #include "cairo.h"
     7 #include "gtest/gtest.h"
     9 namespace mozilla {
    10 namespace layers {
    12 void TryCircle(double centerX, double centerY, double radius) {
    13   printf("TestCairo:TryArcs centerY %f, radius %f\n",centerY,radius);
    15   cairo_surface_t *surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,8,21);
    16   ASSERT_TRUE(surf != nullptr);
    18   cairo_t *cairo = cairo_create(surf);
    19   ASSERT_TRUE(cairo != nullptr);
    21   cairo_set_antialias(cairo, CAIRO_ANTIALIAS_NONE);
    22   cairo_arc(cairo, 0.0, centerY, radius, 0.0, 6.2831853071795862);
    23   cairo_fill_preserve(cairo);
    25   cairo_surface_destroy(surf);
    26   cairo_destroy(cairo);
    27 }
    29 TEST(Cairo, Simple) {
    30   TryCircle(0.0, 0.0, 14.0);
    31   TryCircle(0.0, 1.0, 22.4);
    32   TryCircle(1.0, 0.0, 1422.4);
    33   TryCircle(1.0, 1.0, 3422.4);
    34   TryCircle(-10.0, 1.0, -2);
    35 }
    37 TEST(Cairo, Bug825721) {
    38   // OK:
    39   TryCircle(0.0, 0.0, 8761126469220696064.0);
    40   TryCircle(0.0, 1.0, 8761126469220696064.0);
    42   // OK:
    43   TryCircle(1.0, 0.0, 5761126469220696064.0);
    45   // This was the crash in 825721.  Note that centerY has to be non-zero,
    46   // and radius has to be not only large, but in particular range.
    47   // 825721 has a band-aid fix, where the crash is inevitable, but does
    48   // not fix the cause.  The same code crashes in cairo standalone.
    49   TryCircle(0.0, 1.0, 5761126469220696064.0);
    50 }
    52 }
    53 }

mercurial