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

Side by Side Diff: include/core/SkPicture.h

Issue 214953003: split SkPictureRecorder out of SkPicture (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: yet more cleanup 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
« no previous file with comments | « gm/pictureimagefilter.cpp ('k') | include/core/SkTileGridPicture.h » ('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 2007 The Android Open Source Project 3 * Copyright 2007 The Android Open Source Project
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 8
9 9
10 #ifndef SkPicture_DEFINED 10 #ifndef SkPicture_DEFINED
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 * to the same level it was before the drawPicture call was made. 377 * to the same level it was before the drawPicture call was made.
378 */ 378 */
379 class SK_API SkDrawPictureCallback { 379 class SK_API SkDrawPictureCallback {
380 public: 380 public:
381 SkDrawPictureCallback() {} 381 SkDrawPictureCallback() {}
382 virtual ~SkDrawPictureCallback() {} 382 virtual ~SkDrawPictureCallback() {}
383 383
384 virtual bool abortDrawing() = 0; 384 virtual bool abortDrawing() = 0;
385 }; 385 };
386 386
387 class SkPictureFactory : public SkRefCnt {
388 public:
389 /**
390 * Allocate a new SkPicture. Return NULL on failure.
391 */
392 virtual SkPicture* create(int width, int height) = 0;
393 };
394
395 class SK_API SkPictureRecorder : public SkRefCnt {
mtklein 2014/03/27 21:09:11 What's this extra level of indirection get us? I'
396 public:
397 SK_DECLARE_INST_COUNT(SkPictureRecorder)
398
399 SkPictureRecorder(SkPictureFactory* factory = NULL) {
400 fFactory.reset(factory);
401 if (NULL != fFactory.get()) {
402 fFactory.get()->ref();
403 }
404 }
405
406 /** Returns the canvas that records the drawing commands.
407 @param width the base width for the picture, as if the recording
408 canvas' bitmap had this width.
409 @param height the base width for the picture, as if the recording
410 canvas' bitmap had this height.
411 @param recordFlags optional flags that control recording.
412 @return the canvas.
413 */
414 SkCanvas* beginRecording(int width, int height, uint32_t recordFlags = 0) {
415 if (NULL != fFactory) {
416 fPicture.reset(fFactory->create(width, height));
417 } else {
418 fPicture.reset(SkNEW(SkPicture));
419 }
420
421 return fPicture->beginRecording(width, height, recordFlags);
422 }
423
424 /** Returns the recording canvas if one is active, or NULL if recording is
425 not active. This does not alter the refcnt on the canvas (if present).
426 */
427 SkCanvas* getRecordingCanvas() {
428 if (NULL != fPicture.get()) {
429 return fPicture->getRecordingCanvas();
430 }
431 return NULL;
432 }
433
434 /** Signal that the caller is done recording. This invalidates the canvas
435 returned by beginRecording/getRecordingCanvas, and returns the
436 created SkPicture. Note that the returned picture has its creation
437 ref which the caller must take ownership of.
438 */
439 SkPicture* endRecording() {
440 if (NULL != fPicture.get()) {
441 fPicture->endRecording();
442 return fPicture.detach();
443 }
444 return NULL;
445 }
446
447 /** Enable/disable all the picture recording optimizations (i.e.,
448 those in SkPictureRecord). It is mainly intended for testing the
449 existing optimizations (i.e., to actually have the pattern
450 appear in an .skp we have to disable the optimization). Call right
451 after 'beginRecording'.
452 */
453 void internalOnly_EnableOpts(bool enableOpts) {
454 if (NULL != fPicture.get()) {
455 fPicture->internalOnly_EnableOpts(enableOpts);
456 }
457 }
458
459 private:
460 SkAutoTUnref<SkPictureFactory> fFactory;
461 SkAutoTUnref<SkPicture> fPicture;
462
463 typedef SkRefCnt INHERITED;
464 };
465
387 #endif 466 #endif
OLDNEW
« no previous file with comments | « gm/pictureimagefilter.cpp ('k') | include/core/SkTileGridPicture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698