зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1678656 - Don't rely on mPlanes to compute RenderTextureHost size, since it's only initialized when used with SWGL. r=jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D104141
This commit is contained in:
Родитель
616bcf95fb
Коммит
eaf110a595
|
@ -323,6 +323,10 @@ size_t MacIOSurface::GetBytesPerRow(size_t plane) const {
|
|||
return ::IOSurfaceGetBytesPerRowOfPlane(mIOSurfaceRef.get(), plane);
|
||||
}
|
||||
|
||||
size_t MacIOSurface::GetAllocSize() const {
|
||||
return ::IOSurfaceGetAllocSize(mIOSurfaceRef.get());
|
||||
}
|
||||
|
||||
OSType MacIOSurface::GetPixelFormat() const {
|
||||
return ::IOSurfaceGetPixelFormat(mIOSurfaceRef.get());
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ class MacIOSurface final
|
|||
size_t GetDevicePixelWidth(size_t plane = 0) const;
|
||||
size_t GetDevicePixelHeight(size_t plane = 0) const;
|
||||
size_t GetBytesPerRow(size_t plane = 0) const;
|
||||
size_t GetAllocSize() const;
|
||||
void Lock(bool aReadOnly = true);
|
||||
void Unlock(bool aReadOnly = true);
|
||||
bool IsLocked() const { return mIsLocked; }
|
||||
|
|
|
@ -30,6 +30,8 @@ class RenderBufferTextureHostSWGL final : public RenderTextureHostSWGL {
|
|||
|
||||
void UnmapPlanes() override;
|
||||
|
||||
size_t Bytes() override { return BytesFromPlanes(); }
|
||||
|
||||
private:
|
||||
virtual ~RenderBufferTextureHostSWGL();
|
||||
|
||||
|
|
|
@ -64,6 +64,20 @@ class RenderDXGITextureHost final : public RenderTextureHostSWGL {
|
|||
bool EnsureD3D11Texture2D(ID3D11Device* aDevice);
|
||||
bool LockInternal();
|
||||
|
||||
size_t Bytes() override {
|
||||
size_t bytes = 0;
|
||||
|
||||
size_t bpp = GetPlaneCount() > 1
|
||||
? (GetColorDepth() == gfx::ColorDepth::COLOR_8 ? 1 : 2)
|
||||
: 4;
|
||||
|
||||
for (size_t i = 0; i < GetPlaneCount(); i++) {
|
||||
gfx::IntSize size = GetSize(i);
|
||||
bytes += size.width * size.height * bpp;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual ~RenderDXGITextureHost();
|
||||
|
||||
|
@ -143,6 +157,18 @@ class RenderDXGIYCbCrTextureHost final : public RenderTextureHostSWGL {
|
|||
return mTextures[aChannelIndex];
|
||||
}
|
||||
|
||||
size_t Bytes() override {
|
||||
size_t bytes = 0;
|
||||
|
||||
size_t bpp = mColorDepth == gfx::ColorDepth::COLOR_8 ? 1 : 2;
|
||||
|
||||
for (size_t i = 0; i < GetPlaneCount(); i++) {
|
||||
gfx::IntSize size = GetSize(i);
|
||||
bytes += size.width * size.height * bpp;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual ~RenderDXGIYCbCrTextureHost();
|
||||
|
||||
|
|
|
@ -72,6 +72,10 @@ gfx::IntSize RenderMacIOSurfaceTextureHost::GetSize(
|
|||
mSurface->GetDevicePixelHeight(aChannelIndex));
|
||||
}
|
||||
|
||||
size_t RenderMacIOSurfaceTextureHost::Bytes() {
|
||||
return mSurface->GetAllocSize();
|
||||
}
|
||||
|
||||
wr::WrExternalImage RenderMacIOSurfaceTextureHost::Lock(
|
||||
uint8_t aChannelIndex, gl::GLContext* aGL, wr::ImageRendering aRendering) {
|
||||
if (mGL.get() != aGL) {
|
||||
|
|
|
@ -34,6 +34,8 @@ class RenderMacIOSurfaceTextureHost final : public RenderTextureHostSWGL {
|
|||
return this;
|
||||
}
|
||||
|
||||
size_t Bytes() override;
|
||||
|
||||
MacIOSurface* GetSurface() { return mSurface; }
|
||||
|
||||
// RenderTextureHostSWGL
|
||||
|
|
|
@ -37,6 +37,8 @@ class RenderSharedSurfaceTextureHostSWGL final : public RenderTextureHostSWGL {
|
|||
|
||||
void UnmapPlanes() override;
|
||||
|
||||
size_t Bytes() override { return BytesFromPlanes(); }
|
||||
|
||||
private:
|
||||
virtual ~RenderSharedSurfaceTextureHostSWGL();
|
||||
|
||||
|
|
|
@ -58,7 +58,8 @@ class RenderTextureHostSWGL : public RenderTextureHost {
|
|||
bool LockSWGLCompositeSurface(void* aContext,
|
||||
wr::SWGLCompositeSurfaceInfo* aInfo);
|
||||
|
||||
size_t Bytes() override {
|
||||
size_t BytesFromPlanes() {
|
||||
NS_ASSERTION(mPlanes.size(), "Can't compute bytes without any planes");
|
||||
size_t bytes = 0;
|
||||
for (auto& plane : mPlanes) {
|
||||
bytes += plane.mStride * plane.mSize.height;
|
||||
|
|
|
@ -46,6 +46,10 @@ class RenderTextureHostWrapper final : public RenderTextureHostSWGL {
|
|||
PlaneInfo& aPlaneInfo) override;
|
||||
void UnmapPlanes() override;
|
||||
|
||||
// This is just a wrapper, so doesn't need to report the
|
||||
// size of the wrapped object (which reports itself).
|
||||
size_t Bytes() override { return 0; }
|
||||
|
||||
private:
|
||||
~RenderTextureHostWrapper() override;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче