зеркало из https://github.com/mozilla/moz-skia.git
Cleanup: Rename SkOSPath functions.
Mostly for brevity and matches better with Python: Python | Old C++ | New C++ os.path.join | SkOSPath::SkPathJoin | SkOSPath::Join os.path.basename | SkOSPath::SkBasename | SkOSPath::Basename BUG=None TEST=make all R=mtklein@google.com, bsalomon@google.com Author: tfarina@chromium.org Review URL: https://codereview.chromium.org/428443002
This commit is contained in:
Родитель
2bff230d83
Коммит
a8e2e1504b
|
@ -20,7 +20,7 @@ class DecodeBench : public Benchmark {
|
|||
SkString fName;
|
||||
public:
|
||||
DecodeBench(SkColorType ct) : fPrefColorType(ct) {
|
||||
SkString fname = SkOSPath::SkBasename(FLAGS_decodeBenchFilename[0]);
|
||||
SkString fname = SkOSPath::Basename(FLAGS_decodeBenchFilename[0]);
|
||||
fName.printf("decode_%s_%s", sk_tool_utils::colortype_name(ct), fname.c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
, fFilename(filename)
|
||||
, fStream()
|
||||
, fValid(false) {
|
||||
fName.append(SkOSPath::SkBasename(filename));
|
||||
fName.append(SkOSPath::Basename(filename));
|
||||
}
|
||||
|
||||
virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
|
||||
|
|
|
@ -52,8 +52,7 @@ protected:
|
|||
return;
|
||||
}
|
||||
|
||||
SkString fullPath = SkOSPath::SkPathJoin(resourcePath.c_str(),
|
||||
fFilename.c_str());
|
||||
SkString fullPath = SkOSPath::Join(resourcePath.c_str(), fFilename.c_str());
|
||||
SkFILEStream fileStream(fullPath.c_str());
|
||||
fValid = fileStream.isValid() && fileStream.getLength() > 0;
|
||||
if (fValid) {
|
||||
|
|
|
@ -108,7 +108,7 @@ static void saveFile(const char name[], const char config[], const char dir[],
|
|||
SkString filename;
|
||||
make_filename(name, &filename);
|
||||
filename.appendf("_%s.png", config);
|
||||
SkString path = SkOSPath::SkPathJoin(dir, filename.c_str());
|
||||
SkString path = SkOSPath::Join(dir, filename.c_str());
|
||||
::remove(path.c_str());
|
||||
|
||||
SkFILEWStream stream(path.c_str());
|
||||
|
|
|
@ -128,8 +128,7 @@ static void find_skps(SkTArray<SkString>* skps) {
|
|||
SkString filename;
|
||||
while (it.next(&filename)) {
|
||||
if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, filename.c_str())) {
|
||||
skps->push_back(
|
||||
SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str()));
|
||||
skps->push_back(SkOSPath::Join(FLAGS_skps[0], filename.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +147,7 @@ static void kick_off_skps(const SkTArray<SkString>& skps,
|
|||
exit(1);
|
||||
}
|
||||
|
||||
SkString filename = SkOSPath::SkBasename(skps[i].c_str());
|
||||
SkString filename = SkOSPath::Basename(skps[i].c_str());
|
||||
tasks->add(SkNEW_ARGS(DM::SKPTask, (reporter, tasks, pic, filename)));
|
||||
tasks->add(SkNEW_ARGS(DM::PDFTask, (reporter, tasks, pic, filename,
|
||||
RASTERIZE_PDF_PROC)));
|
||||
|
|
|
@ -136,11 +136,11 @@ void WriteTask::draw() {
|
|||
#endif
|
||||
this->makeDirOrFail(dir);
|
||||
for (int i = 0; i < fSuffixes.count(); i++) {
|
||||
dir = SkOSPath::SkPathJoin(dir.c_str(), fSuffixes[i].c_str());
|
||||
dir = SkOSPath::Join(dir.c_str(), fSuffixes[i].c_str());
|
||||
this->makeDirOrFail(dir);
|
||||
}
|
||||
|
||||
SkString path = SkOSPath::SkPathJoin(dir.c_str(), fGmName.c_str());
|
||||
SkString path = SkOSPath::Join(dir.c_str(), fGmName.c_str());
|
||||
path.append(fExtension);
|
||||
|
||||
const bool ok = fData.get() ? save_data_to_file(fData, path.c_str())
|
||||
|
@ -173,13 +173,13 @@ static SkString path_to_expected_image(const char* root, const Task& task) {
|
|||
SkASSERT(1 == suffixes.count());
|
||||
|
||||
// We'll look in root/suffix for images.
|
||||
const SkString dir = SkOSPath::SkPathJoin(root, suffixes[0].c_str());
|
||||
const SkString dir = SkOSPath::Join(root, suffixes[0].c_str());
|
||||
|
||||
// Remove the suffix and tack on a .png.
|
||||
filename.remove(filename.size() - suffixLength, suffixLength);
|
||||
filename.append(".png");
|
||||
|
||||
return SkOSPath::SkPathJoin(dir.c_str(), filename.c_str());
|
||||
return SkOSPath::Join(dir.c_str(), filename.c_str());
|
||||
}
|
||||
|
||||
bool WriteTask::Expectations::check(const Task& task, SkBitmap bitmap) const {
|
||||
|
|
|
@ -157,7 +157,7 @@ int tool_main(int argc, char** argv) {
|
|||
if (!is_image_file(filename.c_str())) {
|
||||
continue;
|
||||
}
|
||||
SkString fullname = SkOSPath::SkPathJoin(dir, filename.c_str());
|
||||
SkString fullname = SkOSPath::Join(dir, filename.c_str());
|
||||
decodeFileAndWrite(fullname.c_str());
|
||||
}
|
||||
} else if (sk_exists(readPath) && is_image_file(readPath)) {
|
||||
|
|
|
@ -103,7 +103,7 @@ static bool add_page_and_replace_filename_extension(SkString* path, int page,
|
|||
static bool make_output_filepath(SkString* path, const SkString& dir,
|
||||
const SkString& name,
|
||||
int page) {
|
||||
*path = SkOSPath::SkPathJoin(dir.c_str(), name.c_str());
|
||||
*path = SkOSPath::Join(dir.c_str(), name.c_str());
|
||||
return add_page_and_replace_filename_extension(path, page,
|
||||
PDF_FILE_EXTENSION,
|
||||
PNG_FILE_EXTENSION);
|
||||
|
@ -221,7 +221,7 @@ static bool render_page(const SkString& outputDir,
|
|||
static bool process_pdf(const SkString& inputPath, const SkString& outputDir) {
|
||||
SkDebugf("Loading PDF: %s\n", inputPath.c_str());
|
||||
|
||||
SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str());
|
||||
SkString inputFilename = SkOSPath::Basename(inputPath.c_str());
|
||||
|
||||
SkAutoTDelete<SkPdfRenderer> renderer(SkPdfRenderer::CreateFromFile(inputPath.c_str()));
|
||||
if (NULL == renderer.get()) {
|
||||
|
@ -299,7 +299,7 @@ static int process_input(const char* input, const SkString& outputDir) {
|
|||
SkOSFile::Iter iter(input, PDF_FILE_EXTENSION);
|
||||
SkString inputFilename;
|
||||
while (iter.next(&inputFilename)) {
|
||||
SkString inputPath = SkOSPath::SkPathJoin(input, inputFilename.c_str());
|
||||
SkString inputPath = SkOSPath::Join(input, inputFilename.c_str());
|
||||
if (!process_pdf(inputPath, outputDir)) {
|
||||
++failures;
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ namespace skiagm {
|
|||
// IndividualImageExpectationsSource class...
|
||||
|
||||
Expectations IndividualImageExpectationsSource::get(const char *testName) const {
|
||||
SkString path = SkOSPath::SkPathJoin(fRootDir.c_str(), testName);
|
||||
SkString path = SkOSPath::Join(fRootDir.c_str(), testName);
|
||||
SkBitmap referenceBitmap;
|
||||
bool decodedReferenceBitmap =
|
||||
SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap, kN32_SkColorType,
|
||||
|
|
|
@ -237,7 +237,7 @@ public:
|
|||
filename.append(renderModeDescriptor);
|
||||
filename.appendUnichar('.');
|
||||
filename.append(suffix);
|
||||
return SkOSPath::SkPathJoin(path, filename.c_str());
|
||||
return SkOSPath::Join(path, filename.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,7 +257,7 @@ public:
|
|||
filename.append(bitmapDigest.getDigestValue());
|
||||
filename.appendUnichar('.');
|
||||
filename.append(kPNG_FileExtension);
|
||||
return SkOSPath::SkPathJoin(path, filename.c_str());
|
||||
return SkOSPath::Join(path, filename.c_str());
|
||||
} else {
|
||||
return make_filename(path, shortName, configName, renderModeDescriptor,
|
||||
kPNG_FileExtension);
|
||||
|
|
|
@ -133,7 +133,7 @@ public:
|
|||
*
|
||||
* Uses SkPATH_SEPARATOR, to work on all platforms.
|
||||
*/
|
||||
static SkString SkPathJoin(const char *rootPath, const char *relativePath);
|
||||
static SkString Join(const char* rootPath, const char* relativePath);
|
||||
|
||||
/**
|
||||
* Return the name of the file, ignoring the directory structure.
|
||||
|
@ -143,6 +143,7 @@ public:
|
|||
* @return SkString The basename of the file - anything beyond the
|
||||
* final slash, or the full name if there is no slash.
|
||||
*/
|
||||
static SkString SkBasename(const char* fullPath);
|
||||
static SkString Basename(const char* fullPath);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -755,7 +755,7 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
|
|||
SkString filename;
|
||||
while (iter.next(&filename)) {
|
||||
*fSamples.append() = new PictFileFactory(
|
||||
SkOSPath::SkPathJoin(FLAGS_pictureDir[0], filename.c_str()));
|
||||
SkOSPath::Join(FLAGS_pictureDir[0], filename.c_str()));
|
||||
}
|
||||
}
|
||||
if (!FLAGS_picture.isEmpty()) {
|
||||
|
@ -769,7 +769,7 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
|
|||
SkString filename;
|
||||
while (iter.next(&filename)) {
|
||||
*fSamples.append() = new PdfFileViewerFactory(
|
||||
SkOSPath::SkPathJoin(FLAGS_pictureDir[0], filename.c_str()));
|
||||
SkOSPath::Join(FLAGS_pictureDir[0], filename.c_str()));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -106,7 +106,7 @@ protected:
|
|||
}
|
||||
|
||||
// Name, size of the file, and whether or not it is premultiplied.
|
||||
SkString header(SkOSPath::SkBasename(fCurrFile.c_str()));
|
||||
SkString header(SkOSPath::Basename(fCurrFile.c_str()));
|
||||
header.appendf(" [%dx%d] %s", fBitmap.width(), fBitmap.height(),
|
||||
(fPremul ? "premultiplied" : "unpremultiplied"));
|
||||
canvas->drawText(header.c_str(), header.size(), 0, height, paint);
|
||||
|
@ -167,7 +167,7 @@ private:
|
|||
return;
|
||||
}
|
||||
}
|
||||
fCurrFile = SkOSPath::SkPathJoin(fResPath.c_str(), basename.c_str());
|
||||
fCurrFile = SkOSPath::Join(fResPath.c_str(), basename.c_str());
|
||||
this->decodeCurrFile();
|
||||
}
|
||||
|
||||
|
|
|
@ -323,7 +323,7 @@ private:
|
|||
|
||||
while (iter.next(&name, false)) {
|
||||
SkString filename(
|
||||
SkOSPath::SkPathJoin(directory.c_str(), name.c_str()));
|
||||
SkOSPath::Join(directory.c_str(), name.c_str()));
|
||||
|
||||
bool isFixedPitch;
|
||||
SkString realname;
|
||||
|
@ -354,8 +354,7 @@ private:
|
|||
if (name.startsWith(".")) {
|
||||
continue;
|
||||
}
|
||||
SkString dirname(
|
||||
SkOSPath::SkPathJoin(directory.c_str(), name.c_str()));
|
||||
SkString dirname(SkOSPath::Join(directory.c_str(), name.c_str()));
|
||||
load_directory_fonts(dirname);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
#include "SkOSFile.h"
|
||||
|
||||
SkString SkOSPath::SkPathJoin(const char *rootPath, const char *relativePath) {
|
||||
SkString SkOSPath::Join(const char *rootPath, const char *relativePath) {
|
||||
SkString result(rootPath);
|
||||
if (!result.endsWith(SkPATH_SEPARATOR)) {
|
||||
result.appendUnichar(SkPATH_SEPARATOR);
|
||||
|
@ -15,7 +15,7 @@ SkString SkOSPath::SkPathJoin(const char *rootPath, const char *relativePath) {
|
|||
return result;
|
||||
}
|
||||
|
||||
SkString SkOSPath::SkBasename(const char* fullPath) {
|
||||
SkString SkOSPath::Basename(const char* fullPath) {
|
||||
if (!fullPath) {
|
||||
return SkString();
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ static void test_files(skiatest::Reporter* reporter) {
|
|||
return;
|
||||
}
|
||||
|
||||
SkString path = SkOSPath::SkPathJoin(tmpDir.c_str(), "data_test");
|
||||
SkString path = SkOSPath::Join(tmpDir.c_str(), "data_test");
|
||||
|
||||
const char s[] = "abcdefghijklmnopqrstuvwxyz";
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ static void test_abortWithFile(skiatest::Reporter* reporter) {
|
|||
// allways, then all these tests will be disabled.
|
||||
}
|
||||
|
||||
SkString path = SkOSPath::SkPathJoin(tmpDir.c_str(), "aborted.pdf");
|
||||
SkString path = SkOSPath::Join(tmpDir.c_str(), "aborted.pdf");
|
||||
|
||||
// Make sure doc's destructor is called to flush.
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ static void test_file(skiatest::Reporter* reporter) {
|
|||
// allways, then all these tests will be disabled.
|
||||
}
|
||||
|
||||
SkString path = SkOSPath::SkPathJoin(tmpDir.c_str(), "file.pdf");
|
||||
SkString path = SkOSPath::Join(tmpDir.c_str(), "file.pdf");
|
||||
|
||||
SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(path.c_str()));
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ static void test_fontstream(skiatest::Reporter* reporter) {
|
|||
SkDebugf("Could not run fontstream test because resourcePath not specified.");
|
||||
return;
|
||||
}
|
||||
SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "test.ttc");
|
||||
SkString filename = SkOSPath::Join(resourcePath.c_str(), "test.ttc");
|
||||
|
||||
SkFILEStream stream(filename.c_str());
|
||||
if (stream.isValid()) {
|
||||
|
|
|
@ -158,7 +158,7 @@ static void test_unpremul(skiatest::Reporter* reporter) {
|
|||
SkString basename;
|
||||
if (iter.next(&basename)) {
|
||||
do {
|
||||
SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), basename.c_str());
|
||||
SkString filename = SkOSPath::Join(resourcePath.c_str(), basename.c_str());
|
||||
// SkDebugf("about to decode \"%s\"\n", filename.c_str());
|
||||
compare_unpremul(reporter, filename);
|
||||
} while (iter.next(&basename));
|
||||
|
@ -241,7 +241,7 @@ DEF_TEST(ImageDecoding_alphaType, reporter) {
|
|||
SkString basename;
|
||||
if (iter.next(&basename)) {
|
||||
do {
|
||||
SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), basename.c_str());
|
||||
SkString filename = SkOSPath::Join(resourcePath.c_str(), basename.c_str());
|
||||
for (int truth = 0; truth <= 1; ++truth) {
|
||||
test_alphaType(reporter, filename, SkToBool(truth));
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ DEF_TEST(ImageDecoding_unpremul, reporter) {
|
|||
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(suffixes); ++i) {
|
||||
SkString basename = SkStringPrintf("%s%s", root, suffixes[i]);
|
||||
SkString fullName = SkOSPath::SkPathJoin(resourcePath.c_str(), basename.c_str());
|
||||
SkString fullName = SkOSPath::Join(resourcePath.c_str(), basename.c_str());
|
||||
|
||||
SkBitmap bm;
|
||||
SkFILEStream stream(fullName.c_str());
|
||||
|
@ -692,7 +692,7 @@ DEF_TEST(ImageDecoderOptions, reporter) {
|
|||
const bool useDataList[] = {true, false};
|
||||
|
||||
for (size_t fidx = 0; fidx < SK_ARRAY_COUNT(files); ++fidx) {
|
||||
SkString path = SkOSPath::SkPathJoin(resourceDir.c_str(), files[fidx]);
|
||||
SkString path = SkOSPath::Join(resourceDir.c_str(), files[fidx]);
|
||||
if (!sk_exists(path.c_str())) {
|
||||
continue;
|
||||
}
|
||||
|
@ -726,7 +726,7 @@ DEF_TEST(ImageDecoderOptions, reporter) {
|
|||
|
||||
DEF_TEST(DiscardablePixelRef_SecondLockColorTableCheck, r) {
|
||||
SkString resourceDir = GetResourcePath();
|
||||
SkString path = SkOSPath::SkPathJoin(resourceDir.c_str(), "randPixels.gif");
|
||||
SkString path = SkOSPath::Join(resourceDir.c_str(), "randPixels.gif");
|
||||
if (!sk_exists(path.c_str())) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#include "Test.h"
|
||||
|
||||
/**
|
||||
* Test SkPathJoin and SkBasename.
|
||||
* Will use SkPathJoin to append filename to dir, test that it works correctly,
|
||||
* and tests using SkBasename on the result.
|
||||
* Test SkOSPath::Join and SkOSPath::Basename.
|
||||
* Will use SkOSPath::Join to append filename to dir, test that it works correctly,
|
||||
* and tests using SkOSPath::Basename on the result.
|
||||
* @param reporter Reporter for test conditions.
|
||||
* @param dir String representing the path to a folder. May or may not
|
||||
* end with SkPATH_SEPARATOR.
|
||||
|
@ -24,10 +24,10 @@ static void test_dir_with_file(skiatest::Reporter* reporter, SkString dir,
|
|||
// If filename contains SkPATH_SEPARATOR, the tests will fail.
|
||||
SkASSERT(!filename.contains(SkPATH_SEPARATOR));
|
||||
|
||||
// Tests for SkOSPath::SkPathJoin and SkOSPath::SkBasename
|
||||
// Tests for SkOSPath::Join and SkOSPath::Basename
|
||||
|
||||
// fullName should be "dir<SkPATH_SEPARATOR>file"
|
||||
SkString fullName = SkOSPath::SkPathJoin(dir.c_str(), filename.c_str());
|
||||
SkString fullName = SkOSPath::Join(dir.c_str(), filename.c_str());
|
||||
|
||||
// fullName should be the combined size of dir and file, plus one if
|
||||
// dir did not include the final path separator.
|
||||
|
@ -37,7 +37,7 @@ static void test_dir_with_file(skiatest::Reporter* reporter, SkString dir,
|
|||
}
|
||||
REPORTER_ASSERT(reporter, fullName.size() == expectedSize);
|
||||
|
||||
SkString basename = SkOSPath::SkBasename(fullName.c_str());
|
||||
SkString basename = SkOSPath::Basename(fullName.c_str());
|
||||
|
||||
// basename should be the same as filename
|
||||
REPORTER_ASSERT(reporter, basename.equals(filename));
|
||||
|
@ -46,7 +46,7 @@ static void test_dir_with_file(skiatest::Reporter* reporter, SkString dir,
|
|||
REPORTER_ASSERT(reporter, !basename.contains(SkPATH_SEPARATOR));
|
||||
|
||||
// Now take the basename of filename, which should be the same as filename.
|
||||
basename = SkOSPath::SkBasename(filename.c_str());
|
||||
basename = SkOSPath::Basename(filename.c_str());
|
||||
REPORTER_ASSERT(reporter, basename.equals(filename));
|
||||
}
|
||||
|
||||
|
@ -71,15 +71,15 @@ DEF_TEST(OSPath, reporter) {
|
|||
|
||||
// Basename of a directory with a path separator at the end is empty.
|
||||
dir.appendUnichar(SkPATH_SEPARATOR);
|
||||
SkString baseOfDir = SkOSPath::SkBasename(dir.c_str());
|
||||
SkString baseOfDir = SkOSPath::Basename(dir.c_str());
|
||||
REPORTER_ASSERT(reporter, baseOfDir.size() == 0);
|
||||
|
||||
// Basename of NULL is an empty string.
|
||||
SkString empty = SkOSPath::SkBasename(NULL);
|
||||
SkString empty = SkOSPath::Basename(NULL);
|
||||
REPORTER_ASSERT(reporter, empty.size() == 0);
|
||||
|
||||
// Test that NULL can be used for the directory and filename.
|
||||
SkString emptyPath = SkOSPath::SkPathJoin(NULL, NULL);
|
||||
SkString emptyPath = SkOSPath::Join(NULL, NULL);
|
||||
REPORTER_ASSERT(reporter, emptyPath.size() == 1);
|
||||
REPORTER_ASSERT(reporter, emptyPath.contains(SkPATH_SEPARATOR));
|
||||
}
|
||||
|
|
|
@ -299,7 +299,7 @@ static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) {
|
|||
SkDebugf("Could not run fontstream test because resourcePath not specified.");
|
||||
return;
|
||||
}
|
||||
SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "test.ttc");
|
||||
SkString filename = SkOSPath::Join(resourcePath.c_str(), "test.ttc");
|
||||
SkTypeface* typeface = SkTypeface::CreateFromFile(filename.c_str());
|
||||
if (!typeface) {
|
||||
SkDebugf("Could not run fontstream test because test.ttc not found.");
|
||||
|
|
|
@ -37,7 +37,7 @@ static void test_loop_stream(skiatest::Reporter* reporter, SkStream* stream,
|
|||
}
|
||||
|
||||
static void test_filestreams(skiatest::Reporter* reporter, const char* tmpDir) {
|
||||
SkString path = SkOSPath::SkPathJoin(tmpDir, "wstream_test");
|
||||
SkString path = SkOSPath::Join(tmpDir, "wstream_test");
|
||||
|
||||
const char s[] = "abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
|
|
|
@ -72,8 +72,8 @@ namespace sk_tools {
|
|||
// a bitmap directly.
|
||||
// TODO: Share more common code with write() to do this, to properly
|
||||
// write out the JSON summary, etc.
|
||||
SkString pathWithNumber = SkOSPath::SkPathJoin(fWritePath.c_str(),
|
||||
fInputFilename.c_str());
|
||||
SkString pathWithNumber = SkOSPath::Join(fWritePath.c_str(),
|
||||
fInputFilename.c_str());
|
||||
pathWithNumber.remove(pathWithNumber.size() - 4, 4);
|
||||
pathWithNumber.appendf("%i.png", i++);
|
||||
SkBitmap copy;
|
||||
|
|
|
@ -363,7 +363,7 @@ bool RecordPictureRenderer::render(SkBitmap** out) {
|
|||
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
|
||||
if (!fWritePath.isEmpty()) {
|
||||
// Record the new picture as a new SKP with PNG encoded bitmaps.
|
||||
SkString skpPath = SkOSPath::SkPathJoin(fWritePath.c_str(), fInputFilename.c_str());
|
||||
SkString skpPath = SkOSPath::Join(fWritePath.c_str(), fInputFilename.c_str());
|
||||
SkFILEWStream stream(skpPath.c_str());
|
||||
picture->serialize(&stream, &encode_bitmap_to_data);
|
||||
return true;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
DEFINE_string2(resourcePath, i, "resources", "Directory with test resources: images, fonts, etc.");
|
||||
|
||||
SkString GetResourcePath(const char* resource) {
|
||||
return SkOSPath::SkPathJoin(FLAGS_resourcePath[0], resource);
|
||||
return SkOSPath::Join(FLAGS_resourcePath[0], resource);
|
||||
}
|
||||
|
||||
void SetResourcePath(const char* resource) {
|
||||
|
|
|
@ -197,7 +197,7 @@ static bool run_single_benchmark(const SkString& inputPath,
|
|||
return false;
|
||||
}
|
||||
|
||||
SkString filename = SkOSPath::SkBasename(inputPath.c_str());
|
||||
SkString filename = SkOSPath::Basename(inputPath.c_str());
|
||||
|
||||
gWriter.bench(filename.c_str(), picture->width(), picture->height());
|
||||
|
||||
|
@ -376,7 +376,7 @@ static int process_input(const char* input,
|
|||
int failures = 0;
|
||||
if (iter.next(&inputFilename)) {
|
||||
do {
|
||||
SkString inputPath = SkOSPath::SkPathJoin(input, inputFilename.c_str());
|
||||
SkString inputPath = SkOSPath::Join(input, inputFilename.c_str());
|
||||
if (!run_single_benchmark(inputPath, benchmark)) {
|
||||
++failures;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ int tool_main(int argc, char** argv) {
|
|||
continue;
|
||||
}
|
||||
|
||||
const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str());
|
||||
const SkString path = SkOSPath::Join(FLAGS_skps[0], filename.c_str());
|
||||
|
||||
SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str()));
|
||||
if (!stream) {
|
||||
|
|
|
@ -149,7 +149,7 @@ int tool_main(int argc, char** argv) {
|
|||
continue;
|
||||
}
|
||||
|
||||
const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str());
|
||||
const SkString path = SkOSPath::Join(FLAGS_skps[0], filename.c_str());
|
||||
|
||||
SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str()));
|
||||
if (!stream) {
|
||||
|
|
|
@ -816,9 +816,9 @@ int tool_main(int argc, char** argv) {
|
|||
if (iter.next(&inputFilename)) {
|
||||
|
||||
do {
|
||||
inFile = SkOSPath::SkPathJoin(inDir.c_str(), inputFilename.c_str());
|
||||
inFile = SkOSPath::Join(inDir.c_str(), inputFilename.c_str());
|
||||
if (!outDir.isEmpty()) {
|
||||
outFile = SkOSPath::SkPathJoin(outDir.c_str(), inputFilename.c_str());
|
||||
outFile = SkOSPath::Join(outDir.c_str(), inputFilename.c_str());
|
||||
}
|
||||
SkDebugf("Executing %s\n", inputFilename.c_str());
|
||||
filter_picture(inFile, outFile);
|
||||
|
|
|
@ -132,7 +132,7 @@ int tool_main(int argc, char** argv) {
|
|||
SkString filename;
|
||||
SkOSFile::Iter iter(FLAGS_skpPath[i], "skp");
|
||||
while(iter.next(&filename)) {
|
||||
paths.push_back() = SkOSPath::SkPathJoin(directory.c_str(), filename.c_str());
|
||||
paths.push_back() = SkOSPath::Join(directory.c_str(), filename.c_str());
|
||||
}
|
||||
} else {
|
||||
// Add this as an .skp itself.
|
||||
|
|
|
@ -55,12 +55,12 @@ namespace sk_tools {
|
|||
const char *subdirOrNull, const SkString& baseName) {
|
||||
SkString partialPath;
|
||||
if (subdirOrNull) {
|
||||
partialPath = SkOSPath::SkPathJoin(dirPath.c_str(), subdirOrNull);
|
||||
partialPath = SkOSPath::Join(dirPath.c_str(), subdirOrNull);
|
||||
sk_mkdir(partialPath.c_str());
|
||||
} else {
|
||||
partialPath.set(dirPath);
|
||||
}
|
||||
SkString fullPath = SkOSPath::SkPathJoin(partialPath.c_str(), baseName.c_str());
|
||||
SkString fullPath = SkOSPath::Join(partialPath.c_str(), baseName.c_str());
|
||||
if (SkImageEncoder::EncodeFile(fullPath.c_str(), bm, SkImageEncoder::kPNG_Type, 100)) {
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -111,7 +111,7 @@ static SkData* encode_to_dct_data(size_t*, const SkBitmap& bitmap) {
|
|||
*/
|
||||
static bool make_output_filepath(SkString* path, const SkString& dir,
|
||||
const SkString& name) {
|
||||
*path = SkOSPath::SkPathJoin(dir.c_str(), name.c_str());
|
||||
*path = SkOSPath::Join(dir.c_str(), name.c_str());
|
||||
return replace_filename_extension(path,
|
||||
SKP_FILE_EXTENSION,
|
||||
PDF_FILE_EXTENSION);
|
||||
|
@ -149,7 +149,7 @@ static SkWStream* open_stream(const SkString& outputDir,
|
|||
*/
|
||||
static bool render_pdf(const SkString& inputPath, const SkString& outputDir,
|
||||
sk_tools::PdfRenderer& renderer) {
|
||||
SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str());
|
||||
SkString inputFilename = SkOSPath::Basename(inputPath.c_str());
|
||||
|
||||
SkFILEStream inputStream;
|
||||
inputStream.setPath(inputPath.c_str());
|
||||
|
@ -197,7 +197,7 @@ static int process_input(const SkString& input, const SkString& outputDir,
|
|||
SkOSFile::Iter iter(input.c_str(), SKP_FILE_EXTENSION);
|
||||
SkString inputFilename;
|
||||
while (iter.next(&inputFilename)) {
|
||||
SkString inputPath = SkOSPath::SkPathJoin(input.c_str(), inputFilename.c_str());
|
||||
SkString inputPath = SkOSPath::Join(input.c_str(), inputFilename.c_str());
|
||||
if (!render_pdf(inputPath, outputDir, renderer)) {
|
||||
++failures;
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ static bool write_image_to_file(const void* buffer, size_t size, SkBitmap* bitma
|
|||
SkString name = SkStringPrintf("%s_%d%s", gInputFileName.c_str(), gImageNo++,
|
||||
get_suffix_from_format(format));
|
||||
SkString dir(FLAGS_writePath[0]);
|
||||
outPath = SkOSPath::SkPathJoin(dir.c_str(), name.c_str());
|
||||
outPath = SkOSPath::Join(dir.c_str(), name.c_str());
|
||||
SkFILEWStream fileStream(outPath.c_str());
|
||||
if (!(fileStream.isValid() && fileStream.write(buffer, size))) {
|
||||
SkDebugf("Failed to write encoded data to \"%s\"\n", outPath.c_str());
|
||||
|
@ -142,7 +142,7 @@ static bool render_picture_internal(const SkString& inputPath, const SkString* w
|
|||
const SkString* mismatchPath,
|
||||
sk_tools::PictureRenderer& renderer,
|
||||
SkBitmap** out) {
|
||||
SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str());
|
||||
SkString inputFilename = SkOSPath::Basename(inputPath.c_str());
|
||||
SkString writePathString;
|
||||
if (NULL != writePath && writePath->size() > 0 && !FLAGS_writeEncodedImages) {
|
||||
writePathString.set(*writePath);
|
||||
|
@ -345,7 +345,7 @@ static bool render_picture(const SkString& inputPath, const SkString* writePath,
|
|||
if (FLAGS_writeWholeImage) {
|
||||
sk_tools::force_all_opaque(*bitmap);
|
||||
|
||||
SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str());
|
||||
SkString inputFilename = SkOSPath::Basename(inputPath.c_str());
|
||||
SkString outputFilename(inputFilename);
|
||||
sk_tools::replace_char(&outputFilename, '.', '_');
|
||||
outputFilename.append(".png");
|
||||
|
@ -379,7 +379,7 @@ static int process_input(const char* input, const SkString* writePath,
|
|||
SkDebugf("process_input, %s\n", input);
|
||||
if (iter.next(&inputFilename)) {
|
||||
do {
|
||||
SkString inputPath = SkOSPath::SkPathJoin(input, inputFilename.c_str());
|
||||
SkString inputPath = SkOSPath::Join(input, inputFilename.c_str());
|
||||
if (!render_picture(inputPath, writePath, mismatchPath, renderer, jsonSummaryPtr)) {
|
||||
++failures;
|
||||
}
|
||||
|
|
|
@ -80,8 +80,8 @@ static SkImageDecoder::Format guess_format_from_suffix(const char suffix[]) {
|
|||
|
||||
static void make_outname(SkString* dst, const char outDir[], const char src[],
|
||||
const char suffix[]) {
|
||||
SkString basename = SkOSPath::SkBasename(src);
|
||||
dst->set(SkOSPath::SkPathJoin(outDir, basename.c_str()));
|
||||
SkString basename = SkOSPath::Basename(src);
|
||||
dst->set(SkOSPath::Join(outDir, basename.c_str()));
|
||||
dst->append(suffix);
|
||||
}
|
||||
|
||||
|
@ -138,14 +138,14 @@ static bool write_bitmap(const char outDir[], const char src[],
|
|||
if (FLAGS_writeChecksumBasedFilenames) {
|
||||
// First create the directory for the hashtype.
|
||||
const SkString hashType = bitmapAndDigest.fDigest.getHashType();
|
||||
const SkString hashDir = SkOSPath::SkPathJoin(outDir, hashType.c_str());
|
||||
const SkString hashDir = SkOSPath::Join(outDir, hashType.c_str());
|
||||
if (!sk_mkdir(hashDir.c_str())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now create the name of the folder specific to this image.
|
||||
SkString basename = SkOSPath::SkBasename(src);
|
||||
const SkString imageDir = SkOSPath::SkPathJoin(hashDir.c_str(), basename.c_str());
|
||||
SkString basename = SkOSPath::Basename(src);
|
||||
const SkString imageDir = SkOSPath::Join(hashDir.c_str(), basename.c_str());
|
||||
if (!sk_mkdir(imageDir.c_str())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ static bool write_bitmap(const char outDir[], const char src[],
|
|||
SkString checksumBasedName = bitmapAndDigest.fDigest.getDigestValue();
|
||||
checksumBasedName.append(".png");
|
||||
|
||||
filename = SkOSPath::SkPathJoin(imageDir.c_str(), checksumBasedName.c_str());
|
||||
filename = SkOSPath::Join(imageDir.c_str(), checksumBasedName.c_str());
|
||||
} else {
|
||||
make_outname(&filename, outDir, src, ".png");
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ static bool write_subset(const char* writePath, const SkString& subsetName,
|
|||
subsetPath.set(writePath);
|
||||
} else {
|
||||
// Create a subdirectory to hold the results of decodeSubset.
|
||||
subsetPath = SkOSPath::SkPathJoin(writePath, "subsets");
|
||||
subsetPath = SkOSPath::Join(writePath, "subsets");
|
||||
if (!sk_mkdir(subsetPath.c_str())) {
|
||||
gFailedSubsetDecodes.push_back().printf("Successfully decoded subset %s, but "
|
||||
"failed to create a directory to write to.",
|
||||
|
@ -385,7 +385,7 @@ static bool write_subset(const char* writePath, const SkString& subsetName,
|
|||
return false;
|
||||
}
|
||||
|
||||
SkString dirExtracted = SkOSPath::SkPathJoin(writePath, "extracted");
|
||||
SkString dirExtracted = SkOSPath::Join(writePath, "extracted");
|
||||
if (!sk_mkdir(dirExtracted.c_str())) {
|
||||
gFailedSubsetDecodes.push_back().printf("Successfully decoded subset%s, but failed "
|
||||
"to create a directory for extractSubset "
|
||||
|
@ -502,7 +502,7 @@ static void decodeFileAndWrite(const char srcPath[], const SkString* writePath)
|
|||
stream.rewind();
|
||||
|
||||
// Create a string representing just the filename itself, for use in json expectations.
|
||||
SkString basename = SkOSPath::SkBasename(srcPath);
|
||||
SkString basename = SkOSPath::Basename(srcPath);
|
||||
// Replace '_' with '-', so that the names can fit gm_json.py's IMAGE_FILENAME_PATTERN
|
||||
replace_char(&basename, '_', '-');
|
||||
// Replace '.' with '-', so the output filename can still retain the original file extension,
|
||||
|
@ -796,7 +796,7 @@ int tool_main(int argc, char** argv) {
|
|||
if (!is_image_file(filename.c_str())) {
|
||||
continue;
|
||||
}
|
||||
SkString fullname = SkOSPath::SkPathJoin(dir, filename.c_str());
|
||||
SkString fullname = SkOSPath::Join(dir, filename.c_str());
|
||||
decodeFileAndWrite(fullname.c_str(), outDirPtr);
|
||||
}
|
||||
} else if (sk_exists(readPath) && is_image_file(readPath)) {
|
||||
|
|
|
@ -98,8 +98,8 @@ void SkDiffContext::addDiff(const char* baselinePath, const char* testPath) {
|
|||
fRecordMutex.release();
|
||||
|
||||
// compute the common name
|
||||
SkString baseName = SkOSPath::SkBasename(baselinePath);
|
||||
SkString testName = SkOSPath::SkBasename(testPath);
|
||||
SkString baseName = SkOSPath::Basename(baselinePath);
|
||||
SkString testName = SkOSPath::Basename(testPath);
|
||||
newRecord->fCommonName = get_common_prefix(baseName, testName);
|
||||
|
||||
newRecord->fBaselinePath = baselinePath;
|
||||
|
@ -134,8 +134,8 @@ void SkDiffContext::addDiff(const char* baselinePath, const char* testPath) {
|
|||
&& !diffData.fResult.poiAlphaMask.empty()
|
||||
&& !newRecord->fCommonName.isEmpty()) {
|
||||
|
||||
newRecord->fAlphaMaskPath = SkOSPath::SkPathJoin(fAlphaMaskDir.c_str(),
|
||||
newRecord->fCommonName.c_str());
|
||||
newRecord->fAlphaMaskPath = SkOSPath::Join(fAlphaMaskDir.c_str(),
|
||||
newRecord->fCommonName.c_str());
|
||||
|
||||
// compute the image diff and output it
|
||||
SkBitmap copy;
|
||||
|
@ -163,8 +163,8 @@ void SkDiffContext::addDiff(const char* baselinePath, const char* testPath) {
|
|||
newRecord->fMaxGreenDiff = diffData.fResult.maxGreenDiff;
|
||||
newRecord->fMaxBlueDiff = diffData.fResult.maxBlueDiff;
|
||||
|
||||
newRecord->fRgbDiffPath = SkOSPath::SkPathJoin(fRgbDiffDir.c_str(),
|
||||
newRecord->fCommonName.c_str());
|
||||
newRecord->fRgbDiffPath = SkOSPath::Join(fRgbDiffDir.c_str(),
|
||||
newRecord->fCommonName.c_str());
|
||||
SkImageEncoder::EncodeFile(newRecord->fRgbDiffPath.c_str(),
|
||||
diffData.fResult.rgbDiffBitmap,
|
||||
SkImageEncoder::kPNG_Type, 100);
|
||||
|
@ -176,8 +176,8 @@ void SkDiffContext::addDiff(const char* baselinePath, const char* testPath) {
|
|||
&& SkImageDiffer::RESULT_CORRECT != diffData.fResult.result
|
||||
&& !diffData.fResult.whiteDiffBitmap.empty()
|
||||
&& !newRecord->fCommonName.isEmpty()) {
|
||||
newRecord->fWhiteDiffPath = SkOSPath::SkPathJoin(fWhiteDiffDir.c_str(),
|
||||
newRecord->fCommonName.c_str());
|
||||
newRecord->fWhiteDiffPath = SkOSPath::Join(fWhiteDiffDir.c_str(),
|
||||
newRecord->fCommonName.c_str());
|
||||
SkImageEncoder::EncodeFile(newRecord->fWhiteDiffPath.c_str(),
|
||||
diffData.fResult.whiteDiffBitmap,
|
||||
SkImageEncoder::kPNG_Type, 100);
|
||||
|
@ -223,8 +223,8 @@ void SkDiffContext::diffDirectories(const char baselinePath[], const char testPa
|
|||
const char* baseFilename = baselineEntries[x].c_str();
|
||||
|
||||
// Find the real location of each file to compare
|
||||
SkString baselineFile = SkOSPath::SkPathJoin(baselinePath, baseFilename);
|
||||
SkString testFile = SkOSPath::SkPathJoin(testPath, baseFilename);
|
||||
SkString baselineFile = SkOSPath::Join(baselinePath, baseFilename);
|
||||
SkString testFile = SkOSPath::Join(testPath, baseFilename);
|
||||
|
||||
// Check that the test file exists and is a file
|
||||
if (sk_exists(testFile.c_str()) && !sk_isdir(testFile.c_str())) {
|
||||
|
|
|
@ -117,7 +117,7 @@ bool get_directory(const char path[], SkTArray<SkString>* entries) {
|
|||
while ((entry = readdir(dir))) {
|
||||
// dirent only gives relative paths, we need to join them to the base path to check if they
|
||||
// are directories.
|
||||
SkString joinedPath = SkOSPath::SkPathJoin(path, entry->d_name);
|
||||
SkString joinedPath = SkOSPath::Join(path, entry->d_name);
|
||||
|
||||
// We only care about files
|
||||
if (!sk_isdir(joinedPath.c_str())) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче