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

Side by Side Diff: gm/cubicpaths.cpp

Issue 1303873003: fix cubic clip in y (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix override Created 5 years, 4 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 | src/core/SkEdgeClipper.cpp » ('j') | 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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 typedef skiagm::GM INHERITED; 53 typedef skiagm::GM INHERITED;
54 }; 54 };
55 55
56 56
57 class ClippedCubic2GM : public skiagm::GM { 57 class ClippedCubic2GM : public skiagm::GM {
58 public: 58 public:
59 ClippedCubic2GM() {} 59 ClippedCubic2GM() {}
60 60
61 protected: 61 protected:
62 62
63 SkString onShortName() { 63 SkString onShortName() override {
64 return SkString("clippedcubic2"); 64 return SkString("clippedcubic2");
65 } 65 }
66 66
67 SkISize onISize() { return SkISize::Make(1240, 390); } 67 SkISize onISize() override { return SkISize::Make(1240, 390); }
68 68
69 void onDraw(SkCanvas* canvas) override { 69 void onDraw(SkCanvas* canvas) override {
70 canvas->save(); 70 canvas->save();
71 canvas->translate(-2, 20); 71 canvas->translate(-2, 120);
72 drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 80, 150)); 72 drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 80, 150));
73 canvas->translate(0, 170); 73 canvas->translate(0, 170);
74 drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 80, 100)); 74 drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 80, 100));
75 canvas->translate(0, 170); 75 canvas->translate(0, 170);
76 drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 30, 150)); 76 drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 30, 150));
77 canvas->translate(0, 170); 77 canvas->translate(0, 170);
78 drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 10, 150)); 78 drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 10, 150));
79 canvas->restore(); 79 canvas->restore();
80 canvas->save();
81 canvas->translate(20, -2);
82 drawOne(canvas, fFlipped, SkRect::MakeLTRB(0, 0, 150, 80));
83 canvas->translate(170, 0);
84 drawOne(canvas, fFlipped, SkRect::MakeLTRB(0, 0, 100, 80));
85 canvas->translate(170, 0);
86 drawOne(canvas, fFlipped, SkRect::MakeLTRB(0, 0, 150, 30));
87 canvas->translate(170, 0);
88 drawOne(canvas, fFlipped, SkRect::MakeLTRB(0, 0, 150, 10));
89 canvas->restore();
80 } 90 }
81 91
82 void drawOne(SkCanvas* canvas, const SkPath& path, const SkRect& clip) { 92 void drawOne(SkCanvas* canvas, const SkPath& path, const SkRect& clip) {
83 SkPaint framePaint, fillPaint; 93 SkPaint framePaint, fillPaint;
84 framePaint.setStyle(SkPaint::kStroke_Style); 94 framePaint.setStyle(SkPaint::kStroke_Style);
85 canvas->drawRect(clip, framePaint); 95 canvas->drawRect(clip, framePaint);
86 canvas->drawPath(path, framePaint); 96 canvas->drawPath(path, framePaint);
87 canvas->save(); 97 canvas->save();
88 canvas->clipRect(clip); 98 canvas->clipRect(clip);
89 canvas->drawPath(path, fillPaint); 99 canvas->drawPath(path, fillPaint);
90 canvas->restore(); 100 canvas->restore();
91 } 101 }
92 102
93 void onOnceBeforeDraw() override { 103 void onOnceBeforeDraw() override {
94 fPath.moveTo(69.7030518991886f, 0); 104 fPath.moveTo(69.7030518991886f, 0);
95 fPath.cubicTo( 69.7030518991886f, 21.831149999999997f, 105 fPath.cubicTo( 69.7030518991886f, 21.831149999999997f,
96 58.08369508178456f, 43.66448333333333f, 34.8449814469765f, 65.5f ); 106 58.08369508178456f, 43.66448333333333f, 34.8449814469765f, 65.5f );
97 fPath.cubicTo( 11.608591683531916f, 87.33115f, -0.010765133872116195f, 1 09.16448333333332f, 107 fPath.cubicTo( 11.608591683531916f, 87.33115f, -0.010765133872116195f, 1 09.16448333333332f,
98 -0.013089005235602302f, 131); 108 -0.013089005235602302f, 131);
99 fPath.close(); 109 fPath.close();
110 fFlipped = fPath;
111 SkMatrix matrix;
112 matrix.reset();
113 matrix.setScaleX(0);
114 matrix.setScaleY(0);
115 matrix.setSkewX(1);
116 matrix.setSkewY(1);
117 fFlipped.transform(matrix);
100 } 118 }
101 119
102 SkPath fPath; 120 SkPath fPath;
121 SkPath fFlipped;
103 private: 122 private:
104 typedef skiagm::GM INHERITED; 123 typedef skiagm::GM INHERITED;
105 }; 124 };
106 125
107 126
108 class CubicPathGM : public skiagm::GM { 127 class CubicPathGM : public skiagm::GM {
109 public: 128 public:
110 CubicPathGM() {} 129 CubicPathGM() {}
111 130
112 protected: 131 protected:
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 private: 412 private:
394 typedef skiagm::GM INHERITED; 413 typedef skiagm::GM INHERITED;
395 }; 414 };
396 415
397 ////////////////////////////////////////////////////////////////////////////// 416 //////////////////////////////////////////////////////////////////////////////
398 417
399 DEF_GM( return new CubicPathGM; ) 418 DEF_GM( return new CubicPathGM; )
400 DEF_GM( return new CubicClosePathGM; ) 419 DEF_GM( return new CubicClosePathGM; )
401 DEF_GM( return new ClippedCubicGM; ) 420 DEF_GM( return new ClippedCubicGM; )
402 DEF_GM( return new ClippedCubic2GM; ) 421 DEF_GM( return new ClippedCubic2GM; )
OLDNEW
« no previous file with comments | « no previous file | src/core/SkEdgeClipper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698