Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: cc/output/color_lut_cache.cc

Issue 2769863003: cc: Add pixel tests for transfer function shaders (Closed)
Patch Set: Leave transfer substitutions unchanged Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/output/gl_renderer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 lut_samples * 3); 74 lut_samples * 3);
75 for (int i = 0; i < lut_samples; i++) { 75 for (int i = 0; i < lut_samples; i++) {
76 *(lutp++) = *(lutp2++); 76 *(lutp++) = *(lutp2++);
77 *(lutp++) = *(lutp2++); 77 *(lutp++) = *(lutp2++);
78 *(lutp++) = *(lutp2++); 78 *(lutp++) = *(lutp2++);
79 *(lutp++) = alpha; 79 *(lutp++) = alpha;
80 } 80 }
81 } 81 }
82 } 82 }
83 83
84 unsigned int lut_texture; 84 GLuint previously_bound_texture = 0;
85 GLuint lut_texture = 0;
86 gl_->GetIntegerv(GL_TEXTURE_BINDING_2D,
87 reinterpret_cast<GLint*>(&previously_bound_texture));
85 gl_->GenTextures(1, &lut_texture); 88 gl_->GenTextures(1, &lut_texture);
86 gl_->BindTexture(GL_TEXTURE_2D, lut_texture); 89 gl_->BindTexture(GL_TEXTURE_2D, lut_texture);
87 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 90 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
88 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 91 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
89 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 92 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
90 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 93 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
91 gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, lut_samples, 94 gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, lut_samples,
92 lut_samples * lut_samples, 0, GL_RGBA, 95 lut_samples * lut_samples, 0, GL_RGBA,
93 sizeof(T) == 1 ? GL_UNSIGNED_BYTE : GL_HALF_FLOAT_OES, 96 sizeof(T) == 1 ? GL_UNSIGNED_BYTE : GL_HALF_FLOAT_OES,
94 lut.data()); 97 lut.data());
98 gl_->BindTexture(GL_TEXTURE_2D, previously_bound_texture);
95 return lut_texture; 99 return lut_texture;
96 } 100 }
97 101
98 ColorLUTCache::LUT ColorLUTCache::GetLUT(const gfx::ColorTransform* transform) { 102 ColorLUTCache::LUT ColorLUTCache::GetLUT(const gfx::ColorTransform* transform) {
99 auto iter = lut_cache_.Get(transform); 103 auto iter = lut_cache_.Get(transform);
100 if (iter != lut_cache_.end()) { 104 if (iter != lut_cache_.end()) {
101 iter->second.last_used_frame = current_frame_; 105 iter->second.last_used_frame = current_frame_;
102 return iter->second.lut; 106 return iter->second.lut;
103 } 107 }
104 108
(...skipping 16 matching lines...) Expand all
121 125
122 void ColorLUTCache::Swap() { 126 void ColorLUTCache::Swap() {
123 current_frame_++; 127 current_frame_++;
124 while (!lut_cache_.empty() && 128 while (!lut_cache_.empty() &&
125 current_frame_ - lut_cache_.rbegin()->second.last_used_frame > 129 current_frame_ - lut_cache_.rbegin()->second.last_used_frame >
126 kMaxFramesUnused) { 130 kMaxFramesUnused) {
127 gl_->DeleteTextures(1, &lut_cache_.rbegin()->second.lut.texture); 131 gl_->DeleteTextures(1, &lut_cache_.rbegin()->second.lut.texture);
128 lut_cache_.ShrinkToSize(lut_cache_.size() - 1); 132 lut_cache_.ShrinkToSize(lut_cache_.size() - 1);
129 } 133 }
130 } 134 }
OLDNEW
« no previous file with comments | « no previous file | cc/output/gl_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698