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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 for (int y = 0; y < lut_samples; y++) { | 64 for (int y = 0; y < lut_samples; y++) { |
65 *(lutp++) = FloatToLUT(samples[y].x()); | 65 *(lutp++) = FloatToLUT(samples[y].x()); |
66 *(lutp++) = FloatToLUT(samples[y].y()); | 66 *(lutp++) = FloatToLUT(samples[y].y()); |
67 *(lutp++) = FloatToLUT(samples[y].z()); | 67 *(lutp++) = FloatToLUT(samples[y].z()); |
68 *(lutp++) = 255; // alpha | 68 *(lutp++) = 255; // alpha |
69 } | 69 } |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 unsigned int lut_texture; | 73 unsigned int lut_texture; |
| 74 // gl_->GenTextures(1, &lut_texture); |
| 75 // gl_->BindTexture(GL_TEXTURE_3D, lut_texture); |
74 gl_->GenTextures(1, &lut_texture); | 76 gl_->GenTextures(1, &lut_texture); |
75 gl_->BindTexture(GL_TEXTURE_2D, lut_texture); | 77 gl_->BindTexture(GL_TEXTURE_2D, lut_texture); |
76 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 78 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
77 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 79 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
78 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 80 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
79 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 81 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
80 gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, lut_samples, | 82 gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, lut_samples, |
81 lut_samples * lut_samples, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 83 lut_samples * lut_samples, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
82 lut.data()); | 84 lut.data()); |
83 return lut_texture; | 85 return lut_texture; |
(...skipping 16 matching lines...) Expand all Loading... |
100 | 102 |
101 void ColorLUTCache::Swap() { | 103 void ColorLUTCache::Swap() { |
102 current_frame_++; | 104 current_frame_++; |
103 while (!lut_cache_.empty() && | 105 while (!lut_cache_.empty() && |
104 current_frame_ - lut_cache_.rbegin()->second.last_used_frame > | 106 current_frame_ - lut_cache_.rbegin()->second.last_used_frame > |
105 kMaxFramesUnused) { | 107 kMaxFramesUnused) { |
106 gl_->DeleteTextures(1, &lut_cache_.rbegin()->second.texture); | 108 gl_->DeleteTextures(1, &lut_cache_.rbegin()->second.texture); |
107 lut_cache_.ShrinkToSize(lut_cache_.size() - 1); | 109 lut_cache_.ShrinkToSize(lut_cache_.size() - 1); |
108 } | 110 } |
109 } | 111 } |
OLD | NEW |