Bug 1550422 - P19. Convert gfxPrefs::LayersWindowRecordingPath to gfxVars. r?jrmuizel! draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 16 May 2019 15:54:59 +1000
changeset 2008595 e918530cf83b5fce77e585bf7ae55edec2c75c74
parent 2008594 87ecbf679a9fe725e20bfb0aded38d9d82170e80
child 2008596 11ee7cc6ced3d845f3f44285774af0f800ce8f2a
push id363925
push userjyavenard@mozilla.com
push dateSat, 18 May 2019 07:53:18 +0000
treeherdertry@5082cd581229 [default view] [failures only]
reviewersjrmuizel
bugs1550422
milestone68.0a1
Bug 1550422 - P19. Convert gfxPrefs::LayersWindowRecordingPath to gfxVars. r?jrmuizel! StaticPrefs doesn't support nsCString type and the changes required to support this would be rather big. Seeing that there was only a single gfxPrefs using this, and this is a "Once" pref ; we move it to gfxVars instead. Differential Revision: https://phabricator.services.mozilla.com/D31462
gfx/config/gfxVars.h
gfx/layers/CompositionRecorder.cpp
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPrefs.h
--- a/gfx/config/gfxVars.h
+++ b/gfx/config/gfxVars.h
@@ -44,17 +44,18 @@ class gfxVarReceiver;
   _(UseWebRenderDCompWinTripleBuffering, bool, false)              \
   _(UseWebRenderProgramBinaryDisk, bool, false)                    \
   _(WebRenderDebugFlags, int32_t, 0)                               \
   _(ScreenDepth, int32_t, 0)                                       \
   _(GREDirectory, nsString, nsString())                            \
   _(ProfDirectory, nsString, nsString())                           \
   _(UseOMTP, bool, false)                                          \
   _(AllowD3D11KeyedMutex, bool, false)                             \
-  _(SystemTextQuality, int32_t, 5 /* CLEARTYPE_QUALITY */)
+  _(SystemTextQuality, int32_t, 5 /* CLEARTYPE_QUALITY */)         \
+  _(LayersWindowRecordingPath, nsCString, nsCString())
 
 /* Add new entries above this line. */
 
 // Some graphics settings are computed on the UI process and must be
 // communicated to content and GPU processes. gfxVars helps facilitate
 // this. Its function is similar to gfxPrefs, except rather than hold
 // user preferences, it holds dynamically computed values.
 //
--- a/gfx/layers/CompositionRecorder.cpp
+++ b/gfx/layers/CompositionRecorder.cpp
@@ -2,17 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "CompositionRecorder.h"
 #include "gfxUtils.h"
 #include "mozilla/gfx/2D.h"
-#include "gfxPrefs.h"
+#include "mozilla/gfx/gfxVars.h"
 
 #include <ctime>
 #include <iomanip>
 #include "stdio.h"
 #ifdef XP_WIN
 #  include "direct.h"
 #else
 #  include <sys/types.h>
@@ -32,17 +32,17 @@ CompositionRecorder::~CompositionRecorde
 void CompositionRecorder::RecordFrame(RecordedFrame* aFrame) {
   mCollectedFrames.AppendElement(aFrame);
 }
 
 void CompositionRecorder::WriteCollectedFrames() {
   std::time_t t = std::time(nullptr);
   std::tm tm = *std::localtime(&t);
   std::stringstream str;
-  str << gfxPrefs::LayersWindowRecordingPath() << "windowrecording-"
+  str << gfxVars::LayersWindowRecordingPath() << "windowrecording-"
       << std::put_time(&tm, "%Y%m%d%H%M%S");
 
 #ifdef XP_WIN
   _mkdir(str.str().c_str());
 #else
   mkdir(str.str().c_str(), 0777);
 #endif
 
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -885,16 +885,20 @@ void gfxPlatform::Init() {
       gfxVars::SetProfDirectory(nsString());
     } else {
       nsAutoString path;
       profDir->GetPath(path);
       gfxVars::SetProfDirectory(nsString(path));
     }
 
     gfxUtils::RemoveShaderCacheFromDiskIfNecessary();
+
+    nsAutoCString path;
+    Preferences::GetCString("layers.windowrecording.path", path);
+    gfxVars::SetLayersWindowRecordingPath(path);
   }
 
   // Drop a note in the crash report if we end up forcing an option that could
   // destabilize things.  New items should be appended at the end (of an
   // existing or in a new section), so that we don't have to know the version to
   // interpret these cryptic strings.
   {
     nsAutoCString forcedPrefs;
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -284,18 +284,16 @@ class gfxPrefs final {
   };
 
   // clang-format off
 
   // This is where DECL_GFX_PREF for each of the preferences should go.  We
   // will keep these in an alphabetical order to make it easier to see if a
   // method accessing a pref already exists. Just add yours in the list.
 
-  DECL_GFX_PREF(Once, "layers.windowrecording.path",           LayersWindowRecordingPath, std::string, std::string());
-
   // WARNING:
   // Please make sure that you've added your new preference to the list above
   // in alphabetical order.
   // Please do not just append it to the end of the list.
 
   // clang-format on
 
  public: