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

Side by Side Diff: samplecode/SampleArc.cpp

Issue 736583004: allow pictures to have a full bounds (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use new roundOut Created 6 years, 1 month 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 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 "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 19 matching lines...) Expand all
30 r.set(0, 0, 10, 10.5f); 30 r.set(0, 0, 10, 10.5f);
31 SkPath p, p2; 31 SkPath p, p2;
32 SkString str, str2; 32 SkString str, str2;
33 33
34 p.addRect(r); 34 p.addRect(r);
35 SkParsePath::ToSVGString(p, &str); 35 SkParsePath::ToSVGString(p, &str);
36 SkParsePath::FromSVGString(str.c_str(), &p2); 36 SkParsePath::FromSVGString(str.c_str(), &p2);
37 SkParsePath::ToSVGString(p2, &str2); 37 SkParsePath::ToSVGString(p2, &str2);
38 } 38 }
39 39
40 #include "SkPictureRecorder.h"
41 static void test_pictbounds(SkCanvas* canvas) {
42 SkRect r = SkRect::MakeXYWH(100, 50, 100, 100);
43 SkPictureRecorder recorder;
44 {
45 SkCanvas* c = recorder.beginRecording(r, NULL, 0);
46 c->drawOval(r, SkPaint());
47
48 SkIRect ir;
49 c->getClipDeviceBounds(&ir);
50 SkDebugf("devbounds [%d %d %d %d]\n", ir.left(), ir.top(), ir.right(), i r.bottom());
51
52 SkASSERT(!c->quickReject(r));
53 }
54 SkPicture* pic = recorder.endRecording();
55
56 canvas->drawPicture(pic);
57 SkASSERT(pic->cullRect() == r);
58 pic->unref();
59 }
60
40 class ArcsView : public SampleView { 61 class ArcsView : public SampleView {
41 class MyDrawable : public SkCanvasDrawable { 62 class MyDrawable : public SkCanvasDrawable {
42 SkRect fR; 63 SkRect fR;
43 SkScalar fSweep; 64 SkScalar fSweep;
44 public: 65 public:
45 MyDrawable(const SkRect& r) : fR(r), fSweep(0) { 66 MyDrawable(const SkRect& r) : fR(r), fSweep(0) {
46 } 67 }
47 68
48 void setSweep(SkScalar sweep) { 69 void setSweep(SkScalar sweep) {
49 if (fSweep != sweep) { 70 if (fSweep != sweep) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 190
170 draw_label(canvas, r, gAngles[i], gAngles[i+1]); 191 draw_label(canvas, r, gAngles[i], gAngles[i+1]);
171 192
172 canvas->translate(w * 8 / 7, 0); 193 canvas->translate(w * 8 / 7, 0);
173 } 194 }
174 195
175 canvas->restore(); 196 canvas->restore();
176 } 197 }
177 198
178 virtual void onDrawContent(SkCanvas* canvas) { 199 virtual void onDrawContent(SkCanvas* canvas) {
200 if (true) { test_pictbounds(canvas); return; }
f(malita) 2014/11/19 15:02:27 Disabling "Arcs" intentionally?
201
179 fDrawable->setSweep(SampleCode::GetAnimScalar(SkIntToScalar(360)/24, 202 fDrawable->setSweep(SampleCode::GetAnimScalar(SkIntToScalar(360)/24,
180 SkIntToScalar(360))); 203 SkIntToScalar(360)));
181 204
182 SkPaint paint; 205 SkPaint paint;
183 paint.setAntiAlias(true); 206 paint.setAntiAlias(true);
184 paint.setStrokeWidth(SkIntToScalar(2)); 207 paint.setStrokeWidth(SkIntToScalar(2));
185 paint.setStyle(SkPaint::kStroke_Style); 208 paint.setStyle(SkPaint::kStroke_Style);
186 209
187 drawRectWithLines(canvas, fRect, paint); 210 drawRectWithLines(canvas, fRect, paint);
188 211
(...skipping 17 matching lines...) Expand all
206 private: 229 private:
207 SkScalar fSweep; 230 SkScalar fSweep;
208 231
209 typedef SampleView INHERITED; 232 typedef SampleView INHERITED;
210 }; 233 };
211 234
212 ////////////////////////////////////////////////////////////////////////////// 235 //////////////////////////////////////////////////////////////////////////////
213 236
214 static SkView* MyFactory() { return new ArcsView; } 237 static SkView* MyFactory() { return new ArcsView; }
215 static SkViewRegister reg(MyFactory); 238 static SkViewRegister reg(MyFactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698