Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkRSXform.h
Go to the documentation of this file.
1/*
2 * Copyright 2015 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 SkRSXform_DEFINED
9#define SkRSXform_DEFINED
10
13#include "include/core/SkSize.h"
15
16/**
17 * A compressed form of a rotation+scale matrix.
18 *
19 * [ fSCos -fSSin fTx ]
20 * [ fSSin fSCos fTy ]
21 * [ 0 0 1 ]
22 */
24 static SkRSXform Make(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty) {
25 SkRSXform xform = { scos, ssin, tx, ty };
26 return xform;
27 }
28
29 /*
30 * Initialize a new xform based on the scale, rotation (in radians), final tx,ty location
31 * and anchor-point ax,ay within the src quad.
32 *
33 * Note: the anchor point is not normalized (e.g. 0...1) but is in pixels of the src image.
34 */
36 SkScalar ax, SkScalar ay) {
37 const SkScalar s = SkScalarSin(radians) * scale;
38 const SkScalar c = SkScalarCos(radians) * scale;
39 return Make(c, s, tx + -c * ax + s * ay, ty + -s * ax - c * ay);
40 }
41
46
47 bool rectStaysRect() const {
48 return 0 == fSCos || 0 == fSSin;
49 }
50
51 void setIdentity() {
52 fSCos = 1;
53 fSSin = fTx = fTy = 0;
54 }
55
56 void set(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty) {
57 fSCos = scos;
58 fSSin = ssin;
59 fTx = tx;
60 fTy = ty;
61 }
62
63 void toQuad(SkScalar width, SkScalar height, SkPoint quad[4]) const;
64 void toQuad(const SkSize& size, SkPoint quad[4]) const {
65 this->toQuad(size.width(), size.height(), quad);
66 }
67 void toTriStrip(SkScalar width, SkScalar height, SkPoint strip[4]) const;
68};
69
70#endif
71
#define SK_API
Definition SkAPI.h:35
static std::unique_ptr< SkEncoder > Make(SkWStream *dst, const SkPixmap *src, const SkYUVAPixmaps *srcYUVA, const SkColorSpace *srcYUVAColorSpace, const SkJpegEncoder::Options &options)
#define SkScalarSin(radians)
Definition SkScalar.h:45
#define SkScalarCos(radians)
Definition SkScalar.h:46
float SkScalar
Definition extension.cpp:12
struct MyStruct s
int32_t height
int32_t width
const Scalar scale
void setIdentity()
Definition SkRSXform.h:51
SkScalar fTy
Definition SkRSXform.h:45
SkScalar fSCos
Definition SkRSXform.h:42
void set(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty)
Definition SkRSXform.h:56
static SkRSXform Make(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty)
Definition SkRSXform.h:24
bool rectStaysRect() const
Definition SkRSXform.h:47
static SkRSXform MakeFromRadians(SkScalar scale, SkScalar radians, SkScalar tx, SkScalar ty, SkScalar ax, SkScalar ay)
Definition SkRSXform.h:35
void toQuad(const SkSize &size, SkPoint quad[4]) const
Definition SkRSXform.h:64
SkScalar fTx
Definition SkRSXform.h:44
SkScalar fSSin
Definition SkRSXform.h:43