Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2065)

Unified Diff: samplecode/SampleApp.cpp

Issue 1412143005: add --sequence filename option to SampleApp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleApp.cpp
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 07a7a87b7fb2ac83b68a7f927d05ec751b456e99..fb261b092cd61c64c621b95fa0f17df34f46e5c3 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -705,10 +705,35 @@ static bool compareSampleTitle(const SkViewFactory* first, const SkViewFactory*
return strcmp(getSampleTitle(first).c_str(), getSampleTitle(second).c_str()) < 0;
}
+static int find_by_title(const SkViewFactory* const* factories, int count, const char title[]) {
+ for (int i = 0; i < count; i++) {
+ if (getSampleTitle(factories[i]).equals(title)) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+static void restrict_samples(SkTDArray<const SkViewFactory*>& factories, const SkString titles[],
+ int count) {
+ int newCount = 0;
+ for (int i = 0; i < count; ++i) {
+ int index = find_by_title(factories.begin(), factories.count(), titles[i].c_str());
+ if (index >= 0) {
+ SkTSwap(factories.begin()[newCount], factories.begin()[index]);
+ newCount += 1;
+ }
+ }
+ if (newCount) {
+ factories.setCount(newCount);
+ }
+}
+
DEFINE_string(slide, "", "Start on this sample.");
DEFINE_int32(msaa, 0, "Request multisampling with this count.");
DEFINE_string(pictureDir, "", "Read pictures from here.");
DEFINE_string(picture, "", "Path to single picture.");
+DEFINE_string(sequence, "", "Path to file containing the desired samples/gms to show.");
DEFINE_bool(sort, false, "Sort samples by title.");
DEFINE_bool(list, false, "List samples?");
DEFINE_bool(gpu, false, "Start up with gpu?");
@@ -759,6 +784,25 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
}
}
+ if (!FLAGS_sequence.isEmpty()) {
+ // The sequence file just contains a list (separated by CRs) of the samples or GM:gms
+ // you want to restrict to. Only these will appear when you cycle through.
+ // If none are found, or the file is empty, then it will be ignored, and all samples
+ // will be available.
+ SkFILEStream stream(FLAGS_sequence[0]);
+ if (stream.isValid()) {
+ size_t len = stream.getLength();
+ SkAutoMalloc storage(len + 1);
+ char* buffer = (char*)storage.get();
+ stream.read(buffer, len);
+ buffer[len] = 0;
+
+ SkTArray<SkString> titles;
+ SkStrSplit(buffer, "\n\r", &titles);
+ restrict_samples(fSamples, titles.begin(), titles.count());
+ }
+ }
+
if (FLAGS_sort) {
// Sort samples, so foo.skp and foo.pdf are consecutive and we can quickly spot where
// skp -> pdf -> png fails.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698