2014-09-10 19:19:30 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "RecordingBench.h"
|
|
|
|
|
|
|
|
#include "SkBBHFactory.h"
|
|
|
|
#include "SkPictureRecorder.h"
|
|
|
|
|
|
|
|
RecordingBench::RecordingBench(const char* name, const SkPicture* pic, bool useBBH)
|
|
|
|
: fSrc(SkRef(pic))
|
|
|
|
, fName(name)
|
|
|
|
, fUseBBH(useBBH) {}
|
|
|
|
|
|
|
|
const char* RecordingBench::onGetName() {
|
|
|
|
return fName.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RecordingBench::isSuitableFor(Backend backend) {
|
|
|
|
return backend == kNonRendering_Backend;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkIPoint RecordingBench::onGetSize() {
|
|
|
|
return SkIPoint::Make(SkScalarCeilToInt(fSrc->cullRect().width()),
|
|
|
|
SkScalarCeilToInt(fSrc->cullRect().height()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void RecordingBench::onDraw(const int loops, SkCanvas*) {
|
2014-10-29 21:15:10 +00:00
|
|
|
SkRTreeFactory factory;
|
2014-09-10 19:19:30 +00:00
|
|
|
const SkScalar w = fSrc->cullRect().width(),
|
|
|
|
h = fSrc->cullRect().height();
|
|
|
|
|
2015-07-01 14:04:37 +00:00
|
|
|
uint32_t flags = SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag
|
|
|
|
| SkPictureRecorder::kPlaybackDrawPicture_RecordFlag;
|
2014-09-10 19:19:30 +00:00
|
|
|
for (int i = 0; i < loops; i++) {
|
|
|
|
SkPictureRecorder recorder;
|
2015-08-27 14:41:13 +00:00
|
|
|
fSrc->playback(recorder.beginRecording(w, h, fUseBBH ? &factory : nullptr, flags));
|
2014-11-24 20:02:31 +00:00
|
|
|
SkSafeUnref(recorder.endRecording());
|
2014-09-10 19:19:30 +00:00
|
|
|
}
|
|
|
|
}
|