DM: tweaks
- translate filenames to task names instead of using a verbatim mode in WriteTask - add an option to write out only PNG data to the .png if you don't need -r to work BUG=skia: R=reed@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/288823002 git-svn-id: http://skia.googlecode.com/svn/trunk@14742 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
47b679b37d
commit
d6dcacd4fe
@ -5,8 +5,17 @@
|
||||
|
||||
namespace DM {
|
||||
|
||||
SKPTask::SKPTask(Reporter* r, TaskRunner* tr, SkPicture* pic, SkString name)
|
||||
: CpuTask(r, tr), fPicture(SkRef(pic)), fName(name) {}
|
||||
// foo_bar.skp -> foo-bar_skp
|
||||
static SkString filename_to_task_name(SkString filename) {
|
||||
for (size_t i = 0; i < filename.size(); i++) {
|
||||
if ('_' == filename[i]) { filename[i] = '-'; }
|
||||
if ('.' == filename[i]) { filename[i] = '_'; }
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
SKPTask::SKPTask(Reporter* r, TaskRunner* tr, SkPicture* pic, SkString filename)
|
||||
: CpuTask(r, tr), fPicture(SkRef(pic)), fName(filename_to_task_name(filename)) {}
|
||||
|
||||
void SKPTask::draw() {
|
||||
SkBitmap bitmap;
|
||||
@ -17,7 +26,7 @@ void SKPTask::draw() {
|
||||
(*this, fPicture, bitmap, RecordTask::kNoOptimize_Mode)));
|
||||
this->spawnChild(SkNEW_ARGS(RecordTask,
|
||||
(*this, fPicture, bitmap, RecordTask::kOptimize_Mode)));
|
||||
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap, WriteTask::kVerbatim_Mode)));
|
||||
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
|
||||
}
|
||||
|
||||
} // namespace DM
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "SkString.h"
|
||||
|
||||
DEFINE_string2(writePath, w, "", "If set, write GMs here as .pngs.");
|
||||
DEFINE_bool(writePngOnly, false, "If true, don't encode raw bitmap after .png data. "
|
||||
"This means -r won't work, but skdiff will still work fine.");
|
||||
|
||||
namespace DM {
|
||||
|
||||
@ -26,16 +28,12 @@ static int split_suffixes(int N, const char* name, SkTArray<SkString>* out) {
|
||||
return consumed;
|
||||
}
|
||||
|
||||
WriteTask::WriteTask(const Task& parent, SkBitmap bitmap, Mode mode)
|
||||
WriteTask::WriteTask(const Task& parent, SkBitmap bitmap)
|
||||
: CpuTask(parent), fBitmap(bitmap) {
|
||||
if (mode == kVerbatim_Mode) {
|
||||
fGmName.set(parent.name());
|
||||
} else {
|
||||
const int suffixes = parent.depth() + 1;
|
||||
const SkString& name = parent.name();
|
||||
const int totalSuffixLength = split_suffixes(suffixes, name.c_str(), &fSuffixes);
|
||||
fGmName.set(name.c_str(), name.size()-totalSuffixLength);
|
||||
}
|
||||
const int suffixes = parent.depth() + 1;
|
||||
const SkString& name = parent.name();
|
||||
const int totalSuffixLength = split_suffixes(suffixes, name.c_str(), &fSuffixes);
|
||||
fGmName.set(name.c_str(), name.size()-totalSuffixLength);
|
||||
}
|
||||
|
||||
void WriteTask::makeDirOrFail(SkString dir) {
|
||||
@ -61,6 +59,9 @@ struct PngAndRaw {
|
||||
SkDebugf("Can't encode a PNG.\n");
|
||||
return false;
|
||||
}
|
||||
if (FLAGS_writePngOnly) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Pad out so the raw pixels start 4-byte aligned.
|
||||
const uint32_t maxPadding = 0;
|
||||
|
@ -15,13 +15,8 @@ namespace DM {
|
||||
class WriteTask : public CpuTask {
|
||||
|
||||
public:
|
||||
enum Mode {
|
||||
kParseName_Mode, // Parse the parent's name into directories by underscores.
|
||||
kVerbatim_Mode, // Don't parse the name at all.
|
||||
};
|
||||
WriteTask(const Task& parent, // WriteTask must be a child Task. Pass its parent here.
|
||||
SkBitmap bitmap, // Bitmap to write.
|
||||
Mode = kParseName_Mode);
|
||||
SkBitmap bitmap); // Bitmap to write.
|
||||
|
||||
virtual void draw() SK_OVERRIDE;
|
||||
virtual bool shouldSkip() const SK_OVERRIDE;
|
||||
|
Loading…
Reference in New Issue
Block a user