Bug 1209812 (part 3) - Rename SurfaceFormat::R5G6B5 as R5G6B5_UINT16. r=Bas.

This commit is contained in:
Nicholas Nethercote 2015-10-22 23:01:31 -07:00
parent baca16b0bc
commit eed0822094
29 changed files with 49 additions and 48 deletions

View File

@ -4497,7 +4497,7 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& image,
if (ok) {
NativeSurface texSurf;
texSurf.mType = NativeSurfaceType::OPENGL_TEXTURE;
texSurf.mFormat = SurfaceFormat::R5G6B5;
texSurf.mFormat = SurfaceFormat::R5G6B5_UINT16;
texSurf.mSize.width = mCurrentVideoSize.width;
texSurf.mSize.height = mCurrentVideoSize.height;
texSurf.mSurface = (void*)((uintptr_t)mVideoTexture);

View File

@ -1943,7 +1943,7 @@ WebGLContext::SurfaceFromElementResultToImageSurface(nsLayoutUtils::SurfaceFromE
case SurfaceFormat::A8:
*format = WebGLTexelFormat::A8;
break;
case SurfaceFormat::R5G6B5:
case SurfaceFormat::R5G6B5_UINT16:
*format = WebGLTexelFormat::RGB565;
break;
default:

View File

@ -403,7 +403,7 @@ nsresult VP8TrackEncoder::PrepareRawFrame(VideoChunk &aChunk)
cr, halfWidth,
mFrameWidth, mFrameHeight);
break;
case SurfaceFormat::R5G6B5:
case SurfaceFormat::R5G6B5_UINT16:
rv = libyuv::RGB565ToI420(static_cast<uint8*>(map.GetData()),
map.GetStride(),
y, mFrameWidth,

View File

@ -671,7 +671,7 @@ GfxFormatForCairoSurface(cairo_surface_t* surface)
// xlib is currently the only Cairo backend that creates 16bpp surfaces
if (type == CAIRO_SURFACE_TYPE_XLIB &&
cairo_xlib_surface_get_depth(surface) == 16) {
return SurfaceFormat::R5G6B5;
return SurfaceFormat::R5G6B5_UINT16;
}
#endif
return CairoContentToGfxFormat(cairo_surface_get_content(surface));

View File

@ -153,7 +153,7 @@ GfxFormatToCairoFormat(SurfaceFormat format)
return CAIRO_FORMAT_RGB24;
case SurfaceFormat::A8:
return CAIRO_FORMAT_A8;
case SurfaceFormat::R5G6B5:
case SurfaceFormat::R5G6B5_UINT16:
return CAIRO_FORMAT_RGB16_565;
default:
gfxCriticalError() << "Unknown image format " << (int)format;
@ -169,7 +169,7 @@ GfxFormatToCairoContent(SurfaceFormat format)
case SurfaceFormat::B8G8R8A8:
return CAIRO_CONTENT_COLOR_ALPHA;
case SurfaceFormat::B8G8R8X8:
case SurfaceFormat::R5G6B5: //fall through
case SurfaceFormat::R5G6B5_UINT16: //fall through
return CAIRO_CONTENT_COLOR;
case SurfaceFormat::A8:
return CAIRO_CONTENT_ALPHA;
@ -241,7 +241,7 @@ CairoFormatToGfxFormat(cairo_format_t format)
case CAIRO_FORMAT_A8:
return SurfaceFormat::A8;
case CAIRO_FORMAT_RGB16_565:
return SurfaceFormat::R5G6B5;
return SurfaceFormat::R5G6B5_UINT16;
default:
gfxCriticalError() << "Unknown cairo format " << format;
return SurfaceFormat::UNKNOWN;

View File

@ -30,7 +30,7 @@ GfxFormatToSkiaColorType(SurfaceFormat format)
case SurfaceFormat::B8G8R8X8:
// We probably need to do something here.
return kBGRA_8888_SkColorType;
case SurfaceFormat::R5G6B5:
case SurfaceFormat::R5G6B5_UINT16:
return kRGB_565_SkColorType;
case SurfaceFormat::A8:
return kAlpha_8_SkColorType;
@ -47,7 +47,7 @@ SkiaColorTypeToGfxFormat(SkColorType type)
case kBGRA_8888_SkColorType:
return SurfaceFormat::B8G8R8A8;
case kRGB_565_SkColorType:
return SurfaceFormat::R5G6B5;
return SurfaceFormat::R5G6B5_UINT16;
case kAlpha_8_SkColorType:
return SurfaceFormat::A8;
default:
@ -66,7 +66,7 @@ GfxFormatToGrConfig(SurfaceFormat format)
case SurfaceFormat::B8G8R8X8:
// We probably need to do something here.
return kBGRA_8888_GrPixelConfig;
case SurfaceFormat::R5G6B5:
case SurfaceFormat::R5G6B5_UINT16:
return kRGB_565_GrPixelConfig;
case SurfaceFormat::A8:
return kAlpha_8_GrPixelConfig;

View File

@ -399,8 +399,8 @@ public:
case SurfaceFormat::R8G8B8X8:
mMessage << "SurfaceFormat::R8G8B8X8";
break;
case SurfaceFormat::R5G6B5:
mMessage << "SurfaceFormat::R5G6B5";
case SurfaceFormat::R5G6B5_UINT16:
mMessage << "SurfaceFormat::R5G6B5_UINT16";
break;
case SurfaceFormat::A8:
mMessage << "SurfaceFormat::A8";

View File

@ -86,7 +86,7 @@ BytesPerPixel(SurfaceFormat aFormat)
switch (aFormat) {
case SurfaceFormat::A8:
return 1;
case SurfaceFormat::R5G6B5:
case SurfaceFormat::R5G6B5_UINT16:
return 2;
default:
return 4;

View File

@ -34,7 +34,7 @@ enum class SurfaceFormat : int8_t {
B8G8R8X8,
R8G8B8A8,
R8G8B8X8,
R5G6B5,
R5G6B5_UINT16,
A8,
YUV,
NV12,
@ -46,7 +46,7 @@ inline bool IsOpaque(SurfaceFormat aFormat)
switch (aFormat) {
case SurfaceFormat::B8G8R8X8:
case SurfaceFormat::R8G8B8X8:
case SurfaceFormat::R5G6B5:
case SurfaceFormat::R5G6B5_UINT16:
case SurfaceFormat::YUV:
case SurfaceFormat::NV12:
return true;

View File

@ -274,7 +274,7 @@ CopyDataSourceSurface(DataSourceSurface* aSource,
aDest->GetFormat() == SurfaceFormat::R8G8B8X8 ||
aDest->GetFormat() == SurfaceFormat::B8G8R8A8 ||
aDest->GetFormat() == SurfaceFormat::B8G8R8X8 ||
aDest->GetFormat() == SurfaceFormat::R5G6B5);
aDest->GetFormat() == SurfaceFormat::R5G6B5_UINT16);
const bool isSrcBGR = aSource->GetFormat() == SurfaceFormat::B8G8R8A8 ||
aSource->GetFormat() == SurfaceFormat::B8G8R8X8;
@ -288,7 +288,7 @@ CopyDataSourceSurface(DataSourceSurface* aSource,
aDest->GetFormat() == SurfaceFormat::B8G8R8A8;
const bool needsAlphaMask = !srcHasAlpha && destHasAlpha;
const bool needsConvertTo16Bits = aDest->GetFormat() == SurfaceFormat::R5G6B5;
const bool needsConvertTo16Bits = aDest->GetFormat() == SurfaceFormat::R5G6B5_UINT16;
DataSourceSurface::MappedSurface srcMap;
DataSourceSurface::MappedSurface destMap;
@ -394,7 +394,7 @@ ReadPixelsIntoDataSurface(GLContext* gl, DataSourceSurface* dest)
destFormat = LOCAL_GL_RGBA;
destType = LOCAL_GL_UNSIGNED_BYTE;
break;
case SurfaceFormat::R5G6B5:
case SurfaceFormat::R5G6B5_UINT16:
destFormat = LOCAL_GL_RGB;
destType = LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV;
break;
@ -438,7 +438,7 @@ ReadPixelsIntoDataSurface(GLContext* gl, DataSourceSurface* dest)
case LOCAL_GL_RGB: {
MOZ_ASSERT(destPixelSize == 2);
MOZ_ASSERT(readType == LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV);
readFormatGFX = SurfaceFormat::R5G6B5;
readFormatGFX = SurfaceFormat::R5G6B5_UINT16;
break;
}
default: {

View File

@ -486,10 +486,10 @@ UploadImageDataToTexture(GLContext* gl,
}
internalFormat = LOCAL_GL_RGBA;
break;
case SurfaceFormat::R5G6B5:
case SurfaceFormat::R5G6B5_UINT16:
internalFormat = format = LOCAL_GL_RGB;
type = LOCAL_GL_UNSIGNED_SHORT_5_6_5;
surfaceFormat = SurfaceFormat::R5G6B5;
surfaceFormat = SurfaceFormat::R5G6B5_UINT16;
break;
case SurfaceFormat::A8:
internalFormat = format = LOCAL_GL_LUMINANCE;

View File

@ -20,7 +20,7 @@ GLFormatForImage(gfx::SurfaceFormat aFormat)
case gfx::SurfaceFormat::B8G8R8A8:
case gfx::SurfaceFormat::B8G8R8X8:
return LOCAL_GL_RGBA;
case gfx::SurfaceFormat::R5G6B5:
case gfx::SurfaceFormat::R5G6B5_UINT16:
return LOCAL_GL_RGB;
case gfx::SurfaceFormat::A8:
return LOCAL_GL_LUMINANCE;
@ -38,7 +38,7 @@ GLTypeForImage(gfx::SurfaceFormat aFormat)
case gfx::SurfaceFormat::B8G8R8X8:
case gfx::SurfaceFormat::A8:
return LOCAL_GL_UNSIGNED_BYTE;
case gfx::SurfaceFormat::R5G6B5:
case gfx::SurfaceFormat::R5G6B5_UINT16:
return LOCAL_GL_UNSIGNED_SHORT_5_6_5;
default:
NS_WARNING("Unknown GL format for Surface format");
@ -69,7 +69,7 @@ TextureImageEGL::TextureImageEGL(GLuint aTexture,
gfxPlatform::GetPlatform()->Optimal2DFormatForContent(GetContentType());
}
if (mUpdateFormat == gfx::SurfaceFormat::R5G6B5) {
if (mUpdateFormat == gfx::SurfaceFormat::R5G6B5_UINT16) {
mTextureFormat = gfx::SurfaceFormat::R8G8B8X8;
} else if (mUpdateFormat == gfx::SurfaceFormat::B8G8R8X8) {
mTextureFormat = gfx::SurfaceFormat::B8G8R8X8;

View File

@ -267,7 +267,7 @@ CreateTexturedEffect(gfx::SurfaceFormat aFormat,
case gfx::SurfaceFormat::B8G8R8A8:
case gfx::SurfaceFormat::B8G8R8X8:
case gfx::SurfaceFormat::R8G8B8X8:
case gfx::SurfaceFormat::R5G6B5:
case gfx::SurfaceFormat::R5G6B5_UINT16:
case gfx::SurfaceFormat::R8G8B8A8:
result = new EffectRGB(aSource, isAlphaPremultiplied, aFilter);
break;

View File

@ -384,7 +384,7 @@ ConvertOmxYUVFormatToRGB565(android::sp<GraphicBuffer>& aBuffer,
return BAD_VALUE;
}
uint32_t pixelStride = aMappedSurface->mStride/gfx::BytesPerPixel(gfx::SurfaceFormat::R5G6B5);
uint32_t pixelStride = aMappedSurface->mStride/gfx::BytesPerPixel(gfx::SurfaceFormat::R5G6B5_UINT16);
rv = colorConverter.convert(buffer, width, height,
0, 0, width - 1, height - 1 /* source crop */,
aMappedSurface->mData, pixelStride, height,

View File

@ -316,7 +316,8 @@ AppendToString(std::stringstream& aStream, mozilla::gfx::SurfaceFormat format,
case SurfaceFormat::B8G8R8X8: aStream << "SurfaceFormat::B8G8R8X8"; break;
case SurfaceFormat::R8G8B8A8: aStream << "SurfaceFormat::R8G8B8A8"; break;
case SurfaceFormat::R8G8B8X8: aStream << "SurfaceFormat::R8G8B8X8"; break;
case SurfaceFormat::R5G6B5: aStream << "SurfaceFormat::R5G6B5"; break;
case SurfaceFormat::R5G6B5_UINT16:
aStream << "SurfaceFormat::R5G6B5_UINT16"; break;
case SurfaceFormat::A8: aStream << "SurfaceFormat::A8"; break;
case SurfaceFormat::YUV: aStream << "SurfaceFormat::YUV"; break;
case SurfaceFormat::NV12: aStream << "SurfaceFormat::NV12"; break;

View File

@ -833,7 +833,7 @@ CompositorOGL::GetShaderConfigFor(Effect *aEffect,
MOZ_ASSERT_IF(source->GetTextureTarget() == LOCAL_GL_TEXTURE_RECTANGLE_ARB,
source->GetFormat() == gfx::SurfaceFormat::R8G8B8A8 ||
source->GetFormat() == gfx::SurfaceFormat::R8G8B8X8 ||
source->GetFormat() == gfx::SurfaceFormat::R5G6B5);
source->GetFormat() == gfx::SurfaceFormat::R5G6B5_UINT16);
config = ShaderConfigFromTargetAndFormat(source->GetTextureTarget(),
source->GetFormat());
break;

View File

@ -181,7 +181,7 @@ SurfaceFormatForPixelFormat(android::PixelFormat aFormat)
case PIXEL_FORMAT_RGBX_8888:
return gfx::SurfaceFormat::R8G8B8X8;
case PIXEL_FORMAT_RGB_565:
return gfx::SurfaceFormat::R5G6B5;
return gfx::SurfaceFormat::R5G6B5_UINT16;
case HAL_PIXEL_FORMAT_YV12:
return gfx::SurfaceFormat::YUV;
default:
@ -284,7 +284,7 @@ GrallocTextureClientOGL::AllocateForSurface(gfx::IntSize aSize,
format = android::PIXEL_FORMAT_RGBX_8888;
mFlags |= TextureFlags::RB_SWAPPED;
break;
case gfx::SurfaceFormat::R5G6B5:
case gfx::SurfaceFormat::R5G6B5_UINT16:
format = android::PIXEL_FORMAT_RGB_565;
break;
case gfx::SurfaceFormat::YUV:
@ -329,7 +329,7 @@ GrallocTextureClientOGL::AllocateForGLRendering(gfx::IntSize aSize)
// there is no android BGRX format?
format = android::PIXEL_FORMAT_RGBX_8888;
break;
case gfx::SurfaceFormat::R5G6B5:
case gfx::SurfaceFormat::R5G6B5_UINT16:
format = android::PIXEL_FORMAT_RGB_565;
break;
default:

View File

@ -35,7 +35,7 @@ SurfaceFormatForAndroidPixelFormat(android::PixelFormat aFormat,
case android::PIXEL_FORMAT_RGBX_8888:
return swapRB ? gfx::SurfaceFormat::B8G8R8X8 : gfx::SurfaceFormat::R8G8B8X8;
case android::PIXEL_FORMAT_RGB_565:
return gfx::SurfaceFormat::R5G6B5;
return gfx::SurfaceFormat::R5G6B5_UINT16;
case HAL_PIXEL_FORMAT_YCbCr_422_SP:
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
case HAL_PIXEL_FORMAT_YCbCr_422_I:

View File

@ -249,7 +249,7 @@ ShaderConfigFromTargetAndFormat(GLenum aTarget,
aFormat == gfx::SurfaceFormat::B8G8R8X8);
config.SetNoAlpha(aFormat == gfx::SurfaceFormat::B8G8R8X8 ||
aFormat == gfx::SurfaceFormat::R8G8B8X8 ||
aFormat == gfx::SurfaceFormat::R5G6B5);
aFormat == gfx::SurfaceFormat::R5G6B5_UINT16);
return config;
}

View File

@ -88,7 +88,7 @@ inline gfxImageFormat SurfaceFormatToImageFormat(SurfaceFormat aFormat)
return gfxImageFormat::ARGB32;
case SurfaceFormat::B8G8R8X8:
return gfxImageFormat::RGB24;
case SurfaceFormat::R5G6B5:
case SurfaceFormat::R5G6B5_UINT16:
return gfxImageFormat::RGB16_565;
case SurfaceFormat::A8:
return gfxImageFormat::A8;
@ -105,7 +105,7 @@ inline SurfaceFormat ImageFormatToSurfaceFormat(gfxImageFormat aFormat)
case gfxImageFormat::RGB24:
return SurfaceFormat::B8G8R8X8;
case gfxImageFormat::RGB16_565:
return SurfaceFormat::R5G6B5;
return SurfaceFormat::R5G6B5_UINT16;
case gfxImageFormat::A8:
return SurfaceFormat::A8;
default:
@ -117,7 +117,7 @@ inline SurfaceFormat ImageFormatToSurfaceFormat(gfxImageFormat aFormat)
inline gfxContentType ContentForFormat(const SurfaceFormat &aFormat)
{
switch (aFormat) {
case SurfaceFormat::R5G6B5:
case SurfaceFormat::R5G6B5_UINT16:
case SurfaceFormat::B8G8R8X8:
case SurfaceFormat::R8G8B8X8:
return gfxContentType::COLOR;

View File

@ -1852,7 +1852,7 @@ gfxPlatform::Optimal2DFormatForContent(gfxContentType aContent)
case gfxImageFormat::RGB24:
return mozilla::gfx::SurfaceFormat::B8G8R8X8;
case gfxImageFormat::RGB16_565:
return mozilla::gfx::SurfaceFormat::R5G6B5;
return mozilla::gfx::SurfaceFormat::R5G6B5_UINT16;
default:
NS_NOTREACHED("unknown gfxImageFormat for gfxContentType::COLOR");
return mozilla::gfx::SurfaceFormat::B8G8R8A8;

View File

@ -73,7 +73,7 @@ void mozilla_dump_image(void* bytes, int width, int height, int bytepp,
// TODO more flexible; parse string?
switch (bytepp) {
case 2:
format = SurfaceFormat::R5G6B5;
format = SurfaceFormat::R5G6B5_UINT16;
break;
case 4:
default:

View File

@ -28,7 +28,7 @@ GetYCbCrToRGBDestFormatAndSize(const layers::PlanarYCbCrData& aData,
bool prescale = aSuggestedSize.width > 0 && aSuggestedSize.height > 0 &&
aSuggestedSize != aData.mPicSize;
if (aSuggestedFormat == SurfaceFormat::R5G6B5) {
if (aSuggestedFormat == SurfaceFormat::R5G6B5_UINT16) {
#if defined(HAVE_YCBCR_TO_RGB565)
if (prescale &&
!IsScaleYCbCrToRGB565Fast(aData.mPicX,
@ -88,7 +88,7 @@ ConvertYCbCrToRGB(const layers::PlanarYCbCrData& aData,
// Convert from YCbCr to RGB now, scaling the image if needed.
if (aDestSize != aData.mPicSize) {
#if defined(HAVE_YCBCR_TO_RGB565)
if (aDestFormat == SurfaceFormat::R5G6B5) {
if (aDestFormat == SurfaceFormat::R5G6B5_UINT16) {
ScaleYCbCrToRGB565(aData.mYChannel,
aData.mCbChannel,
aData.mCrChannel,
@ -122,7 +122,7 @@ ConvertYCbCrToRGB(const layers::PlanarYCbCrData& aData,
FILTER_BILINEAR);
} else { // no prescale
#if defined(HAVE_YCBCR_TO_RGB565)
if (aDestFormat == SurfaceFormat::R5G6B5) {
if (aDestFormat == SurfaceFormat::R5G6B5_UINT16) {
ConvertYCbCrToRGB565(aData.mYChannel,
aData.mCbChannel,
aData.mCrChannel,

View File

@ -396,7 +396,7 @@ imgFrame::Optimize()
->Optimal2DFormatForContent(gfxContentType::COLOR);
if (mFormat != SurfaceFormat::B8G8R8A8 &&
optFormat == SurfaceFormat::R5G6B5) {
optFormat == SurfaceFormat::R5G6B5_UINT16) {
RefPtr<VolatileBuffer> buf =
AllocateBufferForImage(mSize, optFormat);
if (!buf) {

View File

@ -1205,7 +1205,7 @@ void MediaPipelineTransmit::PipelineListener::ProcessVideoChunk(
yuv + cr_offset, half_width,
size.width, size.height);
break;
case SurfaceFormat::R5G6B5:
case SurfaceFormat::R5G6B5_UINT16:
rv = libyuv::RGB565ToI420(static_cast<uint8*>(map.GetData()),
map.GetStride(),
yuv, size.width,

View File

@ -1861,7 +1861,7 @@ AndroidBridge::CaptureZoomedView(nsIDOMWindow *window, nsIntRect zoomedViewRect,
presContext->DevPixelsToAppUnits(zoomedViewRect.height / scaleFactor ));
bool is24bit = (GetScreenDepth() == 24);
SurfaceFormat format = is24bit ? SurfaceFormat::B8G8R8X8 : SurfaceFormat::R5G6B5;
SurfaceFormat format = is24bit ? SurfaceFormat::B8G8R8X8 : SurfaceFormat::R5G6B5_UINT16;
gfxImageFormat iFormat = gfx::SurfaceFormatToImageFormat(format);
uint32_t stride = gfxASurface::FormatStrideForWidth(iFormat, zoomedViewRect.width);
@ -1980,7 +1980,7 @@ nsresult AndroidBridge::CaptureThumbnail(nsIDOMWindow *window, int32_t bufW, int
IntSize(bufW, bufH),
stride,
is24bit ? SurfaceFormat::B8G8R8X8 :
SurfaceFormat::R5G6B5);
SurfaceFormat::R5G6B5_UINT16);
if (!dt) {
ALOG_BRIDGE("Error creating DrawTarget");
return NS_ERROR_FAILURE;

View File

@ -642,7 +642,7 @@ HalFormatToSurfaceFormat(int aHalFormat)
case HAL_PIXEL_FORMAT_BGRA_8888:
return SurfaceFormat::B8G8R8A8;
case HAL_PIXEL_FORMAT_RGB_565:
return SurfaceFormat::R5G6B5;
return SurfaceFormat::R5G6B5_UINT16;
default:
MOZ_CRASH("Unhandled HAL pixel format");
return SurfaceFormat::UNKNOWN; // not reached

View File

@ -112,7 +112,7 @@ nsShmImage::Create(const IntSize& aSize,
}
goto unsupported;
case 16:
shm->mFormat = SurfaceFormat::R5G6B5;
shm->mFormat = SurfaceFormat::R5G6B5_UINT16;
break;
unsupported:
default:

View File

@ -62,7 +62,7 @@ _moz2dformat_to_qformat(SurfaceFormat aFormat)
return QImage::Format_ARGB32_Premultiplied;
case SurfaceFormat::B8G8R8X8:
return QImage::Format_ARGB32;
case SurfaceFormat::R5G6B5:
case SurfaceFormat::R5G6B5_UINT16:
return QImage::Format_RGB16;
default:
return QImage::Format_Invalid;