Skip to content

Commit

Permalink
[libcg]optimize blend_transformed_argb for CG_TEXTURE_TYPE_PLAIN mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jianjunjiang committed Dec 14, 2021
1 parent b11adcd commit ffcc63b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/cg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1949,19 +1949,24 @@ static inline void blend_transformed_argb(struct cg_surface_t * surface, enum cg
int l = CG_MIN(length, 1024);
uint32_t * end = buffer + l;
uint32_t * b = buffer;
int start = 0;
int clen = 0;
while(b < end)
{
int px = x >> 16;
int py = y >> 16;
if((px < 0) || (px >= image_width) || (py < 0) || (py >= image_height))
*b = 0;
else
if(((unsigned int)px < (unsigned int)image_width) && ((unsigned int)py < (unsigned int)image_height))
{
*b = ((uint32_t *)(texture->pixels + py * texture->stride))[px];
clen++;
}
x += fdx;
y += fdy;
++b;
if(clen == 0)
start++;
}
func(target, l, buffer, coverage);
func(target + start, clen, buffer + start, coverage);
target += l;
length -= l;
}
Expand Down

0 comments on commit ffcc63b

Please sign in to comment.