mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 958490 - Implement ImageContainer::Lock/GetAsCurrentSurface. r=nical
Added member functions GetCurrentAsSourceSurface and LockCurrentAsSourceSurface to return a gfx::SourceSurface instead of a gfxASurface. Deprecated LockCurrentAsSurface and GetCurrentAsSurface
This commit is contained in:
parent
d03468c1ae
commit
e95469b62c
@ -297,7 +297,7 @@ ImageContainer::LockCurrentImage()
|
||||
}
|
||||
|
||||
already_AddRefed<gfxASurface>
|
||||
ImageContainer::LockCurrentAsSurface(gfx::IntSize *aSize, Image** aCurrentImage)
|
||||
ImageContainer::DeprecatedLockCurrentAsSurface(gfx::IntSize *aSize, Image** aCurrentImage)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
@ -347,6 +347,58 @@ ImageContainer::LockCurrentAsSurface(gfx::IntSize *aSize, Image** aCurrentImage)
|
||||
return mActiveImage->DeprecatedGetAsSurface();
|
||||
}
|
||||
|
||||
TemporaryRef<gfx::SourceSurface>
|
||||
ImageContainer::LockCurrentAsSourceSurface(gfx::IntSize *aSize, Image** aCurrentImage)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
if (mRemoteData) {
|
||||
NS_ASSERTION(mRemoteDataMutex, "Should have remote data mutex when having remote data!");
|
||||
mRemoteDataMutex->Lock();
|
||||
|
||||
EnsureActiveImage();
|
||||
|
||||
if (aCurrentImage) {
|
||||
NS_IF_ADDREF(mActiveImage);
|
||||
*aCurrentImage = mActiveImage.get();
|
||||
}
|
||||
|
||||
if (!mActiveImage) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (mActiveImage->GetFormat() == REMOTE_IMAGE_BITMAP) {
|
||||
gfxImageFormat fmt = mRemoteData->mFormat == RemoteImageData::BGRX32
|
||||
? gfxImageFormatARGB32
|
||||
: gfxImageFormatRGB24;
|
||||
|
||||
RefPtr<gfx::DataSourceSurface> newSurf
|
||||
= gfx::Factory::CreateWrappingDataSourceSurface(mRemoteData->mBitmap.mData,
|
||||
mRemoteData->mBitmap.mStride,
|
||||
mRemoteData->mSize,
|
||||
gfx::ImageFormatToSurfaceFormat(fmt));
|
||||
*aSize = newSurf->GetSize();
|
||||
|
||||
return newSurf;
|
||||
}
|
||||
|
||||
*aSize = mActiveImage->GetSize();
|
||||
return mActiveImage->GetAsSourceSurface();
|
||||
}
|
||||
|
||||
if (aCurrentImage) {
|
||||
NS_IF_ADDREF(mActiveImage);
|
||||
*aCurrentImage = mActiveImage.get();
|
||||
}
|
||||
|
||||
if (!mActiveImage) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
*aSize = mActiveImage->GetSize();
|
||||
return mActiveImage->GetAsSourceSurface();
|
||||
}
|
||||
|
||||
void
|
||||
ImageContainer::UnlockCurrentImage()
|
||||
{
|
||||
@ -357,7 +409,7 @@ ImageContainer::UnlockCurrentImage()
|
||||
}
|
||||
|
||||
already_AddRefed<gfxASurface>
|
||||
ImageContainer::GetCurrentAsSurface(gfx::IntSize *aSize)
|
||||
ImageContainer::DeprecatedGetCurrentAsSurface(gfx::IntSize *aSize)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
@ -376,6 +428,26 @@ ImageContainer::GetCurrentAsSurface(gfx::IntSize *aSize)
|
||||
return mActiveImage->DeprecatedGetAsSurface();
|
||||
}
|
||||
|
||||
TemporaryRef<gfx::SourceSurface>
|
||||
ImageContainer::GetCurrentAsSourceSurface(gfx::IntSize *aSize)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
if (mRemoteData) {
|
||||
CrossProcessMutexAutoLock autoLock(*mRemoteDataMutex);
|
||||
EnsureActiveImage();
|
||||
|
||||
if (!mActiveImage)
|
||||
return nullptr;
|
||||
*aSize = mRemoteData->mSize;
|
||||
} else {
|
||||
if (!mActiveImage)
|
||||
return nullptr;
|
||||
*aSize = mActiveImage->GetSize();
|
||||
}
|
||||
return mActiveImage->GetAsSourceSurface();
|
||||
}
|
||||
|
||||
gfx::IntSize
|
||||
ImageContainer::GetCurrentSize()
|
||||
{
|
||||
|
@ -486,7 +486,7 @@ public:
|
||||
* the lock methods should be used to avoid the copy, however this should be
|
||||
* avoided if the surface is required for a long period of time.
|
||||
*/
|
||||
already_AddRefed<gfxASurface> GetCurrentAsSurface(gfx::IntSize* aSizeResult);
|
||||
already_AddRefed<gfxASurface> DeprecatedGetCurrentAsSurface(gfx::IntSize* aSizeResult);
|
||||
|
||||
/**
|
||||
* This is similar to GetCurrentAsSurface, however this does not make a copy
|
||||
@ -496,8 +496,19 @@ public:
|
||||
* type of image. Optionally a pointer can be passed to receive the current
|
||||
* image.
|
||||
*/
|
||||
already_AddRefed<gfxASurface> LockCurrentAsSurface(gfx::IntSize* aSizeResult,
|
||||
Image** aCurrentImage = nullptr);
|
||||
already_AddRefed<gfxASurface> DeprecatedLockCurrentAsSurface(gfx::IntSize* aSizeResult,
|
||||
Image** aCurrentImage = nullptr);
|
||||
|
||||
/**
|
||||
* Same as GetCurrentAsSurface but for Moz2D
|
||||
*/
|
||||
TemporaryRef<gfx::SourceSurface> GetCurrentAsSourceSurface(gfx::IntSize* aSizeResult);
|
||||
|
||||
/**
|
||||
* Same as LockCurrentAsSurface but for Moz2D
|
||||
*/
|
||||
TemporaryRef<gfx::SourceSurface> LockCurrentAsSourceSurface(gfx::IntSize* aSizeResult,
|
||||
Image** aCurrentImage = nullptr);
|
||||
|
||||
/**
|
||||
* Returns the size of the image in pixels.
|
||||
@ -671,7 +682,7 @@ class AutoLockImage
|
||||
public:
|
||||
AutoLockImage(ImageContainer *aContainer) : mContainer(aContainer) { mImage = mContainer->LockCurrentImage(); }
|
||||
AutoLockImage(ImageContainer *aContainer, gfxASurface **aSurface) : mContainer(aContainer) {
|
||||
*aSurface = mContainer->LockCurrentAsSurface(&mSize, getter_AddRefs(mImage)).get();
|
||||
*aSurface = mContainer->DeprecatedLockCurrentAsSurface(&mSize, getter_AddRefs(mImage)).get();
|
||||
}
|
||||
~AutoLockImage() { if (mContainer) { mContainer->UnlockCurrentImage(); } }
|
||||
|
||||
|
@ -167,7 +167,7 @@ BasicImageLayer::GetAsSurface(gfxASurface** aSurface,
|
||||
}
|
||||
|
||||
gfx::IntSize dontCare;
|
||||
nsRefPtr<gfxASurface> surface = mContainer->GetCurrentAsSurface(&dontCare);
|
||||
nsRefPtr<gfxASurface> surface = mContainer->DeprecatedGetCurrentAsSurface(&dontCare);
|
||||
*aSurface = surface.forget().get();
|
||||
return true;
|
||||
}
|
||||
|
@ -4995,7 +4995,7 @@ nsLayoutUtils::SurfaceFromElement(HTMLVideoElement* aElement,
|
||||
return result;
|
||||
|
||||
mozilla::gfx::IntSize size;
|
||||
nsRefPtr<gfxASurface> surf = container->GetCurrentAsSurface(&size);
|
||||
nsRefPtr<gfxASurface> surf = container->DeprecatedGetCurrentAsSurface(&size);
|
||||
if (!surf)
|
||||
return result;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user