OLD | NEW |
1 #include <cmath> | 1 #include <cmath> |
2 | 2 |
3 #include "SkBitmap.h" | 3 #include "SkBitmap.h" |
4 #include "skpdiff_util.h" | 4 #include "skpdiff_util.h" |
5 #include "SkPMetric.h" | 5 #include "SkPMetric.h" |
6 #include "SkPMetricUtil_generated.h" | 6 #include "SkPMetricUtil_generated.h" |
7 | 7 |
8 struct RGB { | 8 struct RGB { |
9 float r, g, b; | 9 float r, g, b; |
10 }; | 10 }; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 118 } |
119 } | 119 } |
120 lab->l = 116.0f * f[1] - 16.0f; | 120 lab->l = 116.0f * f[1] - 16.0f; |
121 lab->a = 500.0f * (f[0] - f[1]); | 121 lab->a = 500.0f * (f[0] - f[1]); |
122 lab->b = 200.0f * (f[1] - f[2]); | 122 lab->b = 200.0f * (f[1] - f[2]); |
123 } | 123 } |
124 | 124 |
125 /// Converts a 8888 bitmap to LAB color space and puts it into the output | 125 /// Converts a 8888 bitmap to LAB color space and puts it into the output |
126 static bool bitmap_to_cielab(const SkBitmap* bitmap, ImageLAB* outImageLAB) { | 126 static bool bitmap_to_cielab(const SkBitmap* bitmap, ImageLAB* outImageLAB) { |
127 SkBitmap bm8888; | 127 SkBitmap bm8888; |
128 if (bitmap->colorType() != kN32_SkColorType) { | 128 if (bitmap->colorType() != kPMColor_SkColorType) { |
129 if (!bitmap->copyTo(&bm8888, kN32_SkColorType)) { | 129 if (!bitmap->copyTo(&bm8888, kPMColor_SkColorType)) { |
130 return false; | 130 return false; |
131 } | 131 } |
132 bitmap = &bm8888; | 132 bitmap = &bm8888; |
133 } | 133 } |
134 | 134 |
135 int width = bitmap->width(); | 135 int width = bitmap->width(); |
136 int height = bitmap->height(); | 136 int height = bitmap->height(); |
137 SkASSERT(outImageLAB->width == width); | 137 SkASSERT(outImageLAB->width == width); |
138 SkASSERT(outImageLAB->height == height); | 138 SkASSERT(outImageLAB->height == height); |
139 | 139 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 if (!bitmap_to_cielab(baseline, &baselineLAB) || !bitmap_to_cielab(test, &te
stLAB)) { | 454 if (!bitmap_to_cielab(baseline, &baselineLAB) || !bitmap_to_cielab(test, &te
stLAB)) { |
455 return true; | 455 return true; |
456 } | 456 } |
457 | 457 |
458 result->poiCount = 0; | 458 result->poiCount = 0; |
459 result->result = pmetric(&baselineLAB, &testLAB, &result->poiCount); | 459 result->result = pmetric(&baselineLAB, &testLAB, &result->poiCount); |
460 result->timeElapsed = get_seconds() - startTime; | 460 result->timeElapsed = get_seconds() - startTime; |
461 | 461 |
462 return true; | 462 return true; |
463 } | 463 } |
OLD | NEW |