mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1573668 - Use the real IOSurfaceRef type in MacIOSurface. r=mattwoodrow
Differential Revision: https://phabricator.services.mozilla.com/D41841 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
cc55a912e9
commit
c31b8d8a28
@ -394,7 +394,7 @@ void AppleVTDecoder::OutputFrame(CVPixelBufferRef aImage,
|
||||
CVPixelBufferUnlockBaseAddress(aImage, kCVPixelBufferLock_ReadOnly);
|
||||
} else {
|
||||
#ifndef MOZ_WIDGET_UIKIT
|
||||
IOSurfacePtr surface = (IOSurfacePtr)CVPixelBufferGetIOSurface(aImage);
|
||||
IOSurfaceRef surface = CVPixelBufferGetIOSurface(aImage);
|
||||
MOZ_ASSERT(surface, "Decoder didn't return an IOSurface backed buffer");
|
||||
|
||||
RefPtr<MacIOSurface> macSurface = new MacIOSurface(surface);
|
||||
|
@ -5,7 +5,6 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "MacIOSurface.h"
|
||||
#include <IOSurface/IOSurface.h>
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/CGLIOSurface.h>
|
||||
#include <QuartzCore/QuartzCore.h>
|
||||
@ -16,20 +15,20 @@
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
MacIOSurface::MacIOSurface(IOSurfacePtr aIOSurfacePtr,
|
||||
MacIOSurface::MacIOSurface(IOSurfaceRef aIOSurfaceRef,
|
||||
double aContentsScaleFactor, bool aHasAlpha,
|
||||
gfx::YUVColorSpace aColorSpace)
|
||||
: mIOSurfacePtr(aIOSurfacePtr),
|
||||
: mIOSurfaceRef(aIOSurfaceRef),
|
||||
mContentsScaleFactor(aContentsScaleFactor),
|
||||
mHasAlpha(aHasAlpha),
|
||||
mColorSpace(aColorSpace) {
|
||||
CFRetain(mIOSurfacePtr);
|
||||
CFRetain(mIOSurfaceRef);
|
||||
IncrementUseCount();
|
||||
}
|
||||
|
||||
MacIOSurface::~MacIOSurface() {
|
||||
DecrementUseCount();
|
||||
CFRelease(mIOSurfacePtr);
|
||||
CFRelease(mIOSurfaceRef);
|
||||
}
|
||||
|
||||
/* static */
|
||||
@ -62,7 +61,7 @@ already_AddRefed<MacIOSurface> MacIOSurface::CreateIOSurface(
|
||||
::CFRelease(cfBytesPerElem);
|
||||
::CFDictionaryAddValue(props, kIOSurfaceIsGlobal, kCFBooleanTrue);
|
||||
|
||||
IOSurfacePtr surfaceRef = ::IOSurfaceCreate(props);
|
||||
IOSurfaceRef surfaceRef = ::IOSurfaceCreate(props);
|
||||
::CFRelease(props);
|
||||
|
||||
if (!surfaceRef) return nullptr;
|
||||
@ -82,7 +81,7 @@ already_AddRefed<MacIOSurface> MacIOSurface::LookupSurface(
|
||||
gfx::YUVColorSpace aColorSpace) {
|
||||
if (aContentsScaleFactor <= 0) return nullptr;
|
||||
|
||||
IOSurfacePtr surfaceRef = (IOSurfacePtr)::IOSurfaceLookup(aIOSurfaceID);
|
||||
IOSurfaceRef surfaceRef = ::IOSurfaceLookup(aIOSurfaceID);
|
||||
if (!surfaceRef) return nullptr;
|
||||
|
||||
RefPtr<MacIOSurface> ioSurface = new MacIOSurface(
|
||||
@ -95,16 +94,15 @@ already_AddRefed<MacIOSurface> MacIOSurface::LookupSurface(
|
||||
}
|
||||
|
||||
IOSurfaceID MacIOSurface::GetIOSurfaceID() const {
|
||||
return ::IOSurfaceGetID((IOSurfaceRef)mIOSurfacePtr);
|
||||
return ::IOSurfaceGetID(mIOSurfaceRef);
|
||||
}
|
||||
|
||||
void* MacIOSurface::GetBaseAddress() const {
|
||||
return ::IOSurfaceGetBaseAddress((IOSurfaceRef)mIOSurfacePtr);
|
||||
return ::IOSurfaceGetBaseAddress(mIOSurfaceRef);
|
||||
}
|
||||
|
||||
void* MacIOSurface::GetBaseAddressOfPlane(size_t aPlaneIndex) const {
|
||||
return ::IOSurfaceGetBaseAddressOfPlane((IOSurfaceRef)mIOSurfacePtr,
|
||||
aPlaneIndex);
|
||||
return ::IOSurfaceGetBaseAddressOfPlane(mIOSurfaceRef, aPlaneIndex);
|
||||
}
|
||||
|
||||
size_t MacIOSurface::GetWidth(size_t plane) const {
|
||||
@ -118,7 +116,7 @@ size_t MacIOSurface::GetHeight(size_t plane) const {
|
||||
}
|
||||
|
||||
size_t MacIOSurface::GetPlaneCount() const {
|
||||
return ::IOSurfaceGetPlaneCount((IOSurfaceRef)mIOSurfacePtr);
|
||||
return ::IOSurfaceGetPlaneCount(mIOSurfaceRef);
|
||||
}
|
||||
|
||||
/*static*/
|
||||
@ -132,37 +130,37 @@ size_t MacIOSurface::GetMaxHeight() {
|
||||
}
|
||||
|
||||
size_t MacIOSurface::GetDevicePixelWidth(size_t plane) const {
|
||||
return ::IOSurfaceGetWidthOfPlane((IOSurfaceRef)mIOSurfacePtr, plane);
|
||||
return ::IOSurfaceGetWidthOfPlane(mIOSurfaceRef, plane);
|
||||
}
|
||||
|
||||
size_t MacIOSurface::GetDevicePixelHeight(size_t plane) const {
|
||||
return ::IOSurfaceGetHeightOfPlane((IOSurfaceRef)mIOSurfacePtr, plane);
|
||||
return ::IOSurfaceGetHeightOfPlane(mIOSurfaceRef, plane);
|
||||
}
|
||||
|
||||
size_t MacIOSurface::GetBytesPerRow(size_t plane) const {
|
||||
return ::IOSurfaceGetBytesPerRowOfPlane((IOSurfaceRef)mIOSurfacePtr, plane);
|
||||
return ::IOSurfaceGetBytesPerRowOfPlane(mIOSurfaceRef, plane);
|
||||
}
|
||||
|
||||
OSType MacIOSurface::GetPixelFormat() const {
|
||||
return ::IOSurfaceGetPixelFormat((IOSurfaceRef)mIOSurfacePtr);
|
||||
return ::IOSurfaceGetPixelFormat(mIOSurfaceRef);
|
||||
}
|
||||
|
||||
void MacIOSurface::IncrementUseCount() {
|
||||
::IOSurfaceIncrementUseCount((IOSurfaceRef)mIOSurfacePtr);
|
||||
::IOSurfaceIncrementUseCount(mIOSurfaceRef);
|
||||
}
|
||||
|
||||
void MacIOSurface::DecrementUseCount() {
|
||||
::IOSurfaceDecrementUseCount((IOSurfaceRef)mIOSurfacePtr);
|
||||
::IOSurfaceDecrementUseCount(mIOSurfaceRef);
|
||||
}
|
||||
|
||||
void MacIOSurface::Lock(bool aReadOnly) {
|
||||
::IOSurfaceLock((IOSurfaceRef)mIOSurfacePtr,
|
||||
aReadOnly ? kIOSurfaceLockReadOnly : 0, nullptr);
|
||||
::IOSurfaceLock(mIOSurfaceRef, aReadOnly ? kIOSurfaceLockReadOnly : 0,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void MacIOSurface::Unlock(bool aReadOnly) {
|
||||
::IOSurfaceUnlock((IOSurfaceRef)mIOSurfacePtr,
|
||||
aReadOnly ? kIOSurfaceLockReadOnly : 0, nullptr);
|
||||
::IOSurfaceUnlock(mIOSurfaceRef, aReadOnly ? kIOSurfaceLockReadOnly : 0,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
using mozilla::gfx::IntSize;
|
||||
@ -231,8 +229,7 @@ CGLError MacIOSurface::CGLTexImageIOSurface2D(CGLContextObj ctx, GLenum target,
|
||||
GLenum format, GLenum type,
|
||||
GLuint plane) const {
|
||||
return ::CGLTexImageIOSurface2D(ctx, target, internalFormat, width, height,
|
||||
format, type, (IOSurfaceRef)mIOSurfacePtr,
|
||||
plane);
|
||||
format, type, mIOSurfaceRef, plane);
|
||||
}
|
||||
|
||||
CGLError MacIOSurface::CGLTexImageIOSurface2D(
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define MacIOSurface_h__
|
||||
#ifdef XP_DARWIN
|
||||
# include <CoreVideo/CoreVideo.h>
|
||||
# include <IOSurface/IOSurface.h>
|
||||
# include <QuartzCore/QuartzCore.h>
|
||||
# include <dlfcn.h>
|
||||
|
||||
@ -29,8 +30,6 @@ typedef kern_return_t IOReturn;
|
||||
typedef int CGLError;
|
||||
# endif
|
||||
|
||||
typedef CFTypeRef IOSurfacePtr;
|
||||
|
||||
# ifdef XP_MACOSX
|
||||
# import <OpenGL/OpenGL.h>
|
||||
# else
|
||||
@ -61,7 +60,7 @@ class MacIOSurface final
|
||||
mozilla::gfx::YUVColorSpace aColorSpace =
|
||||
mozilla::gfx::YUVColorSpace::UNKNOWN);
|
||||
|
||||
explicit MacIOSurface(IOSurfacePtr aIOSurfacePtr,
|
||||
explicit MacIOSurface(IOSurfaceRef aIOSurfaceRef,
|
||||
double aContentsScaleFactor = 1.0,
|
||||
bool aHasAlpha = true,
|
||||
mozilla::gfx::YUVColorSpace aColorSpace =
|
||||
@ -90,7 +89,7 @@ class MacIOSurface final
|
||||
mozilla::gfx::SurfaceFormat GetFormat() const;
|
||||
mozilla::gfx::SurfaceFormat GetReadFormat() const;
|
||||
// This would be better suited on MacIOSurfaceImage type, however due to the
|
||||
// current data structure, this is not possible as only the IOSurfacePtr is
|
||||
// current data structure, this is not possible as only the IOSurfaceRef is
|
||||
// being used across.
|
||||
void SetYUVColorSpace(mozilla::gfx::YUVColorSpace aColorSpace) {
|
||||
mColorSpace = aColorSpace;
|
||||
@ -113,11 +112,10 @@ class MacIOSurface final
|
||||
|
||||
static size_t GetMaxWidth();
|
||||
static size_t GetMaxHeight();
|
||||
const void* GetIOSurfacePtr() { return mIOSurfacePtr; }
|
||||
IOSurfaceRef GetIOSurfaceRef() { return mIOSurfaceRef; }
|
||||
|
||||
private:
|
||||
friend class nsCARenderer;
|
||||
const IOSurfacePtr mIOSurfacePtr;
|
||||
const IOSurfaceRef mIOSurfaceRef;
|
||||
double mContentsScaleFactor;
|
||||
bool mHasAlpha;
|
||||
mozilla::gfx::YUVColorSpace mColorSpace =
|
||||
|
@ -203,8 +203,7 @@ nsresult nsCARenderer::SetupRenderer(void* aCALayer, int aWidth, int aHeight,
|
||||
::glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
::CGLTexImageIOSurface2D(mOpenGLContext, GL_TEXTURE_RECTANGLE_ARB, GL_RGBA,
|
||||
aWidth * intScaleFactor, aHeight * intScaleFactor, GL_BGRA,
|
||||
GL_UNSIGNED_INT_8_8_8_8_REV, (IOSurfaceRef)mIOSurface->mIOSurfacePtr,
|
||||
0);
|
||||
GL_UNSIGNED_INT_8_8_8_8_REV, mIOSurface->GetIOSurfaceRef(), 0);
|
||||
::glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
} else {
|
||||
::glGenTextures(1, &mFBOTexture);
|
||||
@ -335,8 +334,8 @@ void nsCARenderer::AttachIOSurface(MacIOSurface* aSurface) {
|
||||
::glBindTexture(GL_TEXTURE_RECTANGLE_ARB, mIOTexture);
|
||||
::CGLTexImageIOSurface2D(mOpenGLContext, GL_TEXTURE_RECTANGLE_ARB, GL_RGBA,
|
||||
mIOSurface->GetDevicePixelWidth(), mIOSurface->GetDevicePixelHeight(),
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
(IOSurfaceRef)mIOSurface->mIOSurfacePtr, 0);
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, mIOSurface->GetIOSurfaceRef(),
|
||||
0);
|
||||
::glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
|
||||
// Rebind the FBO to make it live
|
||||
|
@ -2126,7 +2126,7 @@ bool OpenVRSession::SubmitFrame(const VRLayerTextureHandle& aTextureHandle,
|
||||
return false;
|
||||
}
|
||||
|
||||
const void* ioSurface = surf->GetIOSurfacePtr();
|
||||
IOSurfaceRef ioSurface = surf->GetIOSurfaceRef();
|
||||
tex.handle = (void*)ioSurface;
|
||||
#else
|
||||
tex.handle = aTextureHandle;
|
||||
|
Loading…
Reference in New Issue
Block a user