Merge change I88d11cfb into eclair
* changes:
one step towards fixing [2071412
] work around mdp 32-bits fade limitation
This commit is contained in:
@ -41,11 +41,12 @@
|
|||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
static void textureToCopyBitImage(
|
static void textureToCopyBitImage(
|
||||||
const GGLSurface* surface, buffer_handle_t buffer, copybit_image_t* img)
|
const GGLSurface* surface, int32_t opFormat,
|
||||||
|
buffer_handle_t buffer, copybit_image_t* img)
|
||||||
{
|
{
|
||||||
img->w = surface->stride;
|
img->w = surface->stride;
|
||||||
img->h = surface->height;
|
img->h = surface->height;
|
||||||
img->format = surface->format;
|
img->format = opFormat;
|
||||||
img->base = surface->data;
|
img->base = surface->data;
|
||||||
img->handle = (native_handle_t *)buffer;
|
img->handle = (native_handle_t *)buffer;
|
||||||
}
|
}
|
||||||
@ -207,39 +208,13 @@ static bool copybit(GLint x, GLint y,
|
|||||||
int planeAlpha = 255;
|
int planeAlpha = 255;
|
||||||
static const int tmu = 0;
|
static const int tmu = 0;
|
||||||
texture_t& tev(c->rasterizer.state.texture[tmu]);
|
texture_t& tev(c->rasterizer.state.texture[tmu]);
|
||||||
bool srcTextureHasAlpha = hasAlpha(textureObject->surface.format);
|
int32_t opFormat = textureObject->surface.format;
|
||||||
|
const bool srcTextureHasAlpha = hasAlpha(opFormat);
|
||||||
if (!srcTextureHasAlpha) {
|
if (!srcTextureHasAlpha) {
|
||||||
planeAlpha = fixedToByte(c->currentColorClamped.a);
|
planeAlpha = fixedToByte(c->currentColorClamped.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (tev.env) {
|
const bool cbHasAlpha = hasAlpha(cbSurface.format);
|
||||||
case GGL_REPLACE:
|
|
||||||
break;
|
|
||||||
case GGL_MODULATE:
|
|
||||||
if (! (c->currentColorClamped.r == FIXED_ONE &&
|
|
||||||
c->currentColorClamped.g == FIXED_ONE &&
|
|
||||||
c->currentColorClamped.b == FIXED_ONE)) {
|
|
||||||
LOGD_IF(DEBUG_COPYBIT,
|
|
||||||
"MODULATE and non white color (%08x, %08x, %08x)",
|
|
||||||
c->currentColorClamped.r,
|
|
||||||
c->currentColorClamped.g,
|
|
||||||
c->currentColorClamped.b);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (srcTextureHasAlpha && c->currentColorClamped.a < FIXED_ONE) {
|
|
||||||
LOGD_IF(DEBUG_COPYBIT,
|
|
||||||
"MODULATE and texture w/alpha and alpha=%08x)",
|
|
||||||
c->currentColorClamped.a);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Incompatible texture environment.
|
|
||||||
LOGD_IF(DEBUG_COPYBIT, "incompatible texture environment");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool blending = false;
|
bool blending = false;
|
||||||
if ((enables & GGL_ENABLE_BLENDING)
|
if ((enables & GGL_ENABLE_BLENDING)
|
||||||
&& !(c->rasterizer.state.blend.src == GL_ONE
|
&& !(c->rasterizer.state.blend.src == GL_ONE
|
||||||
@ -262,32 +237,60 @@ static bool copybit(GLint x, GLint y,
|
|||||||
}
|
}
|
||||||
blending = true;
|
blending = true;
|
||||||
} else {
|
} else {
|
||||||
// No blending is OK if we are not using alpha.
|
if (cbHasAlpha) {
|
||||||
if (srcTextureHasAlpha || planeAlpha != 255) {
|
// NOTE: the result will be slightly wrong in this case because
|
||||||
// Incompatible alpha
|
// the destination alpha channel will be set to 1.0 instead of
|
||||||
LOGD_IF(DEBUG_COPYBIT, "incompatible alpha");
|
// the iterated alpha value. *shrug*.
|
||||||
return false;
|
}
|
||||||
|
// disable plane blending and src blending for supported formats
|
||||||
|
planeAlpha = 255;
|
||||||
|
if (opFormat == COPYBIT_FORMAT_RGBA_8888) {
|
||||||
|
opFormat = COPYBIT_FORMAT_RGBX_8888;
|
||||||
|
} else {
|
||||||
|
if (srcTextureHasAlpha) {
|
||||||
|
LOGD_IF(DEBUG_COPYBIT, "texture format requires blending");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (srcTextureHasAlpha && planeAlpha != 255) {
|
switch (tev.env) {
|
||||||
// Can't do two types of alpha at once.
|
case GGL_REPLACE:
|
||||||
LOGD_IF(DEBUG_COPYBIT, "src alpha and plane alpha");
|
break;
|
||||||
|
case GGL_MODULATE:
|
||||||
|
// only cases allowed is:
|
||||||
|
// RGB source, color={1,1,1,a} -> can be done with GL_REPLACE
|
||||||
|
// RGBA source, color={1,1,1,1} -> can be done with GL_REPLACE
|
||||||
|
if (blending) {
|
||||||
|
if (c->currentColorClamped.r == c->currentColorClamped.a &&
|
||||||
|
c->currentColorClamped.g == c->currentColorClamped.a &&
|
||||||
|
c->currentColorClamped.b == c->currentColorClamped.a) {
|
||||||
|
// TODO: Need to emulate: RGBA source, color={a,a,a,a} / premult
|
||||||
|
// and RGBA source, color={1,1,1,a} / regular-blending
|
||||||
|
// (both are equivalent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOGD_IF(DEBUG_COPYBIT, "GGL_MODULATE");
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
// Incompatible texture environment.
|
||||||
|
LOGD_IF(DEBUG_COPYBIT, "incompatible texture environment");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// LOGW("calling copybits");
|
// LOGW("calling copybits");
|
||||||
|
|
||||||
copybit_device_t* copybit = c->copybits.blitEngine;
|
copybit_device_t* copybit = c->copybits.blitEngine;
|
||||||
|
|
||||||
copybit_image_t dst;
|
copybit_image_t dst;
|
||||||
buffer_handle_t target_hnd = c->copybits.drawSurfaceBuffer;
|
buffer_handle_t target_hnd = c->copybits.drawSurfaceBuffer;
|
||||||
textureToCopyBitImage(&cbSurface, target_hnd, &dst);
|
textureToCopyBitImage(&cbSurface, cbSurface.format, target_hnd, &dst);
|
||||||
copybit_rect_t drect = {x, y, x+w, y+h};
|
copybit_rect_t drect = {x, y, x+w, y+h};
|
||||||
|
|
||||||
copybit_image_t src;
|
copybit_image_t src;
|
||||||
buffer_handle_t source_hnd = textureObject->buffer->handle;
|
buffer_handle_t source_hnd = textureObject->buffer->handle;
|
||||||
textureToCopyBitImage(&textureObject->surface, source_hnd, &src);
|
textureToCopyBitImage(&textureObject->surface, opFormat, source_hnd, &src);
|
||||||
copybit_rect_t srect = { Ucr, Vcr + Hcr, Ucr + Wcr, Vcr };
|
copybit_rect_t srect = { Ucr, Vcr + Hcr, Ucr + Wcr, Vcr };
|
||||||
|
|
||||||
copybit->set_parameter(copybit, COPYBIT_TRANSFORM, transform);
|
copybit->set_parameter(copybit, COPYBIT_TRANSFORM, transform);
|
||||||
|
Reference in New Issue
Block a user