1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_GEOMETRY_DOM_MATRIX_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_GEOMETRY_DOM_MATRIX_H_
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/geometry/dom_matrix_read_only.h"
#include "third_party/blink/renderer/core/typed_arrays/array_buffer_view_helpers.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
namespace blink {
class DOMMatrixInit;
class ExecutionContext;
class V8UnionStringOrUnrestrictedDoubleSequence;
class CORE_EXPORT DOMMatrix : public DOMMatrixReadOnly {
DEFINE_WRAPPERTYPEINFO();
public:
static DOMMatrix* Create();
static DOMMatrix* Create(ExecutionContext*, ExceptionState&);
static DOMMatrix* Create(
ExecutionContext* execution_context,
const V8UnionStringOrUnrestrictedDoubleSequence* init,
ExceptionState& exception_state);
// TODO(fserb): double check those two bellow are needed:
static DOMMatrix* Create(DOMMatrixReadOnly*,
ExceptionState& = ASSERT_NO_EXCEPTION);
static DOMMatrix* fromFloat32Array(NotShared<DOMFloat32Array>,
ExceptionState&);
static DOMMatrix* fromFloat64Array(NotShared<DOMFloat64Array>,
ExceptionState&);
static DOMMatrix* fromMatrix(DOMMatrixInit*, ExceptionState&);
static DOMMatrix* CreateForSerialization(base::span<const double>);
explicit DOMMatrix(const gfx::Transform&, bool is2d = true);
template <typename T>
explicit DOMMatrix(base::span<T> sequence);
void setA(double value) { setM11(value); }
void setB(double value) { setM12(value); }
void setC(double value) { setM21(value); }
void setD(double value) { setM22(value); }
void setE(double value) { setM41(value); }
void setF(double value) { setM42(value); }
void setM11(double value) { matrix_.set_rc(0, 0, value); }
void setM12(double value) { matrix_.set_rc(1, 0, value); }
void setM13(double value) {
matrix_.set_rc(2, 0, value);
SetIs2D(!value);
}
void setM14(double value) {
matrix_.set_rc(3, 0, value);
SetIs2D(!value);
}
void setM21(double value) { matrix_.set_rc(0, 1, value); }
void setM22(double value) { matrix_.set_rc(1, 1, value); }
void setM23(double value) {
matrix_.set_rc(2, 1, value);
SetIs2D(!value);
}
void setM24(double value) {
matrix_.set_rc(3, 1, value);
SetIs2D(!value);
}
void setM31(double value) {
matrix_.set_rc(0, 2, value);
SetIs2D(!value);
}
void setM32(double value) {
matrix_.set_rc(1, 2, value);
SetIs2D(!value);
}
void setM33(double value) {
matrix_.set_rc(2, 2, value);
SetIs2D(value == 1);
}
void setM34(double value) {
matrix_.set_rc(3, 2, value);
SetIs2D(!value);
}
void setM41(double value) { matrix_.set_rc(0, 3, value); }
void setM42(double value) { matrix_.set_rc(1, 3, value); }
void setM43(double value) {
matrix_.set_rc(2, 3, value);
SetIs2D(!value);
}
void setM44(double value) {
matrix_.set_rc(3, 3, value);
SetIs2D(value == 1);
}
DOMMatrix* multiplySelf(DOMMatrixInit*, ExceptionState&);
DOMMatrix* multiplySelf(const DOMMatrix& other_matrix);
DOMMatrix* preMultiplySelf(DOMMatrixInit*, ExceptionState&);
DOMMatrix* translateSelf(double tx = 0, double ty = 0, double tz = 0);
DOMMatrix* scaleSelf(double sx = 1);
DOMMatrix* scaleSelf(double sx,
double sy,
double sz = 1,
double ox = 0,
double oy = 0,
double oz = 0);
DOMMatrix* scale3dSelf(double scale = 1,
double ox = 0,
double oy = 0,
double oz = 0);
DOMMatrix* rotateSelf(double rot_x);
DOMMatrix* rotateSelf(double rot_x, double rot_y);
DOMMatrix* rotateSelf(double rot_x, double rot_y, double rot_z);
DOMMatrix* rotateFromVectorSelf(double x, double y);
DOMMatrix* rotateAxisAngleSelf(double x = 0,
double y = 0,
double z = 0,
double angle = 0);
DOMMatrix* skewXSelf(double sx = 0);
DOMMatrix* skewYSelf(double sy = 0);
DOMMatrix* perspectiveSelf(double p);
DOMMatrix* invertSelf();
DOMMatrix* setMatrixValue(const ExecutionContext*,
const String&,
ExceptionState&);
private:
void SetIs2D(bool value);
void SetNAN();
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_GEOMETRY_DOM_MATRIX_H_
|