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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkColorShader.h" | 9 #include "SkColorShader.h" |
10 #include "SkEmptyShader.h" | 10 #include "SkEmptyShader.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 { SkIntToScalar(10), 0 } | 135 { SkIntToScalar(10), 0 } |
136 }; | 136 }; |
137 SkColor colors[] = { SK_ColorBLUE, SK_ColorBLUE }; | 137 SkColor colors[] = { SK_ColorBLUE, SK_ColorBLUE }; |
138 const SkScalar pos[] = { 0, SK_Scalar1 }; | 138 const SkScalar pos[] = { 0, SK_Scalar1 }; |
139 SkAutoTUnref<SkShader> s(SkGradientShader::CreateLinear(pts, | 139 SkAutoTUnref<SkShader> s(SkGradientShader::CreateLinear(pts, |
140 colors, | 140 colors, |
141 pos, | 141 pos, |
142 2, | 142 2, |
143 SkShader::kClamp_Til
eMode)); | 143 SkShader::kClamp_Til
eMode)); |
144 SkBitmap outBitmap; | 144 SkBitmap outBitmap; |
145 outBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 1); | 145 outBitmap.allocN32Pixels(10, 1); |
146 outBitmap.allocPixels(); | |
147 SkPaint paint; | 146 SkPaint paint; |
148 paint.setShader(s.get()); | 147 paint.setShader(s.get()); |
149 SkBitmapDevice device(outBitmap); | 148 SkCanvas canvas(outBitmap); |
150 SkCanvas canvas(&device); | |
151 canvas.drawPaint(paint); | 149 canvas.drawPaint(paint); |
152 SkAutoLockPixels alp(outBitmap); | 150 SkAutoLockPixels alp(outBitmap); |
153 for (int i = 0; i < 10; i++) { | 151 for (int i = 0; i < 10; i++) { |
154 // The following is commented out because it currently fails | 152 // The following is commented out because it currently fails |
155 // Related bug: https://code.google.com/p/skia/issues/detail?id=1098 | 153 // Related bug: https://code.google.com/p/skia/issues/detail?id=1098 |
156 | 154 |
157 // REPORTER_ASSERT(reporter, SK_ColorBLUE == outBitmap.getColor(i, 0)); | 155 // REPORTER_ASSERT(reporter, SK_ColorBLUE == outBitmap.getColor(i, 0)); |
158 } | 156 } |
159 } | 157 } |
160 | 158 |
(...skipping 28 matching lines...) Expand all Loading... |
189 | 187 |
190 for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) { | 188 for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) { |
191 gProcs[i](reporter, rec); | 189 gProcs[i](reporter, rec); |
192 } | 190 } |
193 } | 191 } |
194 | 192 |
195 DEF_TEST(Gradient, reporter) { | 193 DEF_TEST(Gradient, reporter) { |
196 TestGradientShaders(reporter); | 194 TestGradientShaders(reporter); |
197 TestConstantGradient(reporter); | 195 TestConstantGradient(reporter); |
198 } | 196 } |
OLD | NEW |