blob: 85abb38f7e9563ad846626d81fd72dd6d037cd62 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Mathias Agopianeda65402010-02-22 03:15:57 -080017#include <math.h>
18
Lloyd Pique32cbe282018-10-19 13:09:22 -070019#include <android-base/stringprintf.h>
Mathias Agopianeda65402010-02-22 03:15:57 -080020#include <cutils/compiler.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080021#include <ui/Region.h>
Peiyong Linefefaac2018-08-17 12:27:51 -070022#include <ui/Transform.h>
23#include <utils/String8.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080024
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080025namespace android {
Peiyong Linefefaac2018-08-17 12:27:51 -070026namespace ui {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080027
Mathias Agopianeda65402010-02-22 03:15:57 -080028Transform::Transform() {
29 reset();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080030}
31
32Transform::Transform(const Transform& other)
Mathias Agopianeda65402010-02-22 03:15:57 -080033 : mMatrix(other.mMatrix), mType(other.mType) {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080034}
35
Lloyd Piqueb62cebc2019-11-20 18:31:52 -080036Transform::Transform(uint32_t orientation, int w, int h) {
37 set(orientation, w, h);
Chih-Chung Chang52e72002010-01-21 17:31:06 -080038}
39
Peiyong Linefefaac2018-08-17 12:27:51 -070040Transform::~Transform() = default;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080041
Mathias Agopiand1296592010-03-09 19:17:47 -080042static const float EPSILON = 0.0f;
Mathias Agopianeda65402010-02-22 03:15:57 -080043
44bool Transform::isZero(float f) {
Mathias Agopiand1296592010-03-09 19:17:47 -080045 return fabs(f) <= EPSILON;
Mathias Agopianeda65402010-02-22 03:15:57 -080046}
47
Mathias Agopiand1296592010-03-09 19:17:47 -080048bool Transform::absIsOne(float f) {
49 return isZero(fabs(f) - 1.0f);
Mathias Agopianeda65402010-02-22 03:15:57 -080050}
51
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080052Transform Transform::operator * (const Transform& rhs) const
53{
Mathias Agopianeda65402010-02-22 03:15:57 -080054 if (CC_LIKELY(mType == IDENTITY))
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080055 return rhs;
56
57 Transform r(*this);
Mathias Agopianeda65402010-02-22 03:15:57 -080058 if (rhs.mType == IDENTITY)
59 return r;
60
61 // TODO: we could use mType to optimize the matrix multiply
62 const mat33& A(mMatrix);
63 const mat33& B(rhs.mMatrix);
64 mat33& D(r.mMatrix);
Peiyong Linefefaac2018-08-17 12:27:51 -070065 for (size_t i = 0; i < 3; i++) {
Mathias Agopianeda65402010-02-22 03:15:57 -080066 const float v0 = A[0][i];
67 const float v1 = A[1][i];
68 const float v2 = A[2][i];
69 D[0][i] = v0*B[0][0] + v1*B[0][1] + v2*B[0][2];
70 D[1][i] = v0*B[1][0] + v1*B[1][1] + v2*B[1][2];
71 D[2][i] = v0*B[2][0] + v1*B[2][1] + v2*B[2][2];
72 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080073 r.mType |= rhs.mType;
Mathias Agopianeda65402010-02-22 03:15:57 -080074
75 // TODO: we could recompute this value from r and rhs
76 r.mType &= 0xFF;
77 r.mType |= UNKNOWN_TYPE;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080078 return r;
79}
80
Peiyong Linefefaac2018-08-17 12:27:51 -070081Transform& Transform::operator=(const Transform& other) {
82 mMatrix = other.mMatrix;
83 mType = other.mType;
84 return *this;
85}
86
Mathias Agopianff2ed702013-09-01 21:36:12 -070087const vec3& Transform::operator [] (size_t i) const {
88 return mMatrix[i];
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080089}
90
Mathias Agopian41b6aab2011-08-30 18:51:54 -070091float Transform::tx() const {
92 return mMatrix[2][0];
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080093}
94
Mathias Agopian41b6aab2011-08-30 18:51:54 -070095float Transform::ty() const {
96 return mMatrix[2][1];
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080097}
98
Robert Carre07e1032018-11-26 12:55:53 -080099float Transform::sx() const {
100 return mMatrix[0][0];
101}
102
103float Transform::sy() const {
104 return mMatrix[1][1];
105}
106
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800107void Transform::reset() {
Mathias Agopianeda65402010-02-22 03:15:57 -0800108 mType = IDENTITY;
Peiyong Linefefaac2018-08-17 12:27:51 -0700109 for(size_t i = 0; i < 3; i++) {
Mathias Agopianeda65402010-02-22 03:15:57 -0800110 vec3& v(mMatrix[i]);
Peiyong Linefefaac2018-08-17 12:27:51 -0700111 for (size_t j = 0; j < 3; j++)
112 v[j] = ((i == j) ? 1.0f : 0.0f);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800113 }
114}
115
Mathias Agopianeda65402010-02-22 03:15:57 -0800116void Transform::set(float tx, float ty)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800117{
Mathias Agopianeda65402010-02-22 03:15:57 -0800118 mMatrix[2][0] = tx;
119 mMatrix[2][1] = ty;
120 mMatrix[2][2] = 1.0f;
121
122 if (isZero(tx) && isZero(ty)) {
123 mType &= ~TRANSLATE;
124 } else {
125 mType |= TRANSLATE;
126 }
127}
128
129void Transform::set(float a, float b, float c, float d)
130{
131 mat33& M(mMatrix);
132 M[0][0] = a; M[1][0] = b;
133 M[0][1] = c; M[1][1] = d;
134 M[0][2] = 0; M[1][2] = 0;
135 mType = UNKNOWN_TYPE;
136}
137
Mathias Agopiand1296592010-03-09 19:17:47 -0800138status_t Transform::set(uint32_t flags, float w, float h)
Mathias Agopianeda65402010-02-22 03:15:57 -0800139{
Mathias Agopiand1296592010-03-09 19:17:47 -0800140 if (flags & ROT_INVALID) {
141 // that's not allowed!
142 reset();
143 return BAD_VALUE;
144 }
145
Mathias Agopian0694d0f2010-10-24 14:53:05 -0700146 Transform H, V, R;
Mathias Agopian883dffa2010-10-25 18:29:35 -0700147 if (flags & ROT_90) {
148 // w & h are inverted when rotating by 90 degrees
Peiyong Lin3db42342018-08-16 09:15:59 -0700149 std::swap(w, h);
Mathias Agopian883dffa2010-10-25 18:29:35 -0700150 }
151
Mathias Agopianeda65402010-02-22 03:15:57 -0800152 if (flags & FLIP_H) {
Mathias Agopian0694d0f2010-10-24 14:53:05 -0700153 H.mType = (FLIP_H << 8) | SCALE;
154 H.mType |= isZero(w) ? IDENTITY : TRANSLATE;
155 mat33& M(H.mMatrix);
156 M[0][0] = -1;
157 M[2][0] = w;
Mathias Agopianeda65402010-02-22 03:15:57 -0800158 }
159
160 if (flags & FLIP_V) {
Mathias Agopian0694d0f2010-10-24 14:53:05 -0700161 V.mType = (FLIP_V << 8) | SCALE;
162 V.mType |= isZero(h) ? IDENTITY : TRANSLATE;
163 mat33& M(V.mMatrix);
164 M[1][1] = -1;
165 M[2][1] = h;
Mathias Agopianeda65402010-02-22 03:15:57 -0800166 }
167
Mathias Agopian0694d0f2010-10-24 14:53:05 -0700168 if (flags & ROT_90) {
Mathias Agopian883dffa2010-10-25 18:29:35 -0700169 const float original_w = h;
Mathias Agopian0694d0f2010-10-24 14:53:05 -0700170 R.mType = (ROT_90 << 8) | ROTATE;
Mathias Agopian883dffa2010-10-25 18:29:35 -0700171 R.mType |= isZero(original_w) ? IDENTITY : TRANSLATE;
Mathias Agopian0694d0f2010-10-24 14:53:05 -0700172 mat33& M(R.mMatrix);
Mathias Agopian883dffa2010-10-25 18:29:35 -0700173 M[0][0] = 0; M[1][0] =-1; M[2][0] = original_w;
Mathias Agopian0694d0f2010-10-24 14:53:05 -0700174 M[0][1] = 1; M[1][1] = 0;
Mathias Agopianeda65402010-02-22 03:15:57 -0800175 }
176
Mathias Agopian883dffa2010-10-25 18:29:35 -0700177 *this = (R*(H*V));
Mathias Agopiand1296592010-03-09 19:17:47 -0800178 return NO_ERROR;
Mathias Agopianeda65402010-02-22 03:15:57 -0800179}
180
Mathias Agopianff2ed702013-09-01 21:36:12 -0700181vec2 Transform::transform(const vec2& v) const {
Mathias Agopianeda65402010-02-22 03:15:57 -0800182 vec2 r;
183 const mat33& M(mMatrix);
184 r[0] = M[0][0]*v[0] + M[1][0]*v[1] + M[2][0];
185 r[1] = M[0][1]*v[0] + M[1][1]*v[1] + M[2][1];
186 return r;
187}
188
Mathias Agopianff2ed702013-09-01 21:36:12 -0700189vec3 Transform::transform(const vec3& v) const {
Mathias Agopianeda65402010-02-22 03:15:57 -0800190 vec3 r;
191 const mat33& M(mMatrix);
192 r[0] = M[0][0]*v[0] + M[1][0]*v[1] + M[2][0]*v[2];
193 r[1] = M[0][1]*v[0] + M[1][1]*v[1] + M[2][1]*v[2];
194 r[2] = M[0][2]*v[0] + M[1][2]*v[1] + M[2][2]*v[2];
195 return r;
196}
197
Mathias Agopianff2ed702013-09-01 21:36:12 -0700198vec2 Transform::transform(int x, int y) const
Mathias Agopianeda65402010-02-22 03:15:57 -0800199{
Mathias Agopianff2ed702013-09-01 21:36:12 -0700200 return transform(vec2(x,y));
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800201}
202
203Rect Transform::makeBounds(int w, int h) const
204{
Mathias Agopianeda65402010-02-22 03:15:57 -0800205 return transform( Rect(w, h) );
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800206}
207
Pablo Ceballos51450032016-08-03 10:20:45 -0700208Rect Transform::transform(const Rect& bounds, bool roundOutwards) const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800209{
210 Rect r;
Mathias Agopianeda65402010-02-22 03:15:57 -0800211 vec2 lt( bounds.left, bounds.top );
212 vec2 rt( bounds.right, bounds.top );
213 vec2 lb( bounds.left, bounds.bottom );
214 vec2 rb( bounds.right, bounds.bottom );
215
216 lt = transform(lt);
217 rt = transform(rt);
218 lb = transform(lb);
219 rb = transform(rb);
220
Pablo Ceballos51450032016-08-03 10:20:45 -0700221 if (roundOutwards) {
Peiyong Linefefaac2018-08-17 12:27:51 -0700222 r.left = static_cast<int32_t>(floorf(std::min({lt[0], rt[0], lb[0], rb[0]})));
223 r.top = static_cast<int32_t>(floorf(std::min({lt[1], rt[1], lb[1], rb[1]})));
224 r.right = static_cast<int32_t>(ceilf(std::max({lt[0], rt[0], lb[0], rb[0]})));
225 r.bottom = static_cast<int32_t>(ceilf(std::max({lt[1], rt[1], lb[1], rb[1]})));
Pablo Ceballos51450032016-08-03 10:20:45 -0700226 } else {
Peiyong Linefefaac2018-08-17 12:27:51 -0700227 r.left = static_cast<int32_t>(floorf(std::min({lt[0], rt[0], lb[0], rb[0]}) + 0.5f));
228 r.top = static_cast<int32_t>(floorf(std::min({lt[1], rt[1], lb[1], rb[1]}) + 0.5f));
229 r.right = static_cast<int32_t>(floorf(std::max({lt[0], rt[0], lb[0], rb[0]}) + 0.5f));
230 r.bottom = static_cast<int32_t>(floorf(std::max({lt[1], rt[1], lb[1], rb[1]}) + 0.5f));
Pablo Ceballos51450032016-08-03 10:20:45 -0700231 }
Mathias Agopianeda65402010-02-22 03:15:57 -0800232
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800233 return r;
234}
235
Dan Stoza80d61162017-12-20 15:57:52 -0800236FloatRect Transform::transform(const FloatRect& bounds) const
237{
238 vec2 lt(bounds.left, bounds.top);
239 vec2 rt(bounds.right, bounds.top);
240 vec2 lb(bounds.left, bounds.bottom);
241 vec2 rb(bounds.right, bounds.bottom);
242
243 lt = transform(lt);
244 rt = transform(rt);
245 lb = transform(lb);
246 rb = transform(rb);
247
248 FloatRect r;
Peiyong Lin3db42342018-08-16 09:15:59 -0700249 r.left = std::min({lt[0], rt[0], lb[0], rb[0]});
250 r.top = std::min({lt[1], rt[1], lb[1], rb[1]});
251 r.right = std::max({lt[0], rt[0], lb[0], rb[0]});
252 r.bottom = std::max({lt[1], rt[1], lb[1], rb[1]});
Dan Stoza80d61162017-12-20 15:57:52 -0800253
254 return r;
255}
256
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800257Region Transform::transform(const Region& reg) const
258{
259 Region out;
Dan Stoza22f7fc42016-05-10 16:19:53 -0700260 if (CC_UNLIKELY(type() > TRANSLATE)) {
Mathias Agopianeda65402010-02-22 03:15:57 -0800261 if (CC_LIKELY(preserveRects())) {
Mathias Agopian20f68782009-05-11 00:03:41 -0700262 Region::const_iterator it = reg.begin();
263 Region::const_iterator const end = reg.end();
264 while (it != end) {
265 out.orSelf(transform(*it++));
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800266 }
267 } else {
268 out.set(transform(reg.bounds()));
269 }
270 } else {
Peiyong Linefefaac2018-08-17 12:27:51 -0700271 int xpos = static_cast<int>(floorf(tx() + 0.5f));
272 int ypos = static_cast<int>(floorf(ty() + 0.5f));
Mathias Agopian41b6aab2011-08-30 18:51:54 -0700273 out = reg.translate(xpos, ypos);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800274 }
275 return out;
276}
277
Mathias Agopianeda65402010-02-22 03:15:57 -0800278uint32_t Transform::type() const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800279{
Mathias Agopianeda65402010-02-22 03:15:57 -0800280 if (mType & UNKNOWN_TYPE) {
281 // recompute what this transform is
282
283 const mat33& M(mMatrix);
284 const float a = M[0][0];
285 const float b = M[1][0];
286 const float c = M[0][1];
287 const float d = M[1][1];
288 const float x = M[2][0];
289 const float y = M[2][1];
290
291 bool scale = false;
292 uint32_t flags = ROT_0;
293 if (isZero(b) && isZero(c)) {
Mathias Agopiand1296592010-03-09 19:17:47 -0800294 if (a<0) flags |= FLIP_H;
295 if (d<0) flags |= FLIP_V;
296 if (!absIsOne(a) || !absIsOne(d)) {
297 scale = true;
Mathias Agopianeda65402010-02-22 03:15:57 -0800298 }
299 } else if (isZero(a) && isZero(d)) {
Mathias Agopiand1296592010-03-09 19:17:47 -0800300 flags |= ROT_90;
Mathias Agopian883dffa2010-10-25 18:29:35 -0700301 if (b>0) flags |= FLIP_V;
302 if (c<0) flags |= FLIP_H;
Mathias Agopiand1296592010-03-09 19:17:47 -0800303 if (!absIsOne(b) || !absIsOne(c)) {
304 scale = true;
Mathias Agopianeda65402010-02-22 03:15:57 -0800305 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800306 } else {
Mathias Agopian29a367b2011-07-12 14:51:45 -0700307 // there is a skew component and/or a non 90 degrees rotation
Mathias Agopianeda65402010-02-22 03:15:57 -0800308 flags = ROT_INVALID;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800309 }
Mathias Agopianeda65402010-02-22 03:15:57 -0800310
311 mType = flags << 8;
312 if (flags & ROT_INVALID) {
313 mType |= UNKNOWN;
314 } else {
315 if ((flags & ROT_90) || ((flags & ROT_180) == ROT_180))
316 mType |= ROTATE;
317 if (flags & FLIP_H)
318 mType ^= SCALE;
319 if (flags & FLIP_V)
320 mType ^= SCALE;
321 if (scale)
322 mType |= SCALE;
323 }
324
325 if (!isZero(x) || !isZero(y))
326 mType |= TRANSLATE;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800327 }
Mathias Agopianeda65402010-02-22 03:15:57 -0800328 return mType;
329}
330
Mathias Agopian3da16722013-02-28 17:12:07 -0800331Transform Transform::inverse() const {
332 // our 3x3 matrix is always of the form of a 2x2 transformation
333 // followed by a translation: T*M, therefore:
334 // (T*M)^-1 = M^-1 * T^-1
335 Transform result;
336 if (mType <= TRANSLATE) {
Michael Lentine28ea2172014-11-19 18:32:37 -0800337 // 1 0 0
338 // 0 1 0
339 // x y 1
Mathias Agopian3da16722013-02-28 17:12:07 -0800340 result = *this;
341 result.mMatrix[2][0] = -result.mMatrix[2][0];
342 result.mMatrix[2][1] = -result.mMatrix[2][1];
343 } else {
Michael Lentine28ea2172014-11-19 18:32:37 -0800344 // a c 0
345 // b d 0
346 // x y 1
Mathias Agopian3da16722013-02-28 17:12:07 -0800347 const mat33& M(mMatrix);
348 const float a = M[0][0];
349 const float b = M[1][0];
350 const float c = M[0][1];
351 const float d = M[1][1];
352 const float x = M[2][0];
353 const float y = M[2][1];
354
Peiyong Linefefaac2018-08-17 12:27:51 -0700355 const float idet = 1.0f / (a*d - b*c);
Michael Lentine28ea2172014-11-19 18:32:37 -0800356 result.mMatrix[0][0] = d*idet;
357 result.mMatrix[0][1] = -c*idet;
358 result.mMatrix[1][0] = -b*idet;
359 result.mMatrix[1][1] = a*idet;
360 result.mType = mType;
Mathias Agopian3da16722013-02-28 17:12:07 -0800361
Michael Lentine28ea2172014-11-19 18:32:37 -0800362 vec2 T(-x, -y);
363 T = result.transform(T);
364 result.mMatrix[2][0] = T[0];
365 result.mMatrix[2][1] = T[1];
Mathias Agopian3da16722013-02-28 17:12:07 -0800366 }
367 return result;
368}
369
Mathias Agopianeda65402010-02-22 03:15:57 -0800370uint32_t Transform::getType() const {
371 return type() & 0xFF;
372}
373
374uint32_t Transform::getOrientation() const
375{
376 return (type() >> 8) & 0xFF;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800377}
378
379bool Transform::preserveRects() const
380{
Mathias Agopianab7c13f2011-07-25 13:57:16 -0700381 return (getOrientation() & ROT_INVALID) ? false : true;
Mathias Agopianeda65402010-02-22 03:15:57 -0800382}
383
Lloyd Pique7e06e7f2019-03-15 18:36:44 -0700384mat4 Transform::asMatrix4() const {
385 // Internally Transform uses a 3x3 matrix since the transform is meant for
386 // two-dimensional values. An equivalent 4x4 matrix means inserting an extra
387 // row and column which adds as an identity transform on the third
388 // dimension.
389
390 mat4 m = mat4{mat4::NO_INIT}; // NO_INIT since we explicitly set every element
391
392 m[0][0] = mMatrix[0][0];
393 m[0][1] = mMatrix[0][1];
394 m[0][2] = 0.f;
395 m[0][3] = mMatrix[0][2];
396
397 m[1][0] = mMatrix[1][0];
398 m[1][1] = mMatrix[1][1];
399 m[1][2] = 0.f;
400 m[1][3] = mMatrix[1][2];
401
402 m[2][0] = 0.f;
403 m[2][1] = 0.f;
404 m[2][2] = 1.f;
405 m[2][3] = 0.f;
406
407 m[3][0] = mMatrix[2][0];
408 m[3][1] = mMatrix[2][1];
409 m[3][2] = 0.f;
410 m[3][3] = mMatrix[2][2];
411
412 return m;
413}
414
Lloyd Pique32cbe282018-10-19 13:09:22 -0700415void Transform::dump(std::string& out, const char* name) const {
416 using android::base::StringAppendF;
Mathias Agopianeda65402010-02-22 03:15:57 -0800417
Lloyd Pique32cbe282018-10-19 13:09:22 -0700418 type(); // Ensure the information in mType is up to date
Mathias Agopianeda65402010-02-22 03:15:57 -0800419
Lloyd Pique32cbe282018-10-19 13:09:22 -0700420 const uint32_t type = mType;
421 const uint32_t orient = type >> 8;
422
423 StringAppendF(&out, "%s 0x%08x (", name, orient);
424
425 if (orient & ROT_INVALID) {
426 out.append("ROT_INVALID ");
Mathias Agopiand1296592010-03-09 19:17:47 -0800427 } else {
Lloyd Pique32cbe282018-10-19 13:09:22 -0700428 if (orient & ROT_90) {
429 out.append("ROT_90 ");
Mathias Agopiand1296592010-03-09 19:17:47 -0800430 } else {
Lloyd Pique32cbe282018-10-19 13:09:22 -0700431 out.append("ROT_0 ");
Mathias Agopiand1296592010-03-09 19:17:47 -0800432 }
Lloyd Pique32cbe282018-10-19 13:09:22 -0700433 if (orient & FLIP_V) out.append("FLIP_V ");
434 if (orient & FLIP_H) out.append("FLIP_H ");
Mathias Agopiand1296592010-03-09 19:17:47 -0800435 }
Mathias Agopianeda65402010-02-22 03:15:57 -0800436
Lloyd Pique32cbe282018-10-19 13:09:22 -0700437 StringAppendF(&out, ") 0x%02x (", type);
Mathias Agopianeda65402010-02-22 03:15:57 -0800438
Lloyd Pique32cbe282018-10-19 13:09:22 -0700439 if (!(type & (SCALE | ROTATE | TRANSLATE))) out.append("IDENTITY ");
440 if (type & SCALE) out.append("SCALE ");
441 if (type & ROTATE) out.append("ROTATE ");
442 if (type & TRANSLATE) out.append("TRANSLATE ");
443
444 out.append(")\n");
445
446 for (size_t i = 0; i < 3; i++) {
447 StringAppendF(&out, " %.4f %.4f %.4f\n", static_cast<double>(mMatrix[0][i]),
448 static_cast<double>(mMatrix[1][i]), static_cast<double>(mMatrix[2][i]));
449 }
450}
451
452void Transform::dump(const char* name) const {
453 std::string out;
454 dump(out, name);
455 ALOGD("%s", out.c_str());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800456}
457
Peiyong Linefefaac2018-08-17 12:27:51 -0700458} // namespace ui
459} // namespace android