Bug 1598582 Part 2: Add event to record OptimizeSourceSurface. r=jrmuizel

This also optimizes the surface returned by CreateSourceSurfaceFromData to
match what would happen in the non-recorded case. This means that all surfaces
of type RECORDING are optimized, i.e. they represent a surface type that
matches the DrawTarget type in the Translator.

Differential Revision: https://phabricator.services.mozilla.com/D55292

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bob Owen 2019-11-29 21:59:11 +00:00
Родитель 599d8c4b43
Коммит 2efd34ce2b
3 изменённых файлов: 76 добавлений и 4 удалений

Просмотреть файл

@ -503,13 +503,25 @@ DrawTargetRecording::CreateSourceSurfaceFromData(unsigned char* aData,
SurfaceFormat aFormat) const {
RefPtr<SourceSurface> surf = DataSourceSurfaceRecording::Init(
aData, aSize, aStride, aFormat, mRecorder);
mRecorder->RecordEvent(RecordedOptimizeSourceSurface(surf, this, surf));
return surf.forget();
}
already_AddRefed<SourceSurface> DrawTargetRecording::OptimizeSourceSurface(
SourceSurface* aSurface) const {
RefPtr<SourceSurface> surf(aSurface);
return surf.forget();
if (aSurface->GetType() == SurfaceType::RECORDING) {
return do_AddRef(aSurface);
}
EnsureSurfaceStoredRecording(mRecorder, aSurface, "OptimizeSourceSurface");
RefPtr<SourceSurface> retSurf = new SourceSurfaceRecording(
aSurface->GetSize(), aSurface->GetFormat(), mRecorder);
mRecorder->RecordEvent(
RecordedOptimizeSourceSurface(aSurface, this, retSurf));
return retSurf.forget();
}
already_AddRefed<SourceSurface>

Просмотреть файл

@ -27,7 +27,7 @@ const uint32_t kMagicInt = 0xc001feed;
const uint16_t kMajorRevision = 10;
// A change in minor revision means additions of new events. New streams will
// not play in older players.
const uint16_t kMinorRevision = 0;
const uint16_t kMinorRevision = 1;
struct ReferencePtr {
ReferencePtr() : mLongPtr(0) {}
@ -319,6 +319,7 @@ class RecordedEvent {
EXTERNALSURFACECREATION,
FLUSH,
DETACHALLSNAPSHOTS,
OPTIMIZESOURCESURFACE,
LAST,
};

Просмотреть файл

@ -911,6 +911,35 @@ class RecordedSourceSurfaceDestruction
MOZ_IMPLICIT RecordedSourceSurfaceDestruction(S& aStream);
};
class RecordedOptimizeSourceSurface
: public RecordedEventDerived<RecordedOptimizeSourceSurface> {
public:
RecordedOptimizeSourceSurface(ReferencePtr aSurface, ReferencePtr aDT,
ReferencePtr aOptimizedSurface)
: RecordedEventDerived(OPTIMIZESOURCESURFACE),
mSurface(aSurface),
mDT(aDT),
mOptimizedSurface(aOptimizedSurface) {}
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 "OptimizeSourceSurface"; }
private:
friend class RecordedEvent;
ReferencePtr mSurface;
ReferencePtr mDT;
ReferencePtr mOptimizedSurface;
template <class S>
MOZ_IMPLICIT RecordedOptimizeSourceSurface(S& aStream);
};
class RecordedExternalSurfaceCreation
: public RecordedEventDerived<RecordedExternalSurfaceCreation> {
public:
@ -2869,6 +2898,35 @@ inline void RecordedSourceSurfaceDestruction::OutputSimpleEventInfo(
aStringStream << "[" << mRefPtr << "] SourceSurface Destroyed";
}
inline bool RecordedOptimizeSourceSurface::PlayEvent(
Translator* aTranslator) const {
RefPtr<SourceSurface> src =
aTranslator->LookupDrawTarget(mDT)->OptimizeSourceSurface(
aTranslator->LookupSourceSurface(mSurface));
aTranslator->AddSourceSurface(mOptimizedSurface, src);
return true;
}
template <class S>
void RecordedOptimizeSourceSurface::Record(S& aStream) const {
WriteElement(aStream, mSurface);
WriteElement(aStream, mDT);
WriteElement(aStream, mOptimizedSurface);
}
template <class S>
RecordedOptimizeSourceSurface::RecordedOptimizeSourceSurface(S& aStream)
: RecordedEventDerived(OPTIMIZESOURCESURFACE) {
ReadElement(aStream, mSurface);
ReadElement(aStream, mDT);
ReadElement(aStream, mOptimizedSurface);
}
inline void RecordedOptimizeSourceSurface::OutputSimpleEventInfo(
std::stringstream& aStringStream) const {
aStringStream << "[" << mSurface << "] Surface Optimized (DT: " << mDT << ")";
}
inline bool RecordedExternalSurfaceCreation::PlayEvent(
Translator* aTranslator) const {
RefPtr<SourceSurface> surface = aTranslator->LookupExternalSurface(mKey);
@ -3574,7 +3632,8 @@ inline void RecordedFilterNodeSetInput::OutputSimpleEventInfo(
f(INTOLUMINANCE, RecordedIntoLuminanceSource); \
f(EXTERNALSURFACECREATION, RecordedExternalSurfaceCreation); \
f(FLUSH, RecordedFlush); \
f(DETACHALLSNAPSHOTS, RecordedDetachAllSnapshots);
f(DETACHALLSNAPSHOTS, RecordedDetachAllSnapshots); \
f(OPTIMIZESOURCESURFACE, RecordedOptimizeSourceSurface);
#define DO_WITH_EVENT_TYPE(_typeenum, _class) \
case _typeenum: { \