ab244f045a
This reverts commit9d5f66d9c2
. Reason for revert: Leon landed Android fixes. Original change's description: > Revert "Reland: Remove SkLights include from SkCanvas.h" > > This reverts commitfed00319c9
. > > Reason for revert: breaking the Android roll. > > Original change's description: > > Reland: Remove SkLights include from SkCanvas.h > > > > SkLights.h pulls in a bunch of other headers and is not needed (fwdecl > > works fine). > > > > Change-Id: I3ed97cd7861e51dcb7cfa7950a97b420dbc6fbfb > > TBR=reed@google.com > > Reviewed-on: https://skia-review.googlesource.com/15143 > > Commit-Queue: Florin Malita <fmalita@chromium.org> > > Reviewed-by: Florin Malita <fmalita@chromium.org> > > > > TBR=fmalita@chromium.org,reed@google.com > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > > Change-Id: I3b0e69f1d04d160f16a5567b09982d35cc9ca84e > Reviewed-on: https://skia-review.googlesource.com/15195 > Reviewed-by: Florin Malita <fmalita@chromium.org> > Commit-Queue: Florin Malita <fmalita@chromium.org> > TBR=msarett@google.com,reviews@skia.org,fmalita@chromium.org,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I0a1c2f9df61f16987ab72dfb4f3a205fbcc37667 Reviewed-on: https://skia-review.googlesource.com/15229 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
116 lines
2.8 KiB
C++
116 lines
2.8 KiB
C++
/*
|
|
* Copyright 2017 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "ok.h"
|
|
#include "gm.h"
|
|
#include "SkData.h"
|
|
#include "SkOSFile.h"
|
|
#include "SkPicture.h"
|
|
#include <vector>
|
|
|
|
struct GMStream : Stream {
|
|
const skiagm::GMRegistry* registry = skiagm::GMRegistry::Head();
|
|
|
|
static std::unique_ptr<Stream> Create(Options) {
|
|
GMStream stream;
|
|
return move_unique(stream);
|
|
}
|
|
|
|
struct GMSrc : Src {
|
|
skiagm::GM* (*factory)(void*);
|
|
std::unique_ptr<skiagm::GM> gm;
|
|
|
|
void init() {
|
|
if (gm) { return; }
|
|
gm.reset(factory(nullptr));
|
|
}
|
|
|
|
std::string name() override {
|
|
this->init();
|
|
return gm->getName();
|
|
}
|
|
|
|
SkISize size() override {
|
|
this->init();
|
|
return gm->getISize();
|
|
}
|
|
|
|
Status draw(SkCanvas* canvas) override {
|
|
this->init();
|
|
canvas->clear(0xffffffff);
|
|
canvas->concat(gm->getInitialTransform());
|
|
gm->draw(canvas);
|
|
return Status::OK;
|
|
}
|
|
};
|
|
|
|
std::unique_ptr<Src> next() override {
|
|
if (!registry) {
|
|
return nullptr;
|
|
}
|
|
GMSrc src;
|
|
src.factory = registry->factory();
|
|
registry = registry->next();
|
|
return move_unique(src);
|
|
}
|
|
};
|
|
static Register gm{"gm", "draw GMs linked into this binary", GMStream::Create};
|
|
|
|
struct SKPStream : Stream {
|
|
std::string dir;
|
|
std::vector<std::string> skps;
|
|
|
|
static std::unique_ptr<Stream> Create(Options options) {
|
|
SKPStream stream;
|
|
stream.dir = options("dir", "skps");
|
|
SkOSFile::Iter it{stream.dir.c_str(), ".skp"};
|
|
for (SkString path; it.next(&path); ) {
|
|
stream.skps.push_back(path.c_str());
|
|
}
|
|
return move_unique(stream);
|
|
}
|
|
|
|
struct SKPSrc : Src {
|
|
std::string dir, path;
|
|
sk_sp<SkPicture> pic;
|
|
|
|
void init() {
|
|
if (pic) { return; }
|
|
auto skp = SkData::MakeFromFileName((dir+"/"+path).c_str());
|
|
pic = SkPicture::MakeFromData(skp.get());
|
|
}
|
|
|
|
std::string name() override {
|
|
return path;
|
|
}
|
|
|
|
SkISize size() override {
|
|
this->init();
|
|
return pic->cullRect().roundOut().size();
|
|
}
|
|
|
|
Status draw(SkCanvas* canvas) override {
|
|
this->init();
|
|
canvas->clear(0xffffffff);
|
|
pic->playback(canvas);
|
|
return Status::OK;
|
|
}
|
|
};
|
|
|
|
std::unique_ptr<Src> next() override {
|
|
if (skps.empty()) {
|
|
return nullptr;
|
|
}
|
|
SKPSrc src;
|
|
src.dir = dir;
|
|
src.path = skps.back();
|
|
skps.pop_back();
|
|
return move_unique(src);
|
|
}
|
|
};
|
|
static Register skp{"skp", "draw SKPs from dir=skps", SKPStream::Create};
|