Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
Remove unused sRGB mip-map support
Browse files Browse the repository at this point in the history
Change-Id: I94b27561bfaabe821af280ddc719840e5e25d106
Reviewed-on: https://skia-review.googlesource.com/148669
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
  • Loading branch information
brianosman authored and Skia Commit-Bot committed Aug 22, 2018
1 parent f14a3c0 commit 82cf64a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 478 deletions.
1 change: 0 additions & 1 deletion gn/core.gni
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ skia_core_sources = [
"$_src/core/SkSurfaceCharacterization.cpp",
"$_src/core/SkSurfacePriv.h",
"$_src/core/SkSwizzle.cpp",
"$_src/core/SkSRGB.cpp",
"$_src/core/SkTaskGroup.cpp",
"$_src/core/SkTaskGroup.h",
"$_src/core/SkTDPQueue.h",
Expand Down
202 changes: 8 additions & 194 deletions src/core/SkMipMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "SkMathPriv.h"
#include "SkNx.h"
#include "SkPM4fPriv.h"
#include "SkSRGB.h"
#include "SkTo.h"
#include "SkTypes.h"
#include <new>
Expand All @@ -38,22 +37,6 @@ struct ColorTypeFilter_8888 {
}
};

struct ColorTypeFilter_S32 {
typedef uint32_t Type;
static Sk4h Expand(uint32_t x) {
return Sk4h(sk_linear12_from_srgb[(x ) & 0xFF],
sk_linear12_from_srgb[(x >> 8) & 0xFF],
sk_linear12_from_srgb[(x >> 16) & 0xFF],
(x >> 24) << 4);
}
static uint32_t Compact(const Sk4h& x) {
return sk_linear12_to_srgb[x[0]] |
sk_linear12_to_srgb[x[1]] << 8 |
sk_linear12_to_srgb[x[2]] << 16 |
(x[3] >> 4) << 24;
}
};

struct ColorTypeFilter_565 {
typedef uint16_t Type;
static uint32_t Expand(uint16_t x) {
Expand Down Expand Up @@ -318,163 +301,6 @@ template <typename F> void downsample_3_3(void* dst, const void* src, size_t src

///////////////////////////////////////////////////////////////////////////////////////////////////

// Some sRGB specific performance optimizations.

void downsample_2_2_srgb(void* dst, const void* src, size_t srcRB, int count) {
const uint8_t* p0 = ((const uint8_t*) src);
const uint8_t* p1 = ((const uint8_t*) src) + srcRB;
uint8_t* d = (uint8_t*) dst;

// Given pixels:
// a0 b0 c0 d0 ...
// a1 b1 c1 d1 ...
// We want:
// (a0 + b0 + a1 + b1) / 4
// (c0 + d0 + c1 + d1) / 4
// ...
while (count >= 2) {
Sk8h a0c0 = Sk8h(sk_linear12_from_srgb[p0[ 0]],
sk_linear12_from_srgb[p0[ 1]],
sk_linear12_from_srgb[p0[ 2]],
p0[ 3] << 4 ,
sk_linear12_from_srgb[p0[ 8]],
sk_linear12_from_srgb[p0[ 9]],
sk_linear12_from_srgb[p0[10]],
p0[11] << 4 );
Sk8h b0d0 = Sk8h(sk_linear12_from_srgb[p0[ 4]],
sk_linear12_from_srgb[p0[ 5]],
sk_linear12_from_srgb[p0[ 6]],
p0[ 7] << 4 ,
sk_linear12_from_srgb[p0[12]],
sk_linear12_from_srgb[p0[13]],
sk_linear12_from_srgb[p0[14]],
p0[15] << 4 );
Sk8h a1c1 = Sk8h(sk_linear12_from_srgb[p1[ 0]],
sk_linear12_from_srgb[p1[ 1]],
sk_linear12_from_srgb[p1[ 2]],
p1[ 3] << 4 ,
sk_linear12_from_srgb[p1[ 8]],
sk_linear12_from_srgb[p1[ 9]],
sk_linear12_from_srgb[p1[10]],
p1[11] << 4 );
Sk8h b1d1 = Sk8h(sk_linear12_from_srgb[p1[ 4]],
sk_linear12_from_srgb[p1[ 5]],
sk_linear12_from_srgb[p1[ 6]],
p1[ 7] << 4 ,
sk_linear12_from_srgb[p1[12]],
sk_linear12_from_srgb[p1[13]],
sk_linear12_from_srgb[p1[14]],
p1[15] << 4 );

Sk8h avg = (a0c0 + b0d0 + a1c1 + b1d1) >> 2;
d[0] = sk_linear12_to_srgb[avg[0]];
d[1] = sk_linear12_to_srgb[avg[1]];
d[2] = sk_linear12_to_srgb[avg[2]];
d[3] = avg[3] >> 4;
d[4] = sk_linear12_to_srgb[avg[4]];
d[5] = sk_linear12_to_srgb[avg[5]];
d[6] = sk_linear12_to_srgb[avg[6]];
d[7] = avg[7] >> 4;

p0 += 16;
p1 += 16;
d += 8;
count -= 2;
}

if (count) {
downsample_2_2<ColorTypeFilter_S32>(d, p0, srcRB, count);
}
}

void downsample_2_3_srgb(void* dst, const void* src, size_t srcRB, int count) {
const uint8_t* p0 = ((const uint8_t*) src);
const uint8_t* p1 = p0 + srcRB;
const uint8_t* p2 = p1 + srcRB;
uint8_t* d = (uint8_t*) dst;

// Given pixels:
// a0 b0 c0 d0 ...
// a1 b1 c1 d1 ...
// a2 b2 c2 d2 ...
// We want:
// (a0 + b0 + 2*a1 + 2*b1 + a2 + b2) / 8
// (c0 + d0 + 2*c1 + 2*d1 + c2 + d2) / 8
// ...
while (count >= 2) {
Sk8h a0c0 = Sk8h(sk_linear12_from_srgb[p0[ 0]],
sk_linear12_from_srgb[p0[ 1]],
sk_linear12_from_srgb[p0[ 2]],
p0[ 3] << 4 ,
sk_linear12_from_srgb[p0[ 8]],
sk_linear12_from_srgb[p0[ 9]],
sk_linear12_from_srgb[p0[10]],
p0[11] << 4 );
Sk8h b0d0 = Sk8h(sk_linear12_from_srgb[p0[ 4]],
sk_linear12_from_srgb[p0[ 5]],
sk_linear12_from_srgb[p0[ 6]],
p0[ 7] << 4 ,
sk_linear12_from_srgb[p0[12]],
sk_linear12_from_srgb[p0[13]],
sk_linear12_from_srgb[p0[14]],
p0[15] << 4 );
Sk8h a1c1 = Sk8h(sk_linear12_from_srgb[p1[ 0]],
sk_linear12_from_srgb[p1[ 1]],
sk_linear12_from_srgb[p1[ 2]],
p1[ 3] << 4 ,
sk_linear12_from_srgb[p1[ 8]],
sk_linear12_from_srgb[p1[ 9]],
sk_linear12_from_srgb[p1[10]],
p1[11] << 4 );
Sk8h b1d1 = Sk8h(sk_linear12_from_srgb[p1[ 4]],
sk_linear12_from_srgb[p1[ 5]],
sk_linear12_from_srgb[p1[ 6]],
p1[ 7] << 4 ,
sk_linear12_from_srgb[p1[12]],
sk_linear12_from_srgb[p1[13]],
sk_linear12_from_srgb[p1[14]],
p1[15] << 4 );
Sk8h a2c2 = Sk8h(sk_linear12_from_srgb[p2[ 0]],
sk_linear12_from_srgb[p2[ 1]],
sk_linear12_from_srgb[p2[ 2]],
p2[ 3] << 4 ,
sk_linear12_from_srgb[p2[ 8]],
sk_linear12_from_srgb[p2[ 9]],
sk_linear12_from_srgb[p2[10]],
p2[11] << 4 );
Sk8h b2d2 = Sk8h(sk_linear12_from_srgb[p2[ 4]],
sk_linear12_from_srgb[p2[ 5]],
sk_linear12_from_srgb[p2[ 6]],
p2[ 7] << 4 ,
sk_linear12_from_srgb[p2[12]],
sk_linear12_from_srgb[p2[13]],
sk_linear12_from_srgb[p2[14]],
p2[15] << 4 );

Sk8h avg = (a0c0 + b0d0 + a1c1 + a1c1 + b1d1 + b1d1 + a2c2 + b2d2) >> 3;
d[0] = sk_linear12_to_srgb[avg[0]];
d[1] = sk_linear12_to_srgb[avg[1]];
d[2] = sk_linear12_to_srgb[avg[2]];
d[3] = avg[3] >> 4;
d[4] = sk_linear12_to_srgb[avg[4]];
d[5] = sk_linear12_to_srgb[avg[5]];
d[6] = sk_linear12_to_srgb[avg[6]];
d[7] = avg[7] >> 4;

p0 += 16;
p1 += 16;
p2 += 16;
d += 8;
count -= 2;
}

if (count) {
downsample_2_3<ColorTypeFilter_S32>(d, p0, srcRB, count);
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////

size_t SkMipMap::AllocLevelsSize(int levelCount, size_t pixelSize) {
if (levelCount < 0) {
return 0;
Expand All @@ -500,30 +326,18 @@ SkMipMap* SkMipMap::Build(const SkPixmap& src, SkDiscardableFactoryProc fact) {

const SkColorType ct = src.colorType();
const SkAlphaType at = src.alphaType();
const bool srgbGamma = false; // TODO: sRGB_ColorType

switch (ct) {
case kRGBA_8888_SkColorType:
case kBGRA_8888_SkColorType:
if (srgbGamma) {
proc_1_2 = downsample_1_2<ColorTypeFilter_S32>;
proc_1_3 = downsample_1_3<ColorTypeFilter_S32>;
proc_2_1 = downsample_2_1<ColorTypeFilter_S32>;
proc_2_2 = downsample_2_2_srgb;
proc_2_3 = downsample_2_3_srgb;
proc_3_1 = downsample_3_1<ColorTypeFilter_S32>;
proc_3_2 = downsample_3_2<ColorTypeFilter_S32>;
proc_3_3 = downsample_3_3<ColorTypeFilter_S32>;
} else {
proc_1_2 = downsample_1_2<ColorTypeFilter_8888>;
proc_1_3 = downsample_1_3<ColorTypeFilter_8888>;
proc_2_1 = downsample_2_1<ColorTypeFilter_8888>;
proc_2_2 = downsample_2_2<ColorTypeFilter_8888>;
proc_2_3 = downsample_2_3<ColorTypeFilter_8888>;
proc_3_1 = downsample_3_1<ColorTypeFilter_8888>;
proc_3_2 = downsample_3_2<ColorTypeFilter_8888>;
proc_3_3 = downsample_3_3<ColorTypeFilter_8888>;
}
proc_1_2 = downsample_1_2<ColorTypeFilter_8888>;
proc_1_3 = downsample_1_3<ColorTypeFilter_8888>;
proc_2_1 = downsample_2_1<ColorTypeFilter_8888>;
proc_2_2 = downsample_2_2<ColorTypeFilter_8888>;
proc_2_3 = downsample_2_3<ColorTypeFilter_8888>;
proc_3_1 = downsample_3_1<ColorTypeFilter_8888>;
proc_3_2 = downsample_3_2<ColorTypeFilter_8888>;
proc_3_3 = downsample_3_3<ColorTypeFilter_8888>;
break;
case kRGB_565_SkColorType:
proc_1_2 = downsample_1_2<ColorTypeFilter_565>;
Expand Down
Loading

0 comments on commit 82cf64a

Please sign in to comment.