/* Internal Class Implementation */
/************************************************************************/
+static inline bool _onlyShifted(const Matrix* m)
+{
+ if (mathEqual(m->e11, 1.0f) && mathEqual(m->e22, 1.0f) && mathZero(m->e12) && mathZero(m->e21)) return true;
+ return false;
+}
+
+
static bool _genOutline(SwImage* image, const Matrix* transform, SwMpool* mpool, unsigned tid)
{
image->outline = mpoolReqOutline(mpool, tid);
}
-static inline bool _onlyShifted(const Matrix* m)
-{
- if (mathEqual(m->e11, 1.0f) && mathEqual(m->e22, 1.0f) && mathZero(m->e12) && mathZero(m->e21)) return true;
- return false;
-}
-
-
/************************************************************************/
/* External Class Implementation */
/************************************************************************/
-
bool imagePrepare(SwImage* image, const Matrix* transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid)
{
- image->transformed = !_onlyShifted(transform);
- bool fastTrack;
+ image->direct = _onlyShifted(transform);
+ //Fast track: Non-transformed image but just shifted.
+ if (image->direct) {
+ image->ox = -static_cast<uint32_t>(round(transform->e13));
+ image->oy = -static_cast<uint32_t>(round(transform->e23));
//Figure out the scale factor by transform matrix
- if (image->transformed) {
+ } else {
auto scaleX = sqrtf((transform->e11 * transform->e11) + (transform->e21 * transform->e21));
auto scaleY = sqrtf((transform->e22 * transform->e22) + (transform->e12 * transform->e12));
- //TODO:If the x and y axis scale is different, a separate interpolation algorithm for each axis should be applied.
image->scale = (fabsf(scaleX - scaleY) > 0.01f) ? 1.0f : scaleX;
- fastTrack = false;
- //Fast track: Non-transformed image but just shifted.
- } else {
- image->scale = 1.0f;
- image->x = -static_cast<uint32_t>(round(transform->e13));
- image->y = -static_cast<uint32_t>(round(transform->e23));
- fastTrack = true;
}
if (!_genOutline(image, transform, mpool, tid)) return false;
- return mathUpdateOutlineBBox(image->outline, clipRegion, renderRegion, fastTrack);
+ return mathUpdateOutlineBBox(image->outline, clipRegion, renderRegion, image->direct);
}
for (uint32_t i = 0; i < image->rle->size; ++i, ++span) {
auto dst = &surface->buffer[span->y * surface->stride + span->x];
auto cmp = &cbuffer[span->y * surface->stride + span->x];
- auto img = image->data + (span->y + image->y) * image->stride + (span->x + image->x);
+ auto img = image->data + (span->y + image->oy) * image->stride + (span->x + image->ox);
auto alpha = _multiplyAlpha(span->coverage, opacity);
if (alpha == 255) {
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++cmp, ++img) {
for (uint32_t i = 0; i < image->rle->size; ++i, ++span) {
auto dst = &surface->buffer[span->y * surface->stride + span->x];
- auto img = image->data + (span->y + image->y) * image->stride + (span->x + image->x);
+ auto img = image->data + (span->y + image->oy) * image->stride + (span->x + image->ox);
auto alpha = _multiplyAlpha(span->coverage, opacity);
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++img) {
auto src = ALPHA_BLEND(*img, alpha);
for (uint32_t i = 0; i < image->rle->size; ++i, ++span) {
auto dst = &surface->buffer[span->y * surface->stride + span->x];
- auto img = image->data + (span->y + image->y) * image->stride + (span->x + image->x);
+ auto img = image->data + (span->y + image->oy) * image->stride + (span->x + image->ox);
if (span->coverage == 255) {
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++img) {
*dst = *img;
TVGLOG("SW_ENGINE", "Direct Masked Image");
- auto sbuffer = image->data + (region.min.y + image->y) * image->stride + (region.min.x + image->x);
+ auto sbuffer = image->data + (region.min.y + image->oy) * image->stride + (region.min.x + image->ox);
auto cbuffer = surface->compositor->image.data + (region.min.y * surface->stride) + region.min.x; //compositor buffer
for (uint32_t y = 0; y < h2; ++y) {
static bool __rasterDirectTranslucentImage(SwSurface* surface, const SwImage* image, uint32_t opacity, const SwBBox& region)
{
auto dbuffer = &surface->buffer[region.min.y * surface->stride + region.min.x];
- auto sbuffer = image->data + (region.min.y + image->y) * image->stride + (region.min.x + image->x);
+ auto sbuffer = image->data + (region.min.y + image->oy) * image->stride + (region.min.x + image->ox);
for (auto y = region.min.y; y < region.max.y; ++y) {
auto dst = dbuffer;
static bool _rasterDirectSolidImage(SwSurface* surface, const SwImage* image, const SwBBox& region)
{
auto dbuffer = &surface->buffer[region.min.y * surface->stride + region.min.x];
- auto sbuffer = image->data + (region.min.y + image->y) * image->stride + (region.min.x + image->x);
+ auto sbuffer = image->data + (region.min.y + image->oy) * image->stride + (region.min.x + image->ox);
for (auto y = region.min.y; y < region.max.y; ++y) {
auto dst = dbuffer;
//Clipped Image
if (image->rle) {
- if (image->transformed) {
- if (translucent) return _rasterTransformedTranslucentRleImage(surface, image, opacity, &itransform, halfScale);
- else return _rasterTransformedSolidRleImage(surface, image, &itransform, halfScale);
- } else {
+ if (image->direct) {
if (translucent) return _rasterDirectTranslucentRleImage(surface, image, opacity);
else return _rasterDirectSolidRleImage(surface, image);
+ } else {
+ if (translucent) return _rasterTransformedTranslucentRleImage(surface, image, opacity, &itransform, halfScale);
+ else return _rasterTransformedSolidRleImage(surface, image, &itransform, halfScale);
}
//Whole Image
} else {
- if (image->transformed) {
- if (translucent) return _rasterTransformedTranslucentImage(surface, image, opacity, bbox, &itransform, halfScale);
- else return _rasterTransformedSolidImage(surface, image, bbox, &itransform, halfScale);
- } else {
+ if (image->direct) {
if (translucent) return _rasterDirectTranslucentImage(surface, image, opacity, bbox);
else return _rasterDirectSolidImage(surface, image, bbox);
+ } else {
+ if (translucent) return _rasterTransformedTranslucentImage(surface, image, opacity, bbox, &itransform, halfScale);
+ else return _rasterTransformedSolidImage(surface, image, bbox, &itransform, halfScale);
}
}
}