mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 962629 - Respect max texture size when creating Gralloc textures. r=nical
Add a size hint parameter to CreateTextureClientForDrawing, and use said parameter to not create Gralloc surfaces that are bigger than the maximum texture size.
This commit is contained in:
parent
f3ab58aa4e
commit
f1977b5d50
@ -672,7 +672,8 @@ CairoImage::GetTextureClient(CompositableClient *aClient)
|
||||
MOZ_ASSERT(surface);
|
||||
|
||||
textureClient = aClient->CreateTextureClientForDrawing(surface->GetFormat(),
|
||||
TEXTURE_FLAGS_DEFAULT);
|
||||
TEXTURE_FLAGS_DEFAULT,
|
||||
surface->GetSize());
|
||||
MOZ_ASSERT(textureClient->AsTextureClientDrawTarget());
|
||||
if (!textureClient->AsTextureClientDrawTarget()->AllocateForSurface(surface->GetSize()) ||
|
||||
!textureClient->Lock(OPEN_WRITE_ONLY)) {
|
||||
|
@ -177,10 +177,12 @@ CompositableClient::CreateBufferTextureClient(SurfaceFormat aFormat,
|
||||
|
||||
TemporaryRef<TextureClient>
|
||||
CompositableClient::CreateTextureClientForDrawing(SurfaceFormat aFormat,
|
||||
TextureFlags aTextureFlags)
|
||||
TextureFlags aTextureFlags,
|
||||
const IntSize& aSizeHint)
|
||||
{
|
||||
return TextureClient::CreateTextureClientForDrawing(GetForwarder(), aFormat,
|
||||
aTextureFlags | mTextureFlags);
|
||||
aTextureFlags | mTextureFlags,
|
||||
aSizeHint);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -93,7 +93,8 @@ public:
|
||||
// always be non-null.
|
||||
TemporaryRef<TextureClient>
|
||||
CreateTextureClientForDrawing(gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aTextureFlags);
|
||||
TextureFlags aTextureFlags,
|
||||
const gfx::IntSize& aSizeHint);
|
||||
|
||||
virtual void SetDescriptorFromReply(TextureIdentifier aTextureId,
|
||||
const SurfaceDescriptor& aDescriptor)
|
||||
|
@ -169,14 +169,16 @@ ContentClientRemoteBuffer::CreateAndAllocateTextureClient(RefPtr<TextureClient>&
|
||||
TextureFlags aFlags)
|
||||
{
|
||||
aClient = CreateTextureClientForDrawing(mSurfaceFormat,
|
||||
mTextureInfo.mTextureFlags | aFlags);
|
||||
mTextureInfo.mTextureFlags | aFlags,
|
||||
mSize);
|
||||
if (!aClient) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!aClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_CLEAR_BUFFER)) {
|
||||
aClient = CreateTextureClientForDrawing(mSurfaceFormat,
|
||||
mTextureInfo.mTextureFlags | TEXTURE_ALLOC_FALLBACK | aFlags);
|
||||
mTextureInfo.mTextureFlags | TEXTURE_ALLOC_FALLBACK | aFlags,
|
||||
mSize);
|
||||
if (!aClient) {
|
||||
return false;
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ ImageClientSingle::UpdateImageInternal(ImageContainer* aContainer,
|
||||
gfxImageFormat format
|
||||
= gfxPlatform::GetPlatform()->OptimalFormatForContent(gfx::ContentForFormat(surface->GetFormat()));
|
||||
mFrontBuffer = CreateTextureClientForDrawing(gfx::ImageFormatToSurfaceFormat(format),
|
||||
mTextureFlags);
|
||||
mTextureFlags, size);
|
||||
MOZ_ASSERT(mFrontBuffer->AsTextureClientDrawTarget());
|
||||
if (!mFrontBuffer->AsTextureClientDrawTarget()->AllocateForSurface(size)) {
|
||||
mFrontBuffer = nullptr;
|
||||
|
@ -72,7 +72,7 @@ SimpleTextureClientPool::GetTextureClient(bool aAutoRecycle)
|
||||
if (gfxPrefs::ForceShmemTiles()) {
|
||||
textureClient = TextureClient::CreateBufferTextureClient(mSurfaceAllocator, mFormat, TEXTURE_IMMEDIATE_UPLOAD | TEXTURE_RECYCLE);
|
||||
} else {
|
||||
textureClient = TextureClient::CreateTextureClientForDrawing(mSurfaceAllocator, mFormat, TEXTURE_FLAGS_DEFAULT | TEXTURE_RECYCLE);
|
||||
textureClient = TextureClient::CreateTextureClientForDrawing(mSurfaceAllocator, mFormat, TEXTURE_FLAGS_DEFAULT | TEXTURE_RECYCLE, mSize);
|
||||
}
|
||||
if (!textureClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_DEFAULT)) {
|
||||
NS_WARNING("TextureClient::AllocateForSurface failed!");
|
||||
|
@ -278,7 +278,8 @@ DisableGralloc(SurfaceFormat aFormat)
|
||||
TemporaryRef<TextureClient>
|
||||
TextureClient::CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator,
|
||||
SurfaceFormat aFormat,
|
||||
TextureFlags aTextureFlags)
|
||||
TextureFlags aTextureFlags,
|
||||
const gfx::IntSize& aSizeHint)
|
||||
{
|
||||
RefPtr<TextureClient> result;
|
||||
|
||||
@ -327,7 +328,12 @@ TextureClient::CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator,
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (!DisableGralloc(aFormat)) {
|
||||
result = new GrallocTextureClientOGL(aAllocator, aFormat, aTextureFlags);
|
||||
// Don't allow Gralloc texture clients to exceed the maximum texture size.
|
||||
// BufferTextureClients have code to handle tiling the surface client-side.
|
||||
int32_t maxTextureSize = aAllocator->GetMaxTextureSize();
|
||||
if (aSizeHint.width <= maxTextureSize && aSizeHint.height <= maxTextureSize) {
|
||||
result = new GrallocTextureClientOGL(aAllocator, aFormat, aTextureFlags);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -207,7 +207,8 @@ public:
|
||||
static TemporaryRef<TextureClient>
|
||||
CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aTextureFlags);
|
||||
TextureFlags aTextureFlags,
|
||||
const gfx::IntSize& aSizeHint);
|
||||
|
||||
virtual TextureClientSurface* AsTextureClientSurface() { return nullptr; }
|
||||
virtual TextureClientDrawTarget* AsTextureClientDrawTarget() { return nullptr; }
|
||||
|
@ -51,7 +51,7 @@ TextureClientPool::GetTextureClient()
|
||||
if (gfxPrefs::ForceShmemTiles()) {
|
||||
textureClient = TextureClient::CreateBufferTextureClient(mSurfaceAllocator, mFormat, TEXTURE_IMMEDIATE_UPLOAD);
|
||||
} else {
|
||||
textureClient = TextureClient::CreateTextureClientForDrawing(mSurfaceAllocator, mFormat, TEXTURE_IMMEDIATE_UPLOAD);
|
||||
textureClient = TextureClient::CreateTextureClientForDrawing(mSurfaceAllocator, mFormat, TEXTURE_IMMEDIATE_UPLOAD, mSize);
|
||||
}
|
||||
textureClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_DEFAULT);
|
||||
|
||||
|
@ -213,10 +213,10 @@ public:
|
||||
|
||||
void IdentifyTextureHost(const TextureFactoryIdentifier& aIdentifier);
|
||||
|
||||
/**
|
||||
* Returns the maximum texture size supported by the compositor.
|
||||
*/
|
||||
virtual int32_t GetMaxTextureSize() const { return mTextureFactoryIdentifier.mMaxTextureSize; }
|
||||
virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE
|
||||
{
|
||||
return mTextureFactoryIdentifier.mMaxTextureSize;
|
||||
}
|
||||
|
||||
bool IsOnCompositorSide() const MOZ_OVERRIDE { return false; }
|
||||
|
||||
|
@ -125,6 +125,11 @@ public:
|
||||
uint32_t aCaps,
|
||||
SurfaceDescriptor* aBuffer);
|
||||
|
||||
/**
|
||||
* Returns the maximum texture size supported by the compositor.
|
||||
*/
|
||||
virtual int32_t GetMaxTextureSize() const { return INT32_MAX; }
|
||||
|
||||
virtual void DestroySharedSurface(SurfaceDescriptor* aSurface);
|
||||
|
||||
// method that does the actual allocation work
|
||||
|
Loading…
Reference in New Issue
Block a user