mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
Bug 1400411 - stop mocking most of DrawTarget. r=jrmuizel
Also fixes a bad debug assertion MozReview-Commit-ID: 5OV5KkvbRwZ --HG-- extra : rebase_source : 5de35738733c8f18b2b227109eed7fcd9b4d9ed9
This commit is contained in:
parent
6803f63105
commit
6c9882ed08
@ -94,7 +94,6 @@ public:
|
|||||||
explicit TextDrawTarget()
|
explicit TextDrawTarget()
|
||||||
: mCurrentlyDrawing(Phase::eSelection), mHasUnsupportedFeatures(false)
|
: mCurrentlyDrawing(Phase::eSelection), mHasUnsupportedFeatures(false)
|
||||||
{
|
{
|
||||||
mCurrentTarget = gfx::Factory::CreateDrawTarget(gfx::BackendType::SKIA, IntSize(1, 1), gfx::SurfaceFormat::B8G8R8A8);
|
|
||||||
SetSelectionIndex(0);
|
SetSelectionIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +107,7 @@ public:
|
|||||||
|
|
||||||
void SetSelectionIndex(size_t i) {
|
void SetSelectionIndex(size_t i) {
|
||||||
// i should only be accessed if i-1 has already been
|
// i should only be accessed if i-1 has already been
|
||||||
MOZ_ASSERT(mParts.Length() <= i);
|
MOZ_ASSERT(i <= mParts.Length());
|
||||||
|
|
||||||
if (mParts.Length() == i){
|
if (mParts.Length() == i){
|
||||||
mParts.AppendElement();
|
mParts.AppendElement();
|
||||||
@ -387,9 +386,6 @@ private:
|
|||||||
// Chunks of the text, grouped by selection
|
// Chunks of the text, grouped by selection
|
||||||
nsTArray<SelectedTextRunFragment> mParts;
|
nsTArray<SelectedTextRunFragment> mParts;
|
||||||
|
|
||||||
// A dummy to handle parts of the DrawTarget impl we don't care for
|
|
||||||
RefPtr<DrawTarget> mCurrentTarget;
|
|
||||||
|
|
||||||
// Whether Tofu or SVG fonts were encountered
|
// Whether Tofu or SVG fonts were encountered
|
||||||
bool mHasUnsupportedFeatures;
|
bool mHasUnsupportedFeatures;
|
||||||
|
|
||||||
@ -407,25 +403,28 @@ public:
|
|||||||
bool IsCaptureDT() const override { return false; }
|
bool IsCaptureDT() const override { return false; }
|
||||||
|
|
||||||
already_AddRefed<SourceSurface> Snapshot() override {
|
already_AddRefed<SourceSurface> Snapshot() override {
|
||||||
return mCurrentTarget->Snapshot();
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<SourceSurface> IntoLuminanceSource(LuminanceType aLuminanceType,
|
already_AddRefed<SourceSurface> IntoLuminanceSource(LuminanceType aLuminanceType,
|
||||||
float aOpacity) override {
|
float aOpacity) override {
|
||||||
return mCurrentTarget->IntoLuminanceSource(aLuminanceType, aOpacity);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntSize GetSize() override {
|
IntSize GetSize() override {
|
||||||
return mCurrentTarget->GetSize();
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
|
return IntSize(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Flush() override {
|
void Flush() override {
|
||||||
mCurrentTarget->Flush();
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawCapturedDT(DrawTargetCapture *aCaptureDT,
|
void DrawCapturedDT(DrawTargetCapture *aCaptureDT,
|
||||||
const Matrix& aTransform) override {
|
const Matrix& aTransform) override {
|
||||||
mCurrentTarget->DrawCapturedDT(aCaptureDT, aTransform);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawSurface(SourceSurface *aSurface,
|
void DrawSurface(SourceSurface *aSurface,
|
||||||
@ -433,14 +432,14 @@ public:
|
|||||||
const Rect &aSource,
|
const Rect &aSource,
|
||||||
const DrawSurfaceOptions &aSurfOptions,
|
const DrawSurfaceOptions &aSurfOptions,
|
||||||
const DrawOptions &aOptions) override {
|
const DrawOptions &aOptions) override {
|
||||||
mCurrentTarget->DrawSurface(aSurface, aDest, aSource, aSurfOptions, aOptions);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFilter(FilterNode *aNode,
|
void DrawFilter(FilterNode *aNode,
|
||||||
const Rect &aSourceRect,
|
const Rect &aSourceRect,
|
||||||
const Point &aDestPoint,
|
const Point &aDestPoint,
|
||||||
const DrawOptions &aOptions) override {
|
const DrawOptions &aOptions) override {
|
||||||
mCurrentTarget->DrawFilter(aNode, aSourceRect, aDestPoint, aOptions);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawSurfaceWithShadow(SourceSurface *aSurface,
|
void DrawSurfaceWithShadow(SourceSurface *aSurface,
|
||||||
@ -449,30 +448,30 @@ public:
|
|||||||
const Point &aOffset,
|
const Point &aOffset,
|
||||||
Float aSigma,
|
Float aSigma,
|
||||||
CompositionOp aOperator) override {
|
CompositionOp aOperator) override {
|
||||||
mCurrentTarget->DrawSurfaceWithShadow(aSurface, aDest, aColor, aOffset, aSigma, aOperator);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearRect(const Rect &aRect) override {
|
void ClearRect(const Rect &aRect) override {
|
||||||
mCurrentTarget->ClearRect(aRect);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopySurface(SourceSurface *aSurface,
|
void CopySurface(SourceSurface *aSurface,
|
||||||
const IntRect &aSourceRect,
|
const IntRect &aSourceRect,
|
||||||
const IntPoint &aDestination) override {
|
const IntPoint &aDestination) override {
|
||||||
mCurrentTarget->CopySurface(aSurface, aSourceRect, aDestination);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FillRect(const Rect &aRect,
|
void FillRect(const Rect &aRect,
|
||||||
const Pattern &aPattern,
|
const Pattern &aPattern,
|
||||||
const DrawOptions &aOptions = DrawOptions()) override {
|
const DrawOptions &aOptions = DrawOptions()) override {
|
||||||
mCurrentTarget->FillRect(aRect, aPattern, aOptions);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void StrokeRect(const Rect &aRect,
|
void StrokeRect(const Rect &aRect,
|
||||||
const Pattern &aPattern,
|
const Pattern &aPattern,
|
||||||
const StrokeOptions &aStrokeOptions,
|
const StrokeOptions &aStrokeOptions,
|
||||||
const DrawOptions &aOptions) override {
|
const DrawOptions &aOptions) override {
|
||||||
mCurrentTarget->StrokeRect(aRect, aPattern, aStrokeOptions, aOptions);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void StrokeLine(const Point &aStart,
|
void StrokeLine(const Point &aStart,
|
||||||
@ -480,7 +479,7 @@ public:
|
|||||||
const Pattern &aPattern,
|
const Pattern &aPattern,
|
||||||
const StrokeOptions &aStrokeOptions,
|
const StrokeOptions &aStrokeOptions,
|
||||||
const DrawOptions &aOptions) override {
|
const DrawOptions &aOptions) override {
|
||||||
mCurrentTarget->StrokeLine(aStart, aEnd, aPattern, aStrokeOptions, aOptions);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -488,13 +487,13 @@ public:
|
|||||||
const Pattern &aPattern,
|
const Pattern &aPattern,
|
||||||
const StrokeOptions &aStrokeOptions,
|
const StrokeOptions &aStrokeOptions,
|
||||||
const DrawOptions &aOptions) override {
|
const DrawOptions &aOptions) override {
|
||||||
mCurrentTarget->Stroke(aPath, aPattern, aStrokeOptions, aOptions);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fill(const Path *aPath,
|
void Fill(const Path *aPath,
|
||||||
const Pattern &aPattern,
|
const Pattern &aPattern,
|
||||||
const DrawOptions &aOptions) override {
|
const DrawOptions &aOptions) override {
|
||||||
mCurrentTarget->Fill(aPath, aPattern, aOptions);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void StrokeGlyphs(ScaledFont* aFont,
|
void StrokeGlyphs(ScaledFont* aFont,
|
||||||
@ -503,43 +502,41 @@ public:
|
|||||||
const StrokeOptions& aStrokeOptions,
|
const StrokeOptions& aStrokeOptions,
|
||||||
const DrawOptions& aOptions,
|
const DrawOptions& aOptions,
|
||||||
const GlyphRenderingOptions* aRenderingOptions) override {
|
const GlyphRenderingOptions* aRenderingOptions) override {
|
||||||
MOZ_ASSERT(mCurrentlyDrawing == Phase::eGlyphs);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
mCurrentTarget->StrokeGlyphs(aFont, aBuffer, aPattern,
|
|
||||||
aStrokeOptions, aOptions, aRenderingOptions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mask(const Pattern &aSource,
|
void Mask(const Pattern &aSource,
|
||||||
const Pattern &aMask,
|
const Pattern &aMask,
|
||||||
const DrawOptions &aOptions) override {
|
const DrawOptions &aOptions) override {
|
||||||
return mCurrentTarget->Mask(aSource, aMask, aOptions);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaskSurface(const Pattern &aSource,
|
void MaskSurface(const Pattern &aSource,
|
||||||
SourceSurface *aMask,
|
SourceSurface *aMask,
|
||||||
Point aOffset,
|
Point aOffset,
|
||||||
const DrawOptions &aOptions) override {
|
const DrawOptions &aOptions) override {
|
||||||
return mCurrentTarget->MaskSurface(aSource, aMask, aOffset, aOptions);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Draw3DTransformedSurface(SourceSurface* aSurface,
|
bool Draw3DTransformedSurface(SourceSurface* aSurface,
|
||||||
const Matrix4x4& aMatrix) override {
|
const Matrix4x4& aMatrix) override {
|
||||||
return mCurrentTarget->Draw3DTransformedSurface(aSurface, aMatrix);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PushClip(const Path *aPath) override {
|
void PushClip(const Path *aPath) override {
|
||||||
mCurrentTarget->PushClip(aPath);
|
// Fine to pretend we do this
|
||||||
}
|
}
|
||||||
|
|
||||||
void PushClipRect(const Rect &aRect) override {
|
void PushClipRect(const Rect &aRect) override {
|
||||||
mCurrentTarget->PushClipRect(aRect);
|
// Fine to pretend we do this
|
||||||
}
|
}
|
||||||
|
|
||||||
void PushDeviceSpaceClipRects(const IntRect* aRects, uint32_t aCount) override {
|
void PushDeviceSpaceClipRects(const IntRect* aRects, uint32_t aCount) override {
|
||||||
mCurrentTarget->PushDeviceSpaceClipRects(aRects, aCount);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopClip() override {
|
void PopClip() override {
|
||||||
mCurrentTarget->PopClip();
|
// Fine to pretend we do this
|
||||||
}
|
}
|
||||||
|
|
||||||
void PushLayer(bool aOpaque, Float aOpacity,
|
void PushLayer(bool aOpaque, Float aOpacity,
|
||||||
@ -547,11 +544,11 @@ public:
|
|||||||
const Matrix& aMaskTransform,
|
const Matrix& aMaskTransform,
|
||||||
const IntRect& aBounds,
|
const IntRect& aBounds,
|
||||||
bool aCopyBackground) override {
|
bool aCopyBackground) override {
|
||||||
mCurrentTarget->PushLayer(aOpaque, aOpacity, aMask, aMaskTransform, aBounds, aCopyBackground);
|
// Fine to pretend we do this
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopLayer() override {
|
void PopLayer() override {
|
||||||
mCurrentTarget->PopLayer();
|
// Fine to pretend we do this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -559,49 +556,53 @@ public:
|
|||||||
const IntSize &aSize,
|
const IntSize &aSize,
|
||||||
int32_t aStride,
|
int32_t aStride,
|
||||||
SurfaceFormat aFormat) const override {
|
SurfaceFormat aFormat) const override {
|
||||||
return mCurrentTarget->CreateSourceSurfaceFromData(aData, aSize, aStride, aFormat);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override {
|
already_AddRefed<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override {
|
||||||
return mCurrentTarget->OptimizeSourceSurface(aSurface);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<SourceSurface>
|
already_AddRefed<SourceSurface>
|
||||||
CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const override {
|
CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const override {
|
||||||
return mCurrentTarget->CreateSourceSurfaceFromNativeSurface(aSurface);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<DrawTarget>
|
already_AddRefed<DrawTarget>
|
||||||
CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const override {
|
CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const override {
|
||||||
return mCurrentTarget->CreateSimilarDrawTarget(aSize, aFormat);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<PathBuilder> CreatePathBuilder(FillRule aFillRule) const override {
|
already_AddRefed<PathBuilder> CreatePathBuilder(FillRule aFillRule) const override {
|
||||||
return mCurrentTarget->CreatePathBuilder(aFillRule);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<FilterNode> CreateFilter(FilterType aType) override {
|
already_AddRefed<FilterNode> CreateFilter(FilterType aType) override {
|
||||||
return mCurrentTarget->CreateFilter(aType);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<GradientStops>
|
already_AddRefed<GradientStops>
|
||||||
CreateGradientStops(GradientStop *aStops,
|
CreateGradientStops(GradientStop *aStops,
|
||||||
uint32_t aNumStops,
|
uint32_t aNumStops,
|
||||||
ExtendMode aExtendMode) const override {
|
ExtendMode aExtendMode) const override {
|
||||||
return mCurrentTarget->CreateGradientStops(aStops, aNumStops, aExtendMode);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
}
|
return nullptr;
|
||||||
|
|
||||||
void SetTransform(const Matrix &aTransform) override {
|
|
||||||
mCurrentTarget->SetTransform(aTransform);
|
|
||||||
// Need to do this to make inherited GetTransform to work
|
|
||||||
DrawTarget::SetTransform(aTransform);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void* GetNativeSurface(NativeSurfaceType aType) override {
|
void* GetNativeSurface(NativeSurfaceType aType) override {
|
||||||
return mCurrentTarget->GetNativeSurface(aType);
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetachAllSnapshots() override { mCurrentTarget->DetachAllSnapshots(); }
|
void DetachAllSnapshots() override {
|
||||||
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user