OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkCanvasStateUtils.h" | 9 #include "SkCanvasStateUtils.h" |
10 #include "SkDrawFilter.h" | 10 #include "SkDrawFilter.h" |
11 #include "SkError.h" | 11 #include "SkError.h" |
12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
13 #include "SkRRect.h" | 13 #include "SkRRect.h" |
14 #include "SkRect.h" | 14 #include "SkRect.h" |
15 #include "Test.h" | 15 #include "Test.h" |
16 | 16 |
17 static void test_complex_layers(skiatest::Reporter* reporter) { | 17 static void test_complex_layers(skiatest::Reporter* reporter) { |
18 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG | 18 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG |
19 const int WIDTH = 400; | 19 const int WIDTH = 400; |
20 const int HEIGHT = 400; | 20 const int HEIGHT = 400; |
21 const int SPACER = 10; | 21 const int SPACER = 10; |
22 | 22 |
23 SkRect rect = SkRect::MakeXYWH(SkIntToScalar(SPACER), SkIntToScalar(SPACER), | 23 SkRect rect = SkRect::MakeXYWH(SkIntToScalar(SPACER), SkIntToScalar(SPACER), |
24 SkIntToScalar(WIDTH-(2*SPACER)), | 24 SkIntToScalar(WIDTH-(2*SPACER)), |
25 SkIntToScalar((HEIGHT-(2*SPACER)) / 7)); | 25 SkIntToScalar((HEIGHT-(2*SPACER)) / 7)); |
26 | 26 |
27 const SkColorType colorTypes[] = { | 27 const SkColorType colorTypes[] = { |
28 kRGB_565_SkColorType, kN32_SkColorType | 28 kRGB_565_SkColorType, kN32_SkColorType |
29 }; | 29 }; |
30 const int configCount = sizeof(colorTypes) / sizeof(SkBitmap::Config); | |
31 | 30 |
32 const int layerAlpha[] = { 255, 255, 0 }; | 31 const int layerAlpha[] = { 255, 255, 0 }; |
33 const SkCanvas::SaveFlags flags[] = { SkCanvas::kARGB_NoClipLayer_SaveFlag, | 32 const SkCanvas::SaveFlags flags[] = { SkCanvas::kARGB_NoClipLayer_SaveFlag, |
34 SkCanvas::kARGB_ClipLayer_SaveFlag, | 33 SkCanvas::kARGB_ClipLayer_SaveFlag, |
35 SkCanvas::kARGB_NoClipLayer_SaveFlag | 34 SkCanvas::kARGB_NoClipLayer_SaveFlag |
36 }; | 35 }; |
37 REPORTER_ASSERT(reporter, sizeof(layerAlpha) == sizeof(flags)); | 36 REPORTER_ASSERT(reporter, sizeof(layerAlpha) == sizeof(flags)); |
38 const int layerCombinations = sizeof(layerAlpha) / sizeof(int); | 37 const int layerCombinations = sizeof(layerAlpha) / sizeof(int); |
39 | 38 |
40 for (int i = 0; i < configCount; ++i) { | 39 for (size_t i = 0; i < SK_ARRAY_COUNT(colorTypes); ++i) { |
41 SkBitmap bitmaps[2]; | 40 SkBitmap bitmaps[2]; |
42 for (int j = 0; j < 2; ++j) { | 41 for (int j = 0; j < 2; ++j) { |
43 bitmaps[j].allocPixels(SkImageInfo::Make(WIDTH, HEIGHT, | 42 bitmaps[j].allocPixels(SkImageInfo::Make(WIDTH, HEIGHT, |
44 colorTypes[i], | 43 colorTypes[i], |
45 kPremul_SkAlphaType)); | 44 kPremul_SkAlphaType)); |
46 | 45 |
47 SkCanvas canvas(bitmaps[j]); | 46 SkCanvas canvas(bitmaps[j]); |
48 | 47 |
49 canvas.drawColor(SK_ColorRED); | 48 canvas.drawColor(SK_ColorRED); |
50 | 49 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 #endif | 264 #endif |
266 } | 265 } |
267 | 266 |
268 DEF_TEST(CanvasState, reporter) { | 267 DEF_TEST(CanvasState, reporter) { |
269 test_complex_layers(reporter); | 268 test_complex_layers(reporter); |
270 test_complex_clips(reporter); | 269 test_complex_clips(reporter); |
271 test_draw_filters(reporter); | 270 test_draw_filters(reporter); |
272 test_soft_clips(reporter); | 271 test_soft_clips(reporter); |
273 test_saveLayer_clip(reporter); | 272 test_saveLayer_clip(reporter); |
274 } | 273 } |
OLD | NEW |