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

Side by Side Diff: src/core/SkMatrix.cpp

Issue 1306443004: Use static_assert instead of SK_COMPILE_ASSERT. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/core/SkImageFilter.cpp ('k') | src/core/SkPaint.cpp » ('j') | 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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkMatrix.h" 8 #include "SkMatrix.h"
9 #include "SkFloatBits.h" 9 #include "SkFloatBits.h"
10 #include "SkRSXform.h" 10 #include "SkRSXform.h"
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 } 1585 }
1586 1586
1587 namespace { 1587 namespace {
1588 1588
1589 struct PODMatrix { 1589 struct PODMatrix {
1590 SkScalar matrix[9]; 1590 SkScalar matrix[9];
1591 uint32_t typemask; 1591 uint32_t typemask;
1592 1592
1593 const SkMatrix& asSkMatrix() const { return *reinterpret_cast<const SkMatrix *>(this); } 1593 const SkMatrix& asSkMatrix() const { return *reinterpret_cast<const SkMatrix *>(this); }
1594 }; 1594 };
1595 SK_COMPILE_ASSERT(sizeof(PODMatrix) == sizeof(SkMatrix), PODMatrixSizeMismatch); 1595 static_assert(sizeof(PODMatrix) == sizeof(SkMatrix), "PODMatrixSizeMismatch");
1596 1596
1597 } // namespace 1597 } // namespace
1598 1598
1599 const SkMatrix& SkMatrix::I() { 1599 const SkMatrix& SkMatrix::I() {
1600 SK_COMPILE_ASSERT(offsetof(SkMatrix, fMat) == offsetof(PODMatrix, matri x), BadfMat); 1600 static_assert(offsetof(SkMatrix, fMat) == offsetof(PODMatrix, matrix), "BadfMat");
1601 SK_COMPILE_ASSERT(offsetof(SkMatrix, fTypeMask) == offsetof(PODMatrix, typem ask), BadfTypeMask); 1601 static_assert(offsetof(SkMatrix, fTypeMask) == offsetof(PODMatrix, typemask) , "BadfTypeMask");
1602 1602
1603 static const PODMatrix identity = { {SK_Scalar1, 0, 0, 1603 static const PODMatrix identity = { {SK_Scalar1, 0, 0,
1604 0, SK_Scalar1, 0, 1604 0, SK_Scalar1, 0,
1605 0, 0, SK_Scalar1 }, 1605 0, 0, SK_Scalar1 },
1606 kIdentity_Mask | kRectStaysRect_Mask}; 1606 kIdentity_Mask | kRectStaysRect_Mask};
1607 SkASSERT(identity.asSkMatrix().isIdentity()); 1607 SkASSERT(identity.asSkMatrix().isIdentity());
1608 return identity.asSkMatrix(); 1608 return identity.asSkMatrix();
1609 } 1609 }
1610 1610
1611 const SkMatrix& SkMatrix::InvalidMatrix() { 1611 const SkMatrix& SkMatrix::InvalidMatrix() {
1612 SK_COMPILE_ASSERT(offsetof(SkMatrix, fMat) == offsetof(PODMatrix, matri x), BadfMat); 1612 static_assert(offsetof(SkMatrix, fMat) == offsetof(PODMatrix, matrix), "BadfMat");
1613 SK_COMPILE_ASSERT(offsetof(SkMatrix, fTypeMask) == offsetof(PODMatrix, typem ask), BadfTypeMask); 1613 static_assert(offsetof(SkMatrix, fTypeMask) == offsetof(PODMatrix, typemask) , "BadfTypeMask");
1614 1614
1615 static const PODMatrix invalid = 1615 static const PODMatrix invalid =
1616 { {SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, 1616 { {SK_ScalarMax, SK_ScalarMax, SK_ScalarMax,
1617 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, 1617 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax,
1618 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax }, 1618 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax },
1619 kTranslate_Mask | kScale_Mask | kAffine_Mask | kPerspective_Mask }; 1619 kTranslate_Mask | kScale_Mask | kAffine_Mask | kPerspective_Mask };
1620 return invalid.asSkMatrix(); 1620 return invalid.asSkMatrix();
1621 } 1621 }
1622 1622
1623 bool SkMatrix::decomposeScale(SkSize* scale, SkMatrix* remaining) const { 1623 bool SkMatrix::decomposeScale(SkSize* scale, SkMatrix* remaining) const {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 const SkScalar m11 = m00; 1850 const SkScalar m11 = m00;
1851 const SkScalar m12 = fTy; 1851 const SkScalar m12 = fTy;
1852 1852
1853 quad[0].set(m02, m12); 1853 quad[0].set(m02, m12);
1854 quad[1].set(m00 * width + m02, m10 * width + m12); 1854 quad[1].set(m00 * width + m02, m10 * width + m12);
1855 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12); 1855 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12);
1856 quad[3].set(m01 * height + m02, m11 * height + m12); 1856 quad[3].set(m01 * height + m02, m11 * height + m12);
1857 #endif 1857 #endif
1858 } 1858 }
1859 1859
OLDNEW
« no previous file with comments | « src/core/SkImageFilter.cpp ('k') | src/core/SkPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698