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

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

Issue 81323002: fix compiler error where SK_SCALAR_IS_FLOAT is not defined. (attempt 2) (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 | « no previous file | 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 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 "Sk64.h" 9 #include "Sk64.h"
10 #include "SkFloatBits.h" 10 #include "SkFloatBits.h"
(...skipping 30 matching lines...) Expand all
41 enum { 41 enum {
42 kTranslate_Shift, 42 kTranslate_Shift,
43 kScale_Shift, 43 kScale_Shift,
44 kAffine_Shift, 44 kAffine_Shift,
45 kPerspective_Shift, 45 kPerspective_Shift,
46 kRectStaysRect_Shift 46 kRectStaysRect_Shift
47 }; 47 };
48 48
49 #ifdef SK_SCALAR_IS_FLOAT 49 #ifdef SK_SCALAR_IS_FLOAT
50 static const int32_t kScalar1Int = 0x3f800000; 50 static const int32_t kScalar1Int = 0x3f800000;
51 static const int32_t kPersp1Int = 0x3f800000;
51 #else 52 #else
52 #define scalarAsInt(x) (x) 53 #define scalarAsInt(x) (x)
53 static const int32_t kScalar1Int = (1 << 16); 54 static const int32_t kScalar1Int = (1 << 16);
55 static const int32_t kPersp1Int = (1 << 30);
54 #endif 56 #endif
55 57
56 uint8_t SkMatrix::computePerspectiveTypeMask() const { 58 uint8_t SkMatrix::computePerspectiveTypeMask() const {
57 #ifdef SK_SCALAR_SLOW_COMPARES 59 #ifdef SK_SCALAR_SLOW_COMPARES
58 if (SkScalarAs2sCompliment(fMat[kMPersp0]) | 60 if (SkScalarAs2sCompliment(fMat[kMPersp0]) |
59 SkScalarAs2sCompliment(fMat[kMPersp1]) | 61 SkScalarAs2sCompliment(fMat[kMPersp1]) |
60 (SkScalarAs2sCompliment(fMat[kMPersp2]) - SK_Fract1)) { 62 (SkScalarAs2sCompliment(fMat[kMPersp2]) - kPersp1Int)) {
61 return SkToU8(kORableMasks); 63 return SkToU8(kORableMasks);
62 } 64 }
63 #else 65 #else
64 // Benchmarking suggests that replacing this set of SkScalarAs2sCompliment 66 // Benchmarking suggests that replacing this set of SkScalarAs2sCompliment
65 // is a win, but replacing those below is not. We don't yet understand 67 // is a win, but replacing those below is not. We don't yet understand
66 // that result. 68 // that result.
67 if (fMat[kMPersp0] != 0 || fMat[kMPersp1] != 0 || 69 if (fMat[kMPersp0] != 0 || fMat[kMPersp1] != 0 ||
68 fMat[kMPersp2] != kMatrix22Elem) { 70 fMat[kMPersp2] != kMatrix22Elem) {
69 // If this is a perspective transform, we return true for all other 71 // If this is a perspective transform, we return true for all other
70 // transform flags - this does not disable any optimizations, respects 72 // transform flags - this does not disable any optimizations, respects
71 // the rule that the type mask must be conservative, and speeds up 73 // the rule that the type mask must be conservative, and speeds up
72 // type mask computation. 74 // type mask computation.
73 return SkToU8(kORableMasks); 75 return SkToU8(kORableMasks);
74 } 76 }
75 #endif 77 #endif
76 78
77 return SkToU8(kOnlyPerspectiveValid_Mask | kUnknown_Mask); 79 return SkToU8(kOnlyPerspectiveValid_Mask | kUnknown_Mask);
78 } 80 }
79 81
80 uint8_t SkMatrix::computeTypeMask() const { 82 uint8_t SkMatrix::computeTypeMask() const {
81 unsigned mask = 0; 83 unsigned mask = 0;
82 84
83 #ifdef SK_SCALAR_SLOW_COMPARES 85 #ifdef SK_SCALAR_SLOW_COMPARES
84 if (SkScalarAs2sCompliment(fMat[kMPersp0]) | 86 if (SkScalarAs2sCompliment(fMat[kMPersp0]) |
85 SkScalarAs2sCompliment(fMat[kMPersp1]) | 87 SkScalarAs2sCompliment(fMat[kMPersp1]) |
86 (SkScalarAs2sCompliment(fMat[kMPersp2]) - SK_Fract1)) { 88 (SkScalarAs2sCompliment(fMat[kMPersp2]) - kPersp1Int)) {
87 return SkToU8(kORableMasks); 89 return SkToU8(kORableMasks);
88 } 90 }
89 91
90 if (SkScalarAs2sCompliment(fMat[kMTransX]) | 92 if (SkScalarAs2sCompliment(fMat[kMTransX]) |
91 SkScalarAs2sCompliment(fMat[kMTransY])) { 93 SkScalarAs2sCompliment(fMat[kMTransY])) {
92 mask |= kTranslate_Mask; 94 mask |= kTranslate_Mask;
93 } 95 }
94 #else 96 #else
95 if (fMat[kMPersp0] != 0 || fMat[kMPersp1] != 0 || 97 if (fMat[kMPersp0] != 0 || fMat[kMPersp1] != 0 ||
96 fMat[kMPersp2] != kMatrix22Elem) { 98 fMat[kMPersp2] != kMatrix22Elem) {
(...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after
2107 rotation1->fX = cos1; 2109 rotation1->fX = cos1;
2108 rotation1->fY = sin1; 2110 rotation1->fY = sin1;
2109 } 2111 }
2110 if (NULL != rotation2) { 2112 if (NULL != rotation2) {
2111 rotation2->fX = cos2; 2113 rotation2->fX = cos2;
2112 rotation2->fY = sin2; 2114 rotation2->fY = sin2;
2113 } 2115 }
2114 2116
2115 return true; 2117 return true;
2116 } 2118 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698