1/*
2 * Copyright 2020 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkCanvasMatrix_DEFINED
9#define SkCanvasMatrix_DEFINED
10
11#include "include/core/SkM44.h"
12#include "include/core/SkMatrix.h"
13
14class SkCanvasMatrix : public SkM44 {
15public:
16 SkCanvasMatrix& operator=(const SkMatrix& other) {
17 this->SkM44::operator=(other);
18 return *this;
19 }
20
21 void reset() { this->setIdentity(); }
22
23 operator SkMatrix() const { return this->asM33(); }
24 // the legacy check was just for the 3x3 portion, so we only check those
25 bool isScaleTranslate() const {
26 return this->rc(1,0) == 0 && this->rc(3,0) == 0 &&
27 this->rc(0,1) == 0 && this->rc(3,1) == 0 &&
28 this->rc(3,3) == 1;
29 }
30 bool rectStaysRect() const { return this->asM33().rectStaysRect(); }
31
32 float getScaleX() const { return this->rc(0,0); }
33 float getScaleY() const { return this->rc(1,1); }
34 float getTranslateX() const { return this->rc(0,3); }
35 float getTranslateY() const { return this->rc(1,3); }
36
37 bool mapRect(SkRect* dst, const SkRect& src) { return this->asM33().mapRect(dst, src); }
38};
39
40#endif
41