| 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 #ifndef CC_OUTPUT_COLOR_LUT_CACHE_H_ | 5 #ifndef CC_OUTPUT_COLOR_LUT_CACHE_H_ |
| 6 #define CC_OUTPUT_COLOR_LUT_CACHE_H_ | 6 #define CC_OUTPUT_COLOR_LUT_CACHE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/containers/mru_cache.h" | 10 #include "base/containers/mru_cache.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "ui/gfx/color_space.h" | 12 #include "ui/gfx/color_space.h" |
| 13 | 13 |
| 14 namespace gpu { | 14 namespace gpu { |
| 15 namespace gles2 { | 15 namespace gles2 { |
| 16 class GLES2Interface; | 16 class GLES2Interface; |
| 17 } | 17 } |
| 18 } | 18 } |
| 19 | 19 |
| 20 class ColorLUTCache { | 20 class ColorLUTCache { |
| 21 public: | 21 public: |
| 22 explicit ColorLUTCache(gpu::gles2::GLES2Interface* gl); | 22 explicit ColorLUTCache(gpu::gles2::GLES2Interface* gl, |
| 23 bool texture_half_float_linear); |
| 23 ~ColorLUTCache(); | 24 ~ColorLUTCache(); |
| 24 | 25 |
| 25 unsigned int GetLUT(const gfx::ColorSpace& from, | 26 struct LUT { |
| 26 const gfx::ColorSpace& to, | 27 unsigned int texture; |
| 27 int lut_samples); | 28 int size; |
| 29 }; |
| 30 |
| 31 LUT GetLUT(const gfx::ColorSpace& from, const gfx::ColorSpace& to); |
| 28 | 32 |
| 29 // End of frame, assume all LUTs handed out are no longer used. | 33 // End of frame, assume all LUTs handed out are no longer used. |
| 30 void Swap(); | 34 void Swap(); |
| 31 | 35 |
| 32 private: | 36 private: |
| 37 template <typename T> |
| 33 unsigned int MakeLUT(const gfx::ColorSpace& from, | 38 unsigned int MakeLUT(const gfx::ColorSpace& from, |
| 34 gfx::ColorSpace to, | 39 gfx::ColorSpace to, |
| 35 int lut_samples); | 40 int lut_samples); |
| 36 | 41 |
| 37 typedef std::pair<gfx::ColorSpace, std::pair<gfx::ColorSpace, size_t>> | 42 typedef std::pair<gfx::ColorSpace, gfx::ColorSpace> CacheKey; |
| 38 CacheKey; | |
| 39 | 43 |
| 40 struct CacheVal { | 44 struct CacheVal { |
| 41 CacheVal(unsigned int texture, uint32_t last_used_frame) | 45 CacheVal(LUT lut, uint32_t last_used_frame) |
| 42 : texture(texture), last_used_frame(last_used_frame) {} | 46 : lut(lut), last_used_frame(last_used_frame) {} |
| 43 unsigned int texture; | 47 LUT lut; |
| 44 uint32_t last_used_frame; | 48 uint32_t last_used_frame; |
| 45 }; | 49 }; |
| 46 | 50 |
| 47 base::MRUCache<CacheKey, CacheVal> lut_cache_; | 51 base::MRUCache<CacheKey, CacheVal> lut_cache_; |
| 48 uint32_t current_frame_; | 52 uint32_t current_frame_; |
| 49 gpu::gles2::GLES2Interface* gl_; | 53 gpu::gles2::GLES2Interface* gl_; |
| 54 bool texture_half_float_linear_; |
| 50 DISALLOW_COPY_AND_ASSIGN(ColorLUTCache); | 55 DISALLOW_COPY_AND_ASSIGN(ColorLUTCache); |
| 51 }; | 56 }; |
| 52 | 57 |
| 53 #endif // CC_OUTPUT_COLOR_LUT_CACHE_H_ | 58 #endif // CC_OUTPUT_COLOR_LUT_CACHE_H_ |
| OLD | NEW |