Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1136)

Side by Side Diff: third_party/WebKit/Source/platform/transforms/AffineTransform.cpp

Issue 2265453003: Add platform/transforms pretty printers for logging and testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused code Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
3 * 2010 Dirk Schulze <krit@webkit.org> 3 * 2010 Dirk Schulze <krit@webkit.org>
4 * Copyright (C) 2013 Google Inc. All rights reserved. 4 * Copyright (C) 2013 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 14 matching lines...) Expand all
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "platform/transforms/AffineTransform.h" 28 #include "platform/transforms/AffineTransform.h"
29 29
30 #include "platform/FloatConversion.h" 30 #include "platform/FloatConversion.h"
31 #include "platform/geometry/FloatQuad.h" 31 #include "platform/geometry/FloatQuad.h"
32 #include "platform/geometry/FloatRect.h" 32 #include "platform/geometry/FloatRect.h"
33 #include "platform/geometry/IntRect.h" 33 #include "platform/geometry/IntRect.h"
34 #include "wtf/MathExtras.h" 34 #include "wtf/MathExtras.h"
35 #include "wtf/text/WTFString.h"
35 36
36 namespace blink { 37 namespace blink {
37 38
38 AffineTransform::AffineTransform() 39 AffineTransform::AffineTransform()
39 { 40 {
40 const Transform identity = IDENTITY_TRANSFORM; 41 const Transform identity = IDENTITY_TRANSFORM;
41 setMatrix(identity); 42 setMatrix(identity);
42 } 43 }
43 44
44 AffineTransform::AffineTransform(double a, double b, double c, double d, double e, double f) 45 AffineTransform::AffineTransform(double a, double b, double c, double d, double e, double f)
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 this->setA(decomp.remainderA); 394 this->setA(decomp.remainderA);
394 this->setB(decomp.remainderB); 395 this->setB(decomp.remainderB);
395 this->setC(decomp.remainderC); 396 this->setC(decomp.remainderC);
396 this->setD(decomp.remainderD); 397 this->setD(decomp.remainderD);
397 this->setE(decomp.translateX); 398 this->setE(decomp.translateX);
398 this->setF(decomp.translateY); 399 this->setF(decomp.translateY);
399 this->rotateRadians(decomp.angle); 400 this->rotateRadians(decomp.angle);
400 this->scale(decomp.scaleX, decomp.scaleY); 401 this->scale(decomp.scaleX, decomp.scaleY);
401 } 402 }
402 403
404 String AffineTransform::toString(bool asMatrix) const
405 {
406 if (asMatrix) {
407 // Return as a matrix in row-major order.
408 return String::format("[%lg,%lg,%lg,\n%lg,%lg,%lg]",
409 a(), c(), e(),
410 b(), d(), f());
411 }
412
413 if (isIdentity())
414 return "identity";
415
416 AffineTransform::DecomposedType decomposition;
417 decompose(decomposition);
418
419 if (isIdentityOrTranslation())
420 return String::format("translation(%lg,%lg)", decomposition.translateX, decomposition.translateY);
421
422 return String::format("translation(%lg,%lg), scale(%lg,%lg), angle(%lgrad), remainder(%lg,%lg,%lg,%lg)",
423 decomposition.translateX,
424 decomposition.translateY,
425 decomposition.scaleX,
426 decomposition.scaleY,
427 decomposition.angle,
jbroman 2016/08/21 16:21:07 super-nit: up to you, but I'd expect deg to be mor
pdr. 2016/08/22 17:27:35 begrudgingly done. Radians are the one true way bu
428 decomposition.remainderA,
429 decomposition.remainderB,
430 decomposition.remainderC,
431 decomposition.remainderD);
432 }
433
403 } // namespace blink 434 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698