2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkPictureRecorder_DEFINED
9 #define SkPictureRecorder_DEFINED
11 #include "SkBBHFactory.h"
12 #include "SkPicture.h"
15 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
22 class SkPictureRecord;
26 class SK_API SkPictureRecorder : SkNoncopyable {
31 #ifdef SK_LEGACY_PICTURE_SIZE_API
32 SkCanvas* beginRecording(int width, int height,
33 SkBBHFactory* bbhFactory = NULL,
34 uint32_t recordFlags = 0) {
35 return this->beginRecording(SkIntToScalar(width), SkIntToScalar(height),
36 bbhFactory, recordFlags);
40 /** Returns the canvas that records the drawing commands.
41 @param width the width of the cull rect used when recording this picture.
42 @param height the height of the cull rect used when recording this picture.
43 @param bbhFactory factory to create desired acceleration structure
44 @param recordFlags optional flags that control recording.
47 SkCanvas* beginRecording(SkScalar width, SkScalar height,
48 SkBBHFactory* bbhFactory = NULL,
49 uint32_t recordFlags = 0);
51 /** Returns the recording canvas if one is active, or NULL if recording is
52 not active. This does not alter the refcnt on the canvas (if present).
54 SkCanvas* getRecordingCanvas();
56 /** Signal that the caller is done recording. This invalidates the canvas
57 returned by beginRecording/getRecordingCanvas, and returns the
58 created SkPicture. Note that the returned picture has its creation
59 ref which the caller must take ownership of.
61 SkPicture* endRecording();
66 /** Replay the current (partially recorded) operation stream into
67 canvas. This call doesn't close the current recording.
69 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
70 friend class android::Picture;
72 friend class SkPictureRecorderReplayTester; // for unit testing
73 void partialReplay(SkCanvas* canvas) const;
77 SkAutoTUnref<SkBBoxHierarchy> fBBH;
78 SkAutoTUnref<SkRecorder> fRecorder;
79 SkAutoTDelete<SkRecord> fRecord;
81 typedef SkNoncopyable INHERITED;