Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/resources/video_resource_updater.h" | 5 #include "cc/resources/video_resource_updater.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 for (int bits = 9; bits <= 12; bits++) { | 541 for (int bits = 9; bits <= 12; bits++) { |
| 542 int num_values = 1 << bits; | 542 int num_values = 1 << bits; |
| 543 for (int i = 0; i < num_values; i++) | 543 for (int i = 0; i < num_values; i++) |
| 544 integers[i] = i; | 544 integers[i] = i; |
| 545 | 545 |
| 546 VideoResourceUpdater::MakeHalfFloats(integers, bits, num_values, | 546 VideoResourceUpdater::MakeHalfFloats(integers, bits, num_values, |
| 547 half_floats); | 547 half_floats); |
| 548 | 548 |
| 549 // Multiplier to converting integers to 0.0..1.0 range. | 549 // Multiplier to converting integers to 0.0..1.0 range. |
| 550 double multiplier = 1.0 / (num_values - 1); | 550 double multiplier = 1.0 / (num_values - 1); |
| 551 float expected_precision = 0.f; | |
| 551 | 552 |
| 552 for (int i = 0; i < num_values; i++) { | 553 for (int i = 0; i < num_values; i++) { |
| 553 // We expect the result to be within +/- one least-significant bit. | 554 // We expect the result to be within +/- one least-significant bit. |
| 554 // Within the range we care about, half-floats values and | 555 // Within the range we care about, half-floats values and |
| 555 // their representation both sort in the same order, so we | 556 // their representation both sort in the same order, so we |
| 556 // can just add one to get the next bigger half-float. | 557 // can just add one to get the next bigger half-float. |
| 557 float expected_precision = | 558 if (i < num_values - 1) { |
|
hubbe
2016/10/20 18:55:11
Why is this change needed?
It seems it will just u
fbarchard1
2016/10/20 22:57:34
Done. unittest does not need a change.
| |
| 559 expected_precision = | |
| 558 FromHalfFloat(half_floats[i] + 1) - FromHalfFloat(half_floats[i]); | 560 FromHalfFloat(half_floats[i] + 1) - FromHalfFloat(half_floats[i]); |
| 561 } | |
| 559 EXPECT_NEAR(FromHalfFloat(half_floats[i]), integers[i] * multiplier, | 562 EXPECT_NEAR(FromHalfFloat(half_floats[i]), integers[i] * multiplier, |
| 560 expected_precision) | 563 expected_precision) |
| 561 << "i = " << i << " bits = " << bits; | 564 << "i = " << i << " bits = " << bits; |
| 562 } | 565 } |
| 563 } | 566 } |
| 564 } | 567 } |
| 565 | 568 |
| 566 } // namespace | 569 } // namespace |
| 567 } // namespace cc | 570 } // namespace cc |
| OLD | NEW |