Merge upstream
This commit is contained in:
commit
85452bf2cf
7 changed files with 89 additions and 65 deletions
|
@ -235,9 +235,9 @@ struct BitmapPrivate
|
|||
surf = surfConv;
|
||||
}
|
||||
|
||||
void onModified()
|
||||
void onModified(bool freeSurface = true)
|
||||
{
|
||||
if (surface)
|
||||
if (surface && freeSurface)
|
||||
{
|
||||
SDL_FreeSurface(surface);
|
||||
surface = 0;
|
||||
|
@ -883,6 +883,14 @@ void Bitmap::clear()
|
|||
p->onModified();
|
||||
}
|
||||
|
||||
static uint32_t &getPixelAt(SDL_Surface *surf, SDL_PixelFormat *form, int x, int y)
|
||||
{
|
||||
size_t offset = x*form->BytesPerPixel + y*surf->pitch;
|
||||
uint8_t *bytes = (uint8_t*) surf->pixels + offset;
|
||||
|
||||
return *((uint32_t*) bytes);
|
||||
}
|
||||
|
||||
Color Bitmap::getPixel(int x, int y) const
|
||||
{
|
||||
guardDisposed();
|
||||
|
@ -905,9 +913,7 @@ Color Bitmap::getPixel(int x, int y) const
|
|||
glState.viewport.pop();
|
||||
}
|
||||
|
||||
size_t offset = x*p->format->BytesPerPixel + y*p->surface->pitch;
|
||||
uint8_t *bytes = (uint8_t*) p->surface->pixels + offset;
|
||||
uint32_t pixel = *((uint32_t*) bytes);
|
||||
uint32_t pixel = getPixelAt(p->surface, p->format, x, y);
|
||||
|
||||
return Color((pixel >> p->format->Rshift) & 0xFF,
|
||||
(pixel >> p->format->Gshift) & 0xFF,
|
||||
|
@ -934,7 +940,16 @@ void Bitmap::setPixel(int x, int y, const Color &color)
|
|||
|
||||
p->addTaintedArea(IntRect(x, y, 1, 1));
|
||||
|
||||
p->onModified();
|
||||
/* Setting just a single pixel is no reason to throw away the
|
||||
* whole cached surface; we can just apply the same change */
|
||||
|
||||
if (p->surface)
|
||||
{
|
||||
uint32_t &surfPixel = getPixelAt(p->surface, p->format, x, y);
|
||||
surfPixel = SDL_MapRGBA(p->format, pixel[0], pixel[1], pixel[2], pixel[3]);
|
||||
}
|
||||
|
||||
p->onModified(false);
|
||||
}
|
||||
|
||||
void Bitmap::hueChange(int hue)
|
||||
|
@ -954,13 +969,10 @@ void Bitmap::hueChange(int hue)
|
|||
quad.setTexPosRect(texRect, texRect);
|
||||
quad.setColor(Vec4(1, 1, 1, 1));
|
||||
|
||||
/* Calculate hue parameter */
|
||||
hue = wrapRange(hue, 0, 359);
|
||||
float hueAdj = -((M_PI * 2) / 360) * hue;
|
||||
|
||||
HueShader &shader = shState->shaders().hue;
|
||||
shader.bind();
|
||||
shader.setHueAdjust(hueAdj);
|
||||
/* Shader expects normalized value */
|
||||
shader.setHueAdjust(wrapRange(hue, 0, 359) / 360.0f);
|
||||
|
||||
FBO::bind(newTex.fbo);
|
||||
p->pushSetViewport(shader);
|
||||
|
|
|
@ -551,7 +551,6 @@ HueShader::HueShader()
|
|||
ShaderBase::init();
|
||||
|
||||
GET_U(hueAdjust);
|
||||
GET_U(inputTexture);
|
||||
}
|
||||
|
||||
void HueShader::setHueAdjust(float value)
|
||||
|
@ -559,11 +558,6 @@ void HueShader::setHueAdjust(float value)
|
|||
gl.Uniform1f(u_hueAdjust, value);
|
||||
}
|
||||
|
||||
void HueShader::setInputTexture(TEX::ID tex)
|
||||
{
|
||||
setTexUniform(u_inputTexture, 0, tex);
|
||||
}
|
||||
|
||||
|
||||
SimpleMatrixShader::SimpleMatrixShader()
|
||||
{
|
||||
|
|
|
@ -241,10 +241,9 @@ public:
|
|||
HueShader();
|
||||
|
||||
void setHueAdjust(float value);
|
||||
void setInputTexture(TEX::ID tex);
|
||||
|
||||
private:
|
||||
GLint u_hueAdjust, u_inputTexture;
|
||||
GLint u_hueAdjust;
|
||||
};
|
||||
|
||||
class SimpleMatrixShader : public ShaderBase
|
||||
|
|
|
@ -134,12 +134,23 @@ struct SpritePrivate
|
|||
|
||||
void onSrcRectChange()
|
||||
{
|
||||
if (mirrored)
|
||||
quad.setTexRect(srcRect->toFloatRect().hFlipped());
|
||||
else
|
||||
quad.setTexRect(srcRect->toFloatRect());
|
||||
FloatRect rect = srcRect->toFloatRect();
|
||||
Vec2i bmSize;
|
||||
|
||||
quad.setPosRect(IntRect(0, 0, srcRect->width, srcRect->height));
|
||||
if (bitmap)
|
||||
bmSize = Vec2i(bitmap->width(), bitmap->height());
|
||||
|
||||
if (mirrored)
|
||||
rect = rect.hFlipped();
|
||||
|
||||
/* Clamp the rectangle so it doesn't reach outside
|
||||
* the bitmap bounds */
|
||||
rect.w = clamp<int>(rect.w, 0, bmSize.x-rect.x);
|
||||
rect.h = clamp<int>(rect.h, 0, bmSize.y-rect.y);
|
||||
|
||||
quad.setTexRect(rect);
|
||||
|
||||
quad.setPosRect(FloatRect(0, 0, rect.w, rect.h));
|
||||
recomputeBushDepth();
|
||||
|
||||
wave.dirty = true;
|
||||
|
|
|
@ -852,10 +852,15 @@ void WindowVX::move(int x, int y, int width, int height)
|
|||
|
||||
const Vec2i size(std::max(0, width), std::max(0, height));
|
||||
|
||||
if (p->geo.w != size.x || p->geo.h != size.y)
|
||||
if (p->geo.size() != size)
|
||||
{
|
||||
p->base.vertDirty = true;
|
||||
p->base.texSizeDirty = true;
|
||||
p->clipRectDirty = true;
|
||||
p->ctrlVertDirty = true;
|
||||
}
|
||||
|
||||
p->geo = IntRect(x, y, size.x, size.y);
|
||||
p->geo = IntRect(Vec2i(x, y), size);
|
||||
p->updateBaseQuad();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue