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

Side by Side Diff: samplecode/SampleArc.cpp

Issue 722043005: Revert of allow pictures to have a full bounds (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« no previous file with comments | « include/core/SkPictureRecorder.h ('k') | src/core/SkBBHFactory.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 /* 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
61 class ArcsView : public SampleView { 40 class ArcsView : public SampleView {
62 class MyDrawable : public SkCanvasDrawable { 41 class MyDrawable : public SkCanvasDrawable {
63 SkRect fR; 42 SkRect fR;
64 SkScalar fSweep; 43 SkScalar fSweep;
65 public: 44 public:
66 MyDrawable(const SkRect& r) : fR(r), fSweep(0) { 45 MyDrawable(const SkRect& r) : fR(r), fSweep(0) {
67 } 46 }
68 47
69 void setSweep(SkScalar sweep) { 48 void setSweep(SkScalar sweep) {
70 if (fSweep != sweep) { 49 if (fSweep != sweep) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 169
191 draw_label(canvas, r, gAngles[i], gAngles[i+1]); 170 draw_label(canvas, r, gAngles[i], gAngles[i+1]);
192 171
193 canvas->translate(w * 8 / 7, 0); 172 canvas->translate(w * 8 / 7, 0);
194 } 173 }
195 174
196 canvas->restore(); 175 canvas->restore();
197 } 176 }
198 177
199 virtual void onDrawContent(SkCanvas* canvas) { 178 virtual void onDrawContent(SkCanvas* canvas) {
200 if (true) { test_pictbounds(canvas); return; }
201
202 fDrawable->setSweep(SampleCode::GetAnimScalar(SkIntToScalar(360)/24, 179 fDrawable->setSweep(SampleCode::GetAnimScalar(SkIntToScalar(360)/24,
203 SkIntToScalar(360))); 180 SkIntToScalar(360)));
204 181
205 SkPaint paint; 182 SkPaint paint;
206 paint.setAntiAlias(true); 183 paint.setAntiAlias(true);
207 paint.setStrokeWidth(SkIntToScalar(2)); 184 paint.setStrokeWidth(SkIntToScalar(2));
208 paint.setStyle(SkPaint::kStroke_Style); 185 paint.setStyle(SkPaint::kStroke_Style);
209 186
210 drawRectWithLines(canvas, fRect, paint); 187 drawRectWithLines(canvas, fRect, paint);
211 188
(...skipping 17 matching lines...) Expand all
229 private: 206 private:
230 SkScalar fSweep; 207 SkScalar fSweep;
231 208
232 typedef SampleView INHERITED; 209 typedef SampleView INHERITED;
233 }; 210 };
234 211
235 ////////////////////////////////////////////////////////////////////////////// 212 //////////////////////////////////////////////////////////////////////////////
236 213
237 static SkView* MyFactory() { return new ArcsView; } 214 static SkView* MyFactory() { return new ArcsView; }
238 static SkViewRegister reg(MyFactory); 215 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « include/core/SkPictureRecorder.h ('k') | src/core/SkBBHFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698