Skip to content

Commit

Permalink
Revert "add 'eagle2x' pixel scaler"
Browse files Browse the repository at this point in the history
This reverts commit ce5ae88.
  • Loading branch information
cyxx committed Feb 26, 2018
1 parent c5ba850 commit b96ea95
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 35 deletions.
52 changes: 19 additions & 33 deletions scaler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ void point2x(uint16_t *dst, int dstPitch, const uint16_t *src, int srcPitch, int
while (h--) {
uint16_t *p = dst;
for (int i = 0; i < w; ++i, p += 2) {
const uint16_t color = *(src + i);
p[0] = p[1] = color;
p[dstPitch] = p[dstPitch + 1] = color;
uint16_t c = *(src + i);
*(p) = c;
*(p + 1) = c;
*(p + dstPitch) = c;
*(p + dstPitch + 1) = c;
}
dst += dstPitch * 2;
src += srcPitch;
Expand All @@ -30,10 +32,16 @@ void point3x(uint16_t *dst, int dstPitch, const uint16_t *src, int srcPitch, int
while (h--) {
uint16_t *p = dst;
for (int i = 0; i < w; ++i, p += 3) {
const uint16_t color = *(src + i);
p[0] = p[1] = p[2] = color;
p[dstPitch] = p[dstPitch + 1] = p[dstPitch + 2] = color;
p[dstPitch * 2] = p[dstPitch * 2 + 1] = p[dstPitch * 2 + 2] = color;
uint16_t c = *(src + i);
*(p) = c;
*(p + 1) = c;
*(p + 2) = c;
*(p + dstPitch) = c;
*(p + dstPitch + 1) = c;
*(p + dstPitch + 2) = c;
*(p + 2 * dstPitch) = c;
*(p + 2 * dstPitch + 1) = c;
*(p + 2 * dstPitch + 2) = c;
}
dst += dstPitch * 3;
src += srcPitch;
Expand All @@ -45,10 +53,10 @@ void scale2x(uint16_t *dst, int dstPitch, const uint16_t *src, int srcPitch, int
uint16_t *p = dst;
for (int x = 0; x < w; ++x, p += 2) {
const uint16_t E = *(src + x);
const uint16_t B = (y == 0) ? E : *(src + x - srcPitch);
const uint16_t D = (x == 0) ? E : *(src + x - 1);
const uint16_t F = (x == w - 1) ? E : *(src + x + 1);
const uint16_t H = (y == h - 1) ? E : *(src + x + srcPitch);
uint16_t B = (y == 0) ? E : *(src + x - srcPitch);
uint16_t D = (x == 0) ? E : *(src + x - 1);
uint16_t F = (x == w - 1) ? E : *(src + x + 1);
uint16_t H = (y == h - 1) ? E : *(src + x + srcPitch);
if (B != H && D != F) {
*(p) = D == B ? D : E;
*(p + 1) = B == F ? F : E;
Expand Down Expand Up @@ -118,25 +126,3 @@ void scale3x(uint16_t *dst, int dstPitch, const uint16_t *src, int srcPitch, int
}
}

void eagle2x(uint16_t *dst, int dstPitch, const uint16_t *src, int srcPitch, int w, int h) {
for (int y = 0; y < h; ++y) {
uint16_t *p = dst;
for (int x = 0; x < w; ++x, p += 2) {
const uint16_t C = *(src + x);
const uint16_t S = (y == 0 || x == 0) ? C : *(src + x - 1 - srcPitch);
const uint16_t T = (y == 0) ? C : *(src + x - srcPitch);
const uint16_t U = (y == 0 || x == w - 1) ? C : *(src + x + 1 - srcPitch);
const uint16_t V = (x == 0) ? C : *(src + x - 1);
const uint16_t X = (x == 0 || y == h - 1) ? C : *(src + x - 1 + srcPitch);
const uint16_t W = (x == w - 1) ? C : *(src + x + 1);
const uint16_t Y = (y == h - 1) ? C : *(src + x + srcPitch);
const uint16_t Z = (x == w - 1 || y == h - 1) ? C : *(src + x + 1 + srcPitch);
*(p) = (V == S && S == T) ? S : C;
*(p + 1) = (T == U && U == W) ? U : C;
*(p + dstPitch) = (V == X && X == Y) ? X : C;
*(p + dstPitch + 1) = (W == Z && Z == Y) ? Z : C;
}
dst += dstPitch * 2;
src += srcPitch;
}
}
1 change: 0 additions & 1 deletion scaler.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ void point2x(uint16_t *dst, int dstPitch, const uint16_t *src, int srcPitch, int
void point3x(uint16_t *dst, int dstPitch, const uint16_t *src, int srcPitch, int w, int h);
void scale2x(uint16_t *dst, int dstPitch, const uint16_t *src, int srcPitch, int w, int h);
void scale3x(uint16_t *dst, int dstPitch, const uint16_t *src, int srcPitch, int w, int h);
void eagle2x(uint16_t *dst, int dstPitch, const uint16_t *src, int srcPitch, int w, int h);

#endif // SCALER_H__
1 change: 0 additions & 1 deletion texturecache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ static const struct {
{ point1x, "point1x", 1 },
{ point2x, "point2x", 2 },
{ scale2x, "scale2x", 2 },
{ eagle2x, "eagle2x", 2 },
{ point3x, "point3x", 3 },
{ scale3x, "scale3x", 3 },
{ 0, 0, 0 },
Expand Down

0 comments on commit b96ea95

Please sign in to comment.