Bug 1428258 - Stop using GetNativePath in gfx/. r=jrmuizel

MozReview-Commit-ID: EdcKDRQeGXg

--HG--
extra : rebase_source : 8a6f93091e7f7cf96f998a3b8a5ce518c822f112
extra : intermediate-source : 77d4d136028337085cebdb59201302676a2ec521
extra : source : 477624377a9796459ada93719df68ba152587781
This commit is contained in:
Masatoshi Kimura 2017-12-17 00:13:30 +09:00
Родитель a7c8bc12b4
Коммит dea129ada5
9 изменённых файлов: 33 добавлений и 24 удалений

Просмотреть файл

@ -22,6 +22,7 @@
// to be able to hold on to a GLContext.
#include "mozilla/GenericRefCounted.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/Path.h"
// This RefPtr class isn't ideal for usage in Azure, as it doesn't allow T**
// outparams using the &-operator. But it will have to do as there's no easy
@ -1534,6 +1535,7 @@ struct Config {
class GFX2D_API Factory
{
using char_type = filesystem::Path::value_type;
public:
static void Init(const Config& aConfig);
static void ShutDown();
@ -1698,7 +1700,7 @@ public:
static already_AddRefed<DrawEventRecorder>
CreateEventRecorderForFile(const char *aFilename);
CreateEventRecorderForFile(const char_type* aFilename);
static void SetGlobalEventRecorder(DrawEventRecorder *aRecorder);

Просмотреть файл

@ -35,7 +35,7 @@ DrawEventRecorderMemory::RecordEvent(const RecordedEvent &aEvent)
aEvent.RecordToStream(mOutputStream);
}
DrawEventRecorderFile::DrawEventRecorderFile(const char *aFilename)
DrawEventRecorderFile::DrawEventRecorderFile(const char_type* aFilename)
: mOutputStream(aFilename, ofstream::binary)
{
WriteHeader(mOutputStream);
@ -59,7 +59,7 @@ DrawEventRecorderFile::IsOpen()
}
void
DrawEventRecorderFile::OpenNew(const char *aFilename)
DrawEventRecorderFile::OpenNew(const char_type* aFilename)
{
MOZ_ASSERT(!mOutputStream.is_open());

Просмотреть файл

@ -10,8 +10,7 @@
#include "2D.h"
#include "RecordedEvent.h"
#include "RecordingTypes.h"
#include <ostream>
#include <fstream>
#include "mozilla/FStream.h"
#include <unordered_set>
#include <unordered_map>
@ -129,9 +128,10 @@ protected:
class DrawEventRecorderFile : public DrawEventRecorderPrivate
{
using char_type = filesystem::Path::value_type;
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawEventRecorderFile, override)
explicit DrawEventRecorderFile(const char *aFilename);
explicit DrawEventRecorderFile(const char_type* aFilename);
~DrawEventRecorderFile();
void RecordEvent(const RecordedEvent &aEvent) override;
@ -146,7 +146,7 @@ public:
* objects it has recorded. This can be used with Close, so that a recording
* can be processed in chunks. The file must not already be open.
*/
void OpenNew(const char *aFilename);
void OpenNew(const char_type* aFilename);
/**
* Closes the file so that it can be processed. The recorder does NOT forget
@ -158,7 +158,7 @@ public:
private:
void Flush() override;
std::ofstream mOutputStream;
mozilla::OFStream mOutputStream;
};
typedef std::function<void(MemStream &aStream, std::vector<RefPtr<UnscaledFont>> &aUnscaledFonts)> SerializeResourcesFn;

Просмотреть файл

@ -1140,7 +1140,7 @@ Factory::CopyDataSourceSurface(DataSourceSurface* aSource,
}
already_AddRefed<DrawEventRecorder>
Factory::CreateEventRecorderForFile(const char *aFilename)
Factory::CreateEventRecorderForFile(const char_type* aFilename)
{
return MakeAndAddRef<DrawEventRecorderFile>(aFilename);
}

Просмотреть файл

@ -39,7 +39,7 @@ class gfxVarReceiver;
_(UseWebRenderProgramBinary, bool, false) \
_(WebRenderDebugFlags, int32_t, 0) \
_(ScreenDepth, int32_t, 0) \
_(GREDirectory, nsCString, nsCString()) \
_(GREDirectory, nsString, nsString()) \
_(UseOMTP, bool, false) \
_(AllowD3D11KeyedMutex, bool, false) \

Просмотреть файл

@ -109,13 +109,13 @@ static PRLibrary* LoadApitraceLibrary()
static PRLibrary*
LoadLibraryForEGLOnWindows(const nsAString& filename)
{
nsAutoCString path(gfx::gfxVars::GREDirectory());
nsAutoString path(gfx::gfxVars::GREDirectory());
path.Append(PR_GetDirectorySeparator());
path.Append(ToNewUTF8String(filename));
path.Append(filename);
PRLibSpec lspec;
lspec.type = PR_LibSpec_Pathname;
lspec.value.pathname = path.get();
lspec.type = PR_LibSpec_PathnameU;
lspec.value.pathname_u = path.get();
return PR_LoadLibraryWithFlags(lspec, PR_LD_LAZY | PR_LD_LOCAL);
}

Просмотреть файл

@ -77,6 +77,7 @@ union GfxVarValue
gfxImageFormat;
IntSize;
nsCString;
nsString;
int32_t;
};

Просмотреть файл

@ -364,11 +364,8 @@ FPSCounter::WriteFrameTimeStamps()
WriteFrameTimeStamps(fd);
PR_Close(fd);
nsAutoCString path;
rv = resultFile->GetNativePath(path);
NS_ENSURE_SUCCESS(rv, rv);
printf_stderr("Wrote FPS data to file: %s\n", path.get());
printf_stderr("Wrote FPS data to file: %s\n",
resultFile->HumanReadablePath().get());
return NS_OK;
}

Просмотреть файл

@ -566,7 +566,7 @@ void RecordingPrefChanged(const char *aPrefName, void *aClosure)
nsAutoString prefFileName;
nsresult rv = Preferences::GetString("gfx.2d.recordingfile", prefFileName);
if (NS_SUCCEEDED(rv)) {
fileName.Append(NS_ConvertUTF16toUTF8(prefFileName));
CopyUTF16toUTF8(prefFileName, fileName);
} else {
nsCOMPtr<nsIFile> tmpFile;
if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpFile)))) {
@ -578,12 +578,21 @@ void RecordingPrefChanged(const char *aPrefName, void *aClosure)
if (NS_FAILED(rv))
return;
#ifdef XP_WIN
rv = tmpFile->GetPath(prefFileName);
CopyUTF16toUTF8(prefFileName, fileName);
#else
rv = tmpFile->GetNativePath(fileName);
#endif
if (NS_FAILED(rv))
return;
}
#ifdef XP_WIN
gPlatform->mRecorder = Factory::CreateEventRecorderForFile(prefFileName.BeginReading());
#else
gPlatform->mRecorder = Factory::CreateEventRecorderForFile(fileName.BeginReading());
#endif
printf_stderr("Recording to %s\n", fileName.get());
Factory::SetGlobalEventRecorder(gPlatform->mRecorder);
} else {
@ -675,11 +684,11 @@ gfxPlatform::Init()
nsCOMPtr<nsIFile> file;
nsresult rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(file));
if (NS_FAILED(rv)) {
gfxVars::SetGREDirectory(nsCString());
gfxVars::SetGREDirectory(nsString());
} else {
nsAutoCString nativePath;
file->GetNativePath(nativePath);
gfxVars::SetGREDirectory(nsCString(nativePath));
nsAutoString path;
file->GetPath(path);
gfxVars::SetGREDirectory(nsString(path));
}
}