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