Backed out 3 changesets (bug 1913568) for causing multiple wrench build bustages related to normalized_uvs. CLOSED TREE

Backed out changeset 08890d5674ad (bug 1913568)
Backed out changeset 4aaa0e9d0a6f (bug 1913568)
Backed out changeset b6f9d83c6da0 (bug 1913568)
This commit is contained in:
Iulian Moraru 2024-09-09 13:14:14 +03:00
Родитель 1958e1fbc4
Коммит e53fc69e92
40 изменённых файлов: 224 добавлений и 311 удалений

Просмотреть файл

@ -222,6 +222,17 @@ class RemoteVideoDecoder final : public RemoteDataDecoder {
mJavaDecoder->IsAdaptivePlaybackSupported();
mIsHardwareAccelerated = mJavaDecoder->IsHardwareAccelerated();
// On some devices we have observed that the transform obtained from
// SurfaceTexture.getTransformMatrix() is incorrect for surfaces produced by
// a MediaCodec. We therefore override the transform to be a simple y-flip
// to ensure it is rendered correctly.
const auto hardware = java::sdk::Build::HARDWARE()->ToString();
if (hardware.EqualsASCII("mt6735") || hardware.EqualsASCII("kirin980") ||
hardware.EqualsASCII("mt8696")) {
mTransformOverride = Some(
gfx::Matrix4x4::Scaling(1.0, -1.0, 1.0).PostTranslate(0.0, 1.0, 0.0));
}
mMediaInfoFlag = MediaInfoFlag::None;
mMediaInfoFlag |= mIsHardwareAccelerated ? MediaInfoFlag::HardwareDecoding
: MediaInfoFlag::SoftwareDecoding;
@ -416,7 +427,7 @@ class RemoteVideoDecoder final : public RemoteDataDecoder {
RefPtr<layers::Image> img = new layers::SurfaceTextureImage(
mSurfaceHandle, inputInfo.mImageSize, false /* NOT continuous */,
gl::OriginPos::BottomLeft, mConfig.HasAlpha(), forceBT709ColorSpace,
/* aTransformOverride */ Nothing());
mTransformOverride);
img->AsSurfaceTextureImage()->RegisterSetCurrentCallback(
std::move(releaseSample));
@ -557,6 +568,9 @@ class RemoteVideoDecoder final : public RemoteDataDecoder {
const VideoInfo mConfig;
java::GeckoSurface::GlobalRef mSurface;
AndroidSurfaceTextureHandle mSurfaceHandle{};
// Used to override the SurfaceTexture transform on some devices where the
// decoder provides a buggy value.
Maybe<gfx::Matrix4x4> mTransformOverride;
// Only accessed on reader's task queue.
bool mIsCodecSupportAdaptivePlayback = false;
// Can be accessed on any thread, but only written on during init.

Просмотреть файл

@ -41,12 +41,8 @@ GLReadTexImageHelper::~GLReadTexImageHelper() {
static const GLchar readTextureImageVS[] =
"attribute vec2 aVertex;\n"
"attribute vec2 aTexCoord;\n"
"uniform mat4 uTexMatrix;\n"
"varying vec2 vTexCoord;\n"
"void main() {\n"
" gl_Position = vec4(aVertex, 0, 1);\n"
" vTexCoord = (uTexMatrix * vec4(aTexCoord, 0.0, 1.0)).xy;\n"
"}";
"void main() { gl_Position = vec4(aVertex, 0, 1); vTexCoord = aTexCoord; }";
static const GLchar readTextureImageFS_TEXTURE_2D[] =
"#ifdef GL_ES\n"
@ -486,7 +482,6 @@ already_AddRefed<DataSourceSurface> ReadBackSurface(GLContext* gl,
already_AddRefed<DataSourceSurface> GLReadTexImageHelper::ReadTexImage(
GLuint aTextureId, GLenum aTextureTarget, const gfx::IntSize& aSize,
const gfx::Matrix4x4& aTexMatrix,
/* ShaderConfigOGL.mFeature */ int aConfig, bool aYInvert) {
/* Allocate resulting image surface */
int32_t stride = aSize.width * BytesPerPixel(SurfaceFormat::R8G8B8A8);
@ -496,8 +491,8 @@ already_AddRefed<DataSourceSurface> GLReadTexImageHelper::ReadTexImage(
return nullptr;
}
if (!ReadTexImage(isurf, aTextureId, aTextureTarget, aSize, aTexMatrix,
aConfig, aYInvert)) {
if (!ReadTexImage(isurf, aTextureId, aTextureTarget, aSize, aConfig,
aYInvert)) {
return nullptr;
}
@ -506,7 +501,7 @@ already_AddRefed<DataSourceSurface> GLReadTexImageHelper::ReadTexImage(
bool GLReadTexImageHelper::ReadTexImage(
DataSourceSurface* aDest, GLuint aTextureId, GLenum aTextureTarget,
const gfx::IntSize& aSize, const gfx::Matrix4x4& aTexMatrix,
const gfx::IntSize& aSize,
/* ShaderConfigOGL.mFeature */ int aConfig, bool aYInvert) {
MOZ_ASSERT(aTextureTarget == LOCAL_GL_TEXTURE_2D ||
aTextureTarget == LOCAL_GL_TEXTURE_EXTERNAL ||
@ -572,10 +567,7 @@ bool GLReadTexImageHelper::ReadTexImage(
mGL->fUseProgram(program);
CLEANUP_IF_GLERROR_OCCURRED("when using program");
mGL->fUniform1i(mGL->fGetUniformLocation(program, "uTexture"), 0);
CLEANUP_IF_GLERROR_OCCURRED("when setting uniform uTexture");
mGL->fUniformMatrix4fv(mGL->fGetUniformLocation(program, "uTexMatrix"), 1,
false, aTexMatrix.components);
CLEANUP_IF_GLERROR_OCCURRED("when setting uniform uTexMatrix");
CLEANUP_IF_GLERROR_OCCURRED("when setting uniform location");
/* Setup quad geometry */
mGL->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);

Просмотреть файл

@ -11,7 +11,6 @@
#include "mozilla/Attributes.h"
#include "nsSize.h"
#include "mozilla/RefPtr.h"
#include "mozilla/gfx/MatrixFwd.h"
#include "mozilla/gfx/Types.h"
namespace mozilla {
@ -73,13 +72,11 @@ class GLReadTexImageHelper final {
*/
already_AddRefed<gfx::DataSourceSurface> ReadTexImage(
GLuint aTextureId, GLenum aTextureTarget, const gfx::IntSize& aSize,
const gfx::Matrix4x4& aTexMatrix,
/* ShaderProgramType */ int aShaderProgram, bool aYInvert = false);
bool ReadTexImage(gfx::DataSourceSurface* aDest, GLuint aTextureId,
GLenum aTextureTarget, const gfx::IntSize& aSize,
const gfx::Matrix4x4& aTexMatrix, int aShaderProgram,
bool aYInvert = false);
int aShaderProgram, bool aYInvert = false);
};
} // namespace gl

Просмотреть файл

@ -125,7 +125,7 @@ void DcompSurfaceHandleHost::PushResourceUpdates(
this, wr::AsUint64(aExternalImageId),
policy == TextureHost::NativeTexturePolicy::REQUIRE ? "rect" : "ext");
(aResources.*method)(aImageKeys[0], descriptor, aExternalImageId, imageType,
0, /* aNormalizedUvs */ false);
0);
}
void DcompSurfaceHandleHost::PushDisplayItems(

Просмотреть файл

@ -543,8 +543,7 @@ void BufferTextureHost::PushResourceUpdates(
GetSize(),
ImageDataSerializer::ComputeRGBStride(GetFormat(), GetSize().width),
GetFormat());
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0);
} else {
MOZ_ASSERT(aImageKeys.length() == 3);
@ -556,12 +555,9 @@ void BufferTextureHost::PushResourceUpdates(
wr::ImageDescriptor cbcrDescriptor(
cbcrSize, desc.cbCrStride(),
SurfaceFormatForColorDepth(desc.colorDepth()));
(aResources.*method)(aImageKeys[0], yDescriptor, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[1], cbcrDescriptor, aExtID, imageType, 1,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[2], cbcrDescriptor, aExtID, imageType, 2,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], yDescriptor, aExtID, imageType, 0);
(aResources.*method)(aImageKeys[1], cbcrDescriptor, aExtID, imageType, 1);
(aResources.*method)(aImageKeys[2], cbcrDescriptor, aExtID, imageType, 2);
}
}

Просмотреть файл

@ -1242,8 +1242,7 @@ void DXGITextureHostD3D11::PushResourceUpdates(
wr::ImageBufferKind::TextureRect)
: wr::ExternalImageType::TextureHandle(
wr::ImageBufferKind::TextureExternal);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0);
break;
}
case gfx::SurfaceFormat::P010:
@ -1269,10 +1268,8 @@ void DXGITextureHostD3D11::PushResourceUpdates(
wr::ImageBufferKind::TextureRect)
: wr::ExternalImageType::TextureHandle(
wr::ImageBufferKind::TextureExternal);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1);
break;
}
default: {
@ -1421,12 +1418,9 @@ void DXGIYCbCrTextureHostD3D11::PushResourceUpdates(
wr::ImageDescriptor descriptor0(mSizeY, gfx::SurfaceFormat::A8);
// cb and cr
wr::ImageDescriptor descriptor1(mSizeCbCr, gfx::SurfaceFormat::A8);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[2], descriptor1, aExtID, imageType, 2,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1);
(aResources.*method)(aImageKeys[2], descriptor1, aExtID, imageType, 2);
}
void DXGIYCbCrTextureHostD3D11::PushDisplayItems(

Просмотреть файл

@ -98,8 +98,7 @@ void DMABUFTextureHostOGL::PushResourceUpdates(
// XXX Add RGBA handling. Temporary hack to avoid crash
// With BGRA format setting, rendering works without problem.
wr::ImageDescriptor descriptor(GetSize(), mSurface->GetFormat());
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0);
break;
}
case gfx::SurfaceFormat::NV12: {
@ -111,10 +110,8 @@ void DMABUFTextureHostOGL::PushResourceUpdates(
wr::ImageDescriptor descriptor1(
gfx::IntSize(mSurface->GetWidth(1), mSurface->GetHeight(1)),
gfx::SurfaceFormat::R8G8);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1);
break;
}
case gfx::SurfaceFormat::YUV420: {
@ -126,12 +123,9 @@ void DMABUFTextureHostOGL::PushResourceUpdates(
wr::ImageDescriptor descriptor1(
gfx::IntSize(mSurface->GetWidth(1), mSurface->GetHeight(1)),
gfx::SurfaceFormat::A8);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[2], descriptor1, aExtID, imageType, 2,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1);
(aResources.*method)(aImageKeys[2], descriptor1, aExtID, imageType, 2);
break;
}
default: {

Просмотреть файл

@ -130,8 +130,7 @@ void MacIOSurfaceTextureHostOGL::PushResourceUpdates(
? gfx::SurfaceFormat::B8G8R8A8
: gfx::SurfaceFormat::B8G8R8X8;
wr::ImageDescriptor descriptor(GetSize(), format);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0);
break;
}
case gfx::SurfaceFormat::YUY2: {
@ -142,8 +141,7 @@ void MacIOSurfaceTextureHostOGL::PushResourceUpdates(
MOZ_ASSERT(aImageKeys.length() == 1);
MOZ_ASSERT(mSurface->GetPlaneCount() == 0);
wr::ImageDescriptor descriptor(GetSize(), gfx::SurfaceFormat::B8G8R8X8);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0);
break;
}
case gfx::SurfaceFormat::NV12: {
@ -157,10 +155,8 @@ void MacIOSurfaceTextureHostOGL::PushResourceUpdates(
gfx::IntSize(mSurface->GetDevicePixelWidth(1),
mSurface->GetDevicePixelHeight(1)),
gfx::SurfaceFormat::R8G8);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1);
break;
}
case gfx::SurfaceFormat::P010: {
@ -174,10 +170,8 @@ void MacIOSurfaceTextureHostOGL::PushResourceUpdates(
gfx::IntSize(mSurface->GetDevicePixelWidth(1),
mSurface->GetDevicePixelHeight(1)),
gfx::SurfaceFormat::R16G16);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1);
break;
}
case gfx::SurfaceFormat::NV16: {
@ -191,10 +185,8 @@ void MacIOSurfaceTextureHostOGL::PushResourceUpdates(
gfx::IntSize(mSurface->GetDevicePixelWidth(1),
mSurface->GetDevicePixelHeight(1)),
gfx::SurfaceFormat::R16G16);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1);
break;
}
default: {

Просмотреть файл

@ -571,15 +571,6 @@ void SurfaceTextureHost::PushResourceUpdates(
wr::ImageBufferKind::TextureExternalBT709);
}
// Hardware webrender directly renders from the SurfaceTexture therefore we
// must provide it the (transformed) normalized UVs. For software webrender we
// first read from the SurfaceTexture in to a CPU buffer, which we sample from
// using unnormalized UVs. The readback code handles the texture transform.
// See RenderAndroidSurfaceTextureHost::Lock() and
// RenderAndroidSurfaceTextureHost::ReadTexImage(), respectively.
const bool normalizedUvs =
aResources.GetBackendType() == WebRenderBackend::HARDWARE;
switch (GetFormat()) {
case gfx::SurfaceFormat::R8G8B8X8:
case gfx::SurfaceFormat::R8G8B8A8: {
@ -591,8 +582,7 @@ void SurfaceTextureHost::PushResourceUpdates(
? gfx::SurfaceFormat::B8G8R8A8
: gfx::SurfaceFormat::B8G8R8X8;
wr::ImageDescriptor descriptor(GetSize(), format);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0,
normalizedUvs);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0);
break;
}
default: {
@ -885,8 +875,7 @@ void AndroidHardwareBufferTextureHost::PushResourceUpdates(
? gfx::SurfaceFormat::B8G8R8A8
: gfx::SurfaceFormat::B8G8R8X8;
wr::ImageDescriptor descriptor(GetSize(), format);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0);
break;
}
default: {
@ -1042,8 +1031,7 @@ void EGLImageTextureHost::PushResourceUpdates(
? gfx::SurfaceFormat::B8G8R8A8
: gfx::SurfaceFormat::B8G8R8X8;
wr::ImageDescriptor descriptor(GetSize(), formatTmp);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0,
/* aNormalizedUvs */ false);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0);
}
void EGLImageTextureHost::PushDisplayItems(

Просмотреть файл

@ -843,8 +843,7 @@ bool WebRenderBridgeParent::UpdateSharedExternalImage(
wr::ImageDescriptor descriptor(surfaceSize, dSurf->Stride(),
dSurf->GetFormat());
aResources.UpdateExternalImageWithDirtyRect(
aKey, descriptor, aExtId, imageType, wr::ToDeviceIntRect(aDirtyRect), 0,
/* aNormalizedUvs */ false);
aKey, descriptor, aExtId, imageType, wr::ToDeviceIntRect(aDirtyRect), 0);
return true;
}

Просмотреть файл

@ -132,10 +132,9 @@ wr::WrExternalImage RenderAndroidHardwareBufferTextureHost::Lock(
return InvalidToWrExternalImage();
}
const gfx::IntSize size = GetSize();
return NativeTextureToWrExternalImage(mTextureHandle, 0.0, 0.0,
static_cast<float>(size.width),
static_cast<float>(size.height));
const auto uvs = GetUvCoords(GetSize());
return NativeTextureToWrExternalImage(
mTextureHandle, uvs.first.x, uvs.first.y, uvs.second.x, uvs.second.y);
}
void RenderAndroidHardwareBufferTextureHost::Unlock() {}
@ -210,8 +209,8 @@ RenderAndroidHardwareBufferTextureHost::ReadTexImage() {
int shaderConfig = config.mFeatures;
bool ret = mGL->ReadTexImageHelper()->ReadTexImage(
surf, mTextureHandle, LOCAL_GL_TEXTURE_EXTERNAL, GetSize(),
gfx::Matrix4x4(), shaderConfig, /* aYInvert */ false);
surf, mTextureHandle, LOCAL_GL_TEXTURE_EXTERNAL, GetSize(), shaderConfig,
/* aYInvert */ false);
if (!ret) {
return nullptr;
}

Просмотреть файл

@ -72,20 +72,10 @@ wr::WrExternalImage RenderAndroidSurfaceTextureHost::Lock(uint8_t aChannelIndex,
UpdateTexImageIfNecessary();
const gfx::Matrix4x4 transform = GetTextureTransform();
// We expect this transform to always be rectilinear, usually just a
// y-flip and sometimes an x and y scale/translation. This allows us
// to simply transform 2 points here instead of 4.
MOZ_ASSERT(transform.IsRectilinear(),
"Unexpected non-rectilinear transform returned from "
"SurfaceTexture.GetTransformMatrix()");
gfx::Point uv0(0.0, 0.0);
gfx::Point uv1(1.0, 1.0);
uv0 = transform.TransformPoint(uv0);
uv1 = transform.TransformPoint(uv1);
return NativeTextureToWrExternalImage(mSurfTex->GetTexName(), uv0.x, uv0.y,
uv1.x, uv1.y);
const auto uvs = GetUvCoords(mSize);
return NativeTextureToWrExternalImage(mSurfTex->GetTexName(), uvs.first.x,
uvs.first.y, uvs.second.x,
uvs.second.y);
}
void RenderAndroidSurfaceTextureHost::Unlock() {}
@ -261,7 +251,7 @@ RenderAndroidSurfaceTextureHost::ReadTexImage() {
bool ret = mGL->ReadTexImageHelper()->ReadTexImage(
surf, mSurfTex->GetTexName(), LOCAL_GL_TEXTURE_EXTERNAL, mSize,
GetTextureTransform(), shaderConfig, /* aYInvert */ false);
shaderConfig, /* aYInvert */ false);
if (!ret) {
return nullptr;
}
@ -298,7 +288,8 @@ void RenderAndroidSurfaceTextureHost::UnmapPlanes() {
}
}
gfx::Matrix4x4 RenderAndroidSurfaceTextureHost::GetTextureTransform() const {
std::pair<gfx::Point, gfx::Point> RenderAndroidSurfaceTextureHost::GetUvCoords(
gfx::IntSize aTextureSize) const {
gfx::Matrix4x4 transform;
// GetTransformMatrix() returns the transform set by the producer side of the
@ -314,7 +305,21 @@ gfx::Matrix4x4 RenderAndroidSurfaceTextureHost::GetTextureTransform() const {
gl::AndroidSurfaceTexture::GetTransformMatrix(surf, &transform);
}
return transform;
// We expect this transform to always be rectilinear, usually just a
// y-flip and sometimes an x and y scale. This allows this function
// to simply transform and return 2 points here instead of 4.
MOZ_ASSERT(transform.IsRectilinear(),
"Unexpected non-rectilinear transform returned from "
"SurfaceTexture.GetTransformMatrix()");
transform.PostScale(aTextureSize.width, aTextureSize.height, 0.0);
gfx::Point uv0 = gfx::Point(0.0, 0.0);
gfx::Point uv1 = gfx::Point(1.0, 1.0);
uv0 = transform.TransformPoint(uv0);
uv1 = transform.TransformPoint(uv1);
return std::make_pair(uv0, uv1);
}
RefPtr<layers::TextureSource>

Просмотреть файл

@ -69,10 +69,13 @@ class RenderAndroidSurfaceTextureHost final : public RenderTextureHostSWGL {
virtual ~RenderAndroidSurfaceTextureHost();
bool EnsureAttachedToGLContext();
gfx::Matrix4x4 GetTextureTransform() const;
already_AddRefed<gfx::DataSourceSurface> ReadTexImage();
// Returns the UV coordinates to be used when sampling the texture, taking in
// to account the SurfaceTexture's transform if applicable.
std::pair<gfx::Point, gfx::Point> GetUvCoords(
gfx::IntSize aTextureSize) const override;
enum PrepareStatus {
STATUS_NONE,
STATUS_MIGHT_BE_USED_BY_WR,

Просмотреть файл

@ -380,10 +380,10 @@ wr::WrExternalImage RenderDXGITextureHost::Lock(uint8_t aChannelIndex,
return InvalidToWrExternalImage();
}
const gfx::IntSize size = GetSize(aChannelIndex);
return NativeTextureToWrExternalImage(GetGLHandle(aChannelIndex), 0.0, 0.0,
static_cast<float>(size.width),
static_cast<float>(size.height));
const auto uvs = GetUvCoords(GetSize(aChannelIndex));
return NativeTextureToWrExternalImage(GetGLHandle(aChannelIndex), uvs.first.x,
uvs.first.y, uvs.second.x,
uvs.second.y);
}
bool RenderDXGITextureHost::LockInternal() {
@ -701,10 +701,10 @@ wr::WrExternalImage RenderDXGIYCbCrTextureHost::Lock(uint8_t aChannelIndex,
return InvalidToWrExternalImage();
}
const gfx::IntSize size = GetSize(aChannelIndex);
return NativeTextureToWrExternalImage(GetGLHandle(aChannelIndex), 0.0, 0.0,
static_cast<float>(size.width),
static_cast<float>(size.height));
const auto uvs = GetUvCoords(GetSize(aChannelIndex));
return NativeTextureToWrExternalImage(GetGLHandle(aChannelIndex), uvs.first.x,
uvs.first.y, uvs.second.x,
uvs.second.y);
}
void RenderDXGIYCbCrTextureHost::Unlock() {

Просмотреть файл

@ -46,11 +46,11 @@ wr::WrExternalImage RenderDMABUFTextureHost::Lock(uint8_t aChannelIndex,
mSurface->GetTexture(aChannelIndex));
}
const gfx::IntSize size(mSurface->GetWidth(aChannelIndex),
mSurface->GetHeight(aChannelIndex));
return NativeTextureToWrExternalImage(
mSurface->GetTexture(aChannelIndex), 0.0, 0.0,
static_cast<float>(size.width), static_cast<float>(size.height));
const auto uvs = GetUvCoords(gfx::IntSize(
mSurface->GetWidth(aChannelIndex), mSurface->GetHeight(aChannelIndex)));
return NativeTextureToWrExternalImage(mSurface->GetTexture(aChannelIndex),
uvs.first.x, uvs.first.y, uvs.second.x,
uvs.second.y);
}
void RenderDMABUFTextureHost::Unlock() {}

Просмотреть файл

@ -54,9 +54,9 @@ wr::WrExternalImage RenderEGLImageTextureHost::Lock(uint8_t aChannelIndex,
return InvalidToWrExternalImage();
}
return NativeTextureToWrExternalImage(mTextureHandle, 0.0, 0.0,
static_cast<float>(mSize.width),
static_cast<float>(mSize.height));
const auto uvs = GetUvCoords(mSize);
return NativeTextureToWrExternalImage(
mTextureHandle, uvs.first.x, uvs.first.y, uvs.second.x, uvs.second.y);
}
void RenderEGLImageTextureHost::Unlock() {}
@ -209,8 +209,8 @@ RenderEGLImageTextureHost::ReadTexImage() {
int shaderConfig = config.mFeatures;
bool ret = mGL->ReadTexImageHelper()->ReadTexImage(
surf, mTextureHandle, mTextureTarget, mSize, gfx::Matrix4x4(),
shaderConfig, /* aYInvert */ false);
surf, mTextureHandle, mTextureTarget, mSize, shaderConfig,
/* aYInvert */ false);
if (!ret) {
return nullptr;
}

Просмотреть файл

@ -166,10 +166,9 @@ void RenderExternalTextureHost::UpdateTexture(size_t aIndex) {
texture = new layers::DirectMapTextureSource(mGL, mSurfaces[aIndex]);
const GLuint handle = texture->GetTextureHandle();
const gfx::IntSize size = texture->GetSize();
const auto uvs = GetUvCoords(texture->GetSize());
mImages[aIndex] = NativeTextureToWrExternalImage(
handle, 0.0, 0.0, static_cast<float>(size.width),
static_cast<float>(size.height));
handle, uvs.first.x, uvs.first.y, uvs.second.x, uvs.second.y);
}
MOZ_ASSERT(mGL->GetError() == LOCAL_GL_NO_ERROR);

Просмотреть файл

@ -105,10 +105,10 @@ wr::WrExternalImage RenderMacIOSurfaceTextureHost::Lock(uint8_t aChannelIndex,
}
}
const auto size = GetSize(aChannelIndex);
return NativeTextureToWrExternalImage(GetGLHandle(aChannelIndex), 0.0, 0.0,
static_cast<float>(size.width),
static_cast<float>(size.height));
const auto uvs = GetUvCoords(GetSize(aChannelIndex));
return NativeTextureToWrExternalImage(GetGLHandle(aChannelIndex), uvs.first.x,
uvs.first.y, uvs.second.x,
uvs.second.y);
}
void RenderMacIOSurfaceTextureHost::Unlock() {}

Просмотреть файл

@ -44,6 +44,13 @@ wr::WrExternalImage RenderTextureHost::LockSWGL(uint8_t aChannelIndex,
return InvalidToWrExternalImage();
}
std::pair<gfx::Point, gfx::Point> RenderTextureHost::GetUvCoords(
gfx::IntSize aTextureSize) const {
return std::make_pair(gfx::Point(0.0, 0.0),
gfx::Point(static_cast<float>(aTextureSize.width),
static_cast<float>(aTextureSize.height)));
}
void RenderTextureHost::Destroy() {
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
}

Просмотреть файл

@ -169,6 +169,13 @@ class RenderTextureHost {
protected:
virtual ~RenderTextureHost();
// Returns the UV coordinates to be used when sampling the texture, in pixels.
// For most implementations these will be (0, 0) and (size.x, size.y), but
// some texture types (such as RenderAndroidSurfaceTextureHost) require an
// additional transform to be applied to the coordinates.
virtual std::pair<gfx::Point, gfx::Point> GetUvCoords(
gfx::IntSize aTextureSize) const;
bool mIsFromDRMSource;
// protected by RenderThread::mRenderTextureMapLock

Просмотреть файл

@ -120,17 +120,22 @@ wr::WrExternalImage RenderTextureHostSWGL::LockSWGL(
}
const PlaneInfo& plane = mPlanes[aChannelIndex];
const auto uvs = GetUvCoords(plane.mSize);
// Prefer native textures, unless our backend forbids it.
// If the GetUvCoords call above returned anything other than the default,
// for example if this is a RenderAndroidSurfaceTextureHost, then this won't
// be handled correctly in the RawDataToWrExternalImage path. But we shouldn't
// hit this path in practice with a RenderAndroidSurfaceTextureHost.
layers::TextureHost::NativeTexturePolicy policy =
layers::TextureHost::BackendNativeTexturePolicy(
layers::WebRenderBackend::SOFTWARE, plane.mSize);
return policy == layers::TextureHost::NativeTexturePolicy::FORBID
? RawDataToWrExternalImage((uint8_t*)plane.mData,
plane.mStride * plane.mSize.height)
: NativeTextureToWrExternalImage(
plane.mTexture, 0.0, 0.0,
static_cast<float>(plane.mSize.width),
static_cast<float>(plane.mSize.height));
: NativeTextureToWrExternalImage(plane.mTexture, uvs.first.x,
uvs.first.y, uvs.second.x,
uvs.second.y);
}
void RenderTextureHostSWGL::UnlockSWGL() {

Просмотреть файл

@ -52,6 +52,14 @@ void RenderTextureHostWrapper::Unlock() {
}
}
std::pair<gfx::Point, gfx::Point> RenderTextureHostWrapper::GetUvCoords(
gfx::IntSize aTextureSize) const {
if (mTextureHost) {
return mTextureHost->GetUvCoords(aTextureSize);
}
return RenderTextureHost::GetUvCoords(aTextureSize);
}
void RenderTextureHostWrapper::ClearCachedResources() {
if (mTextureHost) {
mTextureHost->ClearCachedResources();

Просмотреть файл

@ -68,6 +68,11 @@ class RenderTextureHostWrapper final : public RenderTextureHostSWGL {
// size of the wrapped object (which reports itself).
size_t Bytes() override { return 0; }
protected:
// RenderTextureHost
std::pair<gfx::Point, gfx::Point> GetUvCoords(
gfx::IntSize aTextureSize) const override;
private:
~RenderTextureHostWrapper() override;

Просмотреть файл

@ -982,11 +982,9 @@ void TransactionBuilder::AddExternalImage(ImageKey key,
const ImageDescriptor& aDescriptor,
ExternalImageId aExtID,
wr::ExternalImageType aImageType,
uint8_t aChannelIndex,
bool aNormalizedUvs) {
uint8_t aChannelIndex) {
wr_resource_updates_add_external_image(mTxn, key, &aDescriptor, aExtID,
&aImageType, aChannelIndex,
aNormalizedUvs);
&aImageType, aChannelIndex);
}
void TransactionBuilder::AddExternalImageBuffer(
@ -1016,20 +1014,17 @@ void TransactionBuilder::UpdateExternalImage(ImageKey aKey,
const ImageDescriptor& aDescriptor,
ExternalImageId aExtID,
wr::ExternalImageType aImageType,
uint8_t aChannelIndex,
bool aNormalizedUvs) {
uint8_t aChannelIndex) {
wr_resource_updates_update_external_image(mTxn, aKey, &aDescriptor, aExtID,
&aImageType, aChannelIndex,
aNormalizedUvs);
&aImageType, aChannelIndex);
}
void TransactionBuilder::UpdateExternalImageWithDirtyRect(
ImageKey aKey, const ImageDescriptor& aDescriptor, ExternalImageId aExtID,
wr::ExternalImageType aImageType, const wr::DeviceIntRect& aDirtyRect,
uint8_t aChannelIndex, bool aNormalizedUvs) {
uint8_t aChannelIndex) {
wr_resource_updates_update_external_image_with_dirty_rect(
mTxn, aKey, &aDescriptor, aExtID, &aImageType, aChannelIndex,
aNormalizedUvs, aDirtyRect);
mTxn, aKey, &aDescriptor, aExtID, &aImageType, aChannelIndex, aDirtyRect);
}
void TransactionBuilder::SetBlobImageVisibleArea(

Просмотреть файл

@ -157,7 +157,7 @@ class TransactionBuilder final {
void AddExternalImage(ImageKey key, const ImageDescriptor& aDescriptor,
ExternalImageId aExtID,
wr::ExternalImageType aImageType,
uint8_t aChannelIndex = 0, bool aNormalizedUvs = false);
uint8_t aChannelIndex = 0);
void UpdateImageBuffer(wr::ImageKey aKey, const ImageDescriptor& aDescriptor,
wr::Vec<uint8_t>& aBytes);
@ -171,13 +171,14 @@ class TransactionBuilder final {
void UpdateExternalImage(ImageKey aKey, const ImageDescriptor& aDescriptor,
ExternalImageId aExtID,
wr::ExternalImageType aImageType,
uint8_t aChannelIndex = 0,
bool aNormalizedUvs = false);
uint8_t aChannelIndex = 0);
void UpdateExternalImageWithDirtyRect(
ImageKey aKey, const ImageDescriptor& aDescriptor, ExternalImageId aExtID,
wr::ExternalImageType aImageType, const wr::DeviceIntRect& aDirtyRect,
uint8_t aChannelIndex = 0, bool aNormalizedUvs = false);
void UpdateExternalImageWithDirtyRect(ImageKey aKey,
const ImageDescriptor& aDescriptor,
ExternalImageId aExtID,
wr::ExternalImageType aImageType,
const wr::DeviceIntRect& aDirtyRect,
uint8_t aChannelIndex = 0);
void SetBlobImageVisibleArea(BlobImageKey aKey,
const wr::DeviceIntRect& aArea);

Просмотреть файл

@ -2177,7 +2177,6 @@ pub extern "C" fn wr_resource_updates_add_external_image(
external_image_id: ExternalImageId,
image_type: &ExternalImageType,
channel_index: u8,
normalized_uvs: bool,
) {
txn.add_image(
image_key,
@ -2186,7 +2185,6 @@ pub extern "C" fn wr_resource_updates_add_external_image(
id: external_image_id,
channel_index,
image_type: *image_type,
normalized_uvs,
}),
None,
);
@ -2224,7 +2222,6 @@ pub extern "C" fn wr_resource_updates_update_external_image(
external_image_id: ExternalImageId,
image_type: &ExternalImageType,
channel_index: u8,
normalized_uvs: bool,
) {
txn.update_image(
key,
@ -2233,7 +2230,6 @@ pub extern "C" fn wr_resource_updates_update_external_image(
id: external_image_id,
channel_index,
image_type: *image_type,
normalized_uvs,
}),
&DirtyRect::All,
);
@ -2247,7 +2243,6 @@ pub extern "C" fn wr_resource_updates_update_external_image_with_dirty_rect(
external_image_id: ExternalImageId,
image_type: &ExternalImageType,
channel_index: u8,
normalized_uvs: bool,
dirty_rect: DeviceIntRect,
) {
txn.update_image(
@ -2257,7 +2252,6 @@ pub extern "C" fn wr_resource_updates_update_external_image_with_dirty_rect(
id: external_image_id,
channel_index,
image_type: *image_type,
normalized_uvs,
}),
&DirtyRect::Partial(dirty_rect),
);

Просмотреть файл

@ -88,7 +88,6 @@ void text_shader_main(
#define BRUSH_FLAG_SEGMENT_NINEPATCH_MIDDLE 256
#define BRUSH_FLAG_TEXEL_RECT 512
#define BRUSH_FLAG_FORCE_AA 1024
#define BRUSH_FLAG_NORMALIZED_UVS 2048
#define INVALID_SEGMENT_INDEX 0xffff

Просмотреть файл

@ -170,11 +170,6 @@ void brush_vs(
float perspective_interpolate = (brush_flags & BRUSH_FLAG_PERSPECTIVE_INTERPOLATION) != 0 ? 1.0 : 0.0;
v_perspective.x = perspective_interpolate;
if ((brush_flags & BRUSH_FLAG_NORMALIZED_UVS) != 0) {
uv0 *= texture_size;
uv1 *= texture_size;
}
// Handle case where the UV coords are inverted (e.g. from an
// external image).
vec2 min_uv = min(uv0, uv1);

Просмотреть файл

@ -130,7 +130,9 @@ void main(void) {
uv = mix(aUvRect0.xy, aUvRect0.zw, uv);
// The uvs may be inverted, so use the min and max for the bounds
vec4 uvBounds = vec4(min(aUvRect0.xy, aUvRect0.zw), max(aUvRect0.xy, aUvRect0.zw));
if (int(aParams.y) == UV_TYPE_UNNORMALIZED) {
int rescale_uv = int(aParams.y);
if (rescale_uv == 1)
{
// using an atlas, so UVs are in pixels, and need to be
// normalized and clamped.
#if defined(WR_FEATURE_TEXTURE_RECT)

Просмотреть файл

@ -19,34 +19,28 @@ uniform vec2 uTextureSize;
PER_INSTANCE attribute vec4 aScaleTargetRect;
PER_INSTANCE attribute vec4 aScaleSourceRect;
PER_INSTANCE attribute float aSourceRectType;
void main(void) {
vec2 src_offset = aScaleSourceRect.xy;
vec2 src_size = aScaleSourceRect.zw - aScaleSourceRect.xy;
// The uvs may be inverted, so use the min and max for the bounds
vUvRect = vec4(min(aScaleSourceRect.xy, aScaleSourceRect.zw),
max(aScaleSourceRect.xy, aScaleSourceRect.zw));
vUv = (src_offset + src_size * aPosition.xy);
if (int(aSourceRectType) == UV_TYPE_UNNORMALIZED) {
vUvRect = vec4(vUvRect.xy + vec2(0.5), vUvRect.zw - vec2(0.5));
// If this is in WR_FEATURE_TEXTURE_RECT mode, the rect and size use
// non-normalized texture coordinates.
#ifdef WR_FEATURE_TEXTURE_RECT
// In WR_FEATURE_TEXTURE_RECT mode the UV coordinates used to sample
// from the texture should be unnormalized, so we leave them as is.
vec2 texture_size = vec2(1, 1);
vec2 texture_size = vec2(1, 1);
#elif defined(WR_FEATURE_TEXTURE_EXTERNAL_ESSL1)
vec2 texture_size = uTextureSize;
vec2 texture_size = uTextureSize;
#else
vec2 texture_size = vec2(TEX_SIZE(sColor0));
vec2 texture_size = vec2(TEX_SIZE(sColor0));
#endif
vUvRect /= texture_size.xyxy;
vUv /= texture_size;
}
// The uvs may be inverted, so use the min and max for the bounds
vUvRect = vec4(min(aScaleSourceRect.xy, aScaleSourceRect.zw) + vec2(0.5),
max(aScaleSourceRect.xy, aScaleSourceRect.zw) - vec2(0.5)) / texture_size.xyxy;
vec2 pos = mix(aScaleTargetRect.xy, aScaleTargetRect.zw, aPosition.xy);
vUv = (src_offset + src_size * aPosition.xy) / texture_size;
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
}

Просмотреть файл

@ -53,12 +53,6 @@ uniform bool u_mali_workaround_dummy;
#define TEX_SIZE(sampler) textureSize(sampler, 0)
#endif
// Keep these in sync with the corresponding constants in gpu_types.rs
// Specifies that the UV coordinates supplied to certain shaders are normalized.
#define UV_TYPE_NORMALIZED 0
// Specifies that the UV coordinates supplied to certain shaders are not normalized.
#define UV_TYPE_UNNORMALIZED 1
//======================================================================================
// Vertex shader attributes and uniforms
//======================================================================================

Просмотреть файл

@ -2576,11 +2576,6 @@ impl BatchBuilder {
batch_params.prim_user_data,
);
let brush_flags = match image_instance.normalized_uvs {
true => brush_flags | BrushFlags::NORMALIZED_UVS,
false => brush_flags,
};
self.add_segmented_prim_to_batch(
segments,
common_data.opacity,

Просмотреть файл

@ -123,21 +123,6 @@ pub struct BlurInstance {
pub struct ScalingInstance {
pub target_rect: DeviceRect,
pub source_rect: DeviceRect,
source_rect_type: f32,
}
impl ScalingInstance {
pub fn new(target_rect: DeviceRect, source_rect: DeviceRect, source_rect_normalized: bool) -> Self {
let source_rect_type = match source_rect_normalized {
true => UV_TYPE_NORMALIZED,
false => UV_TYPE_UNNORMALIZED,
};
Self {
target_rect,
source_rect,
source_rect_type: pack_as_float(source_rect_type),
}
}
}
#[derive(Clone, Debug)]
@ -254,10 +239,9 @@ pub struct PrimitiveInstanceData {
data: [i32; 4],
}
// Keep these in sync with the correspondong #defines in shared.glsl
/// Specifies that an RGB CompositeInstance or ScalingInstance's UV coordinates are normalized.
/// Specifies that an RGB CompositeInstance's UV coordinates are normalized.
const UV_TYPE_NORMALIZED: u32 = 0;
/// Specifies that an RGB CompositeInstance or ScalingInstance's UV coordinates are not normalized.
/// Specifies that an RGB CompositeInstance's UV coordinates are not normalized.
const UV_TYPE_UNNORMALIZED: u32 = 1;
/// A GPU-friendly representation of the `ScaleOffset` type
@ -334,19 +318,14 @@ impl CompositeInstance {
clip_rect: DeviceRect,
color: PremultipliedColorF,
uv_rect: TexelRect,
normalized_uvs: bool,
flip: (bool, bool),
) -> Self {
let uv_type = match normalized_uvs {
true => UV_TYPE_NORMALIZED,
false => UV_TYPE_UNNORMALIZED,
};
CompositeInstance {
rect,
clip_rect,
color,
_padding: 0.0,
color_space_or_uv_type: pack_as_float(uv_type),
color_space_or_uv_type: pack_as_float(UV_TYPE_UNNORMALIZED),
yuv_format: 0.0,
yuv_channel_bit_depth: 0.0,
uv_rects: [uv_rect, uv_rect, uv_rect],
@ -661,8 +640,6 @@ bitflags! {
/// Whether to force the anti-aliasing when the primitive
/// is axis-aligned.
const FORCE_AA = 1024;
/// Specifies UV coordinates are normalized
const NORMALIZED_UVS = 2048;
}
}

Просмотреть файл

@ -16,7 +16,7 @@ use crate::prim_store::DeferredResolve;
use crate::renderer::BLOCKS_PER_UV_RECT;
use crate::render_task_cache::RenderTaskCacheEntryHandle;
use crate::resource_cache::{ResourceCache, ImageRequest, CacheItem};
use crate::internal_types::{TextureSource, TextureSourceExternal, DeferredResolveIndex};
use crate::internal_types::{TextureSource, DeferredResolveIndex};
/// Resolve a resource cache's imagre request into a texture cache item.
pub fn resolve_image(
@ -50,11 +50,7 @@ pub fn resolve_image(
};
let cache_item = CacheItem {
texture_id: TextureSource::External(TextureSourceExternal {
index: deferred_resolve_index,
kind: image_buffer_kind,
normalized_uvs: external_image.normalized_uvs,
}),
texture_id: TextureSource::External(deferred_resolve_index, image_buffer_kind),
uv_rect_handle: cache_handle,
uv_rect: DeviceIntRect::from_size(
image_properties.descriptor.size,

Просмотреть файл

@ -1015,15 +1015,6 @@ impl CacheTextureId {
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct DeferredResolveIndex(pub u32);
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct TextureSourceExternal {
pub index: DeferredResolveIndex,
pub kind: ImageBufferKind,
pub normalized_uvs: bool,
}
/// Identifies the source of an input texture to a shader.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "capture", derive(Serialize))]
@ -1034,7 +1025,7 @@ pub enum TextureSource {
/// An entry in the texture cache.
TextureCache(CacheTextureId, Swizzle),
/// An external image texture, mananged by the embedding.
External(TextureSourceExternal),
External(DeferredResolveIndex, ImageBufferKind),
/// Select a dummy 1x1 white texture. This can be used by image
/// shaders that want to draw a solid color.
Dummy,
@ -1045,7 +1036,7 @@ impl TextureSource {
match *self {
TextureSource::TextureCache(..) => ImageBufferKind::Texture2D,
TextureSource::External(TextureSourceExternal { kind, .. }) => kind,
TextureSource::External(_, image_buffer_kind) => image_buffer_kind,
// Render tasks use texture arrays for now.
TextureSource::Dummy => ImageBufferKind::Texture2D,
@ -1054,13 +1045,6 @@ impl TextureSource {
}
}
pub fn uses_normalized_uvs(&self) -> bool {
match *self {
TextureSource::External(TextureSourceExternal { normalized_uvs, .. }) => normalized_uvs,
_ => false,
}
}
#[inline]
pub fn is_compatible(
&self,

Просмотреть файл

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use api::{
AlphaType, ColorDepth, ColorF, ColorU, ExternalImageType,
AlphaType, ColorDepth, ColorF, ColorU, ExternalImageData, ExternalImageType,
ImageKey as ApiImageKey, ImageBufferKind, ImageRendering, PremultipliedColorF,
RasterSpace, Shadow, YuvColorSpace, ColorRange, YuvFormat,
};
@ -71,7 +71,6 @@ pub struct ImageInstance {
pub tight_local_clip_rect: LayoutRect,
pub visible_tiles: Vec<VisibleImageTile>,
pub src_color: Option<RenderTaskId>,
pub normalized_uvs: bool,
}
#[cfg_attr(feature = "capture", derive(Serialize))]
@ -177,44 +176,45 @@ impl ImageData {
frame_state.gpu_cache,
);
let mut task_id = frame_state.rg_builder.add().init(
let orig_task_id = frame_state.rg_builder.add().init(
RenderTask::new_image(size, request)
);
if let Some(external_image) = external_image {
// On some devices we cannot render from an ImageBufferKind::TextureExternal
// source using most shaders, so must peform a copy to a regular texture first.
let requires_copy = frame_context.fb_config.external_images_require_copy &&
external_image.image_type ==
ExternalImageType::TextureHandle(ImageBufferKind::TextureExternal);
// On some devices we cannot render from an ImageBufferKind::TextureExternal
// source using most shaders, so must peform a copy to a regular texture first.
let task_id = if frame_context.fb_config.external_images_require_copy
&& matches!(
external_image,
Some(ExternalImageData {
image_type: ExternalImageType::TextureHandle(
ImageBufferKind::TextureExternal
),
..
})
)
{
let target_kind = if descriptor.format.bytes_per_pixel() == 1 {
RenderTargetKind::Alpha
} else {
RenderTargetKind::Color
};
if requires_copy {
let target_kind = if descriptor.format.bytes_per_pixel() == 1 {
RenderTargetKind::Alpha
} else {
RenderTargetKind::Color
};
let task_id = RenderTask::new_scaling(
orig_task_id,
frame_state.rg_builder,
target_kind,
size
);
task_id = RenderTask::new_scaling(
task_id,
frame_state.rg_builder,
target_kind,
size
);
frame_state.surface_builder.add_child_render_task(
task_id,
frame_state.rg_builder,
);
frame_state.surface_builder.add_child_render_task(
task_id,
frame_state.rg_builder,
);
}
// Ensure the instance is rendered using normalized_uvs if the external image
// requires so. If we inserted a scale above this is not required as the
// instance is rendered from a render task rather than the external image.
if !requires_copy {
image_instance.normalized_uvs = external_image.normalized_uvs;
}
}
task_id
} else {
orig_task_id
};
// Every frame, for cached items, we need to request the render
// task cache item. The closure will be invoked on the first
@ -449,7 +449,6 @@ impl InternablePrimitive for Image {
tight_local_clip_rect: LayoutRect::zero(),
visible_tiles: Vec::new(),
src_color: None,
normalized_uvs: false,
});
PrimitiveInstanceKind::Image {

Просмотреть файл

@ -874,11 +874,10 @@ fn add_scaling_instances(
instances
.entry(source)
.or_insert(Vec::new())
.push(ScalingInstance::new(
.push(ScalingInstance {
target_rect,
source_rect,
source.uses_normalized_uvs(),
));
});
}
fn add_svg_filter_instances(

Просмотреть файл

@ -71,7 +71,7 @@ use crate::gpu_cache::{GpuCacheUpdate, GpuCacheUpdateList};
use crate::gpu_cache::{GpuCacheDebugChunk, GpuCacheDebugCmd};
use crate::gpu_types::{ScalingInstance, SvgFilterInstance, SVGFEFilterInstance, CopyInstance, PrimitiveInstanceData};
use crate::gpu_types::{BlurInstance, ClearInstance, CompositeInstance};
use crate::internal_types::{TextureSource, TextureSourceExternal, TextureCacheCategory, FrameId};
use crate::internal_types::{TextureSource, TextureCacheCategory, FrameId};
#[cfg(any(feature = "capture", feature = "replay"))]
use crate::internal_types::DebugOutput;
use crate::internal_types::{CacheTextureId, FastHashMap, FastHashSet, RenderedDocument, ResultMsg};
@ -533,7 +533,7 @@ impl TextureResolver {
device.bind_texture(sampler, &self.dummy_cache_texture, swizzle);
swizzle
}
TextureSource::External(TextureSourceExternal { ref index, .. }) => {
TextureSource::External(ref index, _) => {
let texture = self.external_images
.get(index)
.expect("BUG: External image should be resolved by now");
@ -574,7 +574,7 @@ impl TextureResolver {
default_value: TexelRect,
) -> TexelRect {
match source {
TextureSource::External(TextureSourceExternal { ref index, .. }) => {
TextureSource::External(ref index, _) => {
let texture = self.external_images
.get(index)
.expect("BUG: External image should be resolved by now");
@ -593,11 +593,7 @@ impl TextureResolver {
TextureSource::TextureCache(id, _) => {
self.texture_cache_map[&id].texture.get_dimensions()
},
TextureSource::External(TextureSourceExternal { index, .. }) => {
// If UV coords are normalized then this value will be incorrect. However, the
// texture size is currently only used to set the uTextureSize uniform, so that
// shaders without access to textureSize() can normalize unnormalized UVs. Which
// means this is not a problem.
TextureSource::External(index, _) => {
let uv_rect = self.external_images[&index].get_uv_rect();
(uv_rect.uv1 - uv_rect.uv0).abs().to_size().to_i32()
},
@ -627,8 +623,6 @@ impl TextureResolver {
let mut external_image_bytes = 0;
for img in self.external_images.values() {
let uv_rect = img.get_uv_rect();
// If UV coords are normalized then this value will be incorrect. This is unfortunate
// but doesn't impact end users at all.
let size = (uv_rect.uv1 - uv_rect.uv0).abs().to_size().to_i32();
// Assume 4 bytes per pixels which is true most of the time but
@ -2481,13 +2475,14 @@ impl Renderer {
let instances = match source {
TextureSource::External(..) => {
uv_override_instances = instances.iter().map(|instance| {
let mut new_instance = instance.clone();
let texel_rect: TexelRect = self.texture_resolver.get_uv_rect(
&source,
instance.source_rect.cast().into()
).into();
new_instance.source_rect = DeviceRect::new(texel_rect.uv0, texel_rect.uv1);
new_instance
ScalingInstance {
target_rect: instance.target_rect,
source_rect: DeviceRect::new(texel_rect.uv0, texel_rect.uv1),
}
}).collect::<Vec<_>>();
&uv_override_instances
}
@ -3088,7 +3083,6 @@ impl Renderer {
surface_rect.to_f32(),
PremultipliedColorF::WHITE,
uv_rect,
plane.texture.uses_normalized_uvs(),
(false, false),
);
@ -3237,7 +3231,6 @@ impl Renderer {
clip_rect,
PremultipliedColorF::WHITE,
uv_rect,
plane.texture.uses_normalized_uvs(),
flip,
);
let features = instance.get_rgb_features();
@ -5736,7 +5729,7 @@ impl Renderer {
.expect("Unable to lock the external image handler!");
for def in &deferred_images {
info!("\t{}", def.short_path);
let ExternalImageData { id, channel_index, image_type, .. } = def.external;
let ExternalImageData { id, channel_index, image_type } = def.external;
// The image rendering parameter is irrelevant because no filtering happens during capturing.
let ext_image = handler.lock(id, channel_index);
let (data, short_path) = match ext_image.source {

Просмотреть файл

@ -346,11 +346,6 @@ pub mod desc {
count: 4,
kind: VertexAttributeKind::F32,
},
VertexAttribute {
name: "aSourceRectType",
count: 1,
kind: VertexAttributeKind::F32,
},
],
};

Просмотреть файл

@ -74,9 +74,8 @@ pub enum ExternalImageSource<'a> {
/// The data that an external client should provide about
/// an external image. For instance, if providing video frames,
/// the application could call wr.render() whenever a new
/// video frame is ready. Note that the UV coords are either normalized or
/// unnormalized depending on the value of normalized_uvs in the corresponding
/// ExternalImageData.
/// video frame is ready. Note that the UV coords are supplied
/// in texel-space!
pub struct ExternalImage<'a> {
/// UV coordinates for the image.
pub uv: TexelRect,
@ -145,8 +144,6 @@ pub struct ExternalImageData {
pub channel_index: u8,
/// Storage format identifier.
pub image_type: ExternalImageType,
/// Whether UV coordinates used with this image are normalized.
pub normalized_uvs: bool,
}
/// Specifies the format of a series of pixels, in driver terms.