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

Side by Side Diff: src/utils/SkMatrix44.cpp

Issue 26167002: Make skia almost compile again with clang. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkXfermode.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkMatrix44.h" 8 #include "SkMatrix44.h"
9 9
10 static inline bool eq4(const SkMScalar* SK_RESTRICT a, 10 static inline bool eq4(const SkMScalar* SK_RESTRICT a,
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 399 }
400 400
401 if (useStorage) { 401 if (useStorage) {
402 memcpy(fMat, storage, sizeof(storage)); 402 memcpy(fMat, storage, sizeof(storage));
403 } 403 }
404 this->dirtyTypeMask(); 404 this->dirtyTypeMask();
405 } 405 }
406 406
407 /////////////////////////////////////////////////////////////////////////////// 407 ///////////////////////////////////////////////////////////////////////////////
408 408
409 static inline SkMScalar det2x2(double m00, double m01, double m10, double m11) {
410 return SkDoubleToMScalar(m00 * m11 - m10 * m01);
411 }
412
413 static inline double det3x3(double m00, double m01, double m02,
414 double m10, double m11, double m12,
415 double m20, double m21, double m22) {
416 return m00 * det2x2(m11, m12, m21, m22) -
417 m10 * det2x2(m01, m02, m21, m22) +
418 m20 * det2x2(m01, m02, m11, m12);
419 }
420
421 /** We always perform the calculation in doubles, to avoid prematurely losing 409 /** We always perform the calculation in doubles, to avoid prematurely losing
422 precision along the way. This relies on the compiler automatically 410 precision along the way. This relies on the compiler automatically
423 promoting our SkMScalar values to double (if needed). 411 promoting our SkMScalar values to double (if needed).
424 */ 412 */
425 double SkMatrix44::determinant() const { 413 double SkMatrix44::determinant() const {
426 if (this->isIdentity()) { 414 if (this->isIdentity()) {
427 return 1; 415 return 1;
428 } 416 }
429 if (this->isScaleTranslate()) { 417 if (this->isScaleTranslate()) {
430 return fMat[0][0] * fMat[1][1] * fMat[2][2] * fMat[3][3]; 418 return fMat[0][0] * fMat[1][1] * fMat[2][2] * fMat[3][3];
(...skipping 28 matching lines...) Expand all
459 double b09 = a21 * a32 - a22 * a31; 447 double b09 = a21 * a32 - a22 * a31;
460 double b10 = a21 * a33 - a23 * a31; 448 double b10 = a21 * a33 - a23 * a31;
461 double b11 = a22 * a33 - a23 * a32; 449 double b11 = a22 * a33 - a23 * a32;
462 450
463 // Calculate the determinant 451 // Calculate the determinant
464 return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06 ; 452 return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06 ;
465 } 453 }
466 454
467 /////////////////////////////////////////////////////////////////////////////// 455 ///////////////////////////////////////////////////////////////////////////////
468 456
469 static inline double dabs(double x) {
470 if (x < 0) {
471 x = -x;
472 }
473 return x;
474 }
475
476 bool SkMatrix44::invert(SkMatrix44* inverse) const { 457 bool SkMatrix44::invert(SkMatrix44* inverse) const {
477 if (this->isIdentity()) { 458 if (this->isIdentity()) {
478 if (inverse) { 459 if (inverse) {
479 inverse->setIdentity(); 460 inverse->setIdentity();
480 return true; 461 return true;
481 } 462 }
482 } 463 }
483 if (this->isTranslate()) { 464 if (this->isTranslate()) {
484 if (inverse) { 465 if (inverse) {
485 inverse->setTranslate(-fMat[3][0], -fMat[3][1], -fMat[3][2]); 466 inverse->setTranslate(-fMat[3][0], -fMat[3][1], -fMat[3][2]);
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 dst[SkMatrix::kMScaleX] = SkMScalarToScalar(fMat[0][0]); 928 dst[SkMatrix::kMScaleX] = SkMScalarToScalar(fMat[0][0]);
948 dst[SkMatrix::kMSkewX] = SkMScalarToScalar(fMat[1][0]); 929 dst[SkMatrix::kMSkewX] = SkMScalarToScalar(fMat[1][0]);
949 dst[SkMatrix::kMTransX] = SkMScalarToScalar(fMat[3][0]); 930 dst[SkMatrix::kMTransX] = SkMScalarToScalar(fMat[3][0]);
950 931
951 dst[SkMatrix::kMSkewY] = SkMScalarToScalar(fMat[0][1]); 932 dst[SkMatrix::kMSkewY] = SkMScalarToScalar(fMat[0][1]);
952 dst[SkMatrix::kMScaleY] = SkMScalarToScalar(fMat[1][1]); 933 dst[SkMatrix::kMScaleY] = SkMScalarToScalar(fMat[1][1]);
953 dst[SkMatrix::kMTransY] = SkMScalarToScalar(fMat[3][1]); 934 dst[SkMatrix::kMTransY] = SkMScalarToScalar(fMat[3][1]);
954 935
955 return dst; 936 return dst;
956 } 937 }
OLDNEW
« no previous file with comments | « src/core/SkXfermode.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698