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 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 80 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
81 if (NULL == fBG.get()) { | 81 if (NULL == fBG.get()) { |
82 static uint32_t kCheckerPixelData[] = { 0xFFFFFFFF, | 82 static uint32_t kCheckerPixelData[] = { 0xFFFFFFFF, |
83 0xFFCCCCCC, | 83 0xFFCCCCCC, |
84 0xFFCCCCCC, | 84 0xFFCCCCCC, |
85 0xFFFFFFFF }; | 85 0xFFFFFFFF }; |
86 SkBitmap bitmap; | 86 SkBitmap bitmap; |
87 bitmap.allocN32Pixels(2, 2); | 87 bitmap.allocN32Pixels(2, 2); |
88 memcpy(bitmap.getPixels(), kCheckerPixelData, sizeof(kCheckerPixelDa
ta)); | 88 memcpy(bitmap.getPixels(), kCheckerPixelData, sizeof(kCheckerPixelDa
ta)); |
| 89 SkMatrix lm; |
| 90 lm.setScale(SkIntToScalar(20), SkIntToScalar(20)); |
89 fBG.reset(SkShader::CreateBitmapShader(bitmap, | 91 fBG.reset(SkShader::CreateBitmapShader(bitmap, |
90 SkShader::kRepeat_TileMode, | 92 SkShader::kRepeat_TileMode, |
91 SkShader::kRepeat_TileMode)); | 93 SkShader::kRepeat_TileMode, |
| 94 &lm)); |
92 } | 95 } |
93 SkMatrix lm; | |
94 lm.setScale(SkIntToScalar(20), SkIntToScalar(20)); | |
95 fBG->setLocalMatrix(lm); | |
96 | 96 |
97 SkPaint bgPaint; | 97 SkPaint bgPaint; |
98 bgPaint.setShader(fBG.get()); | 98 bgPaint.setShader(fBG.get()); |
99 canvas->drawPaint(bgPaint); | 99 canvas->drawPaint(bgPaint); |
100 SkISize size = canvas->getDeviceSize(); | 100 SkISize size = canvas->getDeviceSize(); |
101 SkScalar maxScale = SkScalarSqrt((SkIntToScalar(size.fWidth * size.fHeig
ht))) / 300; | 101 SkScalar maxScale = SkScalarSqrt((SkIntToScalar(size.fWidth * size.fHeig
ht))) / 300; |
102 SkRandom random; | 102 SkRandom random; |
103 for (int i = 0; i < kNumShapes; ++i) { | 103 for (int i = 0; i < kNumShapes; ++i) { |
104 SkScalar s = random.nextRangeScalar(SK_Scalar1 / 8, SK_Scalar1) * ma
xScale; | 104 SkScalar s = random.nextRangeScalar(SK_Scalar1 / 8, SK_Scalar1) * ma
xScale; |
105 SkScalar r = random.nextRangeScalar(0, SkIntToScalar(360)); | 105 SkScalar r = random.nextRangeScalar(0, SkIntToScalar(360)); |
(...skipping 30 matching lines...) Expand all Loading... |
136 SkPath fConvexPath; | 136 SkPath fConvexPath; |
137 typedef GM INHERITED; | 137 typedef GM INHERITED; |
138 }; | 138 }; |
139 | 139 |
140 ////////////////////////////////////////////////////////////////////////////// | 140 ////////////////////////////////////////////////////////////////////////////// |
141 | 141 |
142 static GM* MyFactory(void*) { return new MixedXfermodesGM; } | 142 static GM* MyFactory(void*) { return new MixedXfermodesGM; } |
143 static GMRegistry reg(MyFactory); | 143 static GMRegistry reg(MyFactory); |
144 | 144 |
145 } | 145 } |
OLD | NEW |