Added some comments.
This commit is contained in:
parent
d96742b024
commit
0669fef25b
1 changed files with 16 additions and 2 deletions
|
@ -1886,6 +1886,8 @@ X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
Picture src, mask;
|
Picture src, mask;
|
||||||
XRenderPictureAttributes attr;
|
XRenderPictureAttributes attr;
|
||||||
const SDL_Rect *mrect;
|
const SDL_Rect *mrect;
|
||||||
|
/* mrect is the rectangular area of the mask
|
||||||
|
* picture that is aligned with the source. */
|
||||||
|
|
||||||
if (texture->modMode == SDL_TEXTUREMODULATE_NONE) {
|
if (texture->modMode == SDL_TEXTUREMODULATE_NONE) {
|
||||||
src = texturedata->picture;
|
src = texturedata->picture;
|
||||||
|
@ -1901,11 +1903,16 @@ X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
}
|
}
|
||||||
else if (texture->blendMode == SDL_BLENDMODE_MOD)
|
else if (texture->blendMode == SDL_BLENDMODE_MOD)
|
||||||
{
|
{
|
||||||
|
/* SDL_BLENDMODE_MOD requires a temporary buffer
|
||||||
|
* i.e. stencil_pict */
|
||||||
mask = data->stencil_pict;
|
mask = data->stencil_pict;
|
||||||
mrect = dstrect;
|
mrect = dstrect;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* This trick allows on-the-fly multiplication
|
||||||
|
* of the src color channels with it's alpha
|
||||||
|
* channel. */
|
||||||
mask = src;
|
mask = src;
|
||||||
mrect = srcrect;
|
mrect = srcrect;
|
||||||
}
|
}
|
||||||
|
@ -1925,6 +1932,7 @@ X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
mrect->x, mrect->y, dstrect->x, dstrect->y,
|
mrect->x, mrect->y, dstrect->x, dstrect->y,
|
||||||
dstrect->w, dstrect->h);
|
dstrect->w, dstrect->h);
|
||||||
} else {
|
} else {
|
||||||
|
/* The transformation is from the dst to src picture. */
|
||||||
double xscale = ((double) srcrect->w) / dstrect->w;
|
double xscale = ((double) srcrect->w) / dstrect->w;
|
||||||
double yscale = ((double) srcrect->h) / dstrect->h;
|
double yscale = ((double) srcrect->h) / dstrect->h;
|
||||||
XTransform xform = {{
|
XTransform xform = {{
|
||||||
|
@ -1933,16 +1941,20 @@ X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
{XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(xscale * yscale)}}};
|
{XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(xscale * yscale)}}};
|
||||||
XRenderSetPictureTransform(data->display, src, &xform);
|
XRenderSetPictureTransform(data->display, src, &xform);
|
||||||
|
|
||||||
|
/* Black magic follows. */
|
||||||
if (texture->blendMode == SDL_BLENDMODE_MOD) {
|
if (texture->blendMode == SDL_BLENDMODE_MOD) {
|
||||||
|
/* Copy the dst to a temp buffer. */
|
||||||
XRenderComposite(data->display, PictOpSrc, data->drawable_pict,
|
XRenderComposite(data->display, PictOpSrc, data->drawable_pict,
|
||||||
src, data->stencil_pict,
|
src, data->stencil_pict,
|
||||||
dstrect->x, dstrect->y, srcrect->x, srcrect->y,
|
dstrect->x, dstrect->y, srcrect->x, srcrect->y,
|
||||||
dstrect->x, dstrect->y, dstrect->w, dstrect->h);
|
dstrect->x, dstrect->y, dstrect->w, dstrect->h);
|
||||||
|
/* Set the compnent alpha flag on the temp buffer. */
|
||||||
attr.component_alpha = True;
|
attr.component_alpha = True;
|
||||||
XRenderChangePicture(data->display, data->stencil_pict,
|
XRenderChangePicture(data->display, data->stencil_pict,
|
||||||
CPComponentAlpha, &attr);
|
CPComponentAlpha, &attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the picture filter only if a scaling mode is set. */
|
||||||
if (texture->scaleMode != SDL_TEXTURESCALEMODE_NONE) {
|
if (texture->scaleMode != SDL_TEXTURESCALEMODE_NONE) {
|
||||||
XRenderSetPictureFilter(data->display, src,
|
XRenderSetPictureFilter(data->display, src,
|
||||||
texturedata->filter, 0, 0);
|
texturedata->filter, 0, 0);
|
||||||
|
@ -1952,14 +1964,16 @@ X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
src, mask, data->drawable_pict,
|
src, mask, data->drawable_pict,
|
||||||
srcrect->x, srcrect->y, mrect->x, mrect->y,
|
srcrect->x, srcrect->y, mrect->x, mrect->y,
|
||||||
dstrect->x, dstrect->y, dstrect->w, dstrect->h);
|
dstrect->x, dstrect->y, dstrect->w, dstrect->h);
|
||||||
|
/* Set the texture transformation back to the identity matrix. */
|
||||||
XTransform identity = {{
|
XTransform identity = {{
|
||||||
{XDoubleToFixed(1), XDoubleToFixed(0), XDoubleToFixed(0)},
|
{XDoubleToFixed(1), XDoubleToFixed(0), XDoubleToFixed(0)},
|
||||||
{XDoubleToFixed(0), XDoubleToFixed(1), XDoubleToFixed(0)},
|
{XDoubleToFixed(0), XDoubleToFixed(1), XDoubleToFixed(0)},
|
||||||
{XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(1)}}};
|
{XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(1)}}};
|
||||||
XRenderSetPictureTransform(data->display, src, &identity);
|
XRenderSetPictureTransform(data->display, src, &identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reset the component alpha flag only when
|
||||||
|
* the blending mode is SDL_BLENDMODE_MOD. */
|
||||||
if (renderer->blendMode == SDL_BLENDMODE_MOD) {
|
if (renderer->blendMode == SDL_BLENDMODE_MOD) {
|
||||||
attr.component_alpha = False;
|
attr.component_alpha = False;
|
||||||
XRenderChangePicture(data->display, data->stencil_pict,
|
XRenderChangePicture(data->display, data->stencil_pict,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue