Bug 887791 - Use the MacIOSurface TextureClient/Host for sharing MacIOSurface objects. r=roc

This commit is contained in:
Matt Woodrow 2013-11-01 14:54:15 +13:00
parent 57c436400d
commit cea6fae57a

View File

@ -31,6 +31,10 @@
#include "GLContext.h" #include "GLContext.h"
#include "GLContextProvider.h" #include "GLContextProvider.h"
#ifdef XP_MACOSX
#include "MacIOSurfaceImage.h"
#endif
#if defined(OS_WIN) #if defined(OS_WIN)
#include <windowsx.h> #include <windowsx.h>
#include "gfxWindowsPlatform.h" #include "gfxWindowsPlatform.h"
@ -713,26 +717,16 @@ PluginInstanceParent::GetImageContainer(ImageContainer** aContainer)
#ifdef XP_MACOSX #ifdef XP_MACOSX
if (ioSurface) { if (ioSurface) {
ImageFormat format = SHARED_TEXTURE; ImageFormat format = MAC_IOSURFACE;
nsRefPtr<Image> image = container->CreateImage(&format, 1); nsRefPtr<Image> image = container->CreateImage(&format, 1);
if (!image) { if (!image) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_ASSERTION(image->GetFormat() == SHARED_TEXTURE, "Wrong format?"); NS_ASSERTION(image->GetFormat() == MAC_IOSURFACE, "Wrong format?");
SharedTextureImage::Data data; MacIOSurfaceImage* pluginImage = static_cast<MacIOSurfaceImage*>(image.get());
data.mShareType = gl::SameProcess; pluginImage->SetSurface(ioSurface);
data.mHandle = GLContextProviderCGL::CreateSharedHandle(data.mShareType,
ioSurface,
gl::IOSurface);
data.mInverted = false;
// Use the device pixel size of the IOSurface, since layers handles resolution scaling
// already.
data.mSize = gfxIntSize(ioSurface->GetDevicePixelWidth(), ioSurface->GetDevicePixelHeight());
SharedTextureImage* pluginImage = static_cast<SharedTextureImage*>(image.get());
pluginImage->SetData(data);
container->SetCurrentImageInTransaction(pluginImage); container->SetCurrentImageInTransaction(pluginImage);