| 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 <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "gpu/command_buffer/client/gles2_interface.h" | 11 #include "gpu/command_buffer/client/gles2_interface.h" |
| 11 #include "ui/gfx/color_transform.h" | 12 #include "ui/gfx/color_transform.h" |
| 12 | 13 |
| 13 // After a LUT has not been used for this many frames, we release it. | 14 // After a LUT has not been used for this many frames, we release it. |
| 14 const uint32_t kMaxFramesUnused = 10; | 15 const uint32_t kMaxFramesUnused = 10; |
| 15 | 16 |
| 16 ColorLUTCache::ColorLUTCache(gpu::gles2::GLES2Interface* gl) | 17 ColorLUTCache::ColorLUTCache(gpu::gles2::GLES2Interface* gl) |
| 17 : lut_cache_(0), gl_(gl) {} | 18 : lut_cache_(0), gl_(gl) {} |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 100 |
| 100 void ColorLUTCache::Swap() { | 101 void ColorLUTCache::Swap() { |
| 101 current_frame_++; | 102 current_frame_++; |
| 102 while (!lut_cache_.empty() && | 103 while (!lut_cache_.empty() && |
| 103 current_frame_ - lut_cache_.rbegin()->second.first > | 104 current_frame_ - lut_cache_.rbegin()->second.first > |
| 104 kMaxFramesUnused) { | 105 kMaxFramesUnused) { |
| 105 gl_->DeleteTextures(1, &lut_cache_.rbegin()->second.first); | 106 gl_->DeleteTextures(1, &lut_cache_.rbegin()->second.first); |
| 106 lut_cache_.ShrinkToSize(lut_cache_.size() - 1); | 107 lut_cache_.ShrinkToSize(lut_cache_.size() - 1); |
| 107 } | 108 } |
| 108 } | 109 } |
| OLD | NEW |