OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/output/color_lut_cache.h" | 5 #include "cc/output/color_lut_cache.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 if (to == gfx::ColorSpace()) { | 44 if (to == gfx::ColorSpace()) { |
45 to = gfx::ColorSpace::CreateSRGB(); | 45 to = gfx::ColorSpace::CreateSRGB(); |
46 } | 46 } |
47 std::unique_ptr<gfx::ColorTransform> transform( | 47 std::unique_ptr<gfx::ColorTransform> transform( |
48 gfx::ColorTransform::NewColorTransform( | 48 gfx::ColorTransform::NewColorTransform( |
49 from, to, gfx::ColorTransform::Intent::INTENT_PERCEPTUAL)); | 49 from, to, gfx::ColorTransform::Intent::INTENT_PERCEPTUAL)); |
50 | 50 |
51 int lut_entries = lut_samples * lut_samples * lut_samples; | 51 int lut_entries = lut_samples * lut_samples * lut_samples; |
52 float inverse = 1.0f / (lut_samples - 1); | 52 float inverse = 1.0f / (lut_samples - 1); |
53 std::vector<unsigned char> lut(lut_entries * 4); | 53 std::vector<unsigned char> lut(lut_entries * 4); |
54 std::vector<gfx::ColorTransform::TriStim> samples(lut_samples * 3); | 54 std::vector<gfx::ColorTransform::TriStim> samples(lut_samples); |
55 unsigned char* lutp = lut.data(); | 55 unsigned char* lutp = lut.data(); |
56 for (int y = 0; y < lut_samples; y++) { | 56 for (int y = 0; y < lut_samples; y++) { |
57 for (int v = 0; v < lut_samples; v++) { | 57 for (int v = 0; v < lut_samples; v++) { |
58 for (int u = 0; u < lut_samples; u++) { | 58 for (int u = 0; u < lut_samples; u++) { |
59 samples[u].set_x(y * inverse); | 59 samples[u].set_x(y * inverse); |
danakj
2016/09/29 20:09:08
Wait.. this is setting samples[0] once for each va
hubbe
2016/09/29 20:31:52
It's not *keeping* any of the values.
We iterate o
danakj
2016/09/29 20:38:07
Ah, the transform() happens for each y and v also,
| |
60 samples[u].set_y(u * inverse); | 60 samples[u].set_y(u * inverse); |
61 samples[u].set_z(v * inverse); | 61 samples[u].set_z(v * inverse); |
62 } | 62 } |
63 transform->transform(samples.data(), samples.size()); | 63 transform->transform(samples.data(), samples.size()); |
64 for (int u = 0; u < lut_samples; u++) { | 64 for (int u = 0; u < lut_samples; u++) { |
65 *(lutp++) = FloatToLUT(samples[u].x()); | 65 *(lutp++) = FloatToLUT(samples[u].x()); |
66 *(lutp++) = FloatToLUT(samples[u].y()); | 66 *(lutp++) = FloatToLUT(samples[u].y()); |
67 *(lutp++) = FloatToLUT(samples[u].z()); | 67 *(lutp++) = FloatToLUT(samples[u].z()); |
68 *(lutp++) = 255; // alpha | 68 *(lutp++) = 255; // alpha |
69 } | 69 } |
(...skipping 30 matching lines...) Expand all Loading... | |
100 | 100 |
101 void ColorLUTCache::Swap() { | 101 void ColorLUTCache::Swap() { |
102 current_frame_++; | 102 current_frame_++; |
103 while (!lut_cache_.empty() && | 103 while (!lut_cache_.empty() && |
104 current_frame_ - lut_cache_.rbegin()->second.first > | 104 current_frame_ - lut_cache_.rbegin()->second.first > |
105 kMaxFramesUnused) { | 105 kMaxFramesUnused) { |
106 gl_->DeleteTextures(1, &lut_cache_.rbegin()->second.first); | 106 gl_->DeleteTextures(1, &lut_cache_.rbegin()->second.first); |
107 lut_cache_.ShrinkToSize(lut_cache_.size() - 1); | 107 lut_cache_.ShrinkToSize(lut_cache_.size() - 1); |
108 } | 108 } |
109 } | 109 } |
OLD | NEW |