aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkPaint.h12
-rw-r--r--src/core/SkPaint.cpp35
-rw-r--r--tests/PaintTest.cpp31
3 files changed, 41 insertions, 37 deletions
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h
index 7a647f0ea2..e86d01195c 100644
--- a/include/core/SkPaint.h
+++ b/include/core/SkPaint.h
@@ -1046,6 +1046,10 @@ public:
private:
SkTypeface* fTypeface;
+ SkScalar fTextSize;
+ SkScalar fTextScaleX;
+ SkScalar fTextSkewX;
+
SkPathEffect* fPathEffect;
SkShader* fShader;
SkXfermode* fXfermode;
@@ -1056,12 +1060,10 @@ private:
SkImageFilter* fImageFilter;
SkAnnotation* fAnnotation;
- SkScalar fTextSize;
- SkScalar fTextScaleX;
- SkScalar fTextSkewX;
SkColor fColor;
SkScalar fWidth;
SkScalar fMiterLimit;
+
union {
struct {
// all of these bitfields should add up to 32
@@ -1076,11 +1078,11 @@ private:
};
uint32_t fBitfields;
};
- uint32_t fDirtyBits;
-
uint32_t getBitfields() const { return fBitfields; }
void setBitfields(uint32_t bitfields);
+ uint32_t fDirtyBits;
+
SkDrawCacheProc getDrawCacheProc() const;
SkMeasureCacheProc getMeasureCacheProc(TextBufferDirection dir,
bool needFullMetrics) const;
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index c91ada9a3c..2449ed6793 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -108,29 +108,18 @@ SkPaint::SkPaint() {
}
SkPaint::SkPaint(const SkPaint& src) {
-#define COPY(field) field = src.field
-#define REF_COPY(field) field = SkSafeRef(src.field)
- REF_COPY(fTypeface);
- REF_COPY(fPathEffect);
- REF_COPY(fShader);
- REF_COPY(fXfermode);
- REF_COPY(fMaskFilter);
- REF_COPY(fColorFilter);
- REF_COPY(fRasterizer);
- REF_COPY(fLooper);
- REF_COPY(fImageFilter);
- REF_COPY(fAnnotation);
-
- COPY(fTextSize);
- COPY(fTextScaleX);
- COPY(fTextSkewX);
- COPY(fColor);
- COPY(fWidth);
- COPY(fMiterLimit);
- COPY(fBitfields);
- COPY(fDirtyBits);
-#undef COPY
-#undef REF_COPY
+ memcpy(this, &src, sizeof(src));
+
+ SkSafeRef(fTypeface);
+ SkSafeRef(fPathEffect);
+ SkSafeRef(fShader);
+ SkSafeRef(fXfermode);
+ SkSafeRef(fMaskFilter);
+ SkSafeRef(fColorFilter);
+ SkSafeRef(fRasterizer);
+ SkSafeRef(fLooper);
+ SkSafeRef(fImageFilter);
+ SkSafeRef(fAnnotation);
#ifdef SK_BUILD_FOR_ANDROID
new (&fPaintOptionsAndroid) SkPaintOptionsAndroid(src.fPaintOptionsAndroid);
diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp
index f28dbe40e1..e7954b9136 100644
--- a/tests/PaintTest.cpp
+++ b/tests/PaintTest.cpp
@@ -59,11 +59,7 @@ static int find_first_zero(const uint16_t glyphs[], int count) {
return count;
}
-DEF_TEST(Paint_cmap, reporter) {
- // need to implement charsToGlyphs on other backends (e.g. linux, win)
- // before we can run this tests everywhere
- return;
-
+static void test_cmap(skiatest::Reporter* reporter) {
static const int NGLYPHS = 64;
SkUnichar src[NGLYPHS];
@@ -117,7 +113,7 @@ DEF_TEST(Paint_cmap, reporter) {
}
// temparary api for bicubic, just be sure we can set/clear it
-DEF_TEST(Paint_filterlevel, reporter) {
+static void test_filterlevel(skiatest::Reporter* reporter) {
SkPaint p0, p1;
REPORTER_ASSERT(reporter,
@@ -141,7 +137,7 @@ DEF_TEST(Paint_filterlevel, reporter) {
}
}
-DEF_TEST(Paint_copy, reporter) {
+static void test_copy(skiatest::Reporter* reporter) {
SkPaint paint;
// set a few member variables
paint.setStyle(SkPaint::kStrokeAndFill_Style);
@@ -196,7 +192,7 @@ DEF_TEST(Paint_copy, reporter) {
// found and fixed for webkit: mishandling when we hit recursion limit on
// mostly degenerate cubic flatness test
-DEF_TEST(Paint_regression_cubic, reporter) {
+static void regression_cubic(skiatest::Reporter* reporter) {
SkPath path, stroke;
SkPaint paint;
@@ -229,7 +225,7 @@ DEF_TEST(Paint_regression_cubic, reporter) {
}
// found and fixed for android: not initializing rect for string's of length 0
-DEF_TEST(Paint_regression_measureText, reporter) {
+static void regression_measureText(skiatest::Reporter* reporter) {
SkPaint paint;
paint.setTextSize(12.0f);
@@ -242,6 +238,23 @@ DEF_TEST(Paint_regression_measureText, reporter) {
REPORTER_ASSERT(reporter, r.isEmpty());
}
+DEF_TEST(Paint, reporter) {
+ // TODO add general paint tests
+ test_copy(reporter);
+
+ // regression tests
+ regression_cubic(reporter);
+ regression_measureText(reporter);
+
+ test_filterlevel(reporter);
+
+ // need to implement charsToGlyphs on other backends (e.g. linux, win)
+ // before we can run this tests everywhere
+ if (false) {
+ test_cmap(reporter);
+ }
+}
+
#define ASSERT(expr) REPORTER_ASSERT(r, expr)
DEF_TEST(Paint_FlatteningTraits, r) {