Bug 1265824 - Plug holes in texture size restrictions r?mattwoodrow
When computing whether we have an intermediate buffer or not, which
in our case amounts to the inverse of deciding whether we want to use
a DirectMapTextureSource or not, we want to ensure that we don't use
one if the texture is too big to be a single texture in OpenGL. This
will default to using a TiledTextureImage. In a perfect world we
would build tiling logic into the client storage approach, but that
shouldn't block this.
MozReview-Commit-ID: 7Oi86oGis93
--- a/gfx/layers/BufferTexture.cpp
+++ b/gfx/layers/BufferTexture.cpp
@@ -180,21 +180,25 @@ BufferTextureData::CreateForYCbCr(KnowsC
uint32_t yOffset;
uint32_t cbOffset;
uint32_t crOffset;
ImageDataSerializer::ComputeYCbCrOffsets(aYStride, aYSize.height,
aCbCrStride, aCbCrSize.height,
yOffset, cbOffset, crOffset);
+ bool supportsTextureDirectMapping =
+ aAllocator->SupportsTextureDirectMapping() && aAllocator->GetMaxTextureSize() >
+ std::max(aYSize.width, std::max(aYSize.height, std::max(aCbCrSize.width, aCbCrSize.height)));
+
bool hasIntermediateBuffer =
aAllocator
? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
aAllocator->GetCompositorBackendType(),
- aAllocator->SupportsTextureDirectMapping())
+ supportsTextureDirectMapping)
: true;
YCbCrDescriptor descriptor = YCbCrDescriptor(aYSize, aYStride,
aCbCrSize, aCbCrStride,
yOffset, cbOffset, crOffset,
aStereoMode,
aYUVColorSpace,
aBitDepth,
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -1060,17 +1060,18 @@ already_AddRefed<TextureClient>
TextureClient::CreateForDrawing(KnowsCompositor* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
BackendSelector aSelector,
TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags)
{
LayersBackend layersBackend = aAllocator->GetCompositorBackendType();
- if (aAllocator->SupportsTextureDirectMapping()) {
+ if (aAllocator->SupportsTextureDirectMapping() &&
+ std::max(aSize.width, aSize.height) <= aAllocator->GetMaxTextureSize()) {
aAllocFlags = TextureAllocationFlags(aAllocFlags | ALLOC_ALLOW_DIRECT_MAPPING);
}
return TextureClient::CreateForDrawing(aAllocator->GetTextureForwarder(),
aFormat, aSize,
layersBackend,
aAllocator->GetMaxTextureSize(),
aSelector,
aTextureFlags,
--- a/gfx/layers/client/TextureClientPool.cpp
+++ b/gfx/layers/client/TextureClientPool.cpp
@@ -148,17 +148,17 @@ TextureClientPool::GetTextureClient()
void
TextureClientPool::AllocateTextureClient()
{
TCP_LOG("TexturePool %p allocating TextureClient, outstanding %u\n",
this, mOutstandingClients);
TextureAllocationFlags allocFlags = ALLOC_DEFAULT;
- if (mSupportsTextureDirectMapping) {
+ if (mSupportsTextureDirectMapping && std::max(mSize.width, mSize.height) <= mMaxTextureSize) {
allocFlags = TextureAllocationFlags(allocFlags | ALLOC_ALLOW_DIRECT_MAPPING);
}
RefPtr<TextureClient> newClient;
if (gfxPrefs::ForceShmemTiles()) {
// gfx::BackendType::NONE means use the content backend
newClient =
TextureClient::CreateForRawBufferAccess(mSurfaceAllocator,
--- a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
+++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
@@ -111,17 +111,19 @@ SharedPlanarYCbCrImage::AdoptData(const
uint8_t *base = GetBuffer();
uint32_t yOffset = aData.mYChannel - base;
uint32_t cbOffset = aData.mCbChannel - base;
uint32_t crOffset = aData.mCrChannel - base;
auto fwd = mCompositable->GetForwarder();
bool supportsTextureDirectMapping = fwd->SupportsTextureDirectMapping() &&
- std::max(mSize.width, mSize.height) <= fwd->GetMaxTextureSize();
+ std::max(aData.mYSize.width,
+ std::max(aData.mYSize.height,
+ std::max(aData.mCbCrSize.width, aData.mCbCrSize.height))) <= fwd->GetMaxTextureSize();
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(
gfx::SurfaceFormat::YUV, fwd->GetCompositorBackendType(),
supportsTextureDirectMapping);
static_cast<BufferTextureData*>(mTextureClient->GetInternalData())
->SetDesciptor(YCbCrDescriptor(aData.mYSize,
aData.mYStride,
aData.mCbCrSize,