Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / include / core / SkPictureRecorder.h
1 /*
2  * Copyright 2014 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7
8 #ifndef SkPictureRecorder_DEFINED
9 #define SkPictureRecorder_DEFINED
10
11 #include "SkBBHFactory.h"
12 #include "SkPicture.h"
13 #include "SkRefCnt.h"
14
15 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
16 namespace android {
17     class Picture;
18 };
19 #endif
20
21 class SkCanvas;
22 class SkPictureRecord;
23 class SkRecord;
24 class SkRecorder;
25
26 class SK_API SkPictureRecorder : SkNoncopyable {
27 public:
28     SkPictureRecorder();
29     ~SkPictureRecorder();
30
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);
37     }
38 #endif
39
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.
45         @return the canvas.
46     */
47     SkCanvas* beginRecording(SkScalar width, SkScalar height,
48                              SkBBHFactory* bbhFactory = NULL,
49                              uint32_t recordFlags = 0);
50
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).
53     */
54     SkCanvas* getRecordingCanvas();
55
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.
60     */
61     SkPicture* endRecording();
62
63 private:
64     void reset();
65
66     /** Replay the current (partially recorded) operation stream into
67         canvas. This call doesn't close the current recording.
68     */
69 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
70     friend class android::Picture;
71 #endif
72     friend class SkPictureRecorderReplayTester; // for unit testing
73     void partialReplay(SkCanvas* canvas) const;
74
75     SkScalar                      fCullWidth;
76     SkScalar                      fCullHeight;
77     SkAutoTUnref<SkBBoxHierarchy> fBBH;
78     SkAutoTUnref<SkRecorder>      fRecorder;
79     SkAutoTDelete<SkRecord>       fRecord;
80
81     typedef SkNoncopyable INHERITED;
82 };
83
84 #endif