mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 16:58:38 +09:00
Issue #1810 - Implement {get|set}Transform with DOMMatrix arguments.
We already had part of the plumbing for other canvas manipulations, so this is somewhat simplified. This excludes the interface as that is breaking the build at this stage. Some more research is required.
This commit is contained in:
parent
5bd7896c05
commit
71bd54891a
4 changed files with 46 additions and 8 deletions
|
|
@ -129,17 +129,12 @@ DOMMatrixReadOnly::SetDataFromMatrix2DInit(const DOMMatrix2DInit& aMatrixInit) {
|
|||
}
|
||||
|
||||
void
|
||||
DOMMatrixReadOnly::SetDataFromMatrixInit(DOMMatrixInit& aMatrixInit)
|
||||
DOMMatrixReadOnly::SetDataFromMatrixInit(const DOMMatrixInit& aMatrixInit)
|
||||
{
|
||||
const bool is2D = aMatrixInit.mIs2D.Value();
|
||||
MOZ_ASSERT(is2D == Is2D());
|
||||
if (is2D) {
|
||||
mMatrix2D->_11 = aMatrixInit.mM11.Value();
|
||||
mMatrix2D->_12 = aMatrixInit.mM12.Value();
|
||||
mMatrix2D->_21 = aMatrixInit.mM21.Value();
|
||||
mMatrix2D->_22 = aMatrixInit.mM22.Value();
|
||||
mMatrix2D->_31 = aMatrixInit.mM41.Value();
|
||||
mMatrix2D->_32 = aMatrixInit.mM42.Value();
|
||||
SetDataFromMatrix2DInit(aMatrixInit);
|
||||
} else {
|
||||
mMatrix3D->_11 = aMatrixInit.mM11.Value();
|
||||
mMatrix3D->_12 = aMatrixInit.mM12.Value();
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@ public:
|
|||
mMatrix3D = new gfx::Matrix4x4(aMatrix);
|
||||
}
|
||||
|
||||
DOMMatrixReadOnly(nsISupports* aParent, const gfx::Matrix& aMatrix)
|
||||
: mParent(aParent) {
|
||||
mMatrix2D = new gfx::Matrix(aMatrix);
|
||||
}
|
||||
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMMatrixReadOnly)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMMatrixReadOnly)
|
||||
|
||||
|
|
@ -234,7 +239,7 @@ protected:
|
|||
* The init dictionary's dimension must match the matrix one.
|
||||
*/
|
||||
void SetDataFromMatrix2DInit(const DOMMatrix2DInit& aMatrixInit);
|
||||
void SetDataFromMatrixInit(DOMMatrixInit& aMatrixInit);
|
||||
void SetDataFromMatrixInit(const DOMMatrixInit& aMatrixInit);
|
||||
|
||||
DOMMatrixReadOnly* SetMatrixValue(const nsAString& aTransformList, ErrorResult& aRv);
|
||||
void Ensure3DMatrix();
|
||||
|
|
@ -268,6 +273,10 @@ public:
|
|||
: DOMMatrixReadOnly(aParent, aMatrix)
|
||||
{}
|
||||
|
||||
DOMMatrix(nsISupports* aParent, const gfx::Matrix& aMatrix)
|
||||
: DOMMatrixReadOnly(aParent, aMatrix)
|
||||
{}
|
||||
|
||||
static already_AddRefed<DOMMatrix>
|
||||
FromMatrix(nsISupports* aParent, const DOMMatrixInit& aMatrixInit, ErrorResult& aRv);
|
||||
static already_AddRefed<DOMMatrix>
|
||||
|
|
|
|||
|
|
@ -2229,6 +2229,18 @@ CanvasRenderingContext2D::Transform(double aM11, double aM12, double aM21,
|
|||
SetTransformInternal(newMatrix);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrix>
|
||||
CanvasRenderingContext2D::GetTransform(ErrorResult& aError) {
|
||||
EnsureTarget();
|
||||
if (!IsTargetValid()) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<DOMMatrix> matrix =
|
||||
new DOMMatrix(GetParentObject(), mTarget->GetTransform());
|
||||
return matrix.forget();
|
||||
}
|
||||
|
||||
void
|
||||
CanvasRenderingContext2D::SetTransform(double aM11, double aM12,
|
||||
double aM21, double aM22,
|
||||
|
|
@ -2244,6 +2256,22 @@ CanvasRenderingContext2D::SetTransform(double aM11, double aM12,
|
|||
SetTransformInternal(Matrix(aM11, aM12, aM21, aM22, aDx, aDy));
|
||||
}
|
||||
|
||||
void
|
||||
CanvasRenderingContext2D::SetTransform(const DOMMatrix2DInit& aInit,
|
||||
ErrorResult& aError) {
|
||||
TransformWillUpdate();
|
||||
if (!IsTargetValid()) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<DOMMatrixReadOnly> matrix =
|
||||
DOMMatrixReadOnly::FromMatrix(GetParentObject(), aInit, aError);
|
||||
if (!aError.Failed()) {
|
||||
SetTransformInternal(Matrix(*(matrix->GetInternal2D())));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CanvasRenderingContext2D::SetTransformInternal(const Matrix& aTransform)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ class CanvasRenderingContext2DUserData;
|
|||
class CanvasDrawObserver;
|
||||
class CanvasShutdownObserver;
|
||||
|
||||
class DOMMatrix;
|
||||
class DOMMatrixReadOnly;
|
||||
struct DOMMatrix2DInit;
|
||||
|
||||
/**
|
||||
** CanvasRenderingContext2D
|
||||
**/
|
||||
|
|
@ -88,8 +92,10 @@ public:
|
|||
void Translate(double aX, double aY, mozilla::ErrorResult& aError);
|
||||
void Transform(double aM11, double aM12, double aM21, double aM22, double aDx,
|
||||
double aDy, mozilla::ErrorResult& aError);
|
||||
already_AddRefed<DOMMatrix> GetTransform(mozilla::ErrorResult& aError);
|
||||
void SetTransform(double aM11, double aM12, double aM21, double aM22, double aDx,
|
||||
double aDy, mozilla::ErrorResult& aError);
|
||||
void SetTransform(const DOMMatrix2DInit& aInit, mozilla::ErrorResult& aError);
|
||||
void ResetTransform(mozilla::ErrorResult& aError);
|
||||
|
||||
double GlobalAlpha()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue