move SKPaint's defaults (that might be configurable) into a header
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 29 Feb 2012 13:03:00 +0000 (13:03 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 29 Feb 2012 13:03:00 +0000 (13:03 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@3280 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkStroke.h
src/core/SkPaint.cpp
src/core/SkPaintDefaults.h [new file with mode: 0644]
src/core/SkPathEffect.cpp
src/core/SkStroke.cpp

index d055b83..e5d69c4 100644 (file)
 struct SkRect;
 class SkPath;
 
-#define SK_DefaultStrokeWidth       SK_Scalar1
-#define SK_DefaultMiterLimit        SkIntToScalar(4)
-
-
 /** \class SkStroke
     SkStroke is the utility class that constructs paths by stroking
     geometries (lines, rects, ovals, roundrects, paths). This is
index 0578f3c..52d771e 100644 (file)
 #include "SkXfermode.h"
 #include "SkAutoKern.h"
 #include "SkGlyphCache.h"
+#include "SkPaintDefaults.h"
 
 // define this to get a printf for out-of-range parameter in setters
 // e.g. setTextSize(-1)
 //#define SK_REPORT_API_RANGE_CHECK
 
-#define SK_DefaultTextSize      SkIntToScalar(12)
-
-#define SK_DefaultFlags         0   //(kNativeHintsText_Flag)
-
 #ifdef SK_BUILD_FOR_ANDROID
 #define GEN_ID_INC                  fGenerationID++
 #define GEN_ID_INC_EVAL(expression) if (expression) { fGenerationID++; }
@@ -60,17 +57,17 @@ SkPaint::SkPaint() {
     fWidth      = 0;
 #endif
 
-    fTextSize   = SK_DefaultTextSize;
+    fTextSize   = SkPaintDefaults_TextSize;
     fTextScaleX = SK_Scalar1;
     fColor      = SK_ColorBLACK;
-    fMiterLimit = SK_DefaultMiterLimit;
-    fFlags      = SK_DefaultFlags;
+    fMiterLimit = SkPaintDefaults_MiterLimit;
+    fFlags      = SkPaintDefaults_Flags;
     fCapType    = kDefault_Cap;
     fJoinType   = kDefault_Join;
     fTextAlign  = kLeft_Align;
     fStyle      = kFill_Style;
     fTextEncoding = kUTF8_TextEncoding;
-    fHinting    = kNormal_Hinting;
+    fHinting    = SkPaintDefaults_Hinting;
 #ifdef SK_BUILD_FOR_ANDROID
     fGenerationID = 0;
 #endif
diff --git a/src/core/SkPaintDefaults.h b/src/core/SkPaintDefaults.h
new file mode 100644 (file)
index 0000000..3ea1cd3
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkPaintDefaults_DEFINED
+#define SkPaintDefaults_DEFINED
+
+#include "SkPaint.h"
+
+/**
+ *  Any of these can be specified by the build system (or SkUserConfig.h)
+ *  to change the default values for a SkPaint. This file should not be
+ *  edited directly.
+ */
+
+#ifndef SkPaintDefaults_Flags
+    #define SkPaintDefaults_Flags           0
+#endif
+
+#ifndef SkPaintDefaults_TextSize
+    #define SkPaintDefaults_TextSize        SkIntToScalar(12)
+#endif
+
+#ifndef SkPaintDefaults_Hinting
+    #define SkPaintDefaults_Hinting         SkPaint::kNormal_Hinting
+#endif
+
+#ifndef SkPaintDefaults_MiterLimit
+    #define SkPaintDefaults_MiterLimit      SkIntToScalar(4)
+#endif
+
+#endif
index 3e017e2..d81ac9f 100644 (file)
@@ -81,7 +81,7 @@ SkStrokePathEffect::SkStrokePathEffect(SkScalar width, SkPaint::Style style,
         : fWidth(width), fMiter(miter), fStyle(SkToU8(style)),
           fJoin(SkToU8(join)), fCap(SkToU8(cap)) {
     if (miter < 0) {  // signal they want the default
-        fMiter = SK_DefaultMiterLimit;
+        fMiter = SkIntToScalar(4);
     }
 }
 
index 8816de5..4b486b1 100644 (file)
@@ -472,11 +472,11 @@ void SkPathStroker::cubicTo(const SkPoint& pt1, const SkPoint& pt2,
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
 
-#include "SkPaint.h"
+#include "SkPaintDefaults.h"
 
 SkStroke::SkStroke() {
-    fWidth      = SK_DefaultStrokeWidth;
-    fMiterLimit = SK_DefaultMiterLimit;
+    fWidth      = SK_Scalar1;
+    fMiterLimit = SkPaintDefaults_MiterLimit;
     fCap        = SkPaint::kDefault_Cap;
     fJoin       = SkPaint::kDefault_Join;
     fDoFill     = false;