mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1771374 - Respect wr::ImageRendering in DCSurfaceSwapChain. r=gfx-reviewers,nical
Differential Revision: https://phabricator.services.mozilla.com/D152798
This commit is contained in:
parent
4b2a1851ac
commit
0e8f2b213c
@ -566,7 +566,7 @@ void DCLayerTree::AddSurface(wr::NativeSurfaceId aId,
|
||||
|
||||
auto* surfaceSc = surface->AsDCSurfaceSwapChain();
|
||||
if (surfaceSc) {
|
||||
const auto presentationTransform = surfaceSc->EnsurePresented(transform);
|
||||
const auto presentationTransform = surfaceSc->EnsurePresented(transform, aImageRendering);
|
||||
if (presentationTransform) {
|
||||
transform = *presentationTransform;
|
||||
} // else EnsurePresented failed, just limp along?
|
||||
@ -1118,7 +1118,8 @@ static CspaceTransformPlan ChooseCspaceTransformPlan(
|
||||
// -
|
||||
|
||||
Maybe<gfx::Matrix> DCSurfaceSwapChain::EnsurePresented(
|
||||
const gfx::Matrix& aTransform) {
|
||||
const gfx::Matrix& aTransform,
|
||||
const wr::ImageRendering aRendering) {
|
||||
MOZ_RELEASE_ASSERT(mSrc);
|
||||
const auto& srcSize = mSrc->size;
|
||||
|
||||
@ -1160,6 +1161,10 @@ Maybe<gfx::Matrix> DCSurfaceSwapChain::EnsurePresented(
|
||||
mDest = Nothing();
|
||||
}
|
||||
|
||||
if (mDest && mDest->rendering.value() != aRendering) {
|
||||
mDest->needsPresent = true;
|
||||
}
|
||||
|
||||
// -
|
||||
|
||||
// Ok, we have some options:
|
||||
@ -1241,6 +1246,7 @@ Maybe<gfx::Matrix> DCSurfaceSwapChain::EnsurePresented(
|
||||
MOZ_ASSERT(mDest->dest);
|
||||
mVisual->SetContent(mDest->dest->swapChain);
|
||||
}
|
||||
mDest->rendering = Some(aRendering);
|
||||
|
||||
if (!CallBlit()) {
|
||||
RenderThread::Get()->NotifyWebRenderError(
|
||||
@ -1518,6 +1524,12 @@ bool DCSurfaceSwapChain::CallBlitHelper() const {
|
||||
return ret;
|
||||
};
|
||||
|
||||
const auto filter = ToGlTexFilter(mDest->rendering.value());
|
||||
const auto SetRenderingTexFilter = [&](const GLenum texTarget) {
|
||||
gl->fTexParameteri(texTarget, LOCAL_GL_TEXTURE_MAG_FILTER, filter);
|
||||
gl->fTexParameteri(texTarget, LOCAL_GL_TEXTURE_MIN_FILTER, filter);
|
||||
};
|
||||
|
||||
// -
|
||||
// Bind LUT
|
||||
|
||||
@ -1546,6 +1558,7 @@ bool DCSurfaceSwapChain::CallBlitHelper() const {
|
||||
|
||||
gl->fActiveTexture(LOCAL_GL_TEXTURE0 + 0);
|
||||
gl->fBindTexture(LOCAL_GL_TEXTURE_EXTERNAL, image0.handle);
|
||||
SetRenderingTexFilter(LOCAL_GL_TEXTURE_EXTERNAL);
|
||||
|
||||
// -
|
||||
// Bind swapchain RT
|
||||
@ -1608,6 +1621,7 @@ bool DCSurfaceSwapChain::CallBlitHelper() const {
|
||||
|
||||
gl->fActiveTexture(LOCAL_GL_TEXTURE0 + 1);
|
||||
gl->fBindTexture(LOCAL_GL_TEXTURE_EXTERNAL, image1.handle);
|
||||
SetRenderingTexFilter(LOCAL_GL_TEXTURE_EXTERNAL);
|
||||
|
||||
yuvArgs = Some(gl::DrawBlitProg::YUVArgs{texCoordMat1, {}});
|
||||
fragSample = gl::kFragSample_TwoPlane;
|
||||
|
@ -320,7 +320,7 @@ class DCSurfaceSwapChain : public DCSurface {
|
||||
DCSurfaceSwapChain(bool aIsOpaque, DCLayerTree* aDCLayerTree);
|
||||
|
||||
void AttachExternalImage(wr::ExternalImageId aExternalImage);
|
||||
Maybe<gfx::Matrix> EnsurePresented(const gfx::Matrix&);
|
||||
Maybe<gfx::Matrix> EnsurePresented(const gfx::Matrix&, wr::ImageRendering);
|
||||
|
||||
DCSurfaceSwapChain* AsDCSurfaceSwapChain() override { return this; }
|
||||
|
||||
@ -343,6 +343,7 @@ class DCSurfaceSwapChain : public DCSurface {
|
||||
DXGI_COLOR_SPACE_TYPE space;
|
||||
};
|
||||
struct PlanAndDest final {
|
||||
Maybe<wr::ImageRendering> rendering;
|
||||
CspaceAndRange srcSpace;
|
||||
CspaceTransformPlan plan;
|
||||
Maybe<Dest> dest;
|
||||
|
@ -12,19 +12,27 @@
|
||||
namespace mozilla {
|
||||
namespace wr {
|
||||
|
||||
GLenum ToGlTexFilter(const wr::ImageRendering aRendering) {
|
||||
switch (aRendering) {
|
||||
case wr::ImageRendering::Auto:
|
||||
case wr::ImageRendering::CrispEdges:
|
||||
return LOCAL_GL_LINEAR;
|
||||
case wr::ImageRendering::Pixelated:
|
||||
return LOCAL_GL_NEAREST;
|
||||
case wr::ImageRendering::Sentinel:
|
||||
break;
|
||||
}
|
||||
MOZ_CRASH("Bad wr::ImageRendering");
|
||||
}
|
||||
|
||||
void ActivateBindAndTexParameteri(gl::GLContext* aGL, GLenum aActiveTexture,
|
||||
GLenum aBindTarget, GLuint aBindTexture,
|
||||
wr::ImageRendering aRendering) {
|
||||
aGL->fActiveTexture(aActiveTexture);
|
||||
aGL->fBindTexture(aBindTarget, aBindTexture);
|
||||
aGL->fTexParameteri(aBindTarget, LOCAL_GL_TEXTURE_MIN_FILTER,
|
||||
aRendering == wr::ImageRendering::Pixelated
|
||||
? LOCAL_GL_NEAREST
|
||||
: LOCAL_GL_LINEAR);
|
||||
aGL->fTexParameteri(aBindTarget, LOCAL_GL_TEXTURE_MAG_FILTER,
|
||||
aRendering == wr::ImageRendering::Pixelated
|
||||
? LOCAL_GL_NEAREST
|
||||
: LOCAL_GL_LINEAR);
|
||||
const auto filter = ToGlTexFilter(aRendering);
|
||||
aGL->fTexParameteri(aBindTarget, LOCAL_GL_TEXTURE_MIN_FILTER, filter);
|
||||
aGL->fTexParameteri(aBindTarget, LOCAL_GL_TEXTURE_MAG_FILTER, filter);
|
||||
}
|
||||
|
||||
RenderTextureHost::RenderTextureHost()
|
||||
|
@ -32,6 +32,8 @@ class RenderMacIOSurfaceTextureHost;
|
||||
class RenderBufferTextureHost;
|
||||
class RenderTextureHostSWGL;
|
||||
|
||||
GLenum ToGlTexFilter(wr::ImageRendering);
|
||||
|
||||
void ActivateBindAndTexParameteri(gl::GLContext* aGL, GLenum aActiveTexture,
|
||||
GLenum aBindTarget, GLuint aBindTexture,
|
||||
wr::ImageRendering aRendering);
|
||||
|
Loading…
Reference in New Issue
Block a user