Commit 03955f8e authored by Sam Lantinga's avatar Sam Lantinga

Fixed clipping source rect to match destination rect clipping

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403374
parent 20902414
......@@ -2205,6 +2205,19 @@ SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect,
if (!SDL_IntersectRect(dstrect, &real_dstrect, &real_dstrect)) {
return 0;
}
/* Clip srcrect by the same amount as dstrect was clipped */
if (dstrect->w != real_dstrect.w) {
int deltax = (real_dstrect.x - dstrect->x);
int deltaw = (real_dstrect.w - dstrect->w);
real_srcrect.x += (deltax * dstrect->w) / real_srcrect.w;
real_srcrect.w += (deltaw * dstrect->w) / real_srcrect.w;
}
if (dstrect->h != real_dstrect.h) {
int deltay = (real_dstrect.y - dstrect->y);
int deltah = (real_dstrect.h - dstrect->h);
real_srcrect.y += (deltay * dstrect->h) / real_srcrect.h;
real_srcrect.h += (deltah * dstrect->h) / real_srcrect.h;
}
}
return renderer->RenderCopy(renderer, texture, &real_srcrect,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment