19e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com/*
29e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com * Copyright 2012 Google Inc.
39e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com *
49e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com * Use of this source code is governed by a BSD-style license that can be
59e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com * found in the LICENSE file.
69e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com */
7c682590538a27d73489bc91c098e000fdfb07ccfcaryclark@google.com#include "CurveIntersection.h"
8639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com#include "CubicIntersection_TestData.h"
927accef223a27fba437f5e825d99edbae20a045bcaryclark@google.com#include "Intersection_Tests.h"
10639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com
1127accef223a27fba437f5e825d99edbae20a045bcaryclark@google.comvoid CubicBezierClip_Test() {
12639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com    for (size_t index = 0; index < tests_count; ++index) {
13639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com        const Cubic& cubic1 = tests[index][0];
14639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com        const Cubic& cubic2 = tests[index][1];
15639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com        Cubic reduce1, reduce2;
1647d73daa7a971e7eee5822def7922f7d43b2dc47caryclark@google.com        int order1 = reduceOrder(cubic1, reduce1, kReduceOrder_NoQuadraticsAllowed,
1747d73daa7a971e7eee5822def7922f7d43b2dc47caryclark@google.com                kReduceOrder_TreatAsFill);
1847d73daa7a971e7eee5822def7922f7d43b2dc47caryclark@google.com        int order2 = reduceOrder(cubic2, reduce2, kReduceOrder_NoQuadraticsAllowed,
1947d73daa7a971e7eee5822def7922f7d43b2dc47caryclark@google.com                kReduceOrder_TreatAsFill);
20639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com        if (order1 < 4) {
21aa35831d1d0e4c798a63fe772430adc4f3a038cdcaryclark@google.com            SkDebugf("%s [%d] cubic1 order=%d\n", __FUNCTION__, (int) index, order1);
22639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com        }
23639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com        if (order2 < 4) {
24aa35831d1d0e4c798a63fe772430adc4f3a038cdcaryclark@google.com            SkDebugf("%s [%d] cubic2 order=%d\n", __FUNCTION__, (int) index, order2);
25639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com        }
26639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com        if (order1 == 4 && order2 == 4) {
27639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com            double minT = 0;
28639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com            double maxT = 1;
29639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com            bezier_clip(reduce1, reduce2, minT, maxT);
30639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com        }
31639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com    }
32639df891487e40925a4f8d9a34fd3dc0c18b40a7caryclark@google.com}
33