Bug 757346; Use A8 textures (OGL). r=roc

This commit is contained in:
Nicholas Cameron 2012-06-26 14:43:31 +12:00
parent fcf7e7a249
commit 0a4510eccd
4 changed files with 30 additions and 19 deletions

View File

@ -763,6 +763,8 @@ GLFormatForImage(gfxASurface::gfxImageFormat aFormat)
return LOCAL_GL_RGBA;
case gfxASurface::ImageFormatRGB16_565:
return LOCAL_GL_RGB;
case gfxASurface::ImageFormatA8:
return LOCAL_GL_LUMINANCE;
default:
NS_WARNING("Unknown GL format for Image format");
}
@ -780,6 +782,8 @@ PixelFormatForImage(gfxASurface::gfxImageFormat aFormat)
return PIXEL_FORMAT_RGBX_8888;
case gfxASurface::ImageFormatRGB16_565:
return PIXEL_FORMAT_RGB_565;
case gfxASurface::ImageFormatA8:
return PIXEL_FORMAT_L_8;
default:
MOZ_NOT_REACHED("Unknown gralloc pixel format for Image format");
}
@ -793,6 +797,7 @@ GLTypeForImage(gfxASurface::gfxImageFormat aFormat)
switch (aFormat) {
case gfxASurface::ImageFormatARGB32:
case gfxASurface::ImageFormatRGB24:
case gfxASurface::ImageFormatA8:
return LOCAL_GL_UNSIGNED_BYTE;
case gfxASurface::ImageFormatRGB16_565:
return LOCAL_GL_UNSIGNED_SHORT_5_6_5;

View File

@ -2621,7 +2621,8 @@ BasicShadowableImageLayer::Paint(gfxContext* aContext, Layer* aMaskLayer)
return;
}
AutoLockImage autoLock(mContainer);
nsRefPtr<gfxASurface> surface;
AutoLockImage autoLock(mContainer, getter_AddRefs(surface));
Image *image = autoLock.GetImage();
@ -2691,11 +2692,16 @@ BasicShadowableImageLayer::Paint(gfxContext* aContext, Layer* aMaskLayer)
DestroyBackBuffer();
mBufferIsOpaque = isOpaque;
if (!BasicManager()->AllocBuffer(
mSize,
isOpaque ?
gfxASurface::CONTENT_COLOR : gfxASurface::CONTENT_COLOR_ALPHA,
&mBackBuffer))
gfxASurface::gfxContentType type = gfxASurface::CONTENT_COLOR_ALPHA;
if (surface) {
type = surface->GetContentType();
}
if (type != gfxASurface::CONTENT_ALPHA &&
isOpaque) {
type = gfxASurface::CONTENT_COLOR;
}
if (!BasicManager()->AllocBuffer(mSize, type, &mBackBuffer))
NS_RUNTIMEABORT("creating ImageLayer 'front buffer' failed!");
}

View File

@ -151,7 +151,7 @@ uniform sampler2D uMaskTexture;\n\
uniform vec4 uRenderColor;\n\
void main()\n\
{\n\
float mask = texture2D(uMaskTexture, vMaskCoord).a;\n\
float mask = texture2D(uMaskTexture, vMaskCoord).r;\n\
\n\
gl_FragColor = mask * uRenderColor;\n\
}\n\
@ -202,7 +202,7 @@ uniform sampler2D uMaskTexture;\n\
uniform sampler2D uTexture;\n\
void main()\n\
{\n\
float mask = texture2D(uMaskTexture, vMaskCoord).a;\n\
float mask = texture2D(uMaskTexture, vMaskCoord).r;\n\
\n\
gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;\n\
}\n\
@ -230,7 +230,7 @@ uniform sampler2D uTexture;\n\
void main()\n\
{\n\
vec2 maskCoords = vMaskCoord.xy / vMaskCoord.z;\n\
float mask = texture2D(uMaskTexture, maskCoords).a;\n\
float mask = texture2D(uMaskTexture, maskCoords).r;\n\
\n\
gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;\n\
}\n\
@ -295,7 +295,7 @@ uniform sampler2DRect uTexture;\n\
uniform vec2 uTexCoordMultiplier;\n\
void main()\n\
{\n\
float mask = texture2D(uMaskTexture, vMaskCoord).a;\n\
float mask = texture2D(uMaskTexture, vMaskCoord).r;\n\
\n\
gl_FragColor = texture2DRect(uTexture, vec2(vTexCoord * uTexCoordMultiplier)) * uLayerOpacity * mask;\n\
}\n\
@ -333,7 +333,7 @@ uniform vec2 uTexCoordMultiplier;\n\
void main()\n\
{\n\
vec2 maskCoords = vMaskCoord.xy / vMaskCoord.z;\n\
float mask = texture2D(uMaskTexture, maskCoords).a;\n\
float mask = texture2D(uMaskTexture, maskCoords).r;\n\
\n\
gl_FragColor = texture2DRect(uTexture, vec2(vTexCoord * uTexCoordMultiplier)) * uLayerOpacity * mask;\n\
}\n\
@ -390,7 +390,7 @@ uniform sampler2D uMaskTexture;\n\
uniform sampler2D uTexture;\n\
void main()\n\
{\n\
float mask = texture2D(uMaskTexture, vMaskCoord).a;\n\
float mask = texture2D(uMaskTexture, vMaskCoord).r;\n\
\n\
gl_FragColor = texture2D(uTexture, vTexCoord).bgra * uLayerOpacity * mask;\n\
}\n\
@ -441,7 +441,7 @@ uniform sampler2D uMaskTexture;\n\
uniform sampler2D uTexture;\n\
void main()\n\
{\n\
float mask = texture2D(uMaskTexture, vMaskCoord).a;\n\
float mask = texture2D(uMaskTexture, vMaskCoord).r;\n\
\n\
gl_FragColor = vec4(texture2D(uTexture, vTexCoord).rgb, 1.0) * uLayerOpacity * mask;\n\
}\n\
@ -492,7 +492,7 @@ uniform sampler2D uMaskTexture;\n\
uniform sampler2D uTexture;\n\
void main()\n\
{\n\
float mask = texture2D(uMaskTexture, vMaskCoord).a;\n\
float mask = texture2D(uMaskTexture, vMaskCoord).r;\n\
\n\
gl_FragColor = vec4(texture2D(uTexture, vTexCoord).bgr, 1.0) * uLayerOpacity * mask;\n\
}\n\
@ -571,7 +571,7 @@ color.r = yuv.g * 1.164 + yuv.r * 1.596;\n\
color.g = yuv.g * 1.164 - 0.813 * yuv.r - 0.391 * yuv.b;\n\
color.b = yuv.g * 1.164 + yuv.b * 2.018;\n\
color.a = 1.0;\n\
float mask = texture2D(uMaskTexture, vMaskCoord).a;\n\
float mask = texture2D(uMaskTexture, vMaskCoord).r;\n\
\n\
gl_FragColor = color * uLayerOpacity * mask;\n\
}\n\
@ -630,7 +630,7 @@ void main()\n\
vec3 onBlack = texture2D(uBlackTexture, vTexCoord).bgr;\n\
vec3 onWhite = texture2D(uWhiteTexture, vTexCoord).bgr;\n\
vec4 alphas = (1.0 - onWhite + onBlack).rgbg;\n\
float mask = texture2D(uMaskTexture, vMaskCoord).a;\n\
float mask = texture2D(uMaskTexture, vMaskCoord).r;\n\
\n\
gl_FragColor = alphas * uLayerOpacity * mask;\n\
}\n\
@ -689,7 +689,7 @@ void main()\n\
vec3 onBlack = texture2D(uBlackTexture, vTexCoord).bgr;\n\
vec3 onWhite = texture2D(uWhiteTexture, vTexCoord).bgr;\n\
vec4 alphas = (1.0 - onWhite + onBlack).rgbg;\n\
float mask = texture2D(uMaskTexture, vMaskCoord).a;\n\
float mask = texture2D(uMaskTexture, vMaskCoord).r;\n\
\n\
gl_FragColor = vec4(onBlack, alphas.a) * uLayerOpacity * mask;\n\
}\n\

View File

@ -176,12 +176,12 @@ uniform sampler2D uMaskTexture;
@end
@define FRAGMENT_CALC_MASK<Mask>
float mask = texture2D(uMaskTexture, vMaskCoord).a;
float mask = texture2D(uMaskTexture, vMaskCoord).r;
@end
@define FRAGMENT_CALC_MASK<Mask3D>
vec2 maskCoords = vMaskCoord.xy / vMaskCoord.z;
float mask = texture2D(uMaskTexture, maskCoords).a;
float mask = texture2D(uMaskTexture, maskCoords).r;
@end
// Solid color rendering.