OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "CrashHandler.h" | 8 #include "CrashHandler.h" |
9 #include "DMJsonWriter.h" | 9 #include "DMJsonWriter.h" |
10 #include "DMSrcSink.h" | 10 #include "DMSrcSink.h" |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
951 } | 951 } |
952 | 952 |
953 } else if (bitmap.colorType() == kRGBA_F16_SkColorType) { | 953 } else if (bitmap.colorType() == kRGBA_F16_SkColorType) { |
954 // These are premul linear half-float pixels in RGBA order. | 954 // These are premul linear half-float pixels in RGBA order. |
955 // We want unpremul sRGB 8-bit pixels in RGBA order. We'll get there vi a floats. | 955 // We want unpremul sRGB 8-bit pixels in RGBA order. We'll get there vi a floats. |
956 bitmap.lockPixels(); | 956 bitmap.lockPixels(); |
957 auto px = (const uint64_t*)bitmap.getPixels(); | 957 auto px = (const uint64_t*)bitmap.getPixels(); |
958 if (!px) { | 958 if (!px) { |
959 return false; | 959 return false; |
960 } | 960 } |
961 const Sk4f vecZero(0); | |
962 const Sk4f vecOne(1); | |
961 for (int i = 0; i < w*h; i++) { | 963 for (int i = 0; i < w*h; i++) { |
962 Sk4f fs = SkHalfToFloat_01(px[i]); // Convert up to linear floats . | 964 // Convert up to linear floats. |
mtklein
2016/04/14 19:20:13
FYI folks, I do intend to replace SkHalfToFloat_01
| |
965 Sk4f fs(SkHalfToFloat(static_cast<SkHalf>(px[i] >> (0 * 16))), | |
966 SkHalfToFloat(static_cast<SkHalf>(px[i] >> (1 * 16))), | |
967 SkHalfToFloat(static_cast<SkHalf>(px[i] >> (2 * 16))), | |
968 SkHalfToFloat(static_cast<SkHalf>(px[i] >> (3 * 16)))); | |
969 fs = Sk4f::Min(Sk4f::Max(fs, vecZero), vecOne); // Clamp | |
mtklein
2016/04/14 19:20:13
I like to write this as
fs = Sk4f::Max(0.0f, S
| |
963 float invA = 1.0f / fs[3]; | 970 float invA = 1.0f / fs[3]; |
964 fs = fs * Sk4f(invA, invA, invA, 1); // Unpremultiply. | 971 fs = fs * Sk4f(invA, invA, invA, 1); // Unpremultiply. |
965 rgba[i] = Sk4f_toS32(fs); // Pack down to sRGB bytes. | 972 rgba[i] = Sk4f_toS32(fs); // Pack down to sRGB bytes. |
966 } | 973 } |
967 | 974 |
968 | 975 |
969 } else { | 976 } else { |
970 // We "should" gamma correct in here but we don't. | 977 // We "should" gamma correct in here but we don't. |
971 // We want Gold to show exactly what our clients are seeing, broken gamm a. | 978 // We want Gold to show exactly what our clients are seeing, broken gamm a. |
972 | 979 |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1465 #endif | 1472 #endif |
1466 } | 1473 } |
1467 } // namespace skiatest | 1474 } // namespace skiatest |
1468 | 1475 |
1469 #if !defined(SK_BUILD_FOR_IOS) | 1476 #if !defined(SK_BUILD_FOR_IOS) |
1470 int main(int argc, char** argv) { | 1477 int main(int argc, char** argv) { |
1471 SkCommandLineFlags::Parse(argc, argv); | 1478 SkCommandLineFlags::Parse(argc, argv); |
1472 return dm_main(); | 1479 return dm_main(); |
1473 } | 1480 } |
1474 #endif | 1481 #endif |
OLD | NEW |