Debian Codegraph @

third_party/etc2comp/EtcLib/EtcCodec/EtcIndividualTrys.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 "EtcColorFloatRGBA.h"
20
21 namespace Etc
22 {
23
24 class IndividualTrys
25 {
26 public:
27
28 static const unsigned int MAX_RADIUS = 1;
29
30 IndividualTrys(ColorFloatRGBA a_frgbaColor1,
31 ColorFloatRGBA a_frgbaColor2,
32 const unsigned int *a_pauiPixelMapping1,
33 const unsigned int *a_pauiPixelMapping2,
34 unsigned int a_uiRadius);
35
36 inline static int MoveAwayFromEdge(int a_i, int a_iDistance)
37 {
38 if (a_i < (0+ a_iDistance))
39 {
40 return (0 + a_iDistance);
41 }
42 else if (a_i > (15- a_iDistance))
43 {
44 return (15 - a_iDistance);
45 }
46
47 return a_i;
48 }
49
50 class Try
51 {
52 public :
53 static const unsigned int SELECTORS = 8; // per half
54
55 int m_iRed;
56 int m_iGreen;
57 int m_iBlue;
58 unsigned int m_uiCW;
59 unsigned int m_auiSelectors[SELECTORS];
60 float m_fError;
61 };
62
63 class Half
64 {
65 public:
66
67 static const unsigned int MAX_TRYS = 27;
68
69 void Init(int a_iRed, int a_iGreen, int a_iBlue,
70 const unsigned int *a_pauiPixelMapping,
71 unsigned int a_uiRadius);
72
73 // center of trys
74 int m_iRed;
75 int m_iGreen;
76 int m_iBlue;
77
78 const unsigned int *m_pauiPixelMapping;
79 unsigned int m_uiRadius;
80
81 unsigned int m_uiTrys;
82 Try m_atry[MAX_TRYS];
83
84 Try *m_ptryBest;
85 };
86
87 Half m_half1;
88 Half m_half2;
89
90 };
91
92 // ----------------------------------------------------------------------------------------------------
93 //
94
95 } // namespace Etc