Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: src/core/SkStroke.cpp

Issue 1306443004: Use static_assert instead of SK_COMPILE_ASSERT. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkResourceCache.cpp ('k') | src/core/SkTextBlob.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2008 The Android Open Source Project 2 * Copyright 2008 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkStrokerPriv.h" 8 #include "SkStrokerPriv.h"
9 #include "SkGeometry.h" 9 #include "SkGeometry.h"
10 #include "SkPathPriv.h" 10 #include "SkPathPriv.h"
11 11
12 enum { 12 enum {
13 kTangent_RecursiveLimit, 13 kTangent_RecursiveLimit,
14 kCubic_RecursiveLimit, 14 kCubic_RecursiveLimit,
15 kConic_RecursiveLimit, 15 kConic_RecursiveLimit,
16 kQuad_RecursiveLimit 16 kQuad_RecursiveLimit
17 }; 17 };
18 18
19 // quads with extreme widths (e.g. (0,1) (1,6) (0,3) width=5e7) recurse to point of failure 19 // quads with extreme widths (e.g. (0,1) (1,6) (0,3) width=5e7) recurse to point of failure
20 // largest seen for normal cubics : 5, 26 20 // largest seen for normal cubics : 5, 26
21 // largest seen for normal quads : 11 21 // largest seen for normal quads : 11
22 static const int kRecursiveLimits[] = { 5*3, 26*3, 11*3, 11*3 }; // 3x limits se en in practice 22 static const int kRecursiveLimits[] = { 5*3, 26*3, 11*3, 11*3 }; // 3x limits se en in practice
23 23
24 SK_COMPILE_ASSERT(0 == kTangent_RecursiveLimit, cubic_stroke_relies_on_tangent_e qualling_zero); 24 static_assert(0 == kTangent_RecursiveLimit, "cubic_stroke_relies_on_tangent_equa lling_zero");
25 SK_COMPILE_ASSERT(1 == kCubic_RecursiveLimit, cubic_stroke_relies_on_cubic_equal ling_one); 25 static_assert(1 == kCubic_RecursiveLimit, "cubic_stroke_relies_on_cubic_equallin g_one");
26 SK_COMPILE_ASSERT(SK_ARRAY_COUNT(kRecursiveLimits) == kQuad_RecursiveLimit + 1, 26 static_assert(SK_ARRAY_COUNT(kRecursiveLimits) == kQuad_RecursiveLimit + 1,
27 recursive_limits_mismatch); 27 "recursive_limits_mismatch");
28 28
29 #ifdef SK_DEBUG 29 #ifdef SK_DEBUG
30 int gMaxRecursion[SK_ARRAY_COUNT(kRecursiveLimits)] = { 0 }; 30 int gMaxRecursion[SK_ARRAY_COUNT(kRecursiveLimits)] = { 0 };
31 #endif 31 #endif
32 #ifndef DEBUG_QUAD_STROKER 32 #ifndef DEBUG_QUAD_STROKER
33 #define DEBUG_QUAD_STROKER 0 33 #define DEBUG_QUAD_STROKER 0
34 #endif 34 #endif
35 35
36 #if DEBUG_QUAD_STROKER 36 #if DEBUG_QUAD_STROKER
37 /* Enable to show the decisions made in subdividing the curve -- helpful whe n the resulting 37 /* Enable to show the decisions made in subdividing the curve -- helpful whe n the resulting
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 } 537 }
538 SkScalar tValues[3]; 538 SkScalar tValues[3];
539 int count = SkFindCubicMaxCurvature(cubic, tValues); 539 int count = SkFindCubicMaxCurvature(cubic, tValues);
540 if (count == 0) { 540 if (count == 0) {
541 return kLine_ReductionType; 541 return kLine_ReductionType;
542 } 542 }
543 for (int index = 0; index < count; ++index) { 543 for (int index = 0; index < count; ++index) {
544 SkScalar t = tValues[index]; 544 SkScalar t = tValues[index];
545 SkEvalCubicAt(cubic, t, &reduction[index], NULL, NULL); 545 SkEvalCubicAt(cubic, t, &reduction[index], NULL, NULL);
546 } 546 }
547 SK_COMPILE_ASSERT(kQuad_ReductionType + 1 == kDegenerate_ReductionType, enum _out_of_whack); 547 static_assert(kQuad_ReductionType + 1 == kDegenerate_ReductionType, "enum_ou t_of_whack");
548 SK_COMPILE_ASSERT(kQuad_ReductionType + 2 == kDegenerate2_ReductionType, enu m_out_of_whack); 548 static_assert(kQuad_ReductionType + 2 == kDegenerate2_ReductionType, "enum_o ut_of_whack");
549 SK_COMPILE_ASSERT(kQuad_ReductionType + 3 == kDegenerate3_ReductionType, enu m_out_of_whack); 549 static_assert(kQuad_ReductionType + 3 == kDegenerate3_ReductionType, "enum_o ut_of_whack");
550 550
551 return (ReductionType) (kQuad_ReductionType + count); 551 return (ReductionType) (kQuad_ReductionType + count);
552 } 552 }
553 553
554 SkPathStroker::ReductionType SkPathStroker::CheckConicLinear(const SkConic& coni c, 554 SkPathStroker::ReductionType SkPathStroker::CheckConicLinear(const SkConic& coni c,
555 SkPoint* reduction) { 555 SkPoint* reduction) {
556 bool degenerateAB = degenerate_vector(conic.fPts[1] - conic.fPts[0]); 556 bool degenerateAB = degenerate_vector(conic.fPts[1] - conic.fPts[0]);
557 bool degenerateBC = degenerate_vector(conic.fPts[2] - conic.fPts[1]); 557 bool degenerateBC = degenerate_vector(conic.fPts[2] - conic.fPts[1]);
558 if (degenerateAB & degenerateBC) { 558 if (degenerateAB & degenerateBC) {
559 return kPoint_ReductionType; 559 return kPoint_ReductionType;
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 default: 1450 default:
1451 break; 1451 break;
1452 } 1452 }
1453 1453
1454 if (fWidth < SkMinScalar(rw, rh) && !fDoFill) { 1454 if (fWidth < SkMinScalar(rw, rh) && !fDoFill) {
1455 r = rect; 1455 r = rect;
1456 r.inset(radius, radius); 1456 r.inset(radius, radius);
1457 dst->addRect(r, reverse_direction(dir)); 1457 dst->addRect(r, reverse_direction(dir));
1458 } 1458 }
1459 } 1459 }
OLDNEW
« no previous file with comments | « src/core/SkResourceCache.cpp ('k') | src/core/SkTextBlob.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698