EtcBlock4x4Encoding_RGB8A1.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * Copyright 2015 The Etc2Comp Authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #pragma once
  17. #include "EtcBlock4x4Encoding_RGB8.h"
  18. #include "EtcErrorMetric.h"
  19. #include "EtcBlock4x4EncodingBits.h"
  20. namespace Etc
  21. {
  22. // ################################################################################
  23. // Block4x4Encoding_RGB8A1
  24. // RGB8A1 if not completely opaque or transparent
  25. // ################################################################################
  26. class Block4x4Encoding_RGB8A1 : public Block4x4Encoding_RGB8
  27. {
  28. public:
  29. static const unsigned int TRANSPARENT_SELECTOR = 2;
  30. Block4x4Encoding_RGB8A1(void);
  31. virtual ~Block4x4Encoding_RGB8A1(void);
  32. virtual void InitFromSource(Block4x4 *a_pblockParent,
  33. ColorFloatRGBA *a_pafrgbaSource,
  34. unsigned char *a_paucEncodingBits,
  35. ErrorMetric a_errormetric);
  36. virtual void InitFromEncodingBits(Block4x4 *a_pblockParent,
  37. unsigned char *a_paucEncodingBits,
  38. ColorFloatRGBA *a_pafrgbaSource,
  39. ErrorMetric a_errormetric);
  40. virtual void PerformIteration(float a_fEffort);
  41. virtual void SetEncodingBits(void);
  42. void InitFromEncodingBits_ETC1(Block4x4 *a_pblockParent,
  43. unsigned char *a_paucEncodingBits,
  44. ColorFloatRGBA *a_pafrgbaSource,
  45. ErrorMetric a_errormetric);
  46. void InitFromEncodingBits_T(void);
  47. void InitFromEncodingBits_H(void);
  48. void PerformFirstIteration(void);
  49. void Decode_ETC1(void);
  50. void DecodePixels_T(void);
  51. void DecodePixels_H(void);
  52. void SetEncodingBits_ETC1(void);
  53. void SetEncodingBits_T(void);
  54. void SetEncodingBits_H(void);
  55. protected:
  56. bool m_boolOpaque; // all source pixels have alpha >= 0.5
  57. bool m_boolTransparent; // all source pixels have alpha < 0.5
  58. bool m_boolPunchThroughPixels; // some source pixels have alpha < 0.5
  59. static float s_aafCwOpaqueUnsetTable[CW_RANGES][SELECTORS];
  60. private:
  61. void TryDifferential(bool a_boolFlip, unsigned int a_uiRadius,
  62. int a_iGrayOffset1, int a_iGrayOffset2);
  63. void TryDifferentialHalf(DifferentialTrys::Half *a_phalf);
  64. void TryT(unsigned int a_uiRadius);
  65. void TryT_BestSelectorCombination(void);
  66. void TryH(unsigned int a_uiRadius);
  67. void TryH_BestSelectorCombination(void);
  68. void TryDegenerates1(void);
  69. void TryDegenerates2(void);
  70. void TryDegenerates3(void);
  71. void TryDegenerates4(void);
  72. };
  73. // ################################################################################
  74. // Block4x4Encoding_RGB8A1_Opaque
  75. // RGB8A1 if all pixels have alpha==1
  76. // ################################################################################
  77. class Block4x4Encoding_RGB8A1_Opaque : public Block4x4Encoding_RGB8A1
  78. {
  79. public:
  80. virtual void PerformIteration(float a_fEffort);
  81. void PerformFirstIteration(void);
  82. private:
  83. };
  84. // ################################################################################
  85. // Block4x4Encoding_RGB8A1_Transparent
  86. // RGB8A1 if all pixels have alpha==0
  87. // ################################################################################
  88. class Block4x4Encoding_RGB8A1_Transparent : public Block4x4Encoding_RGB8A1
  89. {
  90. public:
  91. virtual void PerformIteration(float a_fEffort);
  92. private:
  93. };
  94. } // namespace Etc