mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1662336 - Implement dependent surface support in the print recording code. r=bobowen
Differential Revision: https://phabricator.services.mozilla.com/D90805
This commit is contained in:
parent
07d5324b11
commit
3f9723aef2
@ -492,6 +492,14 @@ void DrawTargetWrapAndRecord::DrawSurface(
|
||||
aSurfOptions, aOptions);
|
||||
}
|
||||
|
||||
void DrawTargetWrapAndRecord::DrawDependentSurface(
|
||||
uint64_t aId, const Rect& aDest, const DrawSurfaceOptions& aSurfOptions,
|
||||
const DrawOptions& aOptions) {
|
||||
mRecorder->AddDependentSurface(aId);
|
||||
mRecorder->RecordEvent(
|
||||
RecordedDrawDependentSurface(this, aId, aDest, aSurfOptions, aOptions));
|
||||
}
|
||||
|
||||
void DrawTargetWrapAndRecord::DrawSurfaceWithShadow(
|
||||
SourceSurface* aSurface, const Point& aDest, const DeviceColor& aColor,
|
||||
const Point& aOffset, Float aSigma, CompositionOp aOp) {
|
||||
|
@ -59,6 +59,11 @@ class DrawTargetWrapAndRecord : public DrawTarget {
|
||||
const DrawSurfaceOptions& aSurfOptions = DrawSurfaceOptions(),
|
||||
const DrawOptions& aOptions = DrawOptions()) override;
|
||||
|
||||
virtual void DrawDependentSurface(
|
||||
uint64_t aId, const Rect& aDest,
|
||||
const DrawSurfaceOptions& aSurfOptions = DrawSurfaceOptions(),
|
||||
const DrawOptions& aOptions = DrawOptions()) override;
|
||||
|
||||
virtual void DrawFilter(FilterNode* aNode, const Rect& aSourceRect,
|
||||
const Point& aDestPoint,
|
||||
const DrawOptions& aOptions = DrawOptions()) override;
|
||||
|
@ -39,5 +39,13 @@ void DrawEventRecorderPRFileDesc::Close() {
|
||||
mOutputStream.Close();
|
||||
}
|
||||
|
||||
void DrawEventRecorderPRFileDesc::AddDependentSurface(uint64_t aDependencyId) {
|
||||
mDependentSurfaces.AppendElement(aDependencyId);
|
||||
}
|
||||
|
||||
nsTArray<uint64_t>&& DrawEventRecorderPRFileDesc::TakeDependentSurfaces() {
|
||||
return std::move(mDependentSurfaces);
|
||||
}
|
||||
|
||||
} // namespace layout
|
||||
} // namespace mozilla
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "mozilla/gfx/DrawEventRecorder.h"
|
||||
#include "mozilla/gfx/RecordingTypes.h"
|
||||
#include "prio.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layout {
|
||||
@ -149,10 +150,14 @@ class DrawEventRecorderPRFileDesc final : public gfx::DrawEventRecorderPrivate {
|
||||
*/
|
||||
void Close();
|
||||
|
||||
void AddDependentSurface(uint64_t aDependencyId) override;
|
||||
nsTArray<uint64_t>&& TakeDependentSurfaces();
|
||||
|
||||
private:
|
||||
void Flush() override;
|
||||
|
||||
PRFileDescStream mOutputStream;
|
||||
nsTArray<uint64_t> mDependentSurfaces;
|
||||
};
|
||||
|
||||
} // namespace layout
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mozilla/gfx/RecordedEvent.h"
|
||||
#include "mozilla/gfx/RecordingTypes.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "InlineTranslator.h"
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
@ -81,5 +82,26 @@ already_AddRefed<DrawTarget> PrintTranslator::CreateDrawTarget(
|
||||
return drawTarget.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<SourceSurface> PrintTranslator::LookupExternalSurface(
|
||||
uint64_t aKey) {
|
||||
RefPtr<RecordedDependentSurface> surface = mDependentSurfaces.Get(aKey);
|
||||
if (!surface) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<DrawTarget> newDT = GetReferenceDrawTarget()->CreateSimilarDrawTarget(
|
||||
surface->mSize, SurfaceFormat::B8G8R8A8);
|
||||
|
||||
InlineTranslator translator(newDT, nullptr);
|
||||
translator.SetDependentSurfaces(&mDependentSurfaces);
|
||||
if (!translator.TranslateRecording((char*)surface->mRecording.mData,
|
||||
surface->mRecording.mLen)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<SourceSurface> snapshot = newDT->Snapshot();
|
||||
return snapshot.forget();
|
||||
}
|
||||
|
||||
} // namespace layout
|
||||
} // namespace mozilla
|
||||
|
@ -25,6 +25,7 @@ using gfx::FilterNode;
|
||||
using gfx::GradientStops;
|
||||
using gfx::NativeFontResource;
|
||||
using gfx::Path;
|
||||
using gfx::RecordedDependentSurface;
|
||||
using gfx::ReferencePtr;
|
||||
using gfx::ScaledFont;
|
||||
using gfx::SourceSurface;
|
||||
@ -37,6 +38,12 @@ class PrintTranslator final : public Translator {
|
||||
|
||||
bool TranslateRecording(PRFileDescStream& aRecording);
|
||||
|
||||
void SetDependentSurfaces(
|
||||
nsRefPtrHashtable<nsUint64HashKey, RecordedDependentSurface>&&
|
||||
aDependentSurfaces) {
|
||||
mDependentSurfaces = std::move(aDependentSurfaces);
|
||||
}
|
||||
|
||||
DrawTarget* LookupDrawTarget(ReferencePtr aRefPtr) final {
|
||||
DrawTarget* result = mDrawTargets.GetWeak(aRefPtr);
|
||||
MOZ_ASSERT(result);
|
||||
@ -85,6 +92,8 @@ class PrintTranslator final : public Translator {
|
||||
return result;
|
||||
}
|
||||
|
||||
already_AddRefed<SourceSurface> LookupExternalSurface(uint64_t aKey) final;
|
||||
|
||||
void AddDrawTarget(ReferencePtr aRefPtr, DrawTarget* aDT) final {
|
||||
mDrawTargets.Put(aRefPtr, RefPtr{aDT});
|
||||
}
|
||||
@ -163,6 +172,8 @@ class PrintTranslator final : public Translator {
|
||||
nsRefPtrHashtable<nsPtrHashKey<void>, ScaledFont> mScaledFonts;
|
||||
nsRefPtrHashtable<nsPtrHashKey<void>, UnscaledFont> mUnscaledFonts;
|
||||
nsRefPtrHashtable<nsUint64HashKey, NativeFontResource> mNativeFontResources;
|
||||
nsRefPtrHashtable<nsUint64HashKey, RecordedDependentSurface>
|
||||
mDependentSurfaces;
|
||||
};
|
||||
|
||||
} // namespace layout
|
||||
|
Loading…
Reference in New Issue
Block a user