Debian Codegraph @

third_party/etc2comp/EtcLib/EtcCodec/EtcBlock4x4Encoding_RGB8A1.h

raw
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
17 #pragma once
18
19 #include "EtcBlock4x4Encoding_RGB8.h"
20 #include "EtcErrorMetric.h"
21 #include "EtcBlock4x4EncodingBits.h"
22
23 namespace Etc
24 {
25
26 // ################################################################################
27 // Block4x4Encoding_RGB8A1
28 // RGB8A1 if not completely opaque or transparent
29 // ################################################################################
30
31 class Block4x4Encoding_RGB8A1 : public Block4x4Encoding_RGB8
32 {
33 public:
34
35 static const unsigned int TRANSPARENT_SELECTOR = 2;
36
37 Block4x4Encoding_RGB8A1(void);
38 virtual ~Block4x4Encoding_RGB8A1(void);
39
40 virtual void InitFromSource(Block4x4 *a_pblockParent,
41 ColorFloatRGBA *a_pafrgbaSource,
42 unsigned char *a_paucEncodingBits,
43 ErrorMetric a_errormetric);
44
45 virtual void InitFromEncodingBits(Block4x4 *a_pblockParent,
46 unsigned char *a_paucEncodingBits,
47 ColorFloatRGBA *a_pafrgbaSource,
48 ErrorMetric a_errormetric);
49
50 virtual void PerformIteration(float a_fEffort);
51
52 virtual void SetEncodingBits(void);
53
54 void InitFromEncodingBits_ETC1(Block4x4 *a_pblockParent,
55 unsigned char *a_paucEncodingBits,
56 ColorFloatRGBA *a_pafrgbaSource,
57 ErrorMetric a_errormetric);
58
59 void InitFromEncodingBits_T(void);
60 void InitFromEncodingBits_H(void);
61
62 void PerformFirstIteration(void);
63
64 void Decode_ETC1(void);
65 void DecodePixels_T(void);
66 void DecodePixels_H(void);
67 void SetEncodingBits_ETC1(void);
68 void SetEncodingBits_T(void);
69 void SetEncodingBits_H(void);
70
71 protected:
72
73 bool m_boolOpaque; // all source pixels have alpha >= 0.5
74 bool m_boolTransparent; // all source pixels have alpha < 0.5
75 bool m_boolPunchThroughPixels; // some source pixels have alpha < 0.5
76
77 static float s_aafCwOpaqueUnsetTable[CW_RANGES][SELECTORS];
78
79 private:
80
81 void TryDifferential(bool a_boolFlip, unsigned int a_uiRadius,
82 int a_iGrayOffset1, int a_iGrayOffset2);
83 void TryDifferentialHalf(DifferentialTrys::Half *a_phalf);
84
85 void TryT(unsigned int a_uiRadius);
86 void TryT_BestSelectorCombination(void);
87 void TryH(unsigned int a_uiRadius);
88 void TryH_BestSelectorCombination(void);
89
90 void TryDegenerates1(void);
91 void TryDegenerates2(void);
92 void TryDegenerates3(void);
93 void TryDegenerates4(void);
94
95 };
96
97 // ################################################################################
98 // Block4x4Encoding_RGB8A1_Opaque
99 // RGB8A1 if all pixels have alpha==1
100 // ################################################################################
101
102 class Block4x4Encoding_RGB8A1_Opaque : public Block4x4Encoding_RGB8A1
103 {
104 public:
105
106 virtual void PerformIteration(float a_fEffort);
107
108 void PerformFirstIteration(void);
109
110 private:
111
112 };
113
114 // ################################################################################
115 // Block4x4Encoding_RGB8A1_Transparent
116 // RGB8A1 if all pixels have alpha==0
117 // ################################################################################
118
119 class Block4x4Encoding_RGB8A1_Transparent : public Block4x4Encoding_RGB8A1
120 {
121 public:
122
123 virtual void PerformIteration(float a_fEffort);
124
125 private:
126
127 };
128
129 } // namespace Etc