| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 UI_GFX_COLOR_TRANSFORM_H_ | 5 #ifndef UI_GFX_COLOR_TRANSFORM_H_ |
| 6 #define UI_GFX_COLOR_TRANSFORM_H_ | 6 #define UI_GFX_COLOR_TRANSFORM_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "ui/gfx/geometry/point3_f.h" | 12 #include "ui/gfx/geometry/point3_f.h" |
| 13 #include "ui/gfx/gfx_export.h" | 13 #include "ui/gfx/gfx_export.h" |
| 14 #include "ui/gfx/transform.h" |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 | 17 |
| 17 class ColorSpace; | 18 class ColorSpace; |
| 18 | 19 |
| 19 class GFX_EXPORT ColorTransform { | 20 class GFX_EXPORT ColorTransform { |
| 20 public: | 21 public: |
| 21 enum class Intent { INTENT_ABSOLUTE, INTENT_PERCEPTUAL }; | 22 enum class Intent { INTENT_ABSOLUTE, INTENT_PERCEPTUAL }; |
| 22 | 23 |
| 23 // TriStimulus is a color coordinate in any color space. | 24 // TriStimulus is a color coordinate in any color space. |
| 24 // Channel order is XYZ, RGB or YUV. | 25 // Channel order is XYZ, RGB or YUV. |
| 25 typedef Point3F TriStim; | 26 typedef Point3F TriStim; |
| 26 | 27 |
| 27 virtual ~ColorTransform() {} | 28 virtual ~ColorTransform() {} |
| 28 | 29 |
| 29 // Perform transformation of colors, |colors| is both input and output. | 30 // Perform transformation of colors, |colors| is both input and output. |
| 30 virtual void transform(TriStim* colors, size_t num) = 0; | 31 virtual void transform(TriStim* colors, size_t num) const = 0; |
| 32 |
| 33 // Create an affine approximation of this transform. No guarantees |
| 34 // are made as to how accurate the approximation is. |
| 35 // Returns true if successful, false if there was a failure. |
| 36 // This operation can be somewhat costly, considering caching the result |
| 37 // if you plan to use this frequently. |
| 38 virtual bool GetAffineApproximation(Transform* transform) const; |
| 31 | 39 |
| 32 static std::unique_ptr<ColorTransform> NewColorTransform( | 40 static std::unique_ptr<ColorTransform> NewColorTransform( |
| 33 const ColorSpace& from, | 41 const ColorSpace& from, |
| 34 const ColorSpace& to, | 42 const ColorSpace& to, |
| 35 Intent intent); | 43 Intent intent); |
| 36 }; | 44 }; |
| 37 } // namespace gfx | 45 } // namespace gfx |
| 38 | 46 |
| 39 #endif // UI_GFX_COLOR_TRANSFORM_H_ | 47 #endif // UI_GFX_COLOR_TRANSFORM_H_ |
| OLD | NEW |