Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 3330320

Browse files
committed
[[ Bug 19926 ]] Remove unnecessary (and incorrectly scaled) alpha mask from legacy gradient shader
1 parent 3ed3010 commit 3330320

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

libgraphics/src/graphics-internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ class MCGLegacyGradientShader : public SkShader
484484

485485
private:
486486
int32_t m_y;
487-
uint8_t *m_mask;
488487
MCGradientCombiner_t *m_gradient_combiner;
489488

490489
typedef SkShader::Context INHERITED;

libgraphics/src/legacygradients.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct MCCombiner
117117
void (*begin)(MCCombiner *self, int4 y);
118118
void (*advance)(MCCombiner *self, int4 y);
119119
void (*blend)(MCCombiner *self, int4 fx, int4 tx, uint1 value);
120-
void (*combine)(MCCombiner *self, int4 fx, int4 tx, uint1 *mask);
120+
void (*combine)(MCCombiner *self, int4 fx, int4 tx);
121121
void (*end)(MCCombiner *self);
122122
};
123123

@@ -456,7 +456,7 @@ template<MCGradientFillKind x_type> static void MCGradientFillBlend(MCCombiner *
456456
}
457457
}
458458

459-
template<MCGradientFillKind x_type> static void MCGradientFillCombine(MCCombiner *_self, int4 fx, int4 tx, uint1 *mask)
459+
template<MCGradientFillKind x_type> static void MCGradientFillCombine(MCCombiner *_self, int4 fx, int4 tx)
460460
{
461461
MCGradientAffineCombiner *self = (MCGradientAffineCombiner*)_self;
462462
uint4 *d;
@@ -487,7 +487,7 @@ template<MCGradientFillKind x_type> static void MCGradientFillCombine(MCCombiner
487487
s = self->ramp[0].hw_color;
488488
while (t_index <= t_min)
489489
{
490-
uint4 sa = packed_scale_bounded(s | 0xFF000000, ((s >> 24) * *mask++) / 255);
490+
uint4 sa = packed_scale_bounded(s | 0xFF000000, (s >> 24));
491491
d[fx] = packed_scale_bounded(d[fx], 255 - (sa >> 24)) + sa;
492492
fx += 1;
493493
if (fx == tx)
@@ -503,7 +503,7 @@ template<MCGradientFillKind x_type> static void MCGradientFillCombine(MCCombiner
503503
s = self->ramp[self->ramp_length - 1].hw_color;
504504
while (t_index >= t_max)
505505
{
506-
uint4 sa = packed_scale_bounded(s | 0xFF000000, ((s >> 24) * *mask++) / 255);
506+
uint4 sa = packed_scale_bounded(s | 0xFF000000, (s >> 24));
507507
d[fx] = packed_scale_bounded(d[fx], 255 - (sa >> 24)) + sa;
508508
fx += 1;
509509
if (fx == tx)
@@ -530,7 +530,7 @@ template<MCGradientFillKind x_type> static void MCGradientFillCombine(MCCombiner
530530
uint1 a = 255 - b;
531531

532532
s = packed_bilinear_bounded(t_current_color, a, t_next_color, b);
533-
uint4 sa = packed_scale_bounded(s | 0xFF000000, ((s >> 24) * *mask++) / 255);
533+
uint4 sa = packed_scale_bounded(s | 0xFF000000, (s >> 24));
534534
d[fx] = packed_scale_bounded(d[fx], 255 - (sa >> 24)) + sa;
535535
fx += 1;
536536
if (fx == tx)
@@ -697,7 +697,7 @@ template<MCGradientFillKind x_type> static void MCGradientFillBilinearBlend(MCCo
697697
}
698698
}
699699

700-
template<MCGradientFillKind x_type> static void MCGradientFillBilinearCombine(MCCombiner *_self, int4 fx, int4 tx, uint1* mask)
700+
template<MCGradientFillKind x_type> static void MCGradientFillBilinearCombine(MCCombiner *_self, int4 fx, int4 tx)
701701
{
702702
MCGradientAffineCombiner *self = (MCGradientAffineCombiner*)_self;
703703
uint4 *d;
@@ -743,7 +743,7 @@ template<MCGradientFillKind x_type> static void MCGradientFillBilinearCombine(MC
743743
i++;
744744

745745
s = u | v;
746-
uint1 alpha = (s >> 24) * (*mask++) / 255;
746+
uint1 alpha = (s >> 24);
747747
d[fx] = packed_bilinear_bounded(d[fx], 255 - alpha, s | 0xFF000000, alpha);
748748
}
749749
}
@@ -971,7 +971,7 @@ sk_sp<SkFlattenable> MCGLegacyGradientShader::CreateProc(SkReadBuffer& buffer)
971971
}
972972

973973
MCGLegacyGradientShader::MCGLegacyGradientShaderContext::MCGLegacyGradientShaderContext(const MCGLegacyGradientShader& p_shader, const ContextRec& p_rec, MCGGradientRef p_gradient_ref, MCGRectangle p_clip)
974-
: INHERITED(p_shader, p_rec), m_y(0), m_mask(NULL), m_gradient_combiner(NULL)
974+
: INHERITED(p_shader, p_rec), m_y(0), m_gradient_combiner(NULL)
975975
{
976976
MCGRectangle t_clip;
977977

@@ -985,12 +985,8 @@ MCGLegacyGradientShader::MCGLegacyGradientShaderContext::MCGLegacyGradientShader
985985
bool t_success;
986986
t_success = true;
987987

988-
if (t_success)
989-
t_success = MCMemoryAllocate(t_width, m_mask);
990-
991988
if (t_success)
992989
{
993-
memset(m_mask, 0xFF, t_width);
994990
m_gradient_combiner = MCGradientFillCreateCombiner(p_gradient_ref, t_clip, t_matrix);
995991
t_success = m_gradient_combiner != NULL;
996992
}
@@ -1006,7 +1002,6 @@ MCGLegacyGradientShader::MCGLegacyGradientShaderContext::MCGLegacyGradientShader
10061002

10071003
MCGLegacyGradientShader::MCGLegacyGradientShaderContext::~MCGLegacyGradientShaderContext()
10081004
{
1009-
MCMemoryDeallocate(m_mask);
10101005
MCGradientFillDeleteCombiner(m_gradient_combiner);
10111006
}
10121007

@@ -1020,7 +1015,7 @@ void MCGLegacyGradientShader::MCGLegacyGradientShaderContext::shadeSpan(int x, i
10201015
m_y = y;
10211016
memset(dstC, 0x00, count * sizeof(SkPMColor));
10221017
m_gradient_combiner -> bits = dstC - x;
1023-
m_gradient_combiner -> combine(m_gradient_combiner, x, x + count, m_mask);
1018+
m_gradient_combiner -> combine(m_gradient_combiner, x, x + count);
10241019
}
10251020
}
10261021

0 commit comments

Comments
 (0)