skia2/bench/RecordingBench.cpp
robertphillips dda54455a2 Remove GrLayerHoister
This relies on https://codereview.chromium.org/1944013002/ (Add legacy flag to allow Skia to remove Ganesh layer hoister) landing first so as to not break the DEPS roll.

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1950523002

Review-Url: https://codereview.chromium.org/1950523002
2016-07-13 13:27:16 -07:00

43 lines
1.2 KiB
C++

/*
* 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(int loops, SkCanvas*) {
SkRTreeFactory factory;
const SkScalar w = fSrc->cullRect().width(),
h = fSrc->cullRect().height();
uint32_t flags = SkPictureRecorder::kPlaybackDrawPicture_RecordFlag;
for (int i = 0; i < loops; i++) {
SkPictureRecorder recorder;
fSrc->playback(recorder.beginRecording(w, h, fUseBBH ? &factory : nullptr, flags));
(void)recorder.finishRecordingAsPicture();
}
}