| 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 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 for (int i = 0; i < w*h; i++) { | 961 for (int i = 0; i < w*h; i++) { |
| 962 Sk4f fs = SkHalfToFloat_01(px[i]); // Convert up to linear floats
. | 962 // Convert up to linear floats. |
| 963 Sk4f fs(SkHalfToFloat(static_cast<SkHalf>(px[i] >> (0 * 16))), |
| 964 SkHalfToFloat(static_cast<SkHalf>(px[i] >> (1 * 16))), |
| 965 SkHalfToFloat(static_cast<SkHalf>(px[i] >> (2 * 16))), |
| 966 SkHalfToFloat(static_cast<SkHalf>(px[i] >> (3 * 16)))); |
| 967 fs = Sk4f::Max(0.0f, Sk4f::Min(fs, 1.0f)); // Clamp |
| 963 float invA = 1.0f / fs[3]; | 968 float invA = 1.0f / fs[3]; |
| 964 fs = fs * Sk4f(invA, invA, invA, 1); // Unpremultiply. | 969 fs = fs * Sk4f(invA, invA, invA, 1); // Unpremultiply. |
| 965 rgba[i] = Sk4f_toS32(fs); // Pack down to sRGB bytes. | 970 rgba[i] = Sk4f_toS32(fs); // Pack down to sRGB bytes. |
| 966 } | 971 } |
| 967 | 972 |
| 968 | 973 |
| 969 } else { | 974 } else { |
| 970 // We "should" gamma correct in here but we don't. | 975 // 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. | 976 // We want Gold to show exactly what our clients are seeing, broken gamm
a. |
| 972 | 977 |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1465 #endif | 1470 #endif |
| 1466 } | 1471 } |
| 1467 } // namespace skiatest | 1472 } // namespace skiatest |
| 1468 | 1473 |
| 1469 #if !defined(SK_BUILD_FOR_IOS) | 1474 #if !defined(SK_BUILD_FOR_IOS) |
| 1470 int main(int argc, char** argv) { | 1475 int main(int argc, char** argv) { |
| 1471 SkCommandLineFlags::Parse(argc, argv); | 1476 SkCommandLineFlags::Parse(argc, argv); |
| 1472 return dm_main(); | 1477 return dm_main(); |
| 1473 } | 1478 } |
| 1474 #endif | 1479 #endif |
| OLD | NEW |