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

Side by Side Diff: samplecode/SampleAll.cpp

Issue 214953003: split SkPictureRecorder out of SkPicture (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: update to ToT (again) Created 6 years, 8 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 | Annotate | Revision Log
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 "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (index == 0) 295 if (index == 0)
296 path.moveTo(x, y); 296 path.moveTo(x, y);
297 else 297 else
298 path.lineTo(x, y); 298 path.lineTo(x, y);
299 } 299 }
300 path.close(); 300 path.close();
301 } 301 }
302 302
303 virtual void onDrawContent(SkCanvas* canvas) { 303 virtual void onDrawContent(SkCanvas* canvas) {
304 canvas->save(); 304 canvas->save();
305 drawPicture(canvas, 0); 305 this->drawPicture(canvas, 0);
306 canvas->restore(); 306 canvas->restore();
307 307
308 { 308 {
309 SkPicture picture; 309 SkPictureRecorder recorder;
310 SkCanvas* record = picture.beginRecording(320, 480); 310 {
311 drawPicture(record, 120); 311 SkCanvas* record = recorder.beginRecording(320, 480);
312 this->drawPicture(record, 120);
313 }
314 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
315
312 canvas->translate(0, SkIntToScalar(120)); 316 canvas->translate(0, SkIntToScalar(120));
313 317
314 SkRect clip; 318 SkRect clip;
315 clip.set(0, 0, SkIntToScalar(160), SkIntToScalar(160)); 319 clip.set(0, 0, SkIntToScalar(160), SkIntToScalar(160));
316 do { 320 do {
317 canvas->save(); 321 canvas->save();
318 canvas->clipRect(clip); 322 canvas->clipRect(clip);
319 picture.draw(canvas); 323 picture->draw(canvas);
320 canvas->restore(); 324 canvas->restore();
321 if (clip.fRight < SkIntToScalar(320)) 325 if (clip.fRight < SkIntToScalar(320))
322 clip.offset(SkIntToScalar(160), 0); 326 clip.offset(SkIntToScalar(160), 0);
323 else if (clip.fBottom < SkIntToScalar(480)) 327 else if (clip.fBottom < SkIntToScalar(480))
324 clip.offset(-SkIntToScalar(320), SkIntToScalar(160)); 328 clip.offset(-SkIntToScalar(320), SkIntToScalar(160));
325 else 329 else
326 break; 330 break;
327 } while (true); 331 } while (true);
328 } 332 }
329 } 333 }
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 private: 646 private:
643 SkPoint fClickPt; 647 SkPoint fClickPt;
644 SkBitmap fBug, fTb, fTx; 648 SkBitmap fBug, fTb, fTx;
645 typedef SampleView INHERITED; 649 typedef SampleView INHERITED;
646 }; 650 };
647 651
648 ////////////////////////////////////////////////////////////////////////////// 652 //////////////////////////////////////////////////////////////////////////////
649 653
650 static SkView* MyFactory() { return new DemoView; } 654 static SkView* MyFactory() { return new DemoView; }
651 static SkViewRegister reg(MyFactory); 655 static SkViewRegister reg(MyFactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698