Bug 1060802 - Fix some more bad implicit constructors in gfx; r=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Sun, 31 Aug 2014 23:31:20 -0400
changeset 224480 9a507b307d1d66c225d3848591ae6bfa39f1327b
parent 224479 7de1b4a42f1cfd57b3e2b0fc7113fe6f9457aa86
child 224481 45238678ef62d614c15be4bd692584fe37003d8a
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1060802
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1060802 - Fix some more bad implicit constructors in gfx; r=roc
gfx/2d/Coord.h
gfx/2d/DrawCommand.h
gfx/2d/DrawTargetCairo.cpp
gfx/2d/DrawTargetDual.cpp
gfx/2d/DrawTargetRecording.cpp
gfx/2d/FilterNodeSoftware.cpp
gfx/2d/HelpersSkia.h
gfx/2d/PathSkia.h
gfx/2d/ScaledFontBase.h
gfx/2d/ScaledFontMac.cpp
gfx/2d/SourceSurfaceCairo.h
gfx/gl/GLContext.h
gfx/gl/SkiaGLGlue.h
gfx/layers/Effects.h
gfx/layers/apz/src/InputBlockState.h
gfx/tests/gtest/TestAsyncPanZoomController.cpp
gfx/tests/gtest/TestLayers.cpp
gfx/tests/gtest/TestTiledLayerBuffer.cpp
--- a/gfx/2d/Coord.h
+++ b/gfx/2d/Coord.h
@@ -98,32 +98,32 @@ struct IntCoordTyped :
   public CoordOperatorsHelper< IntCoordTyped<units>, float >,
   public CoordOperatorsHelper< IntCoordTyped<units>, double > {
   static_assert(IsPixel<units>::value,
                 "'units' must be a coordinate system tag");
 
   typedef BaseCoord< int32_t, IntCoordTyped<units> > Super;
 
   MOZ_CONSTEXPR IntCoordTyped() : Super() {}
-  MOZ_CONSTEXPR IntCoordTyped(int32_t aValue) : Super(aValue) {}
+  MOZ_CONSTEXPR MOZ_IMPLICIT IntCoordTyped(int32_t aValue) : Super(aValue) {}
 };
 
 template<class units>
 struct CoordTyped :
   public BaseCoord< Float, CoordTyped<units> >,
   public CoordOperatorsHelper< CoordTyped<units>, int32_t >,
   public CoordOperatorsHelper< CoordTyped<units>, uint32_t >,
   public CoordOperatorsHelper< CoordTyped<units>, double > {
   static_assert(IsPixel<units>::value,
                 "'units' must be a coordinate system tag");
 
   typedef BaseCoord< Float, CoordTyped<units> > Super;
 
   MOZ_CONSTEXPR CoordTyped() : Super() {}
-  MOZ_CONSTEXPR CoordTyped(Float aValue) : Super(aValue) {}
+  MOZ_CONSTEXPR MOZ_IMPLICIT CoordTyped(Float aValue) : Super(aValue) {}
   explicit MOZ_CONSTEXPR CoordTyped(const IntCoordTyped<units>& aCoord) : Super(float(aCoord.value)) {}
 
   void Round() {
     this->value = floor(this->value + 0.5);
   }
   void Truncate() {
     this->value = int32_t(this->value);
   }
--- a/gfx/2d/DrawCommand.h
+++ b/gfx/2d/DrawCommand.h
@@ -37,31 +37,31 @@ MOZ_END_ENUM_CLASS(CommandType)
 class DrawingCommand
 {
 public:
   virtual ~DrawingCommand() {}
 
   virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix& aTransform) = 0;
 
 protected:
-  DrawingCommand(CommandType aType)
+  explicit DrawingCommand(CommandType aType)
     : mType(aType)
   {
   }
 
   CommandType GetType() { return mType; }
 
 private:
   CommandType mType;
 };
 
 class StoredPattern
 {
 public:
-  StoredPattern(const Pattern& aPattern)
+  explicit StoredPattern(const Pattern& aPattern)
   {
     Assign(aPattern);
   }
 
   void Assign(const Pattern& aPattern)
   {
     switch (aPattern.GetType()) {
     case PatternType::COLOR:
@@ -164,17 +164,17 @@ private:
   Rect mSourceRect;
   Point mDestPoint;
   DrawOptions mOptions;
 };
 
 class ClearRectCommand : public DrawingCommand
 {
 public:
-  ClearRectCommand(const Rect& aRect)
+  explicit ClearRectCommand(const Rect& aRect)
     : DrawingCommand(CommandType::CLEARRECT)
     , mRect(aRect)
   {
   }
 
   virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix&)
   {
     aDT->ClearRect(mRect);
@@ -426,17 +426,17 @@ private:
   RefPtr<SourceSurface> mMask;
   Point mOffset;
   DrawOptions mOptions;
 };
 
 class PushClipCommand : public DrawingCommand
 {
 public:
-  PushClipCommand(const Path* aPath)
+  explicit PushClipCommand(const Path* aPath)
     : DrawingCommand(CommandType::PUSHCLIP)
     , mPath(const_cast<Path*>(aPath))
   {
   }
 
   virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix&)
   {
     aDT->PushClip(mPath);
@@ -444,17 +444,17 @@ public:
 
 private:
   RefPtr<Path> mPath;
 };
 
 class PushClipRectCommand : public DrawingCommand
 {
 public:
-  PushClipRectCommand(const Rect& aRect)
+  explicit PushClipRectCommand(const Rect& aRect)
     : DrawingCommand(CommandType::PUSHCLIPRECT)
     , mRect(aRect)
   {
   }
 
   virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix&)
   {
     aDT->PushClipRect(mRect);
@@ -476,17 +476,17 @@ public:
   {
     aDT->PopClip();
   }
 };
 
 class SetTransformCommand : public DrawingCommand
 {
 public:
-  SetTransformCommand(const Matrix& aTransform)
+  explicit SetTransformCommand(const Matrix& aTransform)
     : DrawingCommand(CommandType::SETTRANSFORM)
     , mTransform(aTransform)
   {
   }
 
   virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix& aMatrix)
   {
     Matrix transform = mTransform;
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -246,23 +246,23 @@ GetCairoSurfaceForSourceSurface(SourceSu
 }
 
 // An RAII class to temporarily clear any device offset set
 // on a surface. Note that this does not take a reference to the
 // surface.
 class AutoClearDeviceOffset
 {
 public:
-  AutoClearDeviceOffset(SourceSurface* aSurface)
+  explicit AutoClearDeviceOffset(SourceSurface* aSurface)
     : mSurface(nullptr)
   {
     Init(aSurface);
   }
 
-  AutoClearDeviceOffset(const Pattern& aPattern)
+  explicit AutoClearDeviceOffset(const Pattern& aPattern)
     : mSurface(nullptr)
   {
     if (aPattern.GetType() == PatternType::SURFACE) {
       const SurfacePattern& pattern = static_cast<const SurfacePattern&>(aPattern);
       Init(pattern.mSurface);
     }
   }
 
--- a/gfx/2d/DrawTargetDual.cpp
+++ b/gfx/2d/DrawTargetDual.cpp
@@ -7,17 +7,17 @@
 #include "Tools.h"
 
 namespace mozilla {
 namespace gfx {
 
 class DualSurface
 {
 public:
-  inline DualSurface(SourceSurface *aSurface)
+  inline explicit DualSurface(SourceSurface *aSurface)
   {
     if (aSurface->GetType() != SurfaceType::DUAL_DT) {
       mA = mB = aSurface;
       return;
     }
 
     SourceSurfaceDual *ssDual =
       static_cast<SourceSurfaceDual*>(aSurface);
@@ -31,17 +31,17 @@ public:
 
 /* This only needs to split patterns up for SurfacePatterns. Only in that
  * case can we be dealing with a 'dual' source (SourceSurfaceDual) and do
  * we need to pass separate patterns into our destination DrawTargets.
  */
 class DualPattern
 {
 public:
-  inline DualPattern(const Pattern &aPattern)
+  inline explicit DualPattern(const Pattern &aPattern)
     : mPatternsInitialized(false)
   {
     if (aPattern.GetType() != PatternType::SURFACE) {
       mA = mB = &aPattern;
       return;
     }
 
     const SurfacePattern *surfPat =
--- a/gfx/2d/DrawTargetRecording.cpp
+++ b/gfx/2d/DrawTargetRecording.cpp
@@ -152,17 +152,17 @@ GetFilterNode(FilterNode* aNode)
     return aNode;
   }
 
   return static_cast<FilterNodeRecording*>(aNode)->mFinalFilterNode;
 }
 
 struct AdjustedPattern
 {
-  AdjustedPattern(const Pattern &aPattern)
+  explicit AdjustedPattern(const Pattern &aPattern)
     : mPattern(nullptr)
   {
     mOrigPattern = const_cast<Pattern*>(&aPattern);
   }
 
   ~AdjustedPattern() {
     if (mPattern) {
       mPattern->~Pattern();
--- a/gfx/2d/FilterNodeSoftware.cpp
+++ b/gfx/2d/FilterNodeSoftware.cpp
@@ -2159,17 +2159,17 @@ FilterNodeConvolveMatrixSoftware::SetAtt
 
 #ifdef DEBUG
 static bool sColorSamplingAccessControlEnabled = false;
 static uint8_t* sColorSamplingAccessControlStart = nullptr;
 static uint8_t* sColorSamplingAccessControlEnd = nullptr;
 
 struct DebugOnlyAutoColorSamplingAccessControl
 {
-  DebugOnlyAutoColorSamplingAccessControl(DataSourceSurface* aSurface)
+  explicit DebugOnlyAutoColorSamplingAccessControl(DataSourceSurface* aSurface)
   {
     sColorSamplingAccessControlStart = aSurface->GetData();
     sColorSamplingAccessControlEnd = sColorSamplingAccessControlStart +
       aSurface->Stride() * aSurface->GetSize().height;
     sColorSamplingAccessControlEnabled = true;
   }
 
   ~DebugOnlyAutoColorSamplingAccessControl()
--- a/gfx/2d/HelpersSkia.h
+++ b/gfx/2d/HelpersSkia.h
@@ -316,17 +316,17 @@ ExtendModeToTileMode(ExtendMode aMode)
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 template <typename T> class RefPtrSkia {
 public:
   RefPtrSkia() : fObj(NULL) {}
-  RefPtrSkia(T* obj) : fObj(obj) { SkSafeRef(fObj); }
+  explicit RefPtrSkia(T* obj) : fObj(obj) { SkSafeRef(fObj); }
   RefPtrSkia(const RefPtrSkia& o) : fObj(o.fObj) { SkSafeRef(fObj); }
   ~RefPtrSkia() { SkSafeUnref(fObj); }
 
   RefPtrSkia& operator=(const RefPtrSkia& rp) {
     SkRefCnt_SafeAssign(fObj, rp.fObj);
     return *this;
   }
   RefPtrSkia& operator=(T* obj) {
--- a/gfx/2d/PathSkia.h
+++ b/gfx/2d/PathSkia.h
@@ -14,17 +14,17 @@ namespace gfx {
 
 class PathSkia;
 
 class PathBuilderSkia : public PathBuilder
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderSkia)
   PathBuilderSkia(const Matrix& aTransform, const SkPath& aPath, FillRule aFillRule);
-  PathBuilderSkia(FillRule aFillRule);
+  explicit PathBuilderSkia(FillRule aFillRule);
 
   virtual void MoveTo(const Point &aPoint);
   virtual void LineTo(const Point &aPoint);
   virtual void BezierTo(const Point &aCP1,
                         const Point &aCP2,
                         const Point &aCP3);
   virtual void QuadraticBezierTo(const Point &aCP1,
                                  const Point &aCP2);
--- a/gfx/2d/ScaledFontBase.h
+++ b/gfx/2d/ScaledFontBase.h
@@ -25,17 +25,17 @@ class gfxFont;
 
 namespace mozilla {
 namespace gfx {
 
 class ScaledFontBase : public ScaledFont
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontBase)
-  ScaledFontBase(Float aSize);
+  explicit ScaledFontBase(Float aSize);
   virtual ~ScaledFontBase();
 
   virtual TemporaryRef<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget);
 
   virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint);
 
   float GetSize() { return mSize; }
 
--- a/gfx/2d/ScaledFontMac.cpp
+++ b/gfx/2d/ScaledFontMac.cpp
@@ -156,17 +156,17 @@ int maxPow2LessThan(int a)
     while ((x<<(shift+1)) < a) {
         shift++;
     }
     return shift;
 }
 
 struct writeBuf
 {
-    writeBuf(int size)
+    explicit writeBuf(int size)
     {
         this->data = new unsigned char [size];
         this->offset = 0;
     }
     ~writeBuf() {
         delete this->data;
     }
 
--- a/gfx/2d/SourceSurfaceCairo.h
+++ b/gfx/2d/SourceSurfaceCairo.h
@@ -44,17 +44,17 @@ private: // data
   cairo_surface_t* mSurface;
   DrawTargetCairo* mDrawTarget;
 };
 
 class DataSourceSurfaceCairo : public DataSourceSurface
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceCairo)
-  DataSourceSurfaceCairo(cairo_surface_t* imageSurf);
+  explicit DataSourceSurfaceCairo(cairo_surface_t* imageSurf);
   virtual ~DataSourceSurfaceCairo();
   virtual unsigned char *GetData();
   virtual int32_t Stride();
 
   virtual SurfaceType GetType() const { return SurfaceType::CAIRO_IMAGE; }
   virtual IntSize GetSize() const;
   virtual SurfaceFormat GetFormat() const;
 
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -619,17 +619,17 @@ private:
 #endif
 
 public:
     class ScopedLocalErrorCheck {
         GLContext* const mGL;
         bool mHasBeenChecked;
 
     public:
-        ScopedLocalErrorCheck(GLContext* gl)
+        explicit ScopedLocalErrorCheck(GLContext* gl)
             : mGL(gl)
             , mHasBeenChecked(false)
         {
 #ifdef DEBUG
             MOZ_ASSERT(!mGL->mIsInLocalErrorCheck);
             mGL->mIsInLocalErrorCheck = true;
 #endif
             mGL->GetAndPushAllErrors();
--- a/gfx/gl/SkiaGLGlue.h
+++ b/gfx/gl/SkiaGLGlue.h
@@ -14,17 +14,17 @@
 
 namespace mozilla {
 namespace gl {
 
 class SkiaGLGlue : public GenericAtomicRefCounted
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SkiaGLGlue)
-  SkiaGLGlue(GLContext* context);
+  explicit SkiaGLGlue(GLContext* context);
   GLContext* GetGLContext() const { return mGLContext.get(); }
   GrContext* GetGrContext() const { return mGrContext.get(); }
 
 protected:
   virtual ~SkiaGLGlue() {
     /*
      * These members have inter-dependencies, but do not keep each other alive, so
      * destruction order is very important here: mGrContext uses mGrGLInterface, and
@@ -58,9 +58,9 @@ class SkiaGLGlue : public GenericAtomicR
 public:
   SkiaGLGlue(GLContext* context);
   GLContext* GetGLContext() const { return nullptr; }
   GrContext* GetGrContext() const { return nullptr; }
 };
 }
 }
 
-#endif
\ No newline at end of file
+#endif
--- a/gfx/layers/Effects.h
+++ b/gfx/layers/Effects.h
@@ -128,17 +128,17 @@ protected:
     , mRenderTarget(aRenderTarget)
   {}
 
 };
 
 // Render to a render target rather than the screen.
 struct EffectColorMatrix : public Effect
 {
-  EffectColorMatrix(gfx::Matrix5x4 aMatrix)
+  explicit EffectColorMatrix(gfx::Matrix5x4 aMatrix)
     : Effect(EffectTypes::COLOR_MATRIX)
     , mColorMatrix(aMatrix)
   {}
 
   virtual const char* Name() { return "EffectColorMatrix"; }
   virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
   const gfx::Matrix5x4 mColorMatrix;
 };
--- a/gfx/layers/apz/src/InputBlockState.h
+++ b/gfx/layers/apz/src/InputBlockState.h
@@ -18,17 +18,17 @@ class OverscrollHandoffChain;
 
 /**
  * A base class that stores state common to various input blocks.
  * Currently, it just stores the overscroll handoff chain.
  */
 class InputBlockState
 {
 public:
-  InputBlockState(const nsRefPtr<const OverscrollHandoffChain>& aOverscrollHandoffChain);
+  explicit InputBlockState(const nsRefPtr<const OverscrollHandoffChain>& aOverscrollHandoffChain);
 
   const nsRefPtr<const OverscrollHandoffChain>& GetOverscrollHandoffChain() const;
 private:
   nsRefPtr<const OverscrollHandoffChain> mOverscrollHandoffChain;
 };
 
 /**
  * This class represents a single touch block. A touch block is
@@ -61,17 +61,17 @@ private:
  * be populated with some latency. The mAllowedTouchBehaviorSet and
  * mAllowedTouchBehaviors variables track this information.
  */
 class TouchBlockState : public InputBlockState
 {
 public:
   typedef uint32_t TouchBehaviorFlags;
 
-  TouchBlockState(const nsRefPtr<const OverscrollHandoffChain>& aOverscrollHandoffChain);
+  explicit TouchBlockState(const nsRefPtr<const OverscrollHandoffChain>& aOverscrollHandoffChain);
 
   /**
    * Record whether or not content cancelled this block of events.
    * @param aPreventDefault true iff the block is cancelled.
    * @return false if this block has already received a response from
    *         web content, true if not.
    */
   bool SetContentResponse(bool aPreventDefault);
--- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp
+++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp
@@ -182,17 +182,17 @@ TestFrameMetrics()
   fm.mCriticalDisplayPort = CSSRect(0, 0, 10, 10);
   fm.mScrollableRect = CSSRect(0, 0, 100, 100);
 
   return fm;
 }
 
 class APZCBasicTester : public ::testing::Test {
 public:
-  APZCBasicTester(AsyncPanZoomController::GestureBehavior aGestureBehavior = AsyncPanZoomController::DEFAULT_GESTURES)
+  explicit APZCBasicTester(AsyncPanZoomController::GestureBehavior aGestureBehavior = AsyncPanZoomController::DEFAULT_GESTURES)
     : mGestureBehavior(aGestureBehavior)
   {
   }
 
 protected:
   virtual void SetUp()
   {
     gfxPrefs::GetSingleton();
@@ -484,17 +484,17 @@ ApzcPinchWithTouchInputAndCheckStatus(As
       : nsEventStatus_eIgnore;
   EXPECT_EQ(nsEventStatus_eConsumeDoDefault, statuses[0]);
   EXPECT_EQ(expectedMoveStatus, statuses[1]);
   EXPECT_EQ(expectedMoveStatus, statuses[2]);
 }
 
 class APZCPinchTester : public APZCBasicTester {
 public:
-  APZCPinchTester(AsyncPanZoomController::GestureBehavior aGestureBehavior = AsyncPanZoomController::DEFAULT_GESTURES)
+  explicit APZCPinchTester(AsyncPanZoomController::GestureBehavior aGestureBehavior = AsyncPanZoomController::DEFAULT_GESTURES)
     : APZCBasicTester(aGestureBehavior)
   {
   }
 
 protected:
   FrameMetrics GetPinchableFrameMetrics()
   {
     FrameMetrics fm;
@@ -1974,17 +1974,17 @@ public:
 
 private:
   int mRunCount;
   int mCancelCount;
 };
 
 class MockTask : public CancelableTask {
 public:
-  MockTask(TaskRunMetrics& aMetrics)
+  explicit MockTask(TaskRunMetrics& aMetrics)
     : mMetrics(aMetrics)
   {}
 
   virtual void Run() {
     mMetrics.IncrementRunCount();
   }
 
   virtual void Cancel() {
--- a/gfx/tests/gtest/TestLayers.cpp
+++ b/gfx/tests/gtest/TestLayers.cpp
@@ -32,17 +32,17 @@ public:
                               void* aCallbackData,
                               EndTransactionFlags aFlags = END_DEFAULT) {}
   virtual int32_t GetMaxTextureSize() const { return 0; }
   virtual already_AddRefed<ThebesLayer> CreateThebesLayer() { return nullptr; }
 };
 
 class TestContainerLayer: public ContainerLayer {
 public:
-  TestContainerLayer(LayerManager* aManager)
+  explicit TestContainerLayer(LayerManager* aManager)
     : ContainerLayer(aManager, nullptr)
   {}
 
   virtual const char* Name() const {
     return "TestContainerLayer";
   }
 
   virtual LayerType GetType() const {
@@ -51,17 +51,17 @@ public:
 
   virtual void ComputeEffectiveTransforms(const Matrix4x4& aTransformToSurface) {
     DefaultComputeEffectiveTransforms(aTransformToSurface);
   }
 };
 
 class TestThebesLayer: public ThebesLayer {
 public:
-  TestThebesLayer(LayerManager* aManager)
+  explicit TestThebesLayer(LayerManager* aManager)
     : ThebesLayer(aManager, nullptr)
   {}
 
   virtual const char* Name() const {
     return "TestThebesLayer";
   }
 
   virtual LayerType GetType() const {
--- a/gfx/tests/gtest/TestTiledLayerBuffer.cpp
+++ b/gfx/tests/gtest/TestTiledLayerBuffer.cpp
@@ -7,17 +7,17 @@
 
 #include "gtest/gtest.h"
 
 namespace mozilla {
 namespace layers {
 
 struct TestTiledLayerTile {
   int value;
-  TestTiledLayerTile(int v = 0) {
+  explicit TestTiledLayerTile(int v = 0) {
     value = v;
   }
   bool operator== (const TestTiledLayerTile& o) const {
     return value == o.value;
   }
   bool operator!= (const TestTiledLayerTile& o) const {
     return value != o.value;
   }