Only need read access for in_mask_surface

This commit is contained in:
Charles Dang 2024-08-21 00:46:33 -04:00
parent a6e931af11
commit 365fe71e2c
2 changed files with 4 additions and 4 deletions

View file

@ -863,7 +863,7 @@ void mask_surface(surface& nsurf, const surface& nmask, bool* empty_result, cons
*empty_result = empty;
}
bool in_mask_surface(surface nsurf, surface nmask)
bool in_mask_surface(const surface& nsurf, const surface& nmask)
{
if(nsurf == nullptr) {
return false;
@ -878,12 +878,12 @@ bool in_mask_surface(surface nsurf, surface nmask)
}
{
surface_lock lock(nsurf);
const_surface_lock lock(nsurf);
const_surface_lock mlock(nmask);
const uint32_t* mbeg = mlock.pixels();
const uint32_t* mend = mbeg + nmask->w*nmask->h;
uint32_t* beg = lock.pixels();
const uint32_t* beg = lock.pixels();
// no need for 'end', because both surfaces have same size
while(mbeg != mend) {

View file

@ -131,7 +131,7 @@ void adjust_surface_alpha_add(surface& surf, int amount);
void mask_surface(surface& surf, const surface& mask, bool* empty_result = nullptr, const std::string& filename = std::string());
/** Check if a surface fit into a mask */
bool in_mask_surface(surface surf, surface mask);
bool in_mask_surface(const surface& surf, const surface& mask);
/**
* Light surf using lightmap