OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
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 "SkColor.h" | 8 #include "SkColor.h" |
9 #include "SkXfermode.h" | 9 #include "SkXfermode.h" |
10 #include "Test.h" | 10 #include "Test.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 if (xfer) { | 30 if (xfer) { |
31 reportedMode = (SkXfermode::Mode) -1; | 31 reportedMode = (SkXfermode::Mode) -1; |
32 REPORTER_ASSERT(reporter, xfer->asMode(&reportedMode)); | 32 REPORTER_ASSERT(reporter, xfer->asMode(&reportedMode)); |
33 REPORTER_ASSERT(reporter, reportedMode == mode); | 33 REPORTER_ASSERT(reporter, reportedMode == mode); |
34 xfer->unref(); | 34 xfer->unref(); |
35 } else { | 35 } else { |
36 REPORTER_ASSERT(reporter, SkXfermode::kSrcOver_Mode == mode); | 36 REPORTER_ASSERT(reporter, SkXfermode::kSrcOver_Mode == mode); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 SkXfermode* bogusXfer = new SkProcXfermode(bogusXfermodeProc); | 40 SkXfermode* bogusXfer = SkProcXfermode::Create(bogusXfermodeProc); |
41 SkXfermode::Mode reportedMode = ILLEGAL_MODE; | 41 SkXfermode::Mode reportedMode = ILLEGAL_MODE; |
42 REPORTER_ASSERT(reporter, !bogusXfer->asMode(&reportedMode)); | 42 REPORTER_ASSERT(reporter, !bogusXfer->asMode(&reportedMode)); |
43 REPORTER_ASSERT(reporter, reportedMode == ILLEGAL_MODE); | 43 REPORTER_ASSERT(reporter, reportedMode == ILLEGAL_MODE); |
44 REPORTER_ASSERT(reporter, !SkXfermode::AsMode(bogusXfer, &reportedMode)); | 44 REPORTER_ASSERT(reporter, !SkXfermode::AsMode(bogusXfer, &reportedMode)); |
45 REPORTER_ASSERT(reporter, reportedMode == ILLEGAL_MODE); | 45 REPORTER_ASSERT(reporter, reportedMode == ILLEGAL_MODE); |
46 bogusXfer->unref(); | 46 bogusXfer->unref(); |
47 } | 47 } |
48 | 48 |
49 static void test_IsMode(skiatest::Reporter* reporter) { | 49 static void test_IsMode(skiatest::Reporter* reporter) { |
50 REPORTER_ASSERT(reporter, SkXfermode::IsMode(NULL, | 50 REPORTER_ASSERT(reporter, SkXfermode::IsMode(NULL, |
51 SkXfermode::kSrcOver_Mode)); | 51 SkXfermode::kSrcOver_Mode)); |
52 | 52 |
53 for (int i = 0; i <= SkXfermode::kLastMode; ++i) { | 53 for (int i = 0; i <= SkXfermode::kLastMode; ++i) { |
54 SkXfermode::Mode mode = (SkXfermode::Mode)i; | 54 SkXfermode::Mode mode = (SkXfermode::Mode)i; |
55 | 55 |
56 SkXfermode* xfer = SkXfermode::Create(mode); | 56 SkXfermode* xfer = SkXfermode::Create(mode); |
57 REPORTER_ASSERT(reporter, SkXfermode::IsMode(xfer, mode)); | 57 REPORTER_ASSERT(reporter, SkXfermode::IsMode(xfer, mode)); |
58 SkSafeUnref(xfer); | 58 SkSafeUnref(xfer); |
59 | 59 |
60 if (SkXfermode::kSrcOver_Mode != mode) { | 60 if (SkXfermode::kSrcOver_Mode != mode) { |
61 REPORTER_ASSERT(reporter, !SkXfermode::IsMode(NULL, mode)); | 61 REPORTER_ASSERT(reporter, !SkXfermode::IsMode(NULL, mode)); |
62 } | 62 } |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 DEF_TEST(Xfermode, reporter) { | 66 DEF_TEST(Xfermode, reporter) { |
67 test_asMode(reporter); | 67 test_asMode(reporter); |
68 test_IsMode(reporter); | 68 test_IsMode(reporter); |
69 } | 69 } |
OLD | NEW |