Bug 1429508 - Mark DrawTarget::GetSize as const. r?jrmuizel
MozReview-Commit-ID: BmhlrQjmIjW
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -932,17 +932,17 @@ public:
* normally return the same SourceSurface object.
*/
virtual already_AddRefed<SourceSurface> Snapshot() = 0;
// Snapshots the contents and returns an alpha mask
// based on the RGB values.
virtual already_AddRefed<SourceSurface> IntoLuminanceSource(LuminanceType aLuminanceType,
float aOpacity);
- virtual IntSize GetSize() = 0;
+ virtual IntSize GetSize() const = 0;
/**
* If possible returns the bits to this DrawTarget for direct manipulation. While
* the bits is locked any modifications to this DrawTarget is forbidden.
* Release takes the original data pointer for safety.
*/
virtual bool LockBits(uint8_t** aData, IntSize* aSize,
int32_t* aStride, SurfaceFormat* aFormat,
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -676,17 +676,17 @@ DrawTargetCairo::GetType() const
MOZ_CRASH("GFX: Unsupported cairo surface type");
}
}
MOZ_ASSERT(false, "Could not determine DrawTargetType for DrawTargetCairo");
return DrawTargetType::SOFTWARE_RASTER;
}
IntSize
-DrawTargetCairo::GetSize()
+DrawTargetCairo::GetSize() const
{
return mSize;
}
SurfaceFormat
GfxFormatForCairoSurface(cairo_surface_t* surface)
{
cairo_surface_type_t type = cairo_surface_get_type(surface);
--- a/gfx/2d/DrawTargetCairo.h
+++ b/gfx/2d/DrawTargetCairo.h
@@ -60,17 +60,17 @@ public:
DrawTargetCairo();
virtual ~DrawTargetCairo();
virtual bool IsValid() const override;
virtual DrawTargetType GetType() const override;
virtual BackendType GetBackendType() const override { return BackendType::CAIRO; }
virtual already_AddRefed<SourceSurface> Snapshot() override;
- virtual IntSize GetSize() override;
+ virtual IntSize GetSize() const override;
virtual bool IsCurrentGroupOpaque() override;
virtual void SetPermitSubpixelAA(bool aPermitSubpixelAA) override;
virtual bool LockBits(uint8_t** aData, IntSize* aSize,
int32_t* aStride, SurfaceFormat* aFormat,
IntPoint* aOrigin = nullptr) override;
--- a/gfx/2d/DrawTargetCapture.h
+++ b/gfx/2d/DrawTargetCapture.h
@@ -32,17 +32,17 @@ public:
virtual BackendType GetBackendType() const override { return mRefDT->GetBackendType(); }
virtual DrawTargetType GetType() const override { return mRefDT->GetType(); }
virtual bool IsCaptureDT() const override { return true; }
virtual already_AddRefed<SourceSurface> Snapshot() override;
virtual already_AddRefed<SourceSurface> IntoLuminanceSource(LuminanceType aLuminanceType,
float aOpacity) override;
virtual void SetPermitSubpixelAA(bool aPermitSubpixelAA) override;
virtual void DetachAllSnapshots() override;
- virtual IntSize GetSize() override { return mSize; }
+ virtual IntSize GetSize() const override { return mSize; }
virtual void Flush() override {}
virtual void DrawSurface(SourceSurface *aSurface,
const Rect &aDest,
const Rect &aSource,
const DrawSurfaceOptions &aSurfOptions,
const DrawOptions &aOptions) override;
virtual void DrawFilter(FilterNode *aNode,
const Rect &aSourceRect,
--- a/gfx/2d/DrawTargetD2D1.h
+++ b/gfx/2d/DrawTargetD2D1.h
@@ -35,17 +35,17 @@ public:
DrawTargetD2D1();
virtual ~DrawTargetD2D1();
virtual DrawTargetType GetType() const override { return DrawTargetType::HARDWARE_RASTER; }
virtual BackendType GetBackendType() const override { return BackendType::DIRECT2D1_1; }
virtual already_AddRefed<SourceSurface> Snapshot() override;
virtual already_AddRefed<SourceSurface> IntoLuminanceSource(LuminanceType aLuminanceType,
float aOpacity) override;
- virtual IntSize GetSize() override { return mSize; }
+ virtual IntSize GetSize() const override { return mSize; }
virtual void Flush() override;
virtual void DrawSurface(SourceSurface *aSurface,
const Rect &aDest,
const Rect &aSource,
const DrawSurfaceOptions &aSurfOptions,
const DrawOptions &aOptions) override;
virtual void DrawFilter(FilterNode *aNode,
--- a/gfx/2d/DrawTargetDual.h
+++ b/gfx/2d/DrawTargetDual.h
@@ -44,17 +44,17 @@ public:
mFormat = aA->GetFormat();
}
virtual DrawTargetType GetType() const override { return mA->GetType(); }
virtual BackendType GetBackendType() const override { return mA->GetBackendType(); }
virtual already_AddRefed<SourceSurface> Snapshot() override {
return MakeAndAddRef<SourceSurfaceDual>(mA, mB);
}
- virtual IntSize GetSize() override { return mA->GetSize(); }
+ virtual IntSize GetSize() const override { return mA->GetSize(); }
virtual void DetachAllSnapshots() override;
FORWARD_FUNCTION(Flush)
FORWARD_FUNCTION1(PushClip, const Path *, aPath)
FORWARD_FUNCTION1(PushClipRect, const Rect &, aRect)
FORWARD_FUNCTION(PopClip)
FORWARD_FUNCTION(PopLayer)
--- a/gfx/2d/DrawTargetRecording.h
+++ b/gfx/2d/DrawTargetRecording.h
@@ -25,17 +25,17 @@ public:
virtual BackendType GetBackendType() const override { return BackendType::RECORDING; }
virtual bool IsRecording() const override { return true; }
virtual already_AddRefed<SourceSurface> Snapshot() override;
virtual already_AddRefed<SourceSurface> IntoLuminanceSource(LuminanceType aLuminanceType, float aOpacity) override;
virtual void DetachAllSnapshots() override;
- virtual IntSize GetSize() override { return mSize; }
+ virtual IntSize GetSize() const override { return mSize; }
/* Ensure that the DrawTarget backend has flushed all drawing operations to
* this draw target. This must be called before using the backing surface of
* this draw target outside of GFX 2D code.
*/
virtual void Flush() override { mFinalDT->Flush(); }
/*
--- a/gfx/2d/DrawTargetSkia.h
+++ b/gfx/2d/DrawTargetSkia.h
@@ -32,17 +32,17 @@ class DrawTargetSkia : public DrawTarget
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawTargetSkia, override)
DrawTargetSkia();
virtual ~DrawTargetSkia();
virtual DrawTargetType GetType() const override;
virtual BackendType GetBackendType() const override { return BackendType::SKIA; }
virtual already_AddRefed<SourceSurface> Snapshot() override;
- virtual IntSize GetSize() override { return mSize; }
+ virtual IntSize GetSize() const override { return mSize; };
virtual bool LockBits(uint8_t** aData, IntSize* aSize,
int32_t* aStride, SurfaceFormat* aFormat,
IntPoint* aOrigin = nullptr) override;
virtual void ReleaseBits(uint8_t* aData) override;
virtual void Flush() override;
virtual void DrawSurface(SourceSurface *aSurface,
const Rect &aDest,
const Rect &aSource,
--- a/gfx/2d/DrawTargetTiled.h
+++ b/gfx/2d/DrawTargetTiled.h
@@ -42,17 +42,17 @@ public:
virtual bool IsTiledDrawTarget() const override { return true; }
virtual bool IsCaptureDT() const override { return mTiles[0].mDrawTarget->IsCaptureDT(); }
virtual DrawTargetType GetType() const override { return mTiles[0].mDrawTarget->GetType(); }
virtual BackendType GetBackendType() const override { return mTiles[0].mDrawTarget->GetBackendType(); }
virtual already_AddRefed<SourceSurface> Snapshot() override;
virtual void DetachAllSnapshots() override;
- virtual IntSize GetSize() override {
+ virtual IntSize GetSize() const override {
MOZ_ASSERT(mRect.Width() > 0 && mRect.Height() > 0);
return IntSize(mRect.XMost(), mRect.YMost());
}
virtual void Flush() override;
virtual void DrawSurface(SourceSurface *aSurface,
const Rect &aDest,
const Rect &aSource,
--- a/gfx/2d/DrawTargetWrapAndRecord.h
+++ b/gfx/2d/DrawTargetWrapAndRecord.h
@@ -25,17 +25,17 @@ public:
virtual BackendType GetBackendType() const override { return mFinalDT->GetBackendType(); }
virtual bool IsRecording() const override { return true; }
virtual already_AddRefed<SourceSurface> Snapshot() override;
virtual already_AddRefed<SourceSurface> IntoLuminanceSource(LuminanceType aLuminanceType, float aOpacity) override;
virtual void DetachAllSnapshots() override;
- virtual IntSize GetSize() override { return mFinalDT->GetSize(); }
+ virtual IntSize GetSize() const override { return mFinalDT->GetSize(); }
/* Ensure that the DrawTarget backend has flushed all drawing operations to
* this draw target. This must be called before using the backing surface of
* this draw target outside of GFX 2D code.
*/
virtual void Flush() override { mFinalDT->Flush(); }
/*
--- a/layout/generic/TextDrawTarget.h
+++ b/layout/generic/TextDrawTarget.h
@@ -347,17 +347,17 @@ public:
}
already_AddRefed<SourceSurface> IntoLuminanceSource(LuminanceType aLuminanceType,
float aOpacity) override {
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
return nullptr;
}
- IntSize GetSize() override {
+ IntSize GetSize() const override {
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
return IntSize(1, 1);
}
void Flush() override {
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}