Chromium Code Reviews| Index: src/core/SkMatrix.cpp |
| diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp |
| index e0305606268a0af773a2e9ec306b521121e77bd7..d6ae299a3d040f8e89a69230cdc96e2644ad001a 100644 |
| --- a/src/core/SkMatrix.cpp |
| +++ b/src/core/SkMatrix.cpp |
| @@ -1586,33 +1586,34 @@ bool SkMatrix::getMinMaxScales(SkScalar scaleFactors[2]) const { |
| namespace { |
| -struct PODMatrix { |
| +// SkMatrix is C++11 POD (trivial and standard-layout), but not aggragate (it has private fields). |
|
mtklein
2015/08/25 18:04:36
sp. on aggregate
bungeman-skia
2015/08/25 18:07:15
Done.
|
| +struct AggregateMatrix { |
| SkScalar matrix[9]; |
| uint32_t typemask; |
| const SkMatrix& asSkMatrix() const { return *reinterpret_cast<const SkMatrix*>(this); } |
| }; |
| -static_assert(sizeof(PODMatrix) == sizeof(SkMatrix), "PODMatrixSizeMismatch"); |
| +static_assert(sizeof(AggregateMatrix) == sizeof(SkMatrix), "AggregateMatrix size mismatch."); |
| } // namespace |
| const SkMatrix& SkMatrix::I() { |
| - static_assert(offsetof(SkMatrix, fMat) == offsetof(PODMatrix, matrix), "BadfMat"); |
| - static_assert(offsetof(SkMatrix, fTypeMask) == offsetof(PODMatrix, typemask), "BadfTypeMask"); |
| + static_assert(offsetof(SkMatrix,fMat) == offsetof(AggregateMatrix,matrix), "fMat"); |
| + static_assert(offsetof(SkMatrix,fTypeMask) == offsetof(AggregateMatrix,typemask), "fTypeMask"); |
| - static const PODMatrix identity = { {SK_Scalar1, 0, 0, |
| - 0, SK_Scalar1, 0, |
| - 0, 0, SK_Scalar1 }, |
| - kIdentity_Mask | kRectStaysRect_Mask}; |
| + static const AggregateMatrix identity = { {SK_Scalar1, 0, 0, |
| + 0, SK_Scalar1, 0, |
| + 0, 0, SK_Scalar1 }, |
| + kIdentity_Mask | kRectStaysRect_Mask}; |
| SkASSERT(identity.asSkMatrix().isIdentity()); |
| return identity.asSkMatrix(); |
| } |
| const SkMatrix& SkMatrix::InvalidMatrix() { |
| - static_assert(offsetof(SkMatrix, fMat) == offsetof(PODMatrix, matrix), "BadfMat"); |
| - static_assert(offsetof(SkMatrix, fTypeMask) == offsetof(PODMatrix, typemask), "BadfTypeMask"); |
| + static_assert(offsetof(SkMatrix,fMat) == offsetof(AggregateMatrix,matrix), "fMat"); |
| + static_assert(offsetof(SkMatrix,fTypeMask) == offsetof(AggregateMatrix,typemask), "fTypeMask"); |
| - static const PODMatrix invalid = |
| + static const AggregateMatrix invalid = |
| { {SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, |
| SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, |
| SK_ScalarMax, SK_ScalarMax, SK_ScalarMax }, |