зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1720152 - Recurse into replay for dependencies, rather than using a temp surface. r=jrmuizel,bobowen,emilio
Differential Revision: https://phabricator.services.mozilla.com/D120050
This commit is contained in:
Родитель
4a06fcb21e
Коммит
ec9b5dd838
|
@ -1158,10 +1158,7 @@ class DrawTarget : public external::AtomicRefCounted<DrawTarget> {
|
||||||
* This is considered fallible, and replaying this without making the surface
|
* This is considered fallible, and replaying this without making the surface
|
||||||
* available to the replay will just skip the draw.
|
* available to the replay will just skip the draw.
|
||||||
*/
|
*/
|
||||||
virtual void DrawDependentSurface(
|
virtual void DrawDependentSurface(uint64_t aId, const Rect& aDest) {
|
||||||
uint64_t aId, const Rect& aDest,
|
|
||||||
const DrawSurfaceOptions& aSurfOptions = DrawSurfaceOptions(),
|
|
||||||
const DrawOptions& aOptions = DrawOptions()) {
|
|
||||||
MOZ_CRASH("GFX: DrawDependentSurface");
|
MOZ_CRASH("GFX: DrawDependentSurface");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -375,12 +375,10 @@ void DrawTargetRecording::DrawSurface(SourceSurface* aSurface,
|
||||||
aSurfOptions, aOptions));
|
aSurfOptions, aOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawTargetRecording::DrawDependentSurface(
|
void DrawTargetRecording::DrawDependentSurface(uint64_t aId,
|
||||||
uint64_t aId, const Rect& aDest, const DrawSurfaceOptions& aSurfOptions,
|
const Rect& aDest) {
|
||||||
const DrawOptions& aOptions) {
|
|
||||||
mRecorder->AddDependentSurface(aId);
|
mRecorder->AddDependentSurface(aId);
|
||||||
mRecorder->RecordEvent(
|
mRecorder->RecordEvent(RecordedDrawDependentSurface(this, aId, aDest));
|
||||||
RecordedDrawDependentSurface(this, aId, aDest, aSurfOptions, aOptions));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawTargetRecording::DrawSurfaceWithShadow(
|
void DrawTargetRecording::DrawSurfaceWithShadow(
|
||||||
|
|
|
@ -62,10 +62,7 @@ class DrawTargetRecording : public DrawTarget {
|
||||||
const DrawSurfaceOptions& aSurfOptions = DrawSurfaceOptions(),
|
const DrawSurfaceOptions& aSurfOptions = DrawSurfaceOptions(),
|
||||||
const DrawOptions& aOptions = DrawOptions()) override;
|
const DrawOptions& aOptions = DrawOptions()) override;
|
||||||
|
|
||||||
virtual void DrawDependentSurface(
|
virtual void DrawDependentSurface(uint64_t aId, const Rect& aDest) override;
|
||||||
uint64_t aId, const Rect& aDest,
|
|
||||||
const DrawSurfaceOptions& aSurfOptions = DrawSurfaceOptions(),
|
|
||||||
const DrawOptions& aOptions = DrawOptions()) override;
|
|
||||||
|
|
||||||
virtual void DrawFilter(FilterNode* aNode, const Rect& aSourceRect,
|
virtual void DrawFilter(FilterNode* aNode, const Rect& aSourceRect,
|
||||||
const Point& aDestPoint,
|
const Point& aDestPoint,
|
||||||
|
|
|
@ -493,12 +493,10 @@ void DrawTargetWrapAndRecord::DrawSurface(
|
||||||
aSurfOptions, aOptions);
|
aSurfOptions, aOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawTargetWrapAndRecord::DrawDependentSurface(
|
void DrawTargetWrapAndRecord::DrawDependentSurface(uint64_t aId,
|
||||||
uint64_t aId, const Rect& aDest, const DrawSurfaceOptions& aSurfOptions,
|
const Rect& aDest) {
|
||||||
const DrawOptions& aOptions) {
|
|
||||||
mRecorder->AddDependentSurface(aId);
|
mRecorder->AddDependentSurface(aId);
|
||||||
mRecorder->RecordEvent(
|
mRecorder->RecordEvent(RecordedDrawDependentSurface(this, aId, aDest));
|
||||||
RecordedDrawDependentSurface(this, aId, aDest, aSurfOptions, aOptions));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawTargetWrapAndRecord::DrawSurfaceWithShadow(
|
void DrawTargetWrapAndRecord::DrawSurfaceWithShadow(
|
||||||
|
|
|
@ -59,10 +59,7 @@ class DrawTargetWrapAndRecord : public DrawTarget {
|
||||||
const DrawSurfaceOptions& aSurfOptions = DrawSurfaceOptions(),
|
const DrawSurfaceOptions& aSurfOptions = DrawSurfaceOptions(),
|
||||||
const DrawOptions& aOptions = DrawOptions()) override;
|
const DrawOptions& aOptions = DrawOptions()) override;
|
||||||
|
|
||||||
virtual void DrawDependentSurface(
|
virtual void DrawDependentSurface(uint64_t aId, const Rect& aDest) override;
|
||||||
uint64_t aId, const Rect& aDest,
|
|
||||||
const DrawSurfaceOptions& aSurfOptions = DrawSurfaceOptions(),
|
|
||||||
const DrawOptions& aOptions = DrawOptions()) override;
|
|
||||||
|
|
||||||
virtual void DrawFilter(FilterNode* aNode, const Rect& aSourceRect,
|
virtual void DrawFilter(FilterNode* aNode, const Rect& aSourceRect,
|
||||||
const Point& aDestPoint,
|
const Point& aDestPoint,
|
||||||
|
|
|
@ -111,35 +111,11 @@ already_AddRefed<DrawTarget> InlineTranslator::CreateDrawTarget(
|
||||||
|
|
||||||
already_AddRefed<SourceSurface> InlineTranslator::LookupExternalSurface(
|
already_AddRefed<SourceSurface> InlineTranslator::LookupExternalSurface(
|
||||||
uint64_t aKey) {
|
uint64_t aKey) {
|
||||||
if (mExternalSurfaces) {
|
if (!mExternalSurfaces) {
|
||||||
RefPtr<SourceSurface> surface = mExternalSurfaces->Get(aKey);
|
|
||||||
if (surface) {
|
|
||||||
return surface.forget();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mDependentSurfaces) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
RefPtr<SourceSurface> surface = mExternalSurfaces->Get(aKey);
|
||||||
RefPtr<RecordedDependentSurface> recordedSurface =
|
return surface.forget();
|
||||||
mDependentSurfaces->Get(aKey);
|
|
||||||
if (!recordedSurface) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<DrawTarget> newDT = GetReferenceDrawTarget()->CreateSimilarDrawTarget(
|
|
||||||
recordedSurface->mSize, SurfaceFormat::B8G8R8A8);
|
|
||||||
|
|
||||||
InlineTranslator translator(newDT, nullptr);
|
|
||||||
translator.SetDependentSurfaces(mDependentSurfaces);
|
|
||||||
if (!translator.TranslateRecording((char*)recordedSurface->mRecording.mData,
|
|
||||||
recordedSurface->mRecording.mLen)) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<SourceSurface> snapshot = newDT->Snapshot();
|
|
||||||
return snapshot.forget();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mozilla::gfx
|
} // namespace mozilla::gfx
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "mozilla/gfx/2D.h"
|
#include "mozilla/gfx/2D.h"
|
||||||
#include "mozilla/gfx/Filters.h"
|
#include "mozilla/gfx/Filters.h"
|
||||||
#include "mozilla/gfx/RecordedEvent.h"
|
#include "mozilla/gfx/RecordedEvent.h"
|
||||||
#include "nsRefPtrHashtable.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
|
@ -40,10 +39,8 @@ class InlineTranslator : public Translator {
|
||||||
nsRefPtrHashtable<nsUint64HashKey, SourceSurface>* aExternalSurfaces) {
|
nsRefPtrHashtable<nsUint64HashKey, SourceSurface>* aExternalSurfaces) {
|
||||||
mExternalSurfaces = aExternalSurfaces;
|
mExternalSurfaces = aExternalSurfaces;
|
||||||
}
|
}
|
||||||
void SetDependentSurfaces(
|
void SetReferenceDrawTargetTransform(const Matrix& aTransform) {
|
||||||
nsRefPtrHashtable<nsUint64HashKey, RecordedDependentSurface>*
|
mBaseDTTransform = aTransform;
|
||||||
aDependentSurfaces) {
|
|
||||||
mDependentSurfaces = aDependentSurfaces;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawTarget* LookupDrawTarget(ReferencePtr aRefPtr) final {
|
DrawTarget* LookupDrawTarget(ReferencePtr aRefPtr) final {
|
||||||
|
@ -163,12 +160,14 @@ class InlineTranslator : public Translator {
|
||||||
MOZ_ASSERT(mBaseDT, "mBaseDT has not been initialized.");
|
MOZ_ASSERT(mBaseDT, "mBaseDT has not been initialized.");
|
||||||
return mBaseDT;
|
return mBaseDT;
|
||||||
}
|
}
|
||||||
|
Matrix GetReferenceDrawTargetTransform() final { return mBaseDTTransform; }
|
||||||
|
|
||||||
void* GetFontContext() final { return mFontContext; }
|
void* GetFontContext() final { return mFontContext; }
|
||||||
std::string GetError() { return mError; }
|
std::string GetError() { return mError; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RefPtr<DrawTarget> mBaseDT;
|
RefPtr<DrawTarget> mBaseDT;
|
||||||
|
Matrix mBaseDTTransform;
|
||||||
nsRefPtrHashtable<nsPtrHashKey<void>, DrawTarget> mDrawTargets;
|
nsRefPtrHashtable<nsPtrHashKey<void>, DrawTarget> mDrawTargets;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -184,8 +183,6 @@ class InlineTranslator : public Translator {
|
||||||
nsRefPtrHashtable<nsUint64HashKey, NativeFontResource> mNativeFontResources;
|
nsRefPtrHashtable<nsUint64HashKey, NativeFontResource> mNativeFontResources;
|
||||||
nsRefPtrHashtable<nsUint64HashKey, SourceSurface>* mExternalSurfaces =
|
nsRefPtrHashtable<nsUint64HashKey, SourceSurface>* mExternalSurfaces =
|
||||||
nullptr;
|
nullptr;
|
||||||
nsRefPtrHashtable<nsUint64HashKey, RecordedDependentSurface>*
|
|
||||||
mDependentSurfaces = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace gfx
|
} // namespace gfx
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "ScaledFontBase.h"
|
#include "ScaledFontBase.h"
|
||||||
#include "SFNTData.h"
|
#include "SFNTData.h"
|
||||||
|
#include "InlineTranslator.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
|
@ -170,5 +171,39 @@ already_AddRefed<DrawTarget> Translator::CreateDrawTarget(
|
||||||
return newDT.forget();
|
return newDT.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Translator::DrawDependentSurface(ReferencePtr aDrawTarget, uint64_t aKey,
|
||||||
|
const Rect& aRect) {
|
||||||
|
if (!mDependentSurfaces) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawTarget* dt = LookupDrawTarget(aDrawTarget);
|
||||||
|
if (!dt) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RefPtr<RecordedDependentSurface> recordedSurface =
|
||||||
|
mDependentSurfaces->Get(aKey);
|
||||||
|
if (!recordedSurface) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dt->PushClipRect(aRect);
|
||||||
|
|
||||||
|
// Construct a new translator, so we can recurse into translating this
|
||||||
|
// sub-recording into the same DT. Set an initial transform for the
|
||||||
|
// translator, so that all commands get moved into the rect we want to draw.
|
||||||
|
Matrix transform = dt->GetTransform();
|
||||||
|
transform.PreTranslate(aRect.TopLeft());
|
||||||
|
InlineTranslator translator(dt, nullptr);
|
||||||
|
translator.SetReferenceDrawTargetTransform(transform);
|
||||||
|
|
||||||
|
translator.SetDependentSurfaces(mDependentSurfaces);
|
||||||
|
translator.TranslateRecording((char*)recordedSurface->mRecording.mData,
|
||||||
|
recordedSurface->mRecording.mLen);
|
||||||
|
|
||||||
|
dt->PopClip();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace gfx
|
} // namespace gfx
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "mozilla/gfx/Point.h"
|
#include "mozilla/gfx/Point.h"
|
||||||
#include "mozilla/gfx/Types.h"
|
#include "mozilla/gfx/Types.h"
|
||||||
#include "mozilla/ipc/ByteBuf.h"
|
#include "mozilla/ipc/ByteBuf.h"
|
||||||
|
#include "nsRefPtrHashtable.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
|
@ -101,6 +102,8 @@ class Translator {
|
||||||
virtual already_AddRefed<SourceSurface> LookupExternalSurface(uint64_t aKey) {
|
virtual already_AddRefed<SourceSurface> LookupExternalSurface(uint64_t aKey) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
void DrawDependentSurface(ReferencePtr aDrawTarget, uint64_t aKey,
|
||||||
|
const Rect& aRect);
|
||||||
virtual void AddDrawTarget(ReferencePtr aRefPtr, DrawTarget* aDT) = 0;
|
virtual void AddDrawTarget(ReferencePtr aRefPtr, DrawTarget* aDT) = 0;
|
||||||
virtual void RemoveDrawTarget(ReferencePtr aRefPtr) = 0;
|
virtual void RemoveDrawTarget(ReferencePtr aRefPtr) = 0;
|
||||||
virtual void AddPath(ReferencePtr aRefPtr, Path* aPath) = 0;
|
virtual void AddPath(ReferencePtr aRefPtr, Path* aPath) = 0;
|
||||||
|
@ -137,7 +140,17 @@ class Translator {
|
||||||
const IntSize& aSize,
|
const IntSize& aSize,
|
||||||
SurfaceFormat aFormat);
|
SurfaceFormat aFormat);
|
||||||
virtual DrawTarget* GetReferenceDrawTarget() = 0;
|
virtual DrawTarget* GetReferenceDrawTarget() = 0;
|
||||||
|
virtual Matrix GetReferenceDrawTargetTransform() { return Matrix(); }
|
||||||
virtual void* GetFontContext() { return nullptr; }
|
virtual void* GetFontContext() { return nullptr; }
|
||||||
|
|
||||||
|
void SetDependentSurfaces(
|
||||||
|
nsRefPtrHashtable<nsUint64HashKey, RecordedDependentSurface>*
|
||||||
|
aDependentSurfaces) {
|
||||||
|
mDependentSurfaces = aDependentSurfaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsRefPtrHashtable<nsUint64HashKey, RecordedDependentSurface>*
|
||||||
|
mDependentSurfaces = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ColorPatternStorage {
|
struct ColorPatternStorage {
|
||||||
|
|
|
@ -706,14 +706,10 @@ class RecordedDrawSurface : public RecordedDrawingEvent<RecordedDrawSurface> {
|
||||||
class RecordedDrawDependentSurface
|
class RecordedDrawDependentSurface
|
||||||
: public RecordedDrawingEvent<RecordedDrawDependentSurface> {
|
: public RecordedDrawingEvent<RecordedDrawDependentSurface> {
|
||||||
public:
|
public:
|
||||||
RecordedDrawDependentSurface(DrawTarget* aDT, uint64_t aId, const Rect& aDest,
|
RecordedDrawDependentSurface(DrawTarget* aDT, uint64_t aId, const Rect& aDest)
|
||||||
const DrawSurfaceOptions& aDSOptions,
|
|
||||||
const DrawOptions& aOptions)
|
|
||||||
: RecordedDrawingEvent(DRAWDEPENDENTSURFACE, aDT),
|
: RecordedDrawingEvent(DRAWDEPENDENTSURFACE, aDT),
|
||||||
mId(aId),
|
mId(aId),
|
||||||
mDest(aDest),
|
mDest(aDest) {}
|
||||||
mDSOptions(aDSOptions),
|
|
||||||
mOptions(aOptions) {}
|
|
||||||
|
|
||||||
bool PlayEvent(Translator* aTranslator) const override;
|
bool PlayEvent(Translator* aTranslator) const override;
|
||||||
|
|
||||||
|
@ -731,8 +727,6 @@ class RecordedDrawDependentSurface
|
||||||
|
|
||||||
uint64_t mId;
|
uint64_t mId;
|
||||||
Rect mDest;
|
Rect mDest;
|
||||||
DrawSurfaceOptions mDSOptions;
|
|
||||||
DrawOptions mOptions;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RecordedDrawSurfaceWithShadow
|
class RecordedDrawSurfaceWithShadow
|
||||||
|
@ -2780,7 +2774,16 @@ inline bool RecordedSetTransform::PlayEvent(Translator* aTranslator) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dt->SetTransform(mTransform);
|
// If we're drawing to the reference DT, then we need to manually apply
|
||||||
|
// its initial transform, otherwise we'll just clobber it with only the
|
||||||
|
// the transform that was visible to the code doing the recording.
|
||||||
|
if (dt == aTranslator->GetReferenceDrawTarget()) {
|
||||||
|
dt->SetTransform(mTransform *
|
||||||
|
aTranslator->GetReferenceDrawTargetTransform());
|
||||||
|
} else {
|
||||||
|
dt->SetTransform(mTransform);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2846,20 +2849,7 @@ inline void RecordedDrawSurface::OutputSimpleEventInfo(
|
||||||
|
|
||||||
inline bool RecordedDrawDependentSurface::PlayEvent(
|
inline bool RecordedDrawDependentSurface::PlayEvent(
|
||||||
Translator* aTranslator) const {
|
Translator* aTranslator) const {
|
||||||
DrawTarget* dt = aTranslator->LookupDrawTarget(mDT);
|
aTranslator->DrawDependentSurface(mDT, mId, mDest);
|
||||||
if (!dt) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We still return true even if this fails, since dependent surfaces are
|
|
||||||
// used for cross-origin iframe drawing and can fail.
|
|
||||||
RefPtr<SourceSurface> surface = aTranslator->LookupExternalSurface(mId);
|
|
||||||
if (!surface) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
dt->DrawSurface(surface, mDest, Rect(Point(), Size(surface->GetSize())),
|
|
||||||
mDSOptions, mOptions);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2868,8 +2858,6 @@ void RecordedDrawDependentSurface::Record(S& aStream) const {
|
||||||
RecordedDrawingEvent::Record(aStream);
|
RecordedDrawingEvent::Record(aStream);
|
||||||
WriteElement(aStream, mId);
|
WriteElement(aStream, mId);
|
||||||
WriteElement(aStream, mDest);
|
WriteElement(aStream, mDest);
|
||||||
WriteElement(aStream, mDSOptions);
|
|
||||||
WriteElement(aStream, mOptions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class S>
|
template <class S>
|
||||||
|
@ -2877,8 +2865,6 @@ RecordedDrawDependentSurface::RecordedDrawDependentSurface(S& aStream)
|
||||||
: RecordedDrawingEvent(DRAWDEPENDENTSURFACE, aStream) {
|
: RecordedDrawingEvent(DRAWDEPENDENTSURFACE, aStream) {
|
||||||
ReadElement(aStream, mId);
|
ReadElement(aStream, mId);
|
||||||
ReadElement(aStream, mDest);
|
ReadElement(aStream, mDest);
|
||||||
ReadDrawSurfaceOptions(aStream, mDSOptions);
|
|
||||||
ReadDrawOptions(aStream, mOptions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void RecordedDrawDependentSurface::OutputSimpleEventInfo(
|
inline void RecordedDrawDependentSurface::OutputSimpleEventInfo(
|
||||||
|
|
|
@ -1372,9 +1372,19 @@ void nsDisplayRemote::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rendering the inner document will apply a scale to account for its
|
||||||
|
// app units per dev pixel ratio. We want to apply the inverse scaling
|
||||||
|
// using our app units per dev pixel ratio, so that no actual scaling
|
||||||
|
// will be applied if they match. For in-process rendering,
|
||||||
|
// nsSubDocumentFrame creates an nsDisplayZoom item if the app units
|
||||||
|
// per dev pixel ratio changes.
|
||||||
int32_t appUnitsPerDevPixel = pc->AppUnitsPerDevPixel();
|
int32_t appUnitsPerDevPixel = pc->AppUnitsPerDevPixel();
|
||||||
|
gfxFloat scale = gfxFloat(AppUnitsPerCSSPixel()) / appUnitsPerDevPixel;
|
||||||
|
gfxContextMatrixAutoSaveRestore saveMatrix(aCtx);
|
||||||
|
aCtx->Multiply(gfxMatrix::Scaling(scale, scale));
|
||||||
|
|
||||||
Rect destRect =
|
Rect destRect =
|
||||||
NSRectToSnappedRect(GetContentRect(), appUnitsPerDevPixel, *target);
|
NSRectToSnappedRect(GetContentRect(), AppUnitsPerCSSPixel(), *target);
|
||||||
target->DrawDependentSurface(mPaintData.mTabId, destRect);
|
target->DrawDependentSurface(mPaintData.mTabId, destRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,26 +82,5 @@ already_AddRefed<DrawTarget> PrintTranslator::CreateDrawTarget(
|
||||||
return drawTarget.forget();
|
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 layout
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "mozilla/gfx/2D.h"
|
#include "mozilla/gfx/2D.h"
|
||||||
#include "mozilla/gfx/Filters.h"
|
#include "mozilla/gfx/Filters.h"
|
||||||
#include "mozilla/gfx/RecordedEvent.h"
|
#include "mozilla/gfx/RecordedEvent.h"
|
||||||
#include "nsRefPtrHashtable.h"
|
|
||||||
|
|
||||||
class nsDeviceContext;
|
class nsDeviceContext;
|
||||||
|
|
||||||
|
@ -38,12 +37,6 @@ class PrintTranslator final : public Translator {
|
||||||
|
|
||||||
bool TranslateRecording(PRFileDescStream& aRecording);
|
bool TranslateRecording(PRFileDescStream& aRecording);
|
||||||
|
|
||||||
void SetDependentSurfaces(
|
|
||||||
nsRefPtrHashtable<nsUint64HashKey, RecordedDependentSurface>&&
|
|
||||||
aDependentSurfaces) {
|
|
||||||
mDependentSurfaces = std::move(aDependentSurfaces);
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawTarget* LookupDrawTarget(ReferencePtr aRefPtr) final {
|
DrawTarget* LookupDrawTarget(ReferencePtr aRefPtr) final {
|
||||||
DrawTarget* result = mDrawTargets.GetWeak(aRefPtr);
|
DrawTarget* result = mDrawTargets.GetWeak(aRefPtr);
|
||||||
MOZ_ASSERT(result);
|
MOZ_ASSERT(result);
|
||||||
|
@ -91,8 +84,6 @@ class PrintTranslator final : public Translator {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<SourceSurface> LookupExternalSurface(uint64_t aKey) final;
|
|
||||||
|
|
||||||
void AddDrawTarget(ReferencePtr aRefPtr, DrawTarget* aDT) final {
|
void AddDrawTarget(ReferencePtr aRefPtr, DrawTarget* aDT) final {
|
||||||
mDrawTargets.InsertOrUpdate(aRefPtr, RefPtr{aDT});
|
mDrawTargets.InsertOrUpdate(aRefPtr, RefPtr{aDT});
|
||||||
}
|
}
|
||||||
|
@ -171,8 +162,6 @@ class PrintTranslator final : public Translator {
|
||||||
nsRefPtrHashtable<nsPtrHashKey<void>, ScaledFont> mScaledFonts;
|
nsRefPtrHashtable<nsPtrHashKey<void>, ScaledFont> mScaledFonts;
|
||||||
nsRefPtrHashtable<nsPtrHashKey<void>, UnscaledFont> mUnscaledFonts;
|
nsRefPtrHashtable<nsPtrHashKey<void>, UnscaledFont> mUnscaledFonts;
|
||||||
nsRefPtrHashtable<nsUint64HashKey, NativeFontResource> mNativeFontResources;
|
nsRefPtrHashtable<nsUint64HashKey, NativeFontResource> mNativeFontResources;
|
||||||
nsRefPtrHashtable<nsUint64HashKey, RecordedDependentSurface>
|
|
||||||
mDependentSurfaces;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace layout
|
} // namespace layout
|
||||||
|
|
|
@ -162,11 +162,13 @@ nsresult RemotePrintJobParent::PrintPage(
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
if (aFragments) {
|
if (aFragments) {
|
||||||
mPrintTranslator->SetDependentSurfaces(std::move(*aFragments));
|
mPrintTranslator->SetDependentSurfaces(aFragments);
|
||||||
}
|
}
|
||||||
if (!mPrintTranslator->TranslateRecording(aRecording)) {
|
if (!mPrintTranslator->TranslateRecording(aRecording)) {
|
||||||
|
mPrintTranslator->SetDependentSurfaces(nullptr);
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
mPrintTranslator->SetDependentSurfaces(nullptr);
|
||||||
|
|
||||||
rv = mPrintDeviceContext->EndPage();
|
rv = mPrintDeviceContext->EndPage();
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
[iframe-cross-origin-scaled-print.sub.html]
|
||||||
|
expected:
|
||||||
|
if fission and (os == "linux"): FAIL
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!doctype html>
|
||||||
|
<link rel=match href="iframe-nested-scaled-print-ref.html">
|
||||||
|
<style>
|
||||||
|
body { margin: 0 }
|
||||||
|
div {
|
||||||
|
transform-origin: top left;
|
||||||
|
transform: scale(2);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
iframe {
|
||||||
|
width: 100px;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div>
|
||||||
|
<iframe frameborder=0 scrolling=no src="//{{hosts[alt][www]}}:{{ports[http][0]}}{{location[path]}}/../resources/iframe-nested-printing-pass.html"></iframe>
|
||||||
|
</div>
|
|
@ -0,0 +1,15 @@
|
||||||
|
<!doctype html>
|
||||||
|
<style>
|
||||||
|
body { margin: 0 }
|
||||||
|
div {
|
||||||
|
transform-origin: top left;
|
||||||
|
transform: scale(2);
|
||||||
|
}
|
||||||
|
iframe {
|
||||||
|
width: 100px;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div>
|
||||||
|
<iframe frameborder=0 scrolling=no src="resources/iframe-nested-printing-pass.html"></iframe>
|
||||||
|
</div>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<!doctype html>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: calc(0.5px * 2 / 3);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
PASS
|
||||||
|
</body>
|
Загрузка…
Ссылка в новой задаче