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

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

Issue 243173002: Staging for cleanup of SkPicture-related headers (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Add crucial newline at end of file 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 | « include/core/SkBBHFactory.h ('k') | include/core/SkPictureRecorder.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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 * Allocate a new SkPicture. Return NULL on failure. 427 * Allocate a new SkPicture. Return NULL on failure.
428 */ 428 */
429 virtual SkPicture* create(int width, int height) = 0; 429 virtual SkPicture* create(int width, int height) = 0;
430 430
431 private: 431 private:
432 typedef SkRefCnt INHERITED; 432 typedef SkRefCnt INHERITED;
433 }; 433 };
434 434
435 #endif 435 #endif
436 436
437 class SkBBHFactory { 437 #ifdef SK_SUPPORT_LEGACY_PICTURE_HEADERS
438 public: 438 #include "SkPictureRecorder.h"
439 /**
440 * Allocate a new SkBBoxHierarchy. Return NULL on failure.
441 */
442 virtual SkBBoxHierarchy* operator()(int width, int height) const = 0;
443 virtual ~SkBBHFactory() {};
444 };
445
446 class SK_API SkPictureRecorder : SkNoncopyable {
447 public:
448 #ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
449
450 SkPictureRecorder(SkPictureFactory* factory = NULL) {
451 fFactory.reset(factory);
452 if (NULL != fFactory.get()) {
453 fFactory.get()->ref();
454 }
455 }
456
457 /** Returns the canvas that records the drawing commands.
458 @param width the base width for the picture, as if the recording
459 canvas' bitmap had this width.
460 @param height the base width for the picture, as if the recording
461 canvas' bitmap had this height.
462 @param recordFlags optional flags that control recording.
463 @return the canvas.
464 */
465 SkCanvas* beginRecording(int width, int height, uint32_t recordFlags = 0) {
466 if (NULL != fFactory) {
467 fPicture.reset(fFactory->create(width, height));
468 recordFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFlag;
469 } else {
470 fPicture.reset(SkNEW(SkPicture));
471 }
472
473 return fPicture->beginRecording(width, height, recordFlags);
474 }
475 #endif 439 #endif
476 440
477 /** Returns the canvas that records the drawing commands.
478 @param width the base width for the picture, as if the recording
479 canvas' bitmap had this width.
480 @param height the base width for the picture, as if the recording
481 canvas' bitmap had this height.
482 @param bbhFactory factory to create desired acceleration structure
483 @param recordFlags optional flags that control recording.
484 @return the canvas.
485 */
486 // TODO: allow default parameters once the other beginRecoding entry point i s gone
487 SkCanvas* beginRecording(int width, int height,
488 SkBBHFactory* bbhFactory /* = NULL */,
489 uint32_t recordFlags /* = 0 */) {
490 fPicture.reset(SkNEW(SkPicture));
491 return fPicture->beginRecording(width, height, bbhFactory, recordFlags);
492 }
493
494 /** Returns the recording canvas if one is active, or NULL if recording is
495 not active. This does not alter the refcnt on the canvas (if present).
496 */
497 SkCanvas* getRecordingCanvas() {
498 if (NULL != fPicture.get()) {
499 return fPicture->getRecordingCanvas();
500 }
501 return NULL;
502 }
503
504 /** Signal that the caller is done recording. This invalidates the canvas
505 returned by beginRecording/getRecordingCanvas, and returns the
506 created SkPicture. Note that the returned picture has its creation
507 ref which the caller must take ownership of.
508 */
509 SkPicture* endRecording() {
510 if (NULL != fPicture.get()) {
511 fPicture->endRecording();
512 return fPicture.detach();
513 }
514 return NULL;
515 }
516
517 /** Enable/disable all the picture recording optimizations (i.e.,
518 those in SkPictureRecord). It is mainly intended for testing the
519 existing optimizations (i.e., to actually have the pattern
520 appear in an .skp we have to disable the optimization). Call right
521 after 'beginRecording'.
522 */
523 void internalOnly_EnableOpts(bool enableOpts) {
524 if (NULL != fPicture.get()) {
525 fPicture->internalOnly_EnableOpts(enableOpts);
526 }
527 }
528
529 private:
530 #ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
531 SkAutoTUnref<SkPictureFactory> fFactory;
532 #endif 441 #endif
533
534 SkAutoTUnref<SkPicture> fPicture;
535
536 typedef SkNoncopyable INHERITED;
537 };
538
539 #endif
OLDNEW
« no previous file with comments | « include/core/SkBBHFactory.h ('k') | include/core/SkPictureRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698