Bug 1333505 - Some cosmetic cleanup (comments/whitespace/alpha-sorting). r?nical
MozReview-Commit-ID: 2gG7yGZPBbg
--- a/gfx/layers/apz/src/GestureEventListener.cpp
+++ b/gfx/layers/apz/src/GestureEventListener.cpp
@@ -5,20 +5,20 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GestureEventListener.h"
#include <math.h> // for fabsf
#include <stddef.h> // for size_t
#include "AsyncPanZoomController.h" // for AsyncPanZoomController
#include "base/task.h" // for CancelableTask, etc
#include "gfxPrefs.h" // for gfxPrefs
+#include "InputBlockState.h" // for TouchBlockState
#include "mozilla/SizePrintfMacros.h" // for PRIuSIZE
#include "nsDebug.h" // for NS_WARNING
#include "nsMathUtils.h" // for NS_hypot
-#include "InputBlockState.h"
#define GEL_LOG(...)
// #define GEL_LOG(...) printf_stderr("GEL: " __VA_ARGS__)
namespace mozilla {
namespace layers {
/**
--- a/gfx/layers/wr/WebRenderBridgeParent.h
+++ b/gfx/layers/wr/WebRenderBridgeParent.h
@@ -6,20 +6,20 @@
#ifndef mozilla_layers_WebRenderBridgeParent_h
#define mozilla_layers_WebRenderBridgeParent_h
#include "GLContextProvider.h"
#include "mozilla/layers/CompositableTransactionParent.h"
#include "mozilla/layers/CompositorVsyncSchedulerOwner.h"
#include "mozilla/layers/PWebRenderBridgeParent.h"
+#include "mozilla/Maybe.h"
#include "mozilla/webrender/WebRenderTypes.h"
#include "mozilla/webrender/WebRenderAPI.h"
#include "nsTArrayForwardDeclare.h"
-#include "mozilla/Maybe.h"
namespace mozilla {
namespace gl {
class GLContext;
}
namespace widget {
--- a/gfx/webrender_bindings/RenderThread.cpp
+++ b/gfx/webrender_bindings/RenderThread.cpp
@@ -10,17 +10,17 @@
#include "mozilla/StaticPtr.h"
namespace mozilla {
namespace wr {
static StaticRefPtr<RenderThread> sRenderThread;
RenderThread::RenderThread(base::Thread* aThread)
-: mThread(aThread)
+ : mThread(aThread)
{
}
RenderThread::~RenderThread()
{
delete mThread;
}
@@ -181,18 +181,18 @@ RenderThread::UpdateAndRender(wr::Window
// way. We need to merge the two or have a way to associate transaction ids with
// epochs to wire everything up properly.
auto transactionId = 0;
renderer->Update();
renderer->Render(transactionId);
}
-} // namespace
-} // namespace
+} // namespace wr
+} // namespace mozilla
extern "C" {
void wr_notifier_new_frame_ready(WrWindowId aWindowId)
{
mozilla::wr::RenderThread::Get()->NewFrameReady(mozilla::wr::WindowId(aWindowId));
}
--- a/gfx/webrender_bindings/RenderThread.h
+++ b/gfx/webrender_bindings/RenderThread.h
@@ -18,58 +18,60 @@
#include "mozilla/webrender/WebRenderTypes.h"
namespace mozilla {
namespace wr {
class RendererOGL;
class RenderThread;
-/// Base class for an event that can bes cheduled to run on the render thread.
+/// Base class for an event that can be scheduled to run on the render thread.
///
/// The event can be passed through the same channels as regular WebRender messages
/// to preserve ordering.
class RendererEvent
{
public:
virtual ~RendererEvent() {}
virtual void Run(RenderThread& aRenderThread, wr::WindowId aWindow) = 0;
};
/// The render thread is where WebRender issues all of its GPU work, and as much
/// as possible this thread should only serve this purpose.
///
/// The render thread owns the different RendererOGLs (one per window) and implements
/// the RenderNotifier api exposed by the WebRender bindings.
///
-/// We should generally avoid posting tasks to the render thhread's event loop directly
+/// We should generally avoid posting tasks to the render thread's event loop directly
/// and instead use the RendererEvent mechanism which avoids races between the events
/// and WebRender's own messages.
///
/// The GL context(s) should be created and used on this thread only.
/// XXX - I've tried to organize code so that we can potentially avoid making
-/// this a singleton since this bad habbit has a tendency to bite us later, but
-/// I haven't gotten all the way there either in order to focus on the more
+/// this a singleton since this bad habit has a tendency to bite us later, but
+/// I haven't gotten all the way there either, in order to focus on the more
/// important pieces first. So we are a bit in-between (this is totally a singleton
/// but in some places we pretend it's not). Hopefully we can evolve this in a way
/// that keeps the door open to removing the singleton bits.
class RenderThread final
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(RenderThread)
public:
/// Can be called from any thread.
static RenderThread* Get();
+ /// Can only be called from the main thread.
static void Start();
+ /// Can only be called from the main thread.
static void ShutDown();
/// Can be called from any thread.
- /// In most cases it is best to use RendererEvents through WebRender's api instead
+ /// In most cases it is best to post RendererEvents through WebRenderAPI instead
/// of scheduling directly to this message loop (so as to preserve the ordering
/// of the messages).
static MessageLoop* Loop();
/// Can be called from any thread.
static bool IsInRenderThread();
/// Can only be called from the render thread.
@@ -103,12 +105,12 @@ private:
/// Can only be called from the render thread.
void UpdateAndRender(wr::WindowId aWindowId);
base::Thread* const mThread;
std::map<wr::WindowId, UniquePtr<RendererOGL>> mRenderers;
};
-} // namespace
-} // namespace
+} // namespace wr
+} // namespace mozilla
#endif
--- a/gfx/webrender_bindings/RendererOGL.cpp
+++ b/gfx/webrender_bindings/RendererOGL.cpp
@@ -16,22 +16,22 @@ namespace mozilla {
namespace wr {
RendererOGL::RendererOGL(RefPtr<RenderThread>&& aThread,
RefPtr<gl::GLContext>&& aGL,
RefPtr<widget::CompositorWidget>&& aWidget,
wr::WindowId aWindowId,
WrRenderer* aWrRenderer,
layers::CompositorBridgeParentBase* aBridge)
-: mThread(aThread)
-, mGL(aGL)
-, mWidget(aWidget)
-, mWrRenderer(aWrRenderer)
-, mBridge(aBridge)
-, mWindowId(aWindowId)
+ : mThread(aThread)
+ , mGL(aGL)
+ , mWidget(aWidget)
+ , mWrRenderer(aWrRenderer)
+ , mBridge(aBridge)
+ , mWindowId(aWindowId)
{
MOZ_ASSERT(mThread);
MOZ_ASSERT(mGL);
MOZ_ASSERT(mWidget);
MOZ_ASSERT(mWrRenderer);
MOZ_ASSERT(mBridge);
MOZ_COUNT_CTOR(RendererOGL);
}
@@ -100,10 +100,10 @@ RendererOGL::Render(uint64_t aTransactio
}
void
RendererOGL::SetProfilerEnabled(bool aEnabled)
{
wr_renderer_set_profiler_enabled(mWrRenderer, aEnabled);
}
-}
-}
+} // namespace wr
+} // namespace mozilla
--- a/gfx/webrender_bindings/RendererOGL.h
+++ b/gfx/webrender_bindings/RendererOGL.h
@@ -16,63 +16,63 @@ namespace mozilla {
namespace gfx {
class DrawTarget;
}
namespace gl {
class GLContext;
}
+namespace layers {
+class CompositorBridgeParentBase;
+}
+
namespace widget {
class CompositorWidget;
}
-namespace layers {
-class CompositorBridgeParentBase;
-}
-
namespace wr {
/// Owns the WebRender renderer and GL context.
///
/// There is one renderer per window, all owned by the render thread.
/// This class is a similar abstraction to CompositorOGL except that it is used
/// on the render thread instead of the compositor thread.
class RendererOGL
{
public:
- /// Render thread only.
+ /// This can be called on the render thread only.
void Update();
- /// Render thread only.
+ /// This can be called on the render thread only.
bool Render(uint64_t aTransactionId);
- /// Render thread only.
+ /// This can be called on the render thread only.
bool RenderToTarget(gfx::DrawTarget& aTarget);
- /// Render thread only.
+ /// This can be called on the render thread only.
void SetProfilerEnabled(bool aEnabled);
- /// Render thread only.
+ /// This can be called on the render thread only.
~RendererOGL();
- /// Render thread only.
+ /// This can be called on the render thread only.
RendererOGL(RefPtr<RenderThread>&& aThread,
RefPtr<gl::GLContext>&& aGL,
RefPtr<widget::CompositorWidget>&&,
wr::WindowId aWindowId,
WrRenderer* aWrRenderer,
layers::CompositorBridgeParentBase* aBridge);
+
protected:
RefPtr<RenderThread> mThread;
RefPtr<gl::GLContext> mGL;
RefPtr<widget::CompositorWidget> mWidget;
WrRenderer* mWrRenderer;
layers::CompositorBridgeParentBase* mBridge;
wr::WindowId mWindowId;
};
-}
-}
-
+} // namespace wr
+} // namespace mozilla
#endif
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -35,22 +35,22 @@ SurfaceFormatToWrImageFormat(gfx::Surfac
class NewRenderer : public RendererEvent
{
public:
NewRenderer(WrAPI** aApi, layers::CompositorBridgeParentBase* aBridge,
GLint* aMaxTextureSize,
RefPtr<widget::CompositorWidget>&& aWidget,
layers::SynchronousTask* aTask,
bool aEnableProfiler)
- : mWrApi(aApi)
- , mMaxTextureSize(aMaxTextureSize)
- , mBridge(aBridge)
- , mCompositorWidget(Move(aWidget))
- , mTask(aTask)
- , mEnableProfiler(aEnableProfiler)
+ : mWrApi(aApi)
+ , mMaxTextureSize(aMaxTextureSize)
+ , mBridge(aBridge)
+ , mCompositorWidget(Move(aWidget))
+ , mTask(aTask)
+ , mEnableProfiler(aEnableProfiler)
{
MOZ_COUNT_CTOR(NewRenderer);
}
~NewRenderer()
{
MOZ_COUNT_DTOR(NewRenderer);
}
@@ -90,17 +90,17 @@ public:
layers::SynchronousTask* mTask;
bool mEnableProfiler;
};
class RemoveRenderer : public RendererEvent
{
public:
explicit RemoveRenderer(layers::SynchronousTask* aTask)
- : mTask(aTask)
+ : mTask(aTask)
{
MOZ_COUNT_CTOR(RemoveRenderer);
}
~RemoveRenderer()
{
MOZ_COUNT_DTOR(RemoveRenderer);
}
@@ -227,18 +227,26 @@ void
WebRenderAPI::DeleteFont(wr::FontKey aKey)
{
printf("XXX - WebRender does not seem to implement deleting a font! Leaking it...\n");
}
class EnableProfiler : public RendererEvent
{
public:
- explicit EnableProfiler(bool aEnabled) : mEnabled(aEnabled) { MOZ_COUNT_CTOR(EnableProfiler); }
- ~EnableProfiler() { MOZ_COUNT_DTOR(EnableProfiler); }
+ explicit EnableProfiler(bool aEnabled)
+ : mEnabled(aEnabled)
+ {
+ MOZ_COUNT_CTOR(EnableProfiler);
+ }
+
+ ~EnableProfiler()
+ {
+ MOZ_COUNT_DTOR(EnableProfiler);
+ }
virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override
{
auto renderer = aRenderThread.GetRenderer(aWindowId);
if (renderer) {
renderer->SetProfilerEnabled(mEnabled);
}
}
@@ -356,10 +364,10 @@ DisplayListBuilder::PushText(const WrRec
{
wr_dp_push_text(mWrState, aBounds, aClip,
ToWrColor(aColor),
aFontKey.mHandle,
&aGlyphBuffer[0], aGlyphBuffer.length(),
aGlyphSize);
}
-} // namespace
-} // namespace
+} // namespace wr
+} // namespace mozilla
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -27,19 +27,20 @@ namespace wr {
class DisplayListBuilder;
class RendererOGL;
class NewRenderer;
class RendererEvent;
class WebRenderAPI
{
-NS_INLINE_DECL_REFCOUNTING(WebRenderAPI);
+ NS_INLINE_DECL_REFCOUNTING(WebRenderAPI);
+
public:
- /// Compositor thread only.
+ /// This can be called on the compositor thread only.
static already_AddRefed<WebRenderAPI> Create(bool aEnableProfiler,
layers::CompositorBridgeParentBase* aBridge,
RefPtr<widget::CompositorWidget>&& aWidget);
wr::WindowId GetId() const { return mId; }
void SetRootDisplayList(gfx::Color aBgColor,
wr::Epoch aEpoch,
@@ -71,19 +72,19 @@ public:
void SetProfilerEnabled(bool aEnabled);
void RunOnRenderThread(UniquePtr<RendererEvent>&& aEvent);
GLint GetMaxTextureSize() const { return mMaxTextureSize; }
protected:
WebRenderAPI(WrAPI* aRawApi, wr::WindowId aId, GLint aMaxTextureSize)
- : mWrApi(aRawApi)
- , mId(aId)
- , mMaxTextureSize(aMaxTextureSize)
+ : mWrApi(aRawApi)
+ , mId(aId)
+ , mMaxTextureSize(aMaxTextureSize)
{}
~WebRenderAPI();
WrAPI* mWrApi;
wr::WindowId mId;
GLint mMaxTextureSize;
@@ -151,12 +152,12 @@ protected:
WrState* mWrState;
friend class WebRenderAPI;
};
Maybe<WrImageFormat>
SurfaceFormatToWrImageFormat(gfx::SurfaceFormat aFormat);
-} // namespace
-} // namespace
+} // namespace wr
+} // namespace mozilla
#endif