Backed out 6 changesets (bug 1061525) for mochitest-2 failures in test_BufferedSeek_mp4.html CLOSED TREE

Backed out changeset 5e90b9dab7fa (bug 1061525)
Backed out changeset ef5ce3d6412a (bug 1061525)
Backed out changeset 19c8682665a6 (bug 1061525)
Backed out changeset b48d13edb48d (bug 1061525)
Backed out changeset fae6602192a7 (bug 1061525)
Backed out changeset 5dfbd6e73c7a (bug 1061525)
This commit is contained in:
Wes Kocher 2015-08-03 19:53:33 -07:00
parent 7fe3f37d58
commit b822a1fdfc
14 changed files with 94 additions and 309 deletions

View File

@ -474,7 +474,7 @@ AppleVDADecoder::CreateOutputConfiguration()
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
SInt32 PixelFormatTypeValue = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;
SInt32 PixelFormatTypeValue = kCVPixelFormatType_32BGRA;
AutoCFRelease<CFNumberRef> PixelFormatTypeNumber =
CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type,

View File

@ -350,12 +350,14 @@ AppleVTDecoder::CreateDecoderExtensions()
const void* extensionKeys[] =
{ kCVImageBufferChromaLocationBottomFieldKey,
kCVImageBufferChromaLocationTopFieldKey,
AppleCMLinker::skPropExtensionAtoms };
AppleCMLinker::skPropExtensionAtoms,
AppleCMLinker::skPropFullRangeVideo /* Not defined in 10.6 */ };
const void* extensionValues[] =
{ kCVImageBufferChromaLocation_Left,
kCVImageBufferChromaLocation_Left,
atoms };
atoms,
kCFBooleanTrue };
static_assert(ArrayLength(extensionKeys) == ArrayLength(extensionValues),
"Non matching keys/values array size");

View File

@ -46,10 +46,10 @@ IOSurfaceGetIDFunc MacIOSurfaceLib::sGetID;
IOSurfaceLookupFunc MacIOSurfaceLib::sLookup;
IOSurfaceGetBaseAddressFunc MacIOSurfaceLib::sGetBaseAddress;
IOSurfaceGetBaseAddressOfPlaneFunc MacIOSurfaceLib::sGetBaseAddressOfPlane;
IOSurfaceSizePlaneTFunc MacIOSurfaceLib::sWidth;
IOSurfaceSizePlaneTFunc MacIOSurfaceLib::sHeight;
IOSurfaceSizeTFunc MacIOSurfaceLib::sWidth;
IOSurfaceSizeTFunc MacIOSurfaceLib::sHeight;
IOSurfaceSizeTFunc MacIOSurfaceLib::sPlaneCount;
IOSurfaceSizePlaneTFunc MacIOSurfaceLib::sBytesPerRow;
IOSurfaceSizeTFunc MacIOSurfaceLib::sBytesPerRow;
IOSurfaceGetPropertyMaximumFunc MacIOSurfaceLib::sGetPropertyMaximum;
IOSurfaceVoidFunc MacIOSurfaceLib::sIncrementUseCount;
IOSurfaceVoidFunc MacIOSurfaceLib::sDecrementUseCount;
@ -61,7 +61,6 @@ IOSurfaceContextCreateImageFunc MacIOSurfaceLib::sIOSurfaceContextCreateImage;
IOSurfaceContextGetSurfaceFunc MacIOSurfaceLib::sIOSurfaceContextGetSurface;
CVPixelBufferGetIOSurfaceFunc MacIOSurfaceLib::sCVPixelBufferGetIOSurface;
unsigned int (*MacIOSurfaceLib::sCGContextGetTypePtr) (CGContextRef) = nullptr;
IOSurfacePixelFormatFunc MacIOSurfaceLib::sPixelFormat;
CFStringRef MacIOSurfaceLib::kPropWidth;
CFStringRef MacIOSurfaceLib::kPropHeight;
@ -103,26 +102,22 @@ size_t MacIOSurfaceLib::IOSurfaceGetPlaneCount(IOSurfacePtr aIOSurfacePtr) {
return sPlaneCount(aIOSurfacePtr);
}
size_t MacIOSurfaceLib::IOSurfaceGetWidth(IOSurfacePtr aIOSurfacePtr, size_t plane) {
return sWidth(aIOSurfacePtr, plane);
size_t MacIOSurfaceLib::IOSurfaceGetWidth(IOSurfacePtr aIOSurfacePtr) {
return sWidth(aIOSurfacePtr);
}
size_t MacIOSurfaceLib::IOSurfaceGetHeight(IOSurfacePtr aIOSurfacePtr, size_t plane) {
return sHeight(aIOSurfacePtr, plane);
size_t MacIOSurfaceLib::IOSurfaceGetHeight(IOSurfacePtr aIOSurfacePtr) {
return sHeight(aIOSurfacePtr);
}
size_t MacIOSurfaceLib::IOSurfaceGetBytesPerRow(IOSurfacePtr aIOSurfacePtr, size_t plane) {
return sBytesPerRow(aIOSurfacePtr, plane);
size_t MacIOSurfaceLib::IOSurfaceGetBytesPerRow(IOSurfacePtr aIOSurfacePtr) {
return sBytesPerRow(aIOSurfacePtr);
}
size_t MacIOSurfaceLib::IOSurfaceGetPropertyMaximum(CFStringRef property) {
return sGetPropertyMaximum(property);
}
OSType MacIOSurfaceLib::IOSurfaceGetPixelFormat(IOSurfacePtr aIOSurfacePtr) {
return sPixelFormat(aIOSurfacePtr);
}
IOReturn MacIOSurfaceLib::IOSurfaceLock(IOSurfacePtr aIOSurfacePtr,
uint32_t options, uint32_t* seed) {
return sLock(aIOSurfacePtr, options, seed);
@ -223,9 +218,9 @@ void MacIOSurfaceLib::LoadLibrary() {
kPropIsGlobal = GetIOConst("kIOSurfaceIsGlobal");
sCreate = GET_IOSYM(sCreate, "IOSurfaceCreate");
sGetID = GET_IOSYM(sGetID, "IOSurfaceGetID");
sWidth = GET_IOSYM(sWidth, "IOSurfaceGetWidthOfPlane");
sHeight = GET_IOSYM(sHeight, "IOSurfaceGetHeightOfPlane");
sBytesPerRow = GET_IOSYM(sBytesPerRow, "IOSurfaceGetBytesPerRowOfPlane");
sWidth = GET_IOSYM(sWidth, "IOSurfaceGetWidth");
sHeight = GET_IOSYM(sHeight, "IOSurfaceGetHeight");
sBytesPerRow = GET_IOSYM(sBytesPerRow, "IOSurfaceGetBytesPerRow");
sGetPropertyMaximum = GET_IOSYM(sGetPropertyMaximum, "IOSurfaceGetPropertyMaximum");
sLookup = GET_IOSYM(sLookup, "IOSurfaceLookup");
sLock = GET_IOSYM(sLock, "IOSurfaceLock");
@ -238,7 +233,6 @@ void MacIOSurfaceLib::LoadLibrary() {
sGetBaseAddressOfPlane =
GET_IOSYM(sGetBaseAddressOfPlane, "IOSurfaceGetBaseAddressOfPlane");
sPlaneCount = GET_IOSYM(sPlaneCount, "IOSurfaceGetPlaneCount");
sPixelFormat = GET_IOSYM(sPixelFormat, "IOSurfaceGetPixelFormat");
sTexImage = GET_CGLSYM(sTexImage, "CGLTexImageIOSurface2D");
sCGContextGetTypePtr = (unsigned int (*)(CGContext*))dlsym(RTLD_DEFAULT, "CGContextGetType");
@ -380,14 +374,14 @@ void* MacIOSurface::GetBaseAddressOfPlane(size_t aPlaneIndex)
aPlaneIndex);
}
size_t MacIOSurface::GetWidth(size_t plane) {
size_t MacIOSurface::GetWidth() {
size_t intScaleFactor = ceil(mContentsScaleFactor);
return GetDevicePixelWidth(plane) / intScaleFactor;
return GetDevicePixelWidth() / intScaleFactor;
}
size_t MacIOSurface::GetHeight(size_t plane) {
size_t MacIOSurface::GetHeight() {
size_t intScaleFactor = ceil(mContentsScaleFactor);
return GetDevicePixelHeight(plane) / intScaleFactor;
return GetDevicePixelHeight() / intScaleFactor;
}
size_t MacIOSurface::GetPlaneCount() {
@ -406,20 +400,16 @@ size_t MacIOSurface::GetPlaneCount() {
return MacIOSurfaceLib::IOSurfaceGetPropertyMaximum(MacIOSurfaceLib::kPropHeight);
}
size_t MacIOSurface::GetDevicePixelWidth(size_t plane) {
return MacIOSurfaceLib::IOSurfaceGetWidth(mIOSurfacePtr, plane);
size_t MacIOSurface::GetDevicePixelWidth() {
return MacIOSurfaceLib::IOSurfaceGetWidth(mIOSurfacePtr);
}
size_t MacIOSurface::GetDevicePixelHeight(size_t plane) {
return MacIOSurfaceLib::IOSurfaceGetHeight(mIOSurfacePtr, plane);
size_t MacIOSurface::GetDevicePixelHeight() {
return MacIOSurfaceLib::IOSurfaceGetHeight(mIOSurfacePtr);
}
size_t MacIOSurface::GetBytesPerRow(size_t plane) {
return MacIOSurfaceLib::IOSurfaceGetBytesPerRow(mIOSurfacePtr, plane);
}
OSType MacIOSurface::GetPixelFormat() {
return MacIOSurfaceLib::IOSurfaceGetPixelFormat(mIOSurfacePtr);
size_t MacIOSurface::GetBytesPerRow() {
return MacIOSurfaceLib::IOSurfaceGetBytesPerRow(mIOSurfacePtr);
}
void MacIOSurface::IncrementUseCount() {
@ -470,52 +460,17 @@ MacIOSurface::GetAsSurface() {
return surf.forget();
}
SurfaceFormat
MacIOSurface::GetFormat()
{
OSType pixelFormat = GetPixelFormat();
if (pixelFormat == '420v') {
return SurfaceFormat::NV12;
} else {
return HasAlpha() ? SurfaceFormat::R8G8B8A8 : SurfaceFormat::R8G8B8X8;
}
}
CGLError
MacIOSurface::CGLTexImageIOSurface2D(CGLContextObj ctx, size_t plane)
MacIOSurface::CGLTexImageIOSurface2D(CGLContextObj ctx)
{
MOZ_ASSERT(plane >= 0);
OSType pixelFormat = GetPixelFormat();
GLenum internalFormat;
GLenum format;
GLenum type;
if (pixelFormat == '420v') {
MOZ_ASSERT(GetPlaneCount() == 2);
MOZ_ASSERT(plane < 2);
if (plane == 0) {
internalFormat = format = GL_LUMINANCE;
} else {
internalFormat = format = GL_LUMINANCE_ALPHA;
}
type = GL_UNSIGNED_BYTE;
} else {
MOZ_ASSERT(plane == 0);
internalFormat = HasAlpha() ? GL_RGBA : GL_RGB;
format = GL_BGRA;
type = GL_UNSIGNED_INT_8_8_8_8_REV;
}
CGLError temp = MacIOSurfaceLib::CGLTexImageIOSurface2D(ctx,
return MacIOSurfaceLib::CGLTexImageIOSurface2D(ctx,
GL_TEXTURE_RECTANGLE_ARB,
internalFormat,
GetDevicePixelWidth(plane),
GetDevicePixelHeight(plane),
format,
type,
mIOSurfacePtr, plane);
return temp;
HasAlpha() ? GL_RGBA : GL_RGB,
GetDevicePixelWidth(),
GetDevicePixelHeight(),
GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV,
mIOSurfacePtr, 0);
}
static

View File

@ -24,7 +24,6 @@ typedef void* (*IOSurfaceGetBaseAddressFunc)(IOSurfacePtr io_surface);
typedef void* (*IOSurfaceGetBaseAddressOfPlaneFunc)(IOSurfacePtr io_surface,
size_t planeIndex);
typedef size_t (*IOSurfaceSizeTFunc)(IOSurfacePtr io_surface);
typedef size_t (*IOSurfaceSizePlaneTFunc)(IOSurfacePtr io_surface, size_t plane);
typedef size_t (*IOSurfaceGetPropertyMaximumFunc) (CFStringRef property);
typedef CGLError (*CGLTexImageIOSurface2DFunc) (CGLContextObj ctxt,
GLenum target, GLenum internalFormat,
@ -41,8 +40,6 @@ typedef IOSurfacePtr (*IOSurfaceContextGetSurfaceFunc)(CGContextRef ref);
typedef IOSurfacePtr (*CVPixelBufferGetIOSurfaceFunc)(
CVPixelBufferRef pixelBuffer);
typedef OSType (*IOSurfacePixelFormatFunc)(IOSurfacePtr io_surface);
#import <OpenGL/OpenGL.h>
#include "2D.h"
#include "mozilla/RefPtr.h"
@ -88,26 +85,24 @@ public:
void *GetBaseAddress();
void *GetBaseAddressOfPlane(size_t planeIndex);
size_t GetPlaneCount();
OSType GetPixelFormat();
// GetWidth() and GetHeight() return values in "display pixels". A
// "display pixel" is the smallest fully addressable part of a display.
// But in HiDPI modes each "display pixel" corresponds to more than one
// device pixel. Use GetDevicePixel**() to get device pixels.
size_t GetWidth(size_t plane = 0);
size_t GetHeight(size_t plane = 0);
size_t GetWidth();
size_t GetHeight();
double GetContentsScaleFactor() { return mContentsScaleFactor; }
size_t GetDevicePixelWidth(size_t plane = 0);
size_t GetDevicePixelHeight(size_t plane = 0);
size_t GetBytesPerRow(size_t plane = 0);
size_t GetDevicePixelWidth();
size_t GetDevicePixelHeight();
size_t GetBytesPerRow();
void Lock();
void Unlock();
void IncrementUseCount();
void DecrementUseCount();
bool HasAlpha() { return mHasAlpha; }
mozilla::gfx::SurfaceFormat GetFormat();
// We would like to forward declare NSOpenGLContext, but it is an @interface
// and this file is also used from c++, so we use a void *.
CGLError CGLTexImageIOSurface2D(CGLContextObj ctxt, size_t plane = 0);
CGLError CGLTexImageIOSurface2D(CGLContextObj ctxt);
already_AddRefed<SourceSurface> GetAsSurface();
CGContextRef CreateIOSurfaceContext();
@ -144,16 +139,15 @@ public:
static IOSurfaceUnlockFunc sUnlock;
static IOSurfaceVoidFunc sIncrementUseCount;
static IOSurfaceVoidFunc sDecrementUseCount;
static IOSurfaceSizePlaneTFunc sWidth;
static IOSurfaceSizePlaneTFunc sHeight;
static IOSurfaceSizePlaneTFunc sBytesPerRow;
static IOSurfaceSizeTFunc sWidth;
static IOSurfaceSizeTFunc sHeight;
static IOSurfaceSizeTFunc sBytesPerRow;
static IOSurfaceGetPropertyMaximumFunc sGetPropertyMaximum;
static CGLTexImageIOSurface2DFunc sTexImage;
static IOSurfaceContextCreateFunc sIOSurfaceContextCreate;
static IOSurfaceContextCreateImageFunc sIOSurfaceContextCreateImage;
static IOSurfaceContextGetSurfaceFunc sIOSurfaceContextGetSurface;
static CVPixelBufferGetIOSurfaceFunc sCVPixelBufferGetIOSurface;
static IOSurfacePixelFormatFunc sPixelFormat;
static CFStringRef kPropWidth;
static CFStringRef kPropHeight;
static CFStringRef kPropBytesPerElem;
@ -169,9 +163,9 @@ public:
static void* IOSurfaceGetBaseAddressOfPlane(IOSurfacePtr aIOSurfacePtr,
size_t aPlaneIndex);
static size_t IOSurfaceGetPlaneCount(IOSurfacePtr aIOSurfacePtr);
static size_t IOSurfaceGetWidth(IOSurfacePtr aIOSurfacePtr, size_t plane);
static size_t IOSurfaceGetHeight(IOSurfacePtr aIOSurfacePtr, size_t plane);
static size_t IOSurfaceGetBytesPerRow(IOSurfacePtr aIOSurfacePtr, size_t plane);
static size_t IOSurfaceGetWidth(IOSurfacePtr aIOSurfacePtr);
static size_t IOSurfaceGetHeight(IOSurfacePtr aIOSurfacePtr);
static size_t IOSurfaceGetBytesPerRow(IOSurfacePtr aIOSurfacePtr);
static size_t IOSurfaceGetPropertyMaximum(CFStringRef property);
static IOReturn IOSurfaceLock(IOSurfacePtr aIOSurfacePtr,
uint32_t options, uint32_t *seed);
@ -191,7 +185,6 @@ public:
static CGImageRef IOSurfaceContextCreateImage(CGContextRef ref);
static IOSurfacePtr IOSurfaceContextGetSurface(CGContextRef ref);
static IOSurfacePtr CVPixelBufferGetIOSurface(CVPixelBufferRef apixelBuffer);
static OSType IOSurfaceGetPixelFormat(IOSurfacePtr aIOSurfacePtr);
static unsigned int (*sCGContextGetTypePtr) (CGContextRef);
static void LoadLibrary();
static void CloseLibrary();

View File

@ -37,7 +37,6 @@ enum class SurfaceFormat : int8_t {
R5G6B5,
A8,
YUV,
NV12,
UNKNOWN
};
@ -48,7 +47,6 @@ inline bool IsOpaque(SurfaceFormat aFormat)
case SurfaceFormat::R8G8B8X8:
case SurfaceFormat::R5G6B5:
case SurfaceFormat::YUV:
case SurfaceFormat::NV12:
return true;
default:
return false;

View File

@ -121,7 +121,6 @@ enum class EffectTypes : uint8_t {
MAX_SECONDARY, // sentinel for the count of secondary effect types
RGB,
YCBCR,
NV12,
COMPONENT_ALPHA,
SOLID_COLOR,
RENDER_TARGET,

View File

@ -197,15 +197,6 @@ struct EffectYCbCr : public TexturedEffect
virtual const char* Name() { return "EffectYCbCr"; }
};
struct EffectNV12 : public TexturedEffect
{
EffectNV12(TextureSource *aSource, gfx::Filter aFilter)
: TexturedEffect(EffectTypes::NV12, aSource, false, aFilter)
{}
virtual const char* Name() { return "EffectNV12"; }
};
struct EffectComponentAlpha : public TexturedEffect
{
EffectComponentAlpha(TextureSource *aOnBlack,
@ -274,9 +265,6 @@ CreateTexturedEffect(gfx::SurfaceFormat aFormat,
case gfx::SurfaceFormat::YUV:
result = new EffectYCbCr(aSource, aFilter);
break;
case gfx::SurfaceFormat::NV12:
result = new EffectNV12(aSource, aFilter);
break;
default:
NS_WARNING("unhandled program type");
break;

View File

@ -337,7 +337,6 @@ AppendToString(std::stringstream& aStream, mozilla::gfx::SurfaceFormat format,
case SurfaceFormat::R5G6B5: aStream << "SurfaceFormat::R5G6B5"; break;
case SurfaceFormat::A8: aStream << "SurfaceFormat::A8"; break;
case SurfaceFormat::YUV: aStream << "SurfaceFormat::YUV"; break;
case SurfaceFormat::NV12: aStream << "SurfaceFormat::NV12"; break;
case SurfaceFormat::UNKNOWN: aStream << "SurfaceFormat::UNKNOWN"; break;
default:
NS_ERROR("unknown surface format");

View File

@ -7,11 +7,9 @@
#include "mozilla/layers/CompositableClient.h"
#include "mozilla/layers/CompositableForwarder.h"
#include "mozilla/layers/MacIOSurfaceTextureClientOGL.h"
#include "YCbCrUtils.h"
using namespace mozilla;
using namespace mozilla::layers;
using namespace mozilla::gfx;
TextureClient*
MacIOSurfaceImage::GetTextureClient(CompositableClient* aClient)
@ -24,76 +22,30 @@ MacIOSurfaceImage::GetTextureClient(CompositableClient* aClient)
return mTextureClient;
}
already_AddRefed<SourceSurface>
already_AddRefed<gfx::SourceSurface>
MacIOSurfaceImage::GetAsSourceSurface()
{
RefPtr<DataSourceSurface> dataSurface;
mSurface->Lock();
size_t bytesPerRow = mSurface->GetBytesPerRow();
size_t ioWidth = mSurface->GetDevicePixelWidth();
size_t ioHeight = mSurface->GetDevicePixelHeight();
SurfaceFormat format = mSurface->GetFormat() == SurfaceFormat::NV12 ? SurfaceFormat::B8G8R8X8 : SurfaceFormat::B8G8R8A8;
unsigned char* ioData = (unsigned char*)mSurface->GetBaseAddress();
dataSurface = Factory::CreateDataSourceSurface(IntSize(ioWidth, ioHeight), format);
RefPtr<gfx::DataSourceSurface> dataSurface
= gfx::Factory::CreateDataSourceSurface(gfx::IntSize(ioWidth, ioHeight), gfx::SurfaceFormat::B8G8R8A8);
if (NS_WARN_IF(!dataSurface)) {
return nullptr;
}
DataSourceSurface::MappedSurface mappedSurface;
if (!dataSurface->Map(DataSourceSurface::WRITE, &mappedSurface))
gfx::DataSourceSurface::MappedSurface mappedSurface;
if (!dataSurface->Map(gfx::DataSourceSurface::WRITE, &mappedSurface))
return nullptr;
if (mSurface->GetFormat() == SurfaceFormat::NV12) {
if (mSurface->GetDevicePixelWidth() > PlanarYCbCrImage::MAX_DIMENSION ||
mSurface->GetDevicePixelHeight() > PlanarYCbCrImage::MAX_DIMENSION) {
return nullptr;
}
/* Extract and separate the CbCr planes */
size_t cbCrStride = mSurface->GetBytesPerRow(1);
size_t cbCrWidth = mSurface->GetDevicePixelWidth(1);
size_t cbCrHeight = mSurface->GetDevicePixelHeight(1);
nsAutoArrayPtr<uint8_t> cbPlane(new uint8_t[cbCrWidth * cbCrHeight]);
nsAutoArrayPtr<uint8_t> crPlane(new uint8_t[cbCrWidth * cbCrHeight]);
uint8_t* src = (uint8_t*)mSurface->GetBaseAddressOfPlane(1);
uint8_t* cbDest = cbPlane;
uint8_t* crDest = crPlane;
for (size_t i = 0; i < cbCrHeight; i++) {
uint8_t* rowSrc = src + cbCrStride * i;
for (size_t j = 0; j < cbCrWidth; j++) {
*cbDest = *rowSrc;
cbDest++;
rowSrc++;
*crDest = *rowSrc;
crDest++;
rowSrc++;
}
}
/* Convert to RGB */
PlanarYCbCrData data;
data.mYChannel = (uint8_t*)mSurface->GetBaseAddressOfPlane(0);
data.mYStride = mSurface->GetBytesPerRow(0);
data.mYSize = IntSize(mSurface->GetDevicePixelWidth(0), mSurface->GetDevicePixelHeight(0));
data.mCbChannel = cbPlane;
data.mCrChannel = crPlane;
data.mCbCrStride = cbCrWidth;
data.mCbCrSize = IntSize(cbCrWidth, cbCrHeight);
data.mPicSize = data.mYSize;
ConvertYCbCrToRGB(data, SurfaceFormat::B8G8R8X8, IntSize(ioWidth, ioHeight), mappedSurface.mData, mappedSurface.mStride);
} else {
unsigned char* ioData = (unsigned char*)mSurface->GetBaseAddress();
for (size_t i = 0; i < ioHeight; ++i) {
memcpy(mappedSurface.mData + i * mappedSurface.mStride,
ioData + i * bytesPerRow,
ioWidth * 4);
}
for (size_t i = 0; i < ioHeight; ++i) {
memcpy(mappedSurface.mData + i * mappedSurface.mStride,
ioData + i * bytesPerRow,
ioWidth * 4);
}
dataSurface->Unmap();

View File

@ -812,10 +812,6 @@ CompositorOGL::GetShaderConfigFor(Effect *aEffect,
case EffectTypes::YCBCR:
config.SetYCbCr(true);
break;
case EffectTypes::NV12:
config.SetNV12(true);
config.SetTextureTarget(LOCAL_GL_TEXTURE_RECTANGLE_ARB);
break;
case EffectTypes::COMPONENT_ALPHA:
{
config.SetComponentAlpha(true);
@ -1255,40 +1251,6 @@ CompositorOGL::DrawQuad(const Rect& aRect,
sourceYCbCr->GetSubSource(Y));
}
break;
case EffectTypes::NV12: {
EffectNV12* effectNV12 =
static_cast<EffectNV12*>(aEffectChain.mPrimaryEffect.get());
TextureSource* sourceNV12 = effectNV12->mTexture;
const int Y = 0, CbCr = 1;
TextureSourceOGL* sourceY = sourceNV12->GetSubSource(Y)->AsSourceOGL();
TextureSourceOGL* sourceCbCr = sourceNV12->GetSubSource(CbCr)->AsSourceOGL();
if (!sourceY || !sourceCbCr) {
NS_WARNING("Invalid layer texture.");
return;
}
sourceY->BindTexture(LOCAL_GL_TEXTURE0, effectNV12->mFilter);
sourceCbCr->BindTexture(LOCAL_GL_TEXTURE1, effectNV12->mFilter);
if (config.mFeatures & ENABLE_TEXTURE_RECT) {
// This is used by IOSurface that use 0,0...w,h coordinate rather then 0,0..1,1.
program->SetCbCrTexCoordMultiplier(sourceCbCr->GetSize().width, sourceCbCr->GetSize().height);
}
program->SetNV12TextureUnits(Y, CbCr);
program->SetTextureTransform(Matrix4x4());
if (maskType != MaskType::MaskNone) {
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE2, maskQuadTransform);
}
didSetBlendMode = SetBlendMode(gl(), blendMode);
BindAndDrawQuadWithTextureRect(program,
aRect,
effectNV12->mTextureCoords,
sourceNV12->GetSubSource(Y));
}
break;
case EffectTypes::RENDER_TARGET: {
EffectRenderTarget* effectRenderTarget =
static_cast<EffectRenderTarget*>(aEffectChain.mPrimaryEffect.get());

View File

@ -25,26 +25,6 @@ MacIOSurfaceTextureHostOGL::~MacIOSurfaceTextureHostOGL()
MOZ_COUNT_DTOR(MacIOSurfaceTextureHostOGL);
}
GLTextureSource*
MacIOSurfaceTextureHostOGL::CreateTextureSourceForPlane(size_t aPlane)
{
GLuint textureHandle;
gl::GLContext* gl = mCompositor->gl();
gl->fGenTextures(1, &textureHandle);
gl->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, textureHandle);
gl->fTexParameteri(LOCAL_GL_TEXTURE_RECTANGLE_ARB, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
gl->fTexParameteri(LOCAL_GL_TEXTURE_RECTANGLE_ARB, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
mSurface->CGLTexImageIOSurface2D(gl::GLContextCGL::Cast(gl)->GetCGLContext(), aPlane);
return new GLTextureSource(mCompositor, textureHandle, LOCAL_GL_TEXTURE_RECTANGLE_ARB,
gfx::IntSize(mSurface->GetDevicePixelWidth(aPlane),
mSurface->GetDevicePixelHeight(aPlane)),
// XXX: This isn't really correct (but isn't used), we should be using the
// format of the individual plane, not of the whole buffer.
mSurface->GetFormat());
}
bool
MacIOSurfaceTextureHostOGL::Lock()
{
@ -53,14 +33,19 @@ MacIOSurfaceTextureHostOGL::Lock()
}
if (!mTextureSource) {
mTextureSource = CreateTextureSourceForPlane(0);
GLuint textureHandle;
gl::GLContext* gl = mCompositor->gl();
gl->fGenTextures(1, &textureHandle);
gl->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, textureHandle);
gl->fTexParameteri(LOCAL_GL_TEXTURE_RECTANGLE_ARB, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
gl->fTexParameteri(LOCAL_GL_TEXTURE_RECTANGLE_ARB, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
mSurface->CGLTexImageIOSurface2D(gl::GLContextCGL::Cast(gl)->GetCGLContext());
RefPtr<TextureSource> prev = mTextureSource;
for (size_t i = 1; i < mSurface->GetPlaneCount(); i++) {
RefPtr<TextureSource> next = CreateTextureSourceForPlane(i);
prev->SetNextSibling(next);
prev = next;
}
mTextureSource = new GLTextureSource(mCompositor, textureHandle, LOCAL_GL_TEXTURE_RECTANGLE_ARB,
gfx::IntSize(mSurface->GetDevicePixelWidth(),
mSurface->GetDevicePixelHeight()),
mSurface->HasAlpha() ? gfx::SurfaceFormat::R8G8B8A8:
gfx::SurfaceFormat::R8G8B8X8);
}
return true;
}
@ -77,7 +62,11 @@ MacIOSurfaceTextureHostOGL::SetCompositor(Compositor* aCompositor)
gfx::SurfaceFormat
MacIOSurfaceTextureHostOGL::GetFormat() const {
return mSurface->GetFormat();
if (!mSurface) {
return gfx::SurfaceFormat::UNKNOWN;
}
return mSurface->HasAlpha() ? gfx::SurfaceFormat::R8G8B8A8
: gfx::SurfaceFormat::R8G8B8X8;
}
gfx::IntSize

View File

@ -95,8 +95,6 @@ public:
#endif
protected:
GLTextureSource* CreateTextureSourceForPlane(size_t aPlane);
RefPtr<CompositorOGL> mCompositor;
RefPtr<GLTextureSource> mTextureSource;
RefPtr<MacIOSurface> mSurface;

View File

@ -47,7 +47,6 @@ AddUniforms(ProgramProfileOGL& aProfile)
"uMaskTexture",
"uRenderColor",
"uTexCoordMultiplier",
"uCbCrTexCoordMultiplier",
"uTexturePass2",
"uColorMatrix",
"uColorMatrixVector",
@ -109,14 +108,6 @@ void
ShaderConfigOGL::SetYCbCr(bool aEnabled)
{
SetFeature(ENABLE_TEXTURE_YCBCR, aEnabled);
MOZ_ASSERT(!(mFeatures & ENABLE_TEXTURE_NV12));
}
void
ShaderConfigOGL::SetNV12(bool aEnabled)
{
SetFeature(ENABLE_TEXTURE_NV12, aEnabled);
MOZ_ASSERT(!(mFeatures & ENABLE_TEXTURE_YCBCR));
}
void
@ -310,10 +301,6 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
if (aConfig.mFeatures & ENABLE_TEXTURE_RECT) {
fs << "uniform vec2 uTexCoordMultiplier;" << endl;
if (aConfig.mFeatures & ENABLE_TEXTURE_YCBCR ||
aConfig.mFeatures & ENABLE_TEXTURE_NV12) {
fs << "uniform vec2 uCbCrTexCoordMultiplier;" << endl;
}
sampler2D = "sampler2DRect";
texture2D = "texture2DRect";
}
@ -326,9 +313,6 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
fs << "uniform sampler2D uYTexture;" << endl;
fs << "uniform sampler2D uCbTexture;" << endl;
fs << "uniform sampler2D uCrTexture;" << endl;
} else if (aConfig.mFeatures & ENABLE_TEXTURE_NV12) {
fs << "uniform " << sampler2D << " uYTexture;" << endl;
fs << "uniform " << sampler2D << " uCbTexture;" << endl;
} else if (aConfig.mFeatures & ENABLE_TEXTURE_COMPONENT_ALPHA) {
fs << "uniform sampler2D uBlackTexture;" << endl;
fs << "uniform sampler2D uWhiteTexture;" << endl;
@ -350,29 +334,10 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
if (!(aConfig.mFeatures & ENABLE_RENDER_COLOR)) {
fs << "vec4 sample(vec2 coord) {" << endl;
fs << " vec4 color;" << endl;
if (aConfig.mFeatures & ENABLE_TEXTURE_YCBCR ||
aConfig.mFeatures & ENABLE_TEXTURE_NV12) {
if (aConfig.mFeatures & ENABLE_TEXTURE_YCBCR) {
if (aConfig.mFeatures & ENABLE_TEXTURE_RECT) {
fs << " COLOR_PRECISION float y = texture2D(uYTexture, coord * uTexCoordMultiplier).r;" << endl;
fs << " COLOR_PRECISION float cb = texture2D(uCbTexture, coord * uCbCrTexCoordMultiplier).r;" << endl;
fs << " COLOR_PRECISION float cr = texture2D(uCrTexture, coord * uCbCrTexCoordMultiplier).r;" << endl;
} else {
fs << " COLOR_PRECISION float y = texture2D(uYTexture, coord).r;" << endl;
fs << " COLOR_PRECISION float cb = texture2D(uCbTexture, coord).r;" << endl;
fs << " COLOR_PRECISION float cr = texture2D(uCrTexture, coord).r;" << endl;
}
} else {
if (aConfig.mFeatures & ENABLE_TEXTURE_RECT) {
fs << " COLOR_PRECISION float y = " << texture2D << "(uYTexture, coord * uTexCoordMultiplier).r;" << endl;
fs << " COLOR_PRECISION float cb = " << texture2D << "(uCbTexture, coord * uCbCrTexCoordMultiplier).r;" << endl;
fs << " COLOR_PRECISION float cr = " << texture2D << "(uCbTexture, coord * uCbCrTexCoordMultiplier).a;" << endl;
} else {
fs << " COLOR_PRECISION float y = " << texture2D << "(uYTexture, coord).r;" << endl;
fs << " COLOR_PRECISION float cb = " << texture2D << "(uCbTexture, coord).r;" << endl;
fs << " COLOR_PRECISION float cr = " << texture2D << "(uCbTexture, coord).a;" << endl;
}
}
if (aConfig.mFeatures & ENABLE_TEXTURE_YCBCR) {
fs << " COLOR_PRECISION float y = texture2D(uYTexture, coord).r;" << endl;
fs << " COLOR_PRECISION float cb = texture2D(uCbTexture, coord).r;" << endl;
fs << " COLOR_PRECISION float cr = texture2D(uCrTexture, coord).r;" << endl;
/* From Rec601:
[R] [1.1643835616438356, 0.0, 1.5960267857142858] [ Y - 16]
@ -400,11 +365,7 @@ For [0,1] instead of [0,255], and to 5 places:
fs << " else" << endl;
fs << " color = alphas;" << endl;
} else {
if (aConfig.mFeatures & ENABLE_TEXTURE_RECT) {
fs << " color = " << texture2D << "(uTexture, coord * uTexCoordMultiplier);" << endl;
} else {
fs << " color = " << texture2D << "(uTexture, coord);" << endl;
}
fs << " color = " << texture2D << "(uTexture, coord);" << endl;
}
if (aConfig.mFeatures & ENABLE_TEXTURE_RB_SWAP) {
fs << " color = color.bgra;" << endl;
@ -443,7 +404,11 @@ For [0,1] instead of [0,255], and to 5 places:
if (aConfig.mFeatures & ENABLE_RENDER_COLOR) {
fs << " vec4 color = uRenderColor;" << endl;
} else {
fs << " vec4 color = sample(vTexCoord);" << endl;
if (aConfig.mFeatures & ENABLE_TEXTURE_RECT) {
fs << " vec4 color = sample(vTexCoord * uTexCoordMultiplier);" << endl;
} else {
fs << " vec4 color = sample(vTexCoord);" << endl;
}
if (aConfig.mFeatures & ENABLE_BLUR) {
fs << " color = blur(color, vTexCoord);" << endl;
}
@ -490,8 +455,6 @@ For [0,1] instead of [0,255], and to 5 places:
} else {
if (aConfig.mFeatures & ENABLE_TEXTURE_YCBCR) {
result.mTextureCount = 3;
} else if (aConfig.mFeatures & ENABLE_TEXTURE_NV12) {
result.mTextureCount = 2;
} else if (aConfig.mFeatures & ENABLE_TEXTURE_COMPONENT_ALPHA) {
result.mTextureCount = 2;
} else {

View File

@ -32,17 +32,16 @@ enum ShaderFeatures {
ENABLE_TEXTURE_RECT=0x02,
ENABLE_TEXTURE_EXTERNAL=0x04,
ENABLE_TEXTURE_YCBCR=0x08,
ENABLE_TEXTURE_NV12=0x10,
ENABLE_TEXTURE_COMPONENT_ALPHA=0x20,
ENABLE_TEXTURE_NO_ALPHA=0x40,
ENABLE_TEXTURE_RB_SWAP=0x80,
ENABLE_OPACITY=0x100,
ENABLE_BLUR=0x200,
ENABLE_COLOR_MATRIX=0x400,
ENABLE_MASK_2D=0x800,
ENABLE_MASK_3D=0x1000,
ENABLE_PREMULTIPLY=0x2000,
ENABLE_DEAA=0x4000
ENABLE_TEXTURE_COMPONENT_ALPHA=0x10,
ENABLE_TEXTURE_NO_ALPHA=0x20,
ENABLE_TEXTURE_RB_SWAP=0x40,
ENABLE_OPACITY=0x80,
ENABLE_BLUR=0x100,
ENABLE_COLOR_MATRIX=0x200,
ENABLE_MASK_2D=0x400,
ENABLE_MASK_3D=0x800,
ENABLE_PREMULTIPLY=0x1000,
ENABLE_DEAA=0x2000
};
class KnownUniform {
@ -69,7 +68,6 @@ public:
MaskTexture,
RenderColor,
TexCoordMultiplier,
CbCrTexCoordMultiplier,
TexturePass2,
ColorMatrix,
ColorMatrixVector,
@ -217,7 +215,6 @@ public:
void SetNoAlpha(bool aEnabled);
void SetOpacity(bool aEnabled);
void SetYCbCr(bool aEnabled);
void SetNV12(bool aEnabled);
void SetComponentAlpha(bool aEnabled);
void SetColorMatrix(bool aEnabled);
void SetBlur(bool aEnabled);
@ -418,11 +415,6 @@ public:
SetUniform(KnownUniform::CrTexture, aCrUnit);
}
void SetNV12TextureUnits(GLint aYUnit, GLint aCbCrUnit) {
SetUniform(KnownUniform::YTexture, aYUnit);
SetUniform(KnownUniform::CbTexture, aCbCrUnit);
}
void SetBlackTextureUnit(GLint aUnit) {
SetUniform(KnownUniform::BlackTexture, aUnit);
}
@ -454,11 +446,6 @@ public:
SetUniform(KnownUniform::TexCoordMultiplier, 2, f);
}
void SetCbCrTexCoordMultiplier(float aWidth, float aHeight) {
float f[] = {aWidth, aHeight};
SetUniform(KnownUniform::CbCrTexCoordMultiplier, 2, f);
}
// Set whether we want the component alpha shader to return the color
// vector (pass 1, false) or the alpha vector (pass2, true). With support
// for multiple render targets we wouldn't need two passes here.