mirror of
https://github.com/roytam1/UXP.git
synced 2026-05-26 13:58:49 +00:00
Issue #2483 - Support DOMMatrix2DInit for addPath
This commit is contained in:
@@ -16,7 +16,7 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
enum class CanvasWindingRule : uint32_t;
|
||||
class SVGMatrix;
|
||||
struct DOMMatrix2DInit;
|
||||
|
||||
class CanvasPath final :
|
||||
public nsWrapperCache
|
||||
@@ -69,8 +69,8 @@ public:
|
||||
CanvasPath(nsISupports* aParent,
|
||||
already_AddRefed<gfx::PathBuilder> aPathBuilder);
|
||||
|
||||
void AddPath(CanvasPath& aCanvasPath,
|
||||
const Optional<NonNull<SVGMatrix>>& aMatrix);
|
||||
void AddPath(CanvasPath& aCanvasPath, const DOMMatrix2DInit& aInit,
|
||||
ErrorResult& aError);
|
||||
|
||||
private:
|
||||
virtual ~CanvasPath() {}
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/DOMMatrix.h"
|
||||
#include "mozilla/dom/ImageBitmap.h"
|
||||
#include "mozilla/dom/ImageData.h"
|
||||
#include "mozilla/dom/PBrowserParent.h"
|
||||
@@ -6579,19 +6580,28 @@ CanvasPath::BezierTo(const gfx::Point& aCP1,
|
||||
}
|
||||
|
||||
void
|
||||
CanvasPath::AddPath(CanvasPath& aCanvasPath, const Optional<NonNull<SVGMatrix>>& aMatrix)
|
||||
CanvasPath::AddPath(CanvasPath& aCanvasPath, const DOMMatrix2DInit& aInit,
|
||||
ErrorResult& aError)
|
||||
|
||||
{
|
||||
RefPtr<gfx::Path> tempPath = aCanvasPath.GetPath(CanvasWindingRule::Nonzero,
|
||||
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
|
||||
|
||||
if (aMatrix.WasPassed()) {
|
||||
const SVGMatrix& m = aMatrix.Value();
|
||||
Matrix transform(m.A(), m.B(), m.C(), m.D(), m.E(), m.F());
|
||||
RefPtr<DOMMatrixReadOnly> matrix =
|
||||
DOMMatrixReadOnly::FromMatrix(GetParentObject(), aInit, aError);
|
||||
if (aError.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!transform.IsIdentity()) {
|
||||
RefPtr<PathBuilder> tempBuilder = tempPath->TransformedCopyToBuilder(transform, FillRule::FILL_WINDING);
|
||||
tempPath = tempBuilder->Finish();
|
||||
}
|
||||
Matrix transform(*(matrix->GetInternal2D()));
|
||||
|
||||
if (!transform.IsFinite()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!transform.IsIdentity()) {
|
||||
RefPtr<PathBuilder> tempBuilder = tempPath->TransformedCopyToBuilder(transform, FillRule::FILL_WINDING);
|
||||
tempPath = tempBuilder->Finish();
|
||||
}
|
||||
|
||||
EnsurePathBuilder(); // in case a path is added to itself
|
||||
|
||||
@@ -335,6 +335,6 @@ interface TextMetrics {
|
||||
Constructor(DOMString pathString)]
|
||||
interface Path2D
|
||||
{
|
||||
void addPath(Path2D path, optional SVGMatrix transformation);
|
||||
[Throws] void addPath(Path2D path, optional DOMMatrix2DInit transformation);
|
||||
};
|
||||
Path2D implements CanvasPathMethods;
|
||||
|
||||
Reference in New Issue
Block a user