Clean up some gm factory use.
Mostly use unique_ptr more consistently. Change-Id: I6e11b272a7904eb662dea59b03fbc309a4cfc25d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/233984 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
fb83927366
commit
406ff500a4
@ -7,12 +7,10 @@
|
|||||||
|
|
||||||
#include "bench/GMBench.h"
|
#include "bench/GMBench.h"
|
||||||
|
|
||||||
GMBench::GMBench(skiagm::GM* gm) : fGM(gm) {
|
GMBench::GMBench(std::unique_ptr<skiagm::GM> gm) : fGM(std::move(gm)) {
|
||||||
fName.printf("GM_%s", gm->getName());
|
fName.printf("GM_%s", fGM->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
GMBench::~GMBench() { delete fGM; }
|
|
||||||
|
|
||||||
const char* GMBench::onGetName() {
|
const char* GMBench::onGetName() {
|
||||||
return fName.c_str();
|
return fName.c_str();
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
class GMBench : public Benchmark {
|
class GMBench : public Benchmark {
|
||||||
public:
|
public:
|
||||||
// Constructor takes ownership of the GM param.
|
GMBench(std::unique_ptr<skiagm::GM> gm);
|
||||||
GMBench(skiagm::GM* gm);
|
|
||||||
~GMBench() override;
|
|
||||||
|
|
||||||
void modifyGrContextOptions(GrContextOptions* options) override {
|
void modifyGrContextOptions(GrContextOptions* options) override {
|
||||||
return fGM->modifyGrContextOptions(options);
|
return fGM->modifyGrContextOptions(options);
|
||||||
@ -31,7 +29,7 @@ protected:
|
|||||||
SkIPoint onGetSize() override;
|
SkIPoint onGetSize() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
skiagm::GM* fGM;
|
std::unique_ptr<skiagm::GM> fGM;
|
||||||
SkString fName;
|
SkString fName;
|
||||||
typedef Benchmark INHERITED;
|
typedef Benchmark INHERITED;
|
||||||
};
|
};
|
||||||
|
@ -749,12 +749,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (fGMs) {
|
while (fGMs) {
|
||||||
std::unique_ptr<skiagm::GM> gm(fGMs->get()());
|
std::unique_ptr<skiagm::GM> gm = fGMs->get()();
|
||||||
fGMs = fGMs->next();
|
fGMs = fGMs->next();
|
||||||
if (gm->runAsBench()) {
|
if (gm->runAsBench()) {
|
||||||
fSourceType = "gm";
|
fSourceType = "gm";
|
||||||
fBenchType = "micro";
|
fBenchType = "micro";
|
||||||
return new GMBench(gm.release());
|
return new GMBench(std::move(gm));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ int main(int argc, char** argv) {
|
|||||||
if (skiagm::GMFactory* factory = gm_factories.find(name)) {
|
if (skiagm::GMFactory* factory = gm_factories.find(name)) {
|
||||||
std::shared_ptr<skiagm::GM> gm{(*factory)()};
|
std::shared_ptr<skiagm::GM> gm{(*factory)()};
|
||||||
source->name = name;
|
source->name = name;
|
||||||
init(source, gm);
|
init(source, std::move(gm));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
#include "tools/viewer/GMSlide.h"
|
#include "tools/viewer/GMSlide.h"
|
||||||
|
|
||||||
GMSlide::GMSlide(skiagm::GM* gm) : fGM(gm) {
|
GMSlide::GMSlide(std::unique_ptr<skiagm::GM> gm) : fGM(std::move(gm)) {
|
||||||
fName.printf("GM_%s", gm->getName());
|
fName.printf("GM_%s", fGM->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
GMSlide::~GMSlide() = default;
|
GMSlide::~GMSlide() = default;
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
class GMSlide : public Slide {
|
class GMSlide : public Slide {
|
||||||
public:
|
public:
|
||||||
GMSlide(skiagm::GM* gm);
|
GMSlide(std::unique_ptr<skiagm::GM> gm);
|
||||||
~GMSlide() override;
|
~GMSlide() override;
|
||||||
|
|
||||||
SkISize getDimensions() const override { return fGM->getISize(); }
|
SkISize getDimensions() const override { return fGM->getISize(); }
|
||||||
|
@ -676,9 +676,9 @@ void Viewer::initSlides() {
|
|||||||
// GMs
|
// GMs
|
||||||
int firstGM = fSlides.count();
|
int firstGM = fSlides.count();
|
||||||
for (skiagm::GMFactory gmFactory : skiagm::GMRegistry::Range()) {
|
for (skiagm::GMFactory gmFactory : skiagm::GMRegistry::Range()) {
|
||||||
std::unique_ptr<skiagm::GM> gm(gmFactory());
|
std::unique_ptr<skiagm::GM> gm = gmFactory();
|
||||||
if (!CommandLineFlags::ShouldSkip(FLAGS_match, gm->getName())) {
|
if (!CommandLineFlags::ShouldSkip(FLAGS_match, gm->getName())) {
|
||||||
sk_sp<Slide> slide(new GMSlide(gm.release()));
|
sk_sp<Slide> slide(new GMSlide(std::move(gm)));
|
||||||
fSlides.push_back(std::move(slide));
|
fSlides.push_back(std::move(slide));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user