2014-04-18 18:04:41 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkPictureRecorder_DEFINED
|
|
|
|
#define SkPictureRecorder_DEFINED
|
|
|
|
|
|
|
|
#include "SkBBHFactory.h"
|
|
|
|
#include "SkPicture.h"
|
|
|
|
#include "SkRefCnt.h"
|
|
|
|
|
2014-06-17 20:42:59 +00:00
|
|
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
|
|
|
namespace android {
|
|
|
|
class Picture;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2014-04-18 18:04:41 +00:00
|
|
|
class SkCanvas;
|
2014-06-08 12:55:05 +00:00
|
|
|
class SkPictureRecord;
|
2014-06-17 19:08:15 +00:00
|
|
|
class SkRecord;
|
|
|
|
class SkRecorder;
|
2014-04-18 18:04:41 +00:00
|
|
|
|
|
|
|
class SK_API SkPictureRecorder : SkNoncopyable {
|
|
|
|
public:
|
2014-06-23 17:29:10 +00:00
|
|
|
SkPictureRecorder();
|
2014-06-08 12:55:05 +00:00
|
|
|
~SkPictureRecorder();
|
|
|
|
|
2014-08-29 15:03:56 +00:00
|
|
|
#ifdef SK_LEGACY_PICTURE_SIZE_API
|
|
|
|
SkCanvas* beginRecording(int width, int height,
|
|
|
|
SkBBHFactory* bbhFactory = NULL,
|
|
|
|
uint32_t recordFlags = 0) {
|
|
|
|
return this->beginRecording(SkIntToScalar(width), SkIntToScalar(height),
|
|
|
|
bbhFactory, recordFlags);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-11-11 12:54:49 +00:00
|
|
|
enum RecordFlags {
|
|
|
|
// This flag indicates that, if some BHH is being computed, saveLayer
|
|
|
|
// information should also be extracted at the same time.
|
|
|
|
kComputeSaveLayerInfo_RecordFlag = 0x01
|
|
|
|
};
|
|
|
|
|
2014-04-18 18:04:41 +00:00
|
|
|
/** Returns the canvas that records the drawing commands.
|
2014-08-29 15:03:56 +00:00
|
|
|
@param width the width of the cull rect used when recording this picture.
|
|
|
|
@param height the height of the cull rect used when recording this picture.
|
2014-04-18 18:04:41 +00:00
|
|
|
@param bbhFactory factory to create desired acceleration structure
|
|
|
|
@param recordFlags optional flags that control recording.
|
|
|
|
@return the canvas.
|
|
|
|
*/
|
2014-11-19 14:59:41 +00:00
|
|
|
SkCanvas* beginRecording(SkScalar width, SkScalar height,
|
|
|
|
SkBBHFactory* bbhFactory = NULL,
|
2014-11-19 15:17:16 +00:00
|
|
|
uint32_t recordFlags = 0);
|
2014-11-19 14:59:41 +00:00
|
|
|
|
2014-04-18 18:04:41 +00:00
|
|
|
/** Returns the recording canvas if one is active, or NULL if recording is
|
|
|
|
not active. This does not alter the refcnt on the canvas (if present).
|
|
|
|
*/
|
2014-06-08 12:55:05 +00:00
|
|
|
SkCanvas* getRecordingCanvas();
|
2014-04-18 18:04:41 +00:00
|
|
|
|
|
|
|
/** Signal that the caller is done recording. This invalidates the canvas
|
|
|
|
returned by beginRecording/getRecordingCanvas, and returns the
|
|
|
|
created SkPicture. Note that the returned picture has its creation
|
|
|
|
ref which the caller must take ownership of.
|
|
|
|
*/
|
2014-06-08 12:55:05 +00:00
|
|
|
SkPicture* endRecording();
|
2014-04-18 18:04:41 +00:00
|
|
|
|
|
|
|
private:
|
2014-06-17 19:08:15 +00:00
|
|
|
void reset();
|
|
|
|
|
2014-05-27 23:41:45 +00:00
|
|
|
/** Replay the current (partially recorded) operation stream into
|
|
|
|
canvas. This call doesn't close the current recording.
|
|
|
|
*/
|
2014-06-17 20:42:59 +00:00
|
|
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
|
|
|
friend class android::Picture;
|
|
|
|
#endif
|
2014-05-27 23:41:45 +00:00
|
|
|
friend class SkPictureRecorderReplayTester; // for unit testing
|
2014-05-29 15:57:11 +00:00
|
|
|
void partialReplay(SkCanvas* canvas) const;
|
2014-05-27 23:41:45 +00:00
|
|
|
|
2014-11-11 12:54:49 +00:00
|
|
|
uint32_t fFlags;
|
2014-11-19 15:17:16 +00:00
|
|
|
SkScalar fCullWidth;
|
|
|
|
SkScalar fCullHeight;
|
2014-08-11 15:08:43 +00:00
|
|
|
SkAutoTUnref<SkBBoxHierarchy> fBBH;
|
2014-10-01 16:29:35 +00:00
|
|
|
SkAutoTUnref<SkRecorder> fRecorder;
|
|
|
|
SkAutoTDelete<SkRecord> fRecord;
|
2014-04-18 18:04:41 +00:00
|
|
|
|
|
|
|
typedef SkNoncopyable INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|