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

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

Issue 2324843003: Fix storage of gamut transform matrices in SkColorSpace (Closed)
Patch Set: Created 4 years, 3 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 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 const SkMScalar* src = &fMat[0][0]; 78 const SkMScalar* src = &fMat[0][0];
79 #ifdef SK_MSCALAR_IS_DOUBLE 79 #ifdef SK_MSCALAR_IS_DOUBLE
80 for (int i = 0; i < 16; ++i) { 80 for (int i = 0; i < 16; ++i) {
81 dst[i] = SkMScalarToFloat(src[i]); 81 dst[i] = SkMScalarToFloat(src[i]);
82 } 82 }
83 #elif defined SK_MSCALAR_IS_FLOAT 83 #elif defined SK_MSCALAR_IS_FLOAT
84 memcpy(dst, src, 16 * sizeof(float)); 84 memcpy(dst, src, 16 * sizeof(float));
85 #endif 85 #endif
86 } 86 }
87 87
88 void SkMatrix44::as4x3ColMajorf(float dst[]) const { 88 void SkMatrix44::as3x4RowMajorf(float dst[]) const {
89 const SkMScalar* src = &fMat[0][0]; 89 dst[0] = fMat[0][0]; dst[1] = fMat[1][0]; dst[2] = fMat[2][0]; dst[3] = fM at[3][0];
90 #ifdef SK_MSCALAR_IS_DOUBLE 90 dst[4] = fMat[0][1]; dst[5] = fMat[1][1]; dst[6] = fMat[2][1]; dst[7] = fM at[3][1];
91 for (int i = 0; i < 12; ++i) { 91 dst[8] = fMat[0][2]; dst[9] = fMat[1][2]; dst[10] = fMat[2][2]; dst[11] = fM at[3][2];
92 dst[i] = SkMScalarToFloat(src[i]);
93 }
94 #elif defined SK_MSCALAR_IS_FLOAT
95 memcpy(dst, src, 12 * sizeof(float));
96 #endif
97 } 92 }
98 93
99 void SkMatrix44::asColMajord(double dst[]) const { 94 void SkMatrix44::asColMajord(double dst[]) const {
100 const SkMScalar* src = &fMat[0][0]; 95 const SkMScalar* src = &fMat[0][0];
101 #ifdef SK_MSCALAR_IS_DOUBLE 96 #ifdef SK_MSCALAR_IS_DOUBLE
102 memcpy(dst, src, 16 * sizeof(double)); 97 memcpy(dst, src, 16 * sizeof(double));
103 #elif defined SK_MSCALAR_IS_FLOAT 98 #elif defined SK_MSCALAR_IS_FLOAT
104 for (int i = 0; i < 16; ++i) { 99 for (int i = 0; i < 16; ++i) {
105 dst[i] = SkMScalarToDouble(src[i]); 100 dst[i] = SkMScalarToDouble(src[i]);
106 } 101 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 216 }
222 217
223 void SkMatrix44::set3x3RowMajorf(const float src[]) { 218 void SkMatrix44::set3x3RowMajorf(const float src[]) {
224 fMat[0][0] = src[0]; fMat[0][1] = src[3]; fMat[0][2] = src[6]; fMat[0][3] = 0; 219 fMat[0][0] = src[0]; fMat[0][1] = src[3]; fMat[0][2] = src[6]; fMat[0][3] = 0;
225 fMat[1][0] = src[1]; fMat[1][1] = src[4]; fMat[1][2] = src[7]; fMat[1][3] = 0; 220 fMat[1][0] = src[1]; fMat[1][1] = src[4]; fMat[1][2] = src[7]; fMat[1][3] = 0;
226 fMat[2][0] = src[2]; fMat[2][1] = src[5]; fMat[2][2] = src[8]; fMat[2][3] = 0; 221 fMat[2][0] = src[2]; fMat[2][1] = src[5]; fMat[2][2] = src[8]; fMat[2][3] = 0;
227 fMat[3][0] = 0; fMat[3][1] = 0; fMat[3][2] = 0; fMat[3][3] = 1; 222 fMat[3][0] = 0; fMat[3][1] = 0; fMat[3][2] = 0; fMat[3][3] = 1;
228 this->dirtyTypeMask(); 223 this->dirtyTypeMask();
229 } 224 }
230 225
231 void SkMatrix44::set4x3ColMajorf(const float src[]) { 226 void SkMatrix44::set3x4RowMajorf(const float src[]) {
232 fMat[0][0] = src[0]; fMat[0][1] = src[1]; fMat[0][2] = src[2]; fMat[0][3] = src[3]; 227 fMat[0][0] = src[0]; fMat[1][0] = src[1]; fMat[2][0] = src[2]; fMat[3][0] = src[3];
233 fMat[1][0] = src[4]; fMat[1][1] = src[5]; fMat[1][2] = src[6]; fMat[1][3] = src[7]; 228 fMat[0][1] = src[4]; fMat[1][1] = src[5]; fMat[2][1] = src[6]; fMat[3][1] = src[7];
234 fMat[2][0] = src[8]; fMat[2][1] = src[9]; fMat[2][2] = src[10]; fMat[2][3] = src[11]; 229 fMat[0][2] = src[8]; fMat[1][2] = src[9]; fMat[2][2] = src[10]; fMat[3][2] = src[11];
235 fMat[3][0] = 0; fMat[3][1] = 0; fMat[3][2] = 0; fMat[3][3] = 1; 230 fMat[0][3] = 0; fMat[1][3] = 0; fMat[2][3] = 0; fMat[3][3] = 1;
236 this->dirtyTypeMask(); 231 this->dirtyTypeMask();
237 } 232 }
238 233
239 /////////////////////////////////////////////////////////////////////////////// 234 ///////////////////////////////////////////////////////////////////////////////
240 235
241 void SkMatrix44::setTranslate(SkMScalar dx, SkMScalar dy, SkMScalar dz) { 236 void SkMatrix44::setTranslate(SkMScalar dx, SkMScalar dy, SkMScalar dz) {
242 this->setIdentity(); 237 this->setIdentity();
243 238
244 if (!dx && !dy && !dz) { 239 if (!dx && !dy && !dz) {
245 return; 240 return;
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 dst[SkMatrix::kMSkewY] = SkMScalarToScalar(fMat[0][1]); 1009 dst[SkMatrix::kMSkewY] = SkMScalarToScalar(fMat[0][1]);
1015 dst[SkMatrix::kMScaleY] = SkMScalarToScalar(fMat[1][1]); 1010 dst[SkMatrix::kMScaleY] = SkMScalarToScalar(fMat[1][1]);
1016 dst[SkMatrix::kMTransY] = SkMScalarToScalar(fMat[3][1]); 1011 dst[SkMatrix::kMTransY] = SkMScalarToScalar(fMat[3][1]);
1017 1012
1018 dst[SkMatrix::kMPersp0] = SkMScalarToScalar(fMat[0][3]); 1013 dst[SkMatrix::kMPersp0] = SkMScalarToScalar(fMat[0][3]);
1019 dst[SkMatrix::kMPersp1] = SkMScalarToScalar(fMat[1][3]); 1014 dst[SkMatrix::kMPersp1] = SkMScalarToScalar(fMat[1][3]);
1020 dst[SkMatrix::kMPersp2] = SkMScalarToScalar(fMat[3][3]); 1015 dst[SkMatrix::kMPersp2] = SkMScalarToScalar(fMat[3][3]);
1021 1016
1022 return dst; 1017 return dst;
1023 } 1018 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698