OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkBenchmark.h" | 9 #include "SkBenchmark.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 SkASSERT(NULL != xferMode); | 28 SkASSERT(NULL != xferMode); |
29 fXfermode.reset(xferMode); | 29 fXfermode.reset(xferMode); |
30 fName.printf("Xfermode_%s", name); | 30 fName.printf("Xfermode_%s", name); |
31 } | 31 } |
32 | 32 |
33 protected: | 33 protected: |
34 virtual const char* onGetName() SK_OVERRIDE { return fName.c_str(); } | 34 virtual const char* onGetName() SK_OVERRIDE { return fName.c_str(); } |
35 | 35 |
36 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 36 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
37 SkISize size = canvas->getDeviceSize(); | 37 SkISize size = canvas->getDeviceSize(); |
38 SkMWCRandom random; | 38 SkRandom random; |
39 for (int i = 0; i < kNumRects; ++i) { | 39 for (int i = 0; i < kNumRects; ++i) { |
40 SkPaint paint; | 40 SkPaint paint; |
41 paint.setXfermode(fXfermode.get()); | 41 paint.setXfermode(fXfermode.get()); |
42 paint.setColor(random.nextU()); | 42 paint.setColor(random.nextU()); |
43 SkScalar w = random.nextRangeScalar(SkIntToScalar(kMinSize), SkIntTo
Scalar(kMaxSize)); | 43 SkScalar w = random.nextRangeScalar(SkIntToScalar(kMinSize), SkIntTo
Scalar(kMaxSize)); |
44 SkScalar h = random.nextRangeScalar(SkIntToScalar(kMinSize), SkIntTo
Scalar(kMaxSize)); | 44 SkScalar h = random.nextRangeScalar(SkIntToScalar(kMinSize), SkIntTo
Scalar(kMaxSize)); |
45 SkRect rect = SkRect::MakeXYWH( | 45 SkRect rect = SkRect::MakeXYWH( |
46 random.nextUScalar1() * (size.fWidth - w), | 46 random.nextUScalar1() * (size.fWidth - w), |
47 random.nextUScalar1() * (size.fHeight - h), | 47 random.nextUScalar1() * (size.fHeight - h), |
48 w, | 48 w, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 BENCH(SkXfermode::kExclusion_Mode) | 100 BENCH(SkXfermode::kExclusion_Mode) |
101 BENCH(SkXfermode::kMultiply_Mode) | 101 BENCH(SkXfermode::kMultiply_Mode) |
102 | 102 |
103 BENCH(SkXfermode::kHue_Mode) | 103 BENCH(SkXfermode::kHue_Mode) |
104 BENCH(SkXfermode::kSaturation_Mode) | 104 BENCH(SkXfermode::kSaturation_Mode) |
105 BENCH(SkXfermode::kColor_Mode) | 105 BENCH(SkXfermode::kColor_Mode) |
106 BENCH(SkXfermode::kLuminosity_Mode) | 106 BENCH(SkXfermode::kLuminosity_Mode) |
107 | 107 |
108 BENCH(SkLumaMaskXfermode::Create(SkXfermode::kSrcIn_Mode), "SrcInLuma") | 108 BENCH(SkLumaMaskXfermode::Create(SkXfermode::kSrcIn_Mode), "SrcInLuma") |
109 BENCH(SkLumaMaskXfermode::Create(SkXfermode::kDstIn_Mode), "DstInLuma") | 109 BENCH(SkLumaMaskXfermode::Create(SkXfermode::kDstIn_Mode), "DstInLuma") |
OLD | NEW |