summaryrefslogtreecommitdiff
path: root/src/static_libs/rg_etc
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-05-07 17:08:19 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-05-27 12:21:43 +0900
commit939b5e47a0c44b99142a251531931c763ee96beb (patch)
tree8f7e25ac57a796069aae5040cdc935dac8e7444d /src/static_libs/rg_etc
parent525bc4117ac8521eacc8bbcf646dec6a6537da3d (diff)
Evas rg_etc2: Small performance fix
Alpha is always 255 otherwise we need to loop around and clamp the values to 255 anyways.
Diffstat (limited to 'src/static_libs/rg_etc')
-rw-r--r--src/static_libs/rg_etc/rg_etc2.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/static_libs/rg_etc/rg_etc2.c b/src/static_libs/rg_etc/rg_etc2.c
index 0aa43b0838..557184651b 100644
--- a/src/static_libs/rg_etc/rg_etc2.c
+++ b/src/static_libs/rg_etc/rg_etc2.c
@@ -114,7 +114,7 @@ static const int kAlphaModifiers[16][8] = {
114 114
115 115
116static inline void 116static inline void
117_T_mode_color_read(const uint8_t *etc, uint32_t *paint_colors, int alpha) 117_T_mode_color_read(const uint8_t *etc, uint32_t *paint_colors)
118{ 118{
119 // 4 bit colors 119 // 4 bit colors
120 const int r1_4 = (BITS(etc[0], 3, 4) << 2) | BITS(etc[0], 0, 1); 120 const int r1_4 = (BITS(etc[0], 3, 4) << 2) | BITS(etc[0], 0, 1);
@@ -129,20 +129,20 @@ _T_mode_color_read(const uint8_t *etc, uint32_t *paint_colors, int alpha)
129 const int d = kDistances[didx]; 129 const int d = kDistances[didx];
130 130
131 // Write out paint colors for T mode 131 // Write out paint colors for T mode
132 paint_colors[0] = BGRA(_4to8(r1_4), _4to8(g1_4), _4to8(b1_4), alpha); 132 paint_colors[0] = BGRA(_4to8(r1_4), _4to8(g1_4), _4to8(b1_4), 255);
133 paint_colors[1] = BGRA(CLAMPDOWN(_4to8(r2_4) + d), 133 paint_colors[1] = BGRA(CLAMPDOWN(_4to8(r2_4) + d),
134 CLAMPDOWN(_4to8(g2_4) + d), 134 CLAMPDOWN(_4to8(g2_4) + d),
135 CLAMPDOWN(_4to8(b2_4) + d), 135 CLAMPDOWN(_4to8(b2_4) + d),
136 alpha); 136 255);
137 paint_colors[2] = BGRA(_4to8(r2_4), _4to8(g2_4), _4to8(b2_4), alpha); 137 paint_colors[2] = BGRA(_4to8(r2_4), _4to8(g2_4), _4to8(b2_4), 255);
138 paint_colors[3] = BGRA(CLAMPUP(_4to8(r2_4) - d), 138 paint_colors[3] = BGRA(CLAMPUP(_4to8(r2_4) - d),
139 CLAMPUP(_4to8(g2_4) - d), 139 CLAMPUP(_4to8(g2_4) - d),
140 CLAMPUP(_4to8(b2_4) - d), 140 CLAMPUP(_4to8(b2_4) - d),
141 alpha); 141 255);
142} 142}
143 143
144static inline void 144static inline void
145_H_mode_color_read(const uint8_t *etc, uint32_t *paint_colors, int alpha) 145_H_mode_color_read(const uint8_t *etc, uint32_t *paint_colors)
146{ 146{
147 // 4 bit colors 147 // 4 bit colors
148 const int r1_4 = BITS(etc[0], 3, 6); 148 const int r1_4 = BITS(etc[0], 3, 6);
@@ -165,23 +165,23 @@ _H_mode_color_read(const uint8_t *etc, uint32_t *paint_colors, int alpha)
165 paint_colors[0] = BGRA(CLAMPDOWN(_4to8(r1_4) + d), 165 paint_colors[0] = BGRA(CLAMPDOWN(_4to8(r1_4) + d),
166 CLAMPDOWN(_4to8(g1_4) + d), 166 CLAMPDOWN(_4to8(g1_4) + d),
167 CLAMPDOWN(_4to8(b1_4) + d), 167 CLAMPDOWN(_4to8(b1_4) + d),
168 alpha); 168 255);
169 paint_colors[1] = BGRA(CLAMPUP(_4to8(r1_4) - d), 169 paint_colors[1] = BGRA(CLAMPUP(_4to8(r1_4) - d),
170 CLAMPUP(_4to8(g1_4) - d), 170 CLAMPUP(_4to8(g1_4) - d),
171 CLAMPUP(_4to8(b1_4) - d), 171 CLAMPUP(_4to8(b1_4) - d),
172 alpha); 172 255);
173 paint_colors[2] = BGRA(CLAMPDOWN(_4to8(r2_4) + d), 173 paint_colors[2] = BGRA(CLAMPDOWN(_4to8(r2_4) + d),
174 CLAMPDOWN(_4to8(g2_4) + d), 174 CLAMPDOWN(_4to8(g2_4) + d),
175 CLAMPDOWN(_4to8(b2_4) + d), 175 CLAMPDOWN(_4to8(b2_4) + d),
176 alpha); 176 255);
177 paint_colors[3] = BGRA(CLAMPUP(_4to8(r2_4) - d), 177 paint_colors[3] = BGRA(CLAMPUP(_4to8(r2_4) - d),
178 CLAMPUP(_4to8(g2_4) - d), 178 CLAMPUP(_4to8(g2_4) - d),
179 CLAMPUP(_4to8(b2_4) - d), 179 CLAMPUP(_4to8(b2_4) - d),
180 alpha); 180 255);
181} 181}
182 182
183static inline void 183static inline void
184_planar_mode_color_read(const uint8_t *etc, uint32_t *bgra, int alpha) 184_planar_mode_color_read(const uint8_t *etc, uint32_t *bgra)
185{ 185{
186 // RO: Bits 57-62 186 // RO: Bits 57-62
187 const int RO = _6to8(BITS(etc[0], 1, 6)); 187 const int RO = _6to8(BITS(etc[0], 1, 6));
@@ -209,7 +209,7 @@ _planar_mode_color_read(const uint8_t *etc, uint32_t *bgra, int alpha)
209 const int R = CLAMP(((x * (RH - RO)) + y * (RV - RO) + 4 * RO + 2) >> 2); 209 const int R = CLAMP(((x * (RH - RO)) + y * (RV - RO) + 4 * RO + 2) >> 2);
210 const int G = CLAMP(((x * (GH - GO)) + y * (GV - GO) + 4 * GO + 2) >> 2); 210 const int G = CLAMP(((x * (GH - GO)) + y * (GV - GO) + 4 * GO + 2) >> 2);
211 const int B = CLAMP(((x * (BH - BO)) + y * (BV - BO) + 4 * BO + 2) >> 2); 211 const int B = CLAMP(((x * (BH - BO)) + y * (BV - BO) + 4 * BO + 2) >> 2);
212 *bgra++ = BGRA(R, G, B, alpha); 212 *bgra++ = BGRA(R, G, B, 255);
213 } 213 }
214} 214}
215 215
@@ -262,21 +262,21 @@ rg_etc2_rgb8_decode_block(const uint8_t *etc, uint32_t *bgra)
262 if ((R + dR) < 0 || (R + dR) >= 32) 262 if ((R + dR) < 0 || (R + dR) >= 32)
263 { 263 {
264 // T mode 264 // T mode
265 _T_mode_color_read(etc, paint_colors, 255); 265 _T_mode_color_read(etc, paint_colors);
266 _TH_paint(etc, paint_colors, bgra); 266 _TH_paint(etc, paint_colors, bgra);
267 return; 267 return;
268 } 268 }
269 if ((G + dG) < 0 || (G + dG) >= 32) 269 if ((G + dG) < 0 || (G + dG) >= 32)
270 { 270 {
271 // H mode 271 // H mode
272 _H_mode_color_read(etc, paint_colors, 255); 272 _H_mode_color_read(etc, paint_colors);
273 _TH_paint(etc, paint_colors, bgra); 273 _TH_paint(etc, paint_colors, bgra);
274 return; 274 return;
275 } 275 }
276 if ((B + dB) < 0 || (B + dB) >= 32) 276 if ((B + dB) < 0 || (B + dB) >= 32)
277 { 277 {
278 // Planar mode 278 // Planar mode
279 _planar_mode_color_read(etc, bgra, 255); 279 _planar_mode_color_read(etc, bgra);
280 return; 280 return;
281 } 281 }
282 282