mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 1829026 - Implement DrawShadow in DrawTargetRecording. r=aosmond
DrawTargetWebgl relies upon DrawShadow for shadow performance. This was never implemented in DrawTargetRecording, which this patch rectifies. Differential Revision: https://phabricator.services.mozilla.com/D194354
This commit is contained in:
parent
3a265d3692
commit
30d651cabd
@ -393,6 +393,17 @@ void DrawTargetRecording::Stroke(const Path* aPath, const Pattern& aPattern,
|
|||||||
RecordedStroke(this, pathRecording, aPattern, aStrokeOptions, aOptions));
|
RecordedStroke(this, pathRecording, aPattern, aStrokeOptions, aOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawTargetRecording::DrawShadow(const Path* aPath, const Pattern& aPattern,
|
||||||
|
const ShadowOptions& aShadow,
|
||||||
|
const DrawOptions& aOptions,
|
||||||
|
const StrokeOptions* aStrokeOptions) {
|
||||||
|
RefPtr<PathRecording> pathRecording = EnsurePathStored(aPath);
|
||||||
|
EnsurePatternDependenciesStored(aPattern);
|
||||||
|
|
||||||
|
mRecorder->RecordEvent(RecordedDrawShadow(this, pathRecording, aPattern,
|
||||||
|
aShadow, aOptions, aStrokeOptions));
|
||||||
|
}
|
||||||
|
|
||||||
already_AddRefed<SourceSurface> DrawTargetRecording::Snapshot() {
|
already_AddRefed<SourceSurface> DrawTargetRecording::Snapshot() {
|
||||||
RefPtr<SourceSurface> retSurf =
|
RefPtr<SourceSurface> retSurf =
|
||||||
new SourceSurfaceRecording(mRect.Size(), mFormat, mRecorder);
|
new SourceSurfaceRecording(mRect.Size(), mFormat, mRecorder);
|
||||||
|
@ -73,6 +73,11 @@ class DrawTargetRecording : public DrawTarget {
|
|||||||
const ShadowOptions& aShadow,
|
const ShadowOptions& aShadow,
|
||||||
CompositionOp aOperator) override;
|
CompositionOp aOperator) override;
|
||||||
|
|
||||||
|
virtual void DrawShadow(const Path* aPath, const Pattern& aPattern,
|
||||||
|
const ShadowOptions& aShadow,
|
||||||
|
const DrawOptions& aOptions,
|
||||||
|
const StrokeOptions* aStrokeOptions) override;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clear a rectangle on the draw target to transparent black. This will
|
* Clear a rectangle on the draw target to transparent black. This will
|
||||||
* respect the clipping region and transform.
|
* respect the clipping region and transform.
|
||||||
|
@ -384,6 +384,7 @@ class RecordedEvent {
|
|||||||
DRAWSURFACE,
|
DRAWSURFACE,
|
||||||
DRAWDEPENDENTSURFACE,
|
DRAWDEPENDENTSURFACE,
|
||||||
DRAWSURFACEWITHSHADOW,
|
DRAWSURFACEWITHSHADOW,
|
||||||
|
DRAWSHADOW,
|
||||||
PATHCREATION,
|
PATHCREATION,
|
||||||
PATHDESTRUCTION,
|
PATHDESTRUCTION,
|
||||||
SOURCESURFACECREATION,
|
SOURCESURFACECREATION,
|
||||||
|
@ -824,6 +824,44 @@ class RecordedDrawSurfaceWithShadow
|
|||||||
CompositionOp mOp;
|
CompositionOp mOp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RecordedDrawShadow : public RecordedDrawingEvent<RecordedDrawShadow> {
|
||||||
|
public:
|
||||||
|
RecordedDrawShadow(DrawTarget* aDT, ReferencePtr aPath,
|
||||||
|
const Pattern& aPattern, const ShadowOptions& aShadow,
|
||||||
|
const DrawOptions& aOptions,
|
||||||
|
const StrokeOptions* aStrokeOptions)
|
||||||
|
: RecordedDrawingEvent(DRAWSHADOW, aDT),
|
||||||
|
mPath(aPath),
|
||||||
|
mPattern(),
|
||||||
|
mShadow(aShadow),
|
||||||
|
mOptions(aOptions),
|
||||||
|
mHasStrokeOptions(!!aStrokeOptions),
|
||||||
|
mStrokeOptions(aStrokeOptions ? *aStrokeOptions : StrokeOptions()) {
|
||||||
|
StorePattern(mPattern, aPattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PlayEvent(Translator* aTranslator) const override;
|
||||||
|
|
||||||
|
template <class S>
|
||||||
|
void Record(S& aStream) const;
|
||||||
|
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
|
||||||
|
|
||||||
|
std::string GetName() const override { return "DrawShadow"; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class RecordedEvent;
|
||||||
|
|
||||||
|
template <class S>
|
||||||
|
MOZ_IMPLICIT RecordedDrawShadow(S& aStream);
|
||||||
|
|
||||||
|
ReferencePtr mPath;
|
||||||
|
PatternStorage mPattern;
|
||||||
|
ShadowOptions mShadow;
|
||||||
|
DrawOptions mOptions;
|
||||||
|
bool mHasStrokeOptions;
|
||||||
|
StrokeOptions mStrokeOptions;
|
||||||
|
};
|
||||||
|
|
||||||
class RecordedDrawFilter : public RecordedDrawingEvent<RecordedDrawFilter> {
|
class RecordedDrawFilter : public RecordedDrawingEvent<RecordedDrawFilter> {
|
||||||
public:
|
public:
|
||||||
RecordedDrawFilter(DrawTarget* aDT, ReferencePtr aNode,
|
RecordedDrawFilter(DrawTarget* aDT, ReferencePtr aNode,
|
||||||
@ -3098,6 +3136,55 @@ inline void RecordedDrawSurfaceWithShadow::OutputSimpleEventInfo(
|
|||||||
<< mShadow.mColor.a << ")";
|
<< mShadow.mColor.a << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool RecordedDrawShadow::PlayEvent(Translator* aTranslator) const {
|
||||||
|
DrawTarget* dt = aTranslator->LookupDrawTarget(mDT);
|
||||||
|
if (!dt) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Path* path = aTranslator->LookupPath(mPath);
|
||||||
|
if (!path) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
dt->DrawShadow(path, *GenericPattern(mPattern, aTranslator), mShadow,
|
||||||
|
mOptions, mHasStrokeOptions ? &mStrokeOptions : nullptr);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class S>
|
||||||
|
void RecordedDrawShadow::Record(S& aStream) const {
|
||||||
|
RecordedDrawingEvent::Record(aStream);
|
||||||
|
WriteElement(aStream, mPath);
|
||||||
|
RecordPatternData(aStream, mPattern);
|
||||||
|
WriteElement(aStream, mShadow);
|
||||||
|
WriteElement(aStream, mOptions);
|
||||||
|
WriteElement(aStream, mHasStrokeOptions);
|
||||||
|
if (mHasStrokeOptions) {
|
||||||
|
RecordStrokeOptions(aStream, mStrokeOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class S>
|
||||||
|
RecordedDrawShadow::RecordedDrawShadow(S& aStream)
|
||||||
|
: RecordedDrawingEvent(DRAWSHADOW, aStream) {
|
||||||
|
ReadElement(aStream, mPath);
|
||||||
|
ReadPatternData(aStream, mPattern);
|
||||||
|
ReadElement(aStream, mShadow);
|
||||||
|
ReadDrawOptions(aStream, mOptions);
|
||||||
|
ReadElement(aStream, mHasStrokeOptions);
|
||||||
|
if (mHasStrokeOptions) {
|
||||||
|
ReadStrokeOptions(aStream, mStrokeOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void RecordedDrawShadow::OutputSimpleEventInfo(
|
||||||
|
std::stringstream& aStringStream) const {
|
||||||
|
aStringStream << "[" << mDT << "] DrawShadow (" << mPath << ") DeviceColor: ("
|
||||||
|
<< mShadow.mColor.r << ", " << mShadow.mColor.g << ", "
|
||||||
|
<< mShadow.mColor.b << ", " << mShadow.mColor.a << ")";
|
||||||
|
}
|
||||||
|
|
||||||
inline RecordedPathCreation::RecordedPathCreation(PathRecording* aPath)
|
inline RecordedPathCreation::RecordedPathCreation(PathRecording* aPath)
|
||||||
: RecordedEventDerived(PATHCREATION),
|
: RecordedEventDerived(PATHCREATION),
|
||||||
mRefPtr(aPath),
|
mRefPtr(aPath),
|
||||||
@ -4154,6 +4241,7 @@ inline void RecordedDestination::OutputSimpleEventInfo(
|
|||||||
f(DRAWSURFACE, RecordedDrawSurface); \
|
f(DRAWSURFACE, RecordedDrawSurface); \
|
||||||
f(DRAWDEPENDENTSURFACE, RecordedDrawDependentSurface); \
|
f(DRAWDEPENDENTSURFACE, RecordedDrawDependentSurface); \
|
||||||
f(DRAWSURFACEWITHSHADOW, RecordedDrawSurfaceWithShadow); \
|
f(DRAWSURFACEWITHSHADOW, RecordedDrawSurfaceWithShadow); \
|
||||||
|
f(DRAWSHADOW, RecordedDrawShadow); \
|
||||||
f(DRAWFILTER, RecordedDrawFilter); \
|
f(DRAWFILTER, RecordedDrawFilter); \
|
||||||
f(PATHCREATION, RecordedPathCreation); \
|
f(PATHCREATION, RecordedPathCreation); \
|
||||||
f(PATHDESTRUCTION, RecordedPathDestruction); \
|
f(PATHDESTRUCTION, RecordedPathDestruction); \
|
||||||
|
Loading…
Reference in New Issue
Block a user