Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Side by Side Diff: gm/gradients.cpp

Issue 1734343004: add gm to illustrate bug (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "gm.h" 8 #include "gm.h"
9 #include "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 #include "SkLinearGradient.h" 10 #include "SkLinearGradient.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 } 297 }
298 298
299 private: 299 private:
300 bool fDither; 300 bool fDither;
301 301
302 typedef GM INHERITED; 302 typedef GM INHERITED;
303 }; 303 };
304 DEF_GM( return new GradientsDegenrate2PointGM(true); ) 304 DEF_GM( return new GradientsDegenrate2PointGM(true); )
305 DEF_GM( return new GradientsDegenrate2PointGM(false); ) 305 DEF_GM( return new GradientsDegenrate2PointGM(false); )
306 306
307 /* bug.skia.org/517
308 <canvas id="canvas"></canvas>
309 <script>
310 var c = document.getElementById("canvas");
311 var ctx = c.getContext("2d");
312 ctx.fillStyle = '#ff0';
313 ctx.fillRect(0, 0, 100, 50);
314
315 var g = ctx.createRadialGradient(200, 25, 20, 200, 25, 10);
316 g.addColorStop(0, '#0f0');
317 g.addColorStop(0.003, '#f00'); // 0.004 makes this work
318 g.addColorStop(1, '#ff0');
319 ctx.fillStyle = g;
320 ctx.fillRect(0, 0, 100, 50);
321 </script>
322 */
323
324 // should draw only green
325 DEF_SIMPLE_GM(small_color_stop, canvas, 100, 150) {
326 SkColor colors[] = { SK_ColorGREEN, SK_ColorRED, SK_ColorYELLOW };
327 SkScalar pos[] = { 0, 0.003f, SK_Scalar1 }; // 0.004f makes this work
328 SkPoint c0 = { 200, 25 };
329 SkScalar r0 = 20;
330 SkPoint c1 = { 200, 25 };
331 SkScalar r1 = 10;
332 SkShader* s = SkGradientShader::CreateTwoPointConical(c0, r0, c1, r1, colors ,
333 pos, SK_ARRAY_COUNT(po s),
334 SkShader::kClamp_TileM ode);
335 SkPaint paint;
336 paint.setColor(SK_ColorYELLOW);
337 canvas->drawRect(SkRect::MakeWH(100, 150), paint);
338 paint.setShader(s)->unref();
339 canvas->drawRect(SkRect::MakeWH(100, 150), paint);
340 }
341
342
307 /// Tests correctness of *optimized* codepaths in gradients. 343 /// Tests correctness of *optimized* codepaths in gradients.
308 344
309 class ClampedGradientsGM : public GM { 345 class ClampedGradientsGM : public GM {
310 public: 346 public:
311 ClampedGradientsGM(bool dither) : fDither(dither) {} 347 ClampedGradientsGM(bool dither) : fDither(dither) {}
312 348
313 protected: 349 protected:
314 SkString onShortName() { 350 SkString onShortName() {
315 return SkString(fDither ? "clamped_gradients" : "clamped_gradients_nodit her"); 351 return SkString(fDither ? "clamped_gradients" : "clamped_gradients_nodit her");
316 } 352 }
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 canvas->drawRect(SkRect::MakeXYWH(0, 0, 500, 500), p); 808 canvas->drawRect(SkRect::MakeXYWH(0, 0, 500, 500), p);
773 } 809 }
774 810
775 DEF_SIMPLE_GM(gradient_many_stops, canvas, 500, 500) { 811 DEF_SIMPLE_GM(gradient_many_stops, canvas, 500, 500) {
776 draw_many_stops(canvas, 0); 812 draw_many_stops(canvas, 0);
777 } 813 }
778 814
779 DEF_SIMPLE_GM(gradient_many_stops_4f, canvas, 500, 500) { 815 DEF_SIMPLE_GM(gradient_many_stops_4f, canvas, 500, 500) {
780 draw_many_stops(canvas, SkLinearGradient::kForce4fContext_PrivateFlag); 816 draw_many_stops(canvas, SkLinearGradient::kForce4fContext_PrivateFlag);
781 } 817 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698