2012-09-24 08:02:50 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "DrawTargetRecording.h"
|
|
|
|
#include "PathRecording.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "Logging.h"
|
|
|
|
#include "Tools.h"
|
2013-11-27 03:25:28 -08:00
|
|
|
#include "Filters.h"
|
2012-09-24 08:02:50 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
class SourceSurfaceRecording : public SourceSurface
|
|
|
|
{
|
|
|
|
public:
|
2014-02-24 05:23:37 -08:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceRecording)
|
2012-09-24 08:02:50 -07:00
|
|
|
SourceSurfaceRecording(SourceSurface *aFinalSurface, DrawEventRecorderPrivate *aRecorder)
|
|
|
|
: mFinalSurface(aFinalSurface), mRecorder(aRecorder)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~SourceSurfaceRecording()
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedSourceSurfaceDestruction(this));
|
|
|
|
}
|
|
|
|
|
2014-01-10 10:55:24 -08:00
|
|
|
virtual SurfaceType GetType() const { return SurfaceType::RECORDING; }
|
2012-09-24 08:02:50 -07:00
|
|
|
virtual IntSize GetSize() const { return mFinalSurface->GetSize(); }
|
|
|
|
virtual SurfaceFormat GetFormat() const { return mFinalSurface->GetFormat(); }
|
|
|
|
virtual TemporaryRef<DataSourceSurface> GetDataSurface() { return mFinalSurface->GetDataSurface(); }
|
|
|
|
|
|
|
|
RefPtr<SourceSurface> mFinalSurface;
|
|
|
|
RefPtr<DrawEventRecorderPrivate> mRecorder;
|
|
|
|
};
|
|
|
|
|
|
|
|
class GradientStopsRecording : public GradientStops
|
|
|
|
{
|
|
|
|
public:
|
2014-02-24 05:23:37 -08:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GradientStopsRecording)
|
2012-09-24 08:02:50 -07:00
|
|
|
GradientStopsRecording(GradientStops *aFinalGradientStops, DrawEventRecorderPrivate *aRecorder)
|
|
|
|
: mFinalGradientStops(aFinalGradientStops), mRecorder(aRecorder)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~GradientStopsRecording()
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedGradientStopsDestruction(this));
|
|
|
|
}
|
|
|
|
|
2014-01-10 11:06:16 -08:00
|
|
|
virtual BackendType GetBackendType() const { return BackendType::RECORDING; }
|
2012-09-24 08:02:50 -07:00
|
|
|
|
|
|
|
RefPtr<GradientStops> mFinalGradientStops;
|
|
|
|
RefPtr<DrawEventRecorderPrivate> mRecorder;
|
|
|
|
};
|
|
|
|
|
|
|
|
static SourceSurface *
|
|
|
|
GetSourceSurface(SourceSurface *aSurface)
|
|
|
|
{
|
2014-01-10 10:55:24 -08:00
|
|
|
if (aSurface->GetType() != SurfaceType::RECORDING) {
|
2012-09-24 08:02:50 -07:00
|
|
|
return aSurface;
|
|
|
|
}
|
|
|
|
|
|
|
|
return static_cast<SourceSurfaceRecording*>(aSurface)->mFinalSurface;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GradientStops *
|
|
|
|
GetGradientStops(GradientStops *aStops)
|
|
|
|
{
|
2014-01-10 11:06:16 -08:00
|
|
|
if (aStops->GetBackendType() != BackendType::RECORDING) {
|
2012-09-24 08:02:50 -07:00
|
|
|
return aStops;
|
|
|
|
}
|
|
|
|
|
|
|
|
return static_cast<GradientStopsRecording*>(aStops)->mFinalGradientStops;
|
|
|
|
}
|
|
|
|
|
2013-11-27 03:25:28 -08:00
|
|
|
class FilterNodeRecording : public FilterNode
|
|
|
|
{
|
|
|
|
public:
|
2015-03-21 09:28:04 -07:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeRecording, override)
|
2013-11-27 03:25:28 -08:00
|
|
|
using FilterNode::SetAttribute;
|
|
|
|
|
|
|
|
FilterNodeRecording(FilterNode *aFinalFilterNode, DrawEventRecorderPrivate *aRecorder)
|
|
|
|
: mFinalFilterNode(aFinalFilterNode), mRecorder(aRecorder)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~FilterNodeRecording()
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedFilterNodeDestruction(this));
|
|
|
|
}
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void SetInput(uint32_t aIndex, SourceSurface *aSurface) override
|
2013-11-27 03:25:28 -08:00
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedFilterNodeSetInput(this, aIndex, aSurface));
|
|
|
|
mFinalFilterNode->SetInput(aIndex, GetSourceSurface(aSurface));
|
|
|
|
}
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void SetInput(uint32_t aIndex, FilterNode *aFilter) override
|
2013-11-27 03:25:28 -08:00
|
|
|
{
|
|
|
|
FilterNode *finalNode = aFilter;
|
|
|
|
if (aFilter->GetBackendType() != FILTER_BACKEND_RECORDING) {
|
|
|
|
gfxWarning() << "Non recording filter node used with recording DrawTarget!";
|
|
|
|
} else {
|
|
|
|
finalNode = static_cast<FilterNodeRecording*>(aFilter)->mFinalFilterNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
mRecorder->RecordEvent(RecordedFilterNodeSetInput(this, aIndex, aFilter));
|
|
|
|
mFinalFilterNode->SetInput(aIndex, finalNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define FORWARD_SET_ATTRIBUTE(type, argtype) \
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void SetAttribute(uint32_t aIndex, type aValue) override { \
|
2013-11-27 03:25:28 -08:00
|
|
|
mRecorder->RecordEvent(RecordedFilterNodeSetAttribute(this, aIndex, aValue, RecordedFilterNodeSetAttribute::ARGTYPE_##argtype)); \
|
|
|
|
mFinalFilterNode->SetAttribute(aIndex, aValue); \
|
|
|
|
}
|
|
|
|
|
|
|
|
FORWARD_SET_ATTRIBUTE(bool, BOOL);
|
|
|
|
FORWARD_SET_ATTRIBUTE(uint32_t, UINT32);
|
|
|
|
FORWARD_SET_ATTRIBUTE(Float, FLOAT);
|
|
|
|
FORWARD_SET_ATTRIBUTE(const Size&, SIZE);
|
|
|
|
FORWARD_SET_ATTRIBUTE(const IntSize&, INTSIZE);
|
|
|
|
FORWARD_SET_ATTRIBUTE(const IntPoint&, INTPOINT);
|
|
|
|
FORWARD_SET_ATTRIBUTE(const Rect&, RECT);
|
|
|
|
FORWARD_SET_ATTRIBUTE(const IntRect&, INTRECT);
|
|
|
|
FORWARD_SET_ATTRIBUTE(const Point&, POINT);
|
|
|
|
FORWARD_SET_ATTRIBUTE(const Matrix5x4&, MATRIX5X4);
|
|
|
|
FORWARD_SET_ATTRIBUTE(const Point3D&, POINT3D);
|
|
|
|
FORWARD_SET_ATTRIBUTE(const Color&, COLOR);
|
|
|
|
|
|
|
|
#undef FORWARD_SET_ATTRIBUTE
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void SetAttribute(uint32_t aIndex, const Float* aFloat, uint32_t aSize) override {
|
2013-11-27 03:25:28 -08:00
|
|
|
mRecorder->RecordEvent(RecordedFilterNodeSetAttribute(this, aIndex, aFloat, aSize));
|
|
|
|
mFinalFilterNode->SetAttribute(aIndex, aFloat, aSize);
|
|
|
|
}
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual FilterBackend GetBackendType() override { return FILTER_BACKEND_RECORDING; }
|
2013-11-27 03:25:28 -08:00
|
|
|
|
|
|
|
RefPtr<FilterNode> mFinalFilterNode;
|
|
|
|
RefPtr<DrawEventRecorderPrivate> mRecorder;
|
|
|
|
};
|
|
|
|
|
|
|
|
static FilterNode*
|
|
|
|
GetFilterNode(FilterNode* aNode)
|
|
|
|
{
|
|
|
|
if (aNode->GetBackendType() != FILTER_BACKEND_RECORDING) {
|
|
|
|
gfxWarning() << "Non recording filter node used with recording DrawTarget!";
|
|
|
|
return aNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return static_cast<FilterNodeRecording*>(aNode)->mFinalFilterNode;
|
|
|
|
}
|
|
|
|
|
2012-09-24 08:02:50 -07:00
|
|
|
struct AdjustedPattern
|
|
|
|
{
|
2014-08-31 20:31:20 -07:00
|
|
|
explicit AdjustedPattern(const Pattern &aPattern)
|
2013-07-20 01:48:55 -07:00
|
|
|
: mPattern(nullptr)
|
2012-09-24 08:02:50 -07:00
|
|
|
{
|
|
|
|
mOrigPattern = const_cast<Pattern*>(&aPattern);
|
|
|
|
}
|
|
|
|
|
|
|
|
~AdjustedPattern() {
|
|
|
|
if (mPattern) {
|
|
|
|
mPattern->~Pattern();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
operator Pattern*()
|
|
|
|
{
|
|
|
|
switch(mOrigPattern->GetType()) {
|
2014-01-10 11:06:17 -08:00
|
|
|
case PatternType::COLOR:
|
2012-09-24 08:02:50 -07:00
|
|
|
return mOrigPattern;
|
2014-01-10 11:06:17 -08:00
|
|
|
case PatternType::SURFACE:
|
2012-09-24 08:02:50 -07:00
|
|
|
{
|
|
|
|
SurfacePattern *surfPat = static_cast<SurfacePattern*>(mOrigPattern);
|
|
|
|
mPattern =
|
|
|
|
new (mSurfPat) SurfacePattern(GetSourceSurface(surfPat->mSurface),
|
|
|
|
surfPat->mExtendMode, surfPat->mMatrix,
|
|
|
|
surfPat->mFilter);
|
|
|
|
return mPattern;
|
|
|
|
}
|
2014-01-10 11:06:17 -08:00
|
|
|
case PatternType::LINEAR_GRADIENT:
|
2012-09-24 08:02:50 -07:00
|
|
|
{
|
|
|
|
LinearGradientPattern *linGradPat = static_cast<LinearGradientPattern*>(mOrigPattern);
|
|
|
|
mPattern =
|
|
|
|
new (mLinGradPat) LinearGradientPattern(linGradPat->mBegin, linGradPat->mEnd,
|
|
|
|
GetGradientStops(linGradPat->mStops),
|
|
|
|
linGradPat->mMatrix);
|
|
|
|
return mPattern;
|
|
|
|
}
|
2014-01-10 11:06:17 -08:00
|
|
|
case PatternType::RADIAL_GRADIENT:
|
2012-09-24 08:02:50 -07:00
|
|
|
{
|
|
|
|
RadialGradientPattern *radGradPat = static_cast<RadialGradientPattern*>(mOrigPattern);
|
|
|
|
mPattern =
|
|
|
|
new (mRadGradPat) RadialGradientPattern(radGradPat->mCenter1, radGradPat->mCenter2,
|
|
|
|
radGradPat->mRadius1, radGradPat->mRadius2,
|
|
|
|
GetGradientStops(radGradPat->mStops),
|
|
|
|
radGradPat->mMatrix);
|
|
|
|
return mPattern;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return new (mColPat) ColorPattern(Color());
|
|
|
|
}
|
|
|
|
|
|
|
|
return mPattern;
|
|
|
|
}
|
|
|
|
|
|
|
|
union {
|
|
|
|
char mColPat[sizeof(ColorPattern)];
|
|
|
|
char mLinGradPat[sizeof(LinearGradientPattern)];
|
|
|
|
char mRadGradPat[sizeof(RadialGradientPattern)];
|
|
|
|
char mSurfPat[sizeof(SurfacePattern)];
|
|
|
|
};
|
|
|
|
|
|
|
|
Pattern *mOrigPattern;
|
|
|
|
Pattern *mPattern;
|
|
|
|
};
|
|
|
|
|
2013-11-27 03:21:57 -08:00
|
|
|
DrawTargetRecording::DrawTargetRecording(DrawEventRecorder *aRecorder, DrawTarget *aDT, bool aHasData)
|
2012-09-24 08:02:50 -07:00
|
|
|
: mRecorder(static_cast<DrawEventRecorderPrivate*>(aRecorder))
|
|
|
|
, mFinalDT(aDT)
|
|
|
|
{
|
2013-11-27 03:21:57 -08:00
|
|
|
RefPtr<SourceSurface> snapshot = aHasData ? mFinalDT->Snapshot() : nullptr;
|
2014-06-19 13:35:33 -07:00
|
|
|
mRecorder->RecordEvent(RecordedDrawTargetCreation(this,
|
|
|
|
mFinalDT->GetBackendType(),
|
|
|
|
mFinalDT->GetSize(),
|
|
|
|
mFinalDT->GetFormat(),
|
2013-11-27 03:21:57 -08:00
|
|
|
aHasData, snapshot));
|
2012-09-24 08:02:50 -07:00
|
|
|
mFormat = mFinalDT->GetFormat();
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawTargetRecording::~DrawTargetRecording()
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedDrawTargetDestruction(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetRecording::FillRect(const Rect &aRect,
|
|
|
|
const Pattern &aPattern,
|
|
|
|
const DrawOptions &aOptions)
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedFillRect(this, aRect, aPattern, aOptions));
|
|
|
|
mFinalDT->FillRect(aRect, *AdjustedPattern(aPattern), aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetRecording::StrokeRect(const Rect &aRect,
|
|
|
|
const Pattern &aPattern,
|
|
|
|
const StrokeOptions &aStrokeOptions,
|
|
|
|
const DrawOptions &aOptions)
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedStrokeRect(this, aRect, aPattern, aStrokeOptions, aOptions));
|
|
|
|
mFinalDT->StrokeRect(aRect, *AdjustedPattern(aPattern), aStrokeOptions, aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetRecording::StrokeLine(const Point &aBegin,
|
|
|
|
const Point &aEnd,
|
|
|
|
const Pattern &aPattern,
|
|
|
|
const StrokeOptions &aStrokeOptions,
|
|
|
|
const DrawOptions &aOptions)
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedStrokeLine(this, aBegin, aEnd, aPattern, aStrokeOptions, aOptions));
|
|
|
|
mFinalDT->StrokeLine(aBegin, aEnd, *AdjustedPattern(aPattern), aStrokeOptions, aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
Path*
|
|
|
|
DrawTargetRecording::GetPathForPathRecording(const Path *aPath) const
|
|
|
|
{
|
2014-01-10 11:06:16 -08:00
|
|
|
if (aPath->GetBackendType() != BackendType::RECORDING) {
|
2013-07-20 01:48:55 -07:00
|
|
|
return nullptr;
|
2012-09-24 08:02:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return static_cast<const PathRecording*>(aPath)->mPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetRecording::Fill(const Path *aPath,
|
|
|
|
const Pattern &aPattern,
|
|
|
|
const DrawOptions &aOptions)
|
|
|
|
{
|
|
|
|
EnsureStored(aPath);
|
|
|
|
|
|
|
|
mRecorder->RecordEvent(RecordedFill(this, const_cast<Path*>(aPath), aPattern, aOptions));
|
|
|
|
mFinalDT->Fill(GetPathForPathRecording(aPath), *AdjustedPattern(aPattern), aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct RecordingFontUserData
|
|
|
|
{
|
|
|
|
void *refPtr;
|
|
|
|
RefPtr<DrawEventRecorderPrivate> recorder;
|
|
|
|
};
|
|
|
|
|
|
|
|
void RecordingFontUserDataDestroyFunc(void *aUserData)
|
|
|
|
{
|
|
|
|
RecordingFontUserData *userData =
|
|
|
|
static_cast<RecordingFontUserData*>(aUserData);
|
|
|
|
|
2014-02-12 23:27:40 -08:00
|
|
|
// TODO support font in b2g recordings
|
|
|
|
#ifndef MOZ_WIDGET_GONK
|
2012-09-24 08:02:50 -07:00
|
|
|
userData->recorder->RecordEvent(RecordedScaledFontDestruction(userData->refPtr));
|
2014-02-12 23:27:40 -08:00
|
|
|
#endif
|
2012-09-24 08:02:50 -07:00
|
|
|
|
|
|
|
delete userData;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetRecording::FillGlyphs(ScaledFont *aFont,
|
|
|
|
const GlyphBuffer &aBuffer,
|
|
|
|
const Pattern &aPattern,
|
|
|
|
const DrawOptions &aOptions,
|
|
|
|
const GlyphRenderingOptions *aRenderingOptions)
|
|
|
|
{
|
|
|
|
if (!aFont->GetUserData(reinterpret_cast<UserDataKey*>(mRecorder.get()))) {
|
2014-02-12 23:27:40 -08:00
|
|
|
// TODO support font in b2g recordings
|
|
|
|
#ifndef MOZ_WIDGET_GONK
|
2012-09-24 08:02:50 -07:00
|
|
|
mRecorder->RecordEvent(RecordedScaledFontCreation(aFont, aFont));
|
2014-02-12 23:27:40 -08:00
|
|
|
#endif
|
2012-09-24 08:02:50 -07:00
|
|
|
RecordingFontUserData *userData = new RecordingFontUserData;
|
|
|
|
userData->refPtr = aFont;
|
|
|
|
userData->recorder = mRecorder;
|
|
|
|
aFont->AddUserData(reinterpret_cast<UserDataKey*>(mRecorder.get()), userData,
|
|
|
|
&RecordingFontUserDataDestroyFunc);
|
|
|
|
}
|
|
|
|
|
2014-02-12 23:27:40 -08:00
|
|
|
// TODO support font in b2g recordings
|
|
|
|
#ifndef MOZ_WIDGET_GONK
|
2012-09-24 08:02:50 -07:00
|
|
|
mRecorder->RecordEvent(RecordedFillGlyphs(this, aFont, aPattern, aOptions, aBuffer.mGlyphs, aBuffer.mNumGlyphs));
|
2014-02-12 23:27:40 -08:00
|
|
|
#endif
|
2012-09-24 08:02:50 -07:00
|
|
|
mFinalDT->FillGlyphs(aFont, aBuffer, aPattern, aOptions, aRenderingOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetRecording::Mask(const Pattern &aSource,
|
|
|
|
const Pattern &aMask,
|
|
|
|
const DrawOptions &aOptions)
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedMask(this, aSource, aMask, aOptions));
|
|
|
|
mFinalDT->Mask(*AdjustedPattern(aSource), *AdjustedPattern(aMask), aOptions);
|
|
|
|
}
|
|
|
|
|
2013-06-27 13:20:30 -07:00
|
|
|
void
|
|
|
|
DrawTargetRecording::MaskSurface(const Pattern &aSource,
|
|
|
|
SourceSurface *aMask,
|
|
|
|
Point aOffset,
|
|
|
|
const DrawOptions &aOptions)
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedMaskSurface(this, aSource, aMask, aOffset, aOptions));
|
|
|
|
mFinalDT->MaskSurface(*AdjustedPattern(aSource), GetSourceSurface(aMask), aOffset, aOptions);
|
|
|
|
}
|
|
|
|
|
2012-09-24 08:02:50 -07:00
|
|
|
void
|
|
|
|
DrawTargetRecording::Stroke(const Path *aPath,
|
|
|
|
const Pattern &aPattern,
|
|
|
|
const StrokeOptions &aStrokeOptions,
|
|
|
|
const DrawOptions &aOptions)
|
|
|
|
{
|
|
|
|
EnsureStored(aPath);
|
|
|
|
|
|
|
|
mRecorder->RecordEvent(RecordedStroke(this, const_cast<Path*>(aPath), aPattern, aStrokeOptions, aOptions));
|
|
|
|
mFinalDT->Stroke(GetPathForPathRecording(aPath), *AdjustedPattern(aPattern), aStrokeOptions, aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<SourceSurface>
|
|
|
|
DrawTargetRecording::Snapshot()
|
|
|
|
{
|
|
|
|
RefPtr<SourceSurface> surf = mFinalDT->Snapshot();
|
|
|
|
|
|
|
|
RefPtr<SourceSurface> retSurf = new SourceSurfaceRecording(surf, mRecorder);
|
|
|
|
|
|
|
|
mRecorder->RecordEvent(RecordedSnapshot(retSurf, this));
|
|
|
|
|
2014-06-13 09:09:23 -07:00
|
|
|
return retSurf.forget();
|
2012-09-24 08:02:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetRecording::DrawSurface(SourceSurface *aSurface,
|
|
|
|
const Rect &aDest,
|
|
|
|
const Rect &aSource,
|
|
|
|
const DrawSurfaceOptions &aSurfOptions,
|
|
|
|
const DrawOptions &aOptions)
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedDrawSurface(this, aSurface, aDest, aSource, aSurfOptions, aOptions));
|
|
|
|
mFinalDT->DrawSurface(GetSourceSurface(aSurface), aDest, aSource, aSurfOptions, aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetRecording::DrawSurfaceWithShadow(SourceSurface *aSurface,
|
|
|
|
const Point &aDest,
|
|
|
|
const Color &aColor,
|
|
|
|
const Point &aOffset,
|
|
|
|
Float aSigma,
|
|
|
|
CompositionOp aOp)
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedDrawSurfaceWithShadow(this, aSurface, aDest, aColor, aOffset, aSigma, aOp));
|
|
|
|
mFinalDT->DrawSurfaceWithShadow(GetSourceSurface(aSurface), aDest, aColor, aOffset, aSigma, aOp);
|
|
|
|
}
|
|
|
|
|
2013-11-27 03:25:28 -08:00
|
|
|
void
|
|
|
|
DrawTargetRecording::DrawFilter(FilterNode *aNode,
|
|
|
|
const Rect &aSourceRect,
|
|
|
|
const Point &aDestPoint,
|
|
|
|
const DrawOptions &aOptions)
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedDrawFilter(this, aNode, aSourceRect, aDestPoint, aOptions));
|
|
|
|
mFinalDT->DrawFilter(GetFilterNode(aNode), aSourceRect, aDestPoint, aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<FilterNode>
|
|
|
|
DrawTargetRecording::CreateFilter(FilterType aType)
|
|
|
|
{
|
|
|
|
RefPtr<FilterNode> node = mFinalDT->CreateFilter(aType);
|
|
|
|
|
|
|
|
RefPtr<FilterNode> retNode = new FilterNodeRecording(node, mRecorder);
|
|
|
|
|
|
|
|
mRecorder->RecordEvent(RecordedFilterNodeCreation(retNode, aType));
|
|
|
|
|
2014-06-13 09:09:23 -07:00
|
|
|
return retNode.forget();
|
2013-11-27 03:25:28 -08:00
|
|
|
}
|
|
|
|
|
2012-09-24 08:02:50 -07:00
|
|
|
void
|
|
|
|
DrawTargetRecording::ClearRect(const Rect &aRect)
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedClearRect(this, aRect));
|
|
|
|
mFinalDT->ClearRect(aRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetRecording::CopySurface(SourceSurface *aSurface,
|
|
|
|
const IntRect &aSourceRect,
|
|
|
|
const IntPoint &aDestination)
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedCopySurface(this, aSurface, aSourceRect, aDestination));
|
|
|
|
mFinalDT->CopySurface(GetSourceSurface(aSurface), aSourceRect, aDestination);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetRecording::PushClip(const Path *aPath)
|
|
|
|
{
|
|
|
|
EnsureStored(aPath);
|
|
|
|
|
|
|
|
mRecorder->RecordEvent(RecordedPushClip(this, const_cast<Path*>(aPath)));
|
|
|
|
mFinalDT->PushClip(GetPathForPathRecording(aPath));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetRecording::PushClipRect(const Rect &aRect)
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedPushClipRect(this, aRect));
|
|
|
|
mFinalDT->PushClipRect(aRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetRecording::PopClip()
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedPopClip(this));
|
|
|
|
mFinalDT->PopClip();
|
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<SourceSurface>
|
|
|
|
DrawTargetRecording::CreateSourceSurfaceFromData(unsigned char *aData,
|
|
|
|
const IntSize &aSize,
|
|
|
|
int32_t aStride,
|
|
|
|
SurfaceFormat aFormat) const
|
|
|
|
{
|
|
|
|
RefPtr<SourceSurface> surf = mFinalDT->CreateSourceSurfaceFromData(aData, aSize, aStride, aFormat);
|
|
|
|
|
|
|
|
RefPtr<SourceSurface> retSurf = new SourceSurfaceRecording(surf, mRecorder);
|
|
|
|
|
|
|
|
mRecorder->RecordEvent(RecordedSourceSurfaceCreation(retSurf, aData, aStride, aSize, aFormat));
|
|
|
|
|
2014-06-13 09:09:23 -07:00
|
|
|
return retSurf.forget();
|
2012-09-24 08:02:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<SourceSurface>
|
|
|
|
DrawTargetRecording::OptimizeSourceSurface(SourceSurface *aSurface) const
|
|
|
|
{
|
|
|
|
RefPtr<SourceSurface> surf = mFinalDT->OptimizeSourceSurface(aSurface);
|
|
|
|
|
|
|
|
RefPtr<SourceSurface> retSurf = new SourceSurfaceRecording(surf, mRecorder);
|
|
|
|
|
|
|
|
RefPtr<DataSourceSurface> dataSurf = surf->GetDataSurface();
|
|
|
|
|
|
|
|
if (!dataSurf) {
|
|
|
|
// Let's try get it off the original surface.
|
|
|
|
dataSurf = aSurface->GetDataSurface();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dataSurf) {
|
|
|
|
gfxWarning() << "Recording failed to record SourceSurface created from OptimizeSourceSurface";
|
|
|
|
// Insert a bogus source surface.
|
|
|
|
uint8_t *sourceData = new uint8_t[surf->GetSize().width * surf->GetSize().height * BytesPerPixel(surf->GetFormat())];
|
|
|
|
memset(sourceData, 0, surf->GetSize().width * surf->GetSize().height * BytesPerPixel(surf->GetFormat()));
|
|
|
|
mRecorder->RecordEvent(
|
|
|
|
RecordedSourceSurfaceCreation(retSurf, sourceData,
|
|
|
|
surf->GetSize().width * BytesPerPixel(surf->GetFormat()),
|
|
|
|
surf->GetSize(), surf->GetFormat()));
|
|
|
|
delete [] sourceData;
|
|
|
|
} else {
|
|
|
|
mRecorder->RecordEvent(
|
|
|
|
RecordedSourceSurfaceCreation(retSurf, dataSurf->GetData(), dataSurf->Stride(),
|
|
|
|
dataSurf->GetSize(), dataSurf->GetFormat()));
|
|
|
|
}
|
|
|
|
|
2014-06-13 09:09:23 -07:00
|
|
|
return retSurf.forget();
|
2012-09-24 08:02:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<SourceSurface>
|
|
|
|
DrawTargetRecording::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
|
|
|
|
{
|
|
|
|
RefPtr<SourceSurface> surf = mFinalDT->CreateSourceSurfaceFromNativeSurface(aSurface);
|
|
|
|
|
|
|
|
RefPtr<SourceSurface> retSurf = new SourceSurfaceRecording(surf, mRecorder);
|
|
|
|
|
|
|
|
RefPtr<DataSourceSurface> dataSurf = surf->GetDataSurface();
|
|
|
|
|
|
|
|
if (!dataSurf) {
|
|
|
|
gfxWarning() << "Recording failed to record SourceSurface created from OptimizeSourceSurface";
|
|
|
|
// Insert a bogus source surface.
|
|
|
|
uint8_t *sourceData = new uint8_t[surf->GetSize().width * surf->GetSize().height * BytesPerPixel(surf->GetFormat())];
|
|
|
|
memset(sourceData, 0, surf->GetSize().width * surf->GetSize().height * BytesPerPixel(surf->GetFormat()));
|
|
|
|
mRecorder->RecordEvent(
|
|
|
|
RecordedSourceSurfaceCreation(retSurf, sourceData,
|
|
|
|
surf->GetSize().width * BytesPerPixel(surf->GetFormat()),
|
|
|
|
surf->GetSize(), surf->GetFormat()));
|
|
|
|
delete [] sourceData;
|
|
|
|
} else {
|
|
|
|
mRecorder->RecordEvent(
|
|
|
|
RecordedSourceSurfaceCreation(retSurf, dataSurf->GetData(), dataSurf->Stride(),
|
|
|
|
dataSurf->GetSize(), dataSurf->GetFormat()));
|
|
|
|
}
|
|
|
|
|
2014-06-13 09:09:23 -07:00
|
|
|
return retSurf.forget();
|
2012-09-24 08:02:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<DrawTarget>
|
|
|
|
DrawTargetRecording::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
|
|
|
|
{
|
|
|
|
RefPtr<DrawTarget> dt = mFinalDT->CreateSimilarDrawTarget(aSize, aFormat);
|
2014-06-13 09:09:23 -07:00
|
|
|
return new DrawTargetRecording(mRecorder.get(), dt);
|
2012-09-24 08:02:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<PathBuilder>
|
|
|
|
DrawTargetRecording::CreatePathBuilder(FillRule aFillRule) const
|
|
|
|
{
|
|
|
|
RefPtr<PathBuilder> builder = mFinalDT->CreatePathBuilder(aFillRule);
|
|
|
|
return new PathBuilderRecording(builder, aFillRule);
|
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<GradientStops>
|
|
|
|
DrawTargetRecording::CreateGradientStops(GradientStop *aStops,
|
|
|
|
uint32_t aNumStops,
|
|
|
|
ExtendMode aExtendMode) const
|
|
|
|
{
|
|
|
|
RefPtr<GradientStops> stops = mFinalDT->CreateGradientStops(aStops, aNumStops, aExtendMode);
|
|
|
|
|
|
|
|
RefPtr<GradientStops> retStops = new GradientStopsRecording(stops, mRecorder);
|
|
|
|
|
|
|
|
mRecorder->RecordEvent(RecordedGradientStopsCreation(retStops, aStops, aNumStops, aExtendMode));
|
|
|
|
|
2014-06-13 09:09:23 -07:00
|
|
|
return retStops.forget();
|
2012-09-24 08:02:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetRecording::SetTransform(const Matrix &aTransform)
|
|
|
|
{
|
|
|
|
mRecorder->RecordEvent(RecordedSetTransform(this, aTransform));
|
|
|
|
DrawTarget::SetTransform(aTransform);
|
|
|
|
mFinalDT->SetTransform(aTransform);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetRecording::EnsureStored(const Path *aPath)
|
|
|
|
{
|
|
|
|
if (!mRecorder->HasStoredPath(aPath)) {
|
2014-01-10 11:06:16 -08:00
|
|
|
if (aPath->GetBackendType() != BackendType::RECORDING) {
|
2012-09-24 08:02:50 -07:00
|
|
|
gfxWarning() << "Cannot record this fill path properly!";
|
|
|
|
} else {
|
|
|
|
PathRecording *recPath = const_cast<PathRecording*>(static_cast<const PathRecording*>(aPath));
|
|
|
|
mRecorder->RecordEvent(RecordedPathCreation(recPath));
|
|
|
|
mRecorder->AddStoredPath(aPath);
|
|
|
|
recPath->mStoredRecorders.push_back(mRecorder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|