mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-29 02:27:30 +09:00
Bug 1388020. r=nical, a=RyanVM
This commit is contained in:
parent
55bde34653
commit
e3e79721f6
6 changed files with 41 additions and 6 deletions
|
|
@ -149,6 +149,9 @@ BasicTextureImage::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion
|
||||||
&uploadSize,
|
&uploadSize,
|
||||||
needInit,
|
needInit,
|
||||||
aFrom);
|
aFrom);
|
||||||
|
if (mTextureFormat == SurfaceFormat::UNKNOWN) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (uploadSize > 0) {
|
if (uploadSize > 0) {
|
||||||
UpdateUploadSize(uploadSize);
|
UpdateUploadSize(uploadSize);
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,23 @@ DataOffset(const IntPoint& aPoint, int32_t aStride, SurfaceFormat aFormat)
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
CheckUploadBounds(const IntSize& aDst, const IntSize& aSrc, const IntPoint& aOffset)
|
||||||
|
{
|
||||||
|
if (aOffset.x < 0 || aOffset.y < 0 ||
|
||||||
|
aOffset.x >= aSrc.width ||
|
||||||
|
aOffset.y >= aSrc.height) {
|
||||||
|
MOZ_ASSERT_UNREACHABLE("Offset outside source bounds");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (aDst.width > (aSrc.width - aOffset.x) ||
|
||||||
|
aDst.height > (aSrc.height - aOffset.y)) {
|
||||||
|
MOZ_ASSERT_UNREACHABLE("Source has insufficient data");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static GLint GetAddressAlignment(ptrdiff_t aAddress)
|
static GLint GetAddressAlignment(ptrdiff_t aAddress)
|
||||||
{
|
{
|
||||||
if (!(aAddress & 0x7)) {
|
if (!(aAddress & 0x7)) {
|
||||||
|
|
@ -375,6 +392,7 @@ TexImage2DHelper(GLContext* gl,
|
||||||
SurfaceFormat
|
SurfaceFormat
|
||||||
UploadImageDataToTexture(GLContext* gl,
|
UploadImageDataToTexture(GLContext* gl,
|
||||||
unsigned char* aData,
|
unsigned char* aData,
|
||||||
|
const gfx::IntSize& aDataSize,
|
||||||
int32_t aStride,
|
int32_t aStride,
|
||||||
SurfaceFormat aFormat,
|
SurfaceFormat aFormat,
|
||||||
const nsIntRegion& aDstRegion,
|
const nsIntRegion& aDstRegion,
|
||||||
|
|
@ -498,6 +516,10 @@ UploadImageDataToTexture(GLContext* gl,
|
||||||
// Upload each rect in the region to the texture
|
// Upload each rect in the region to the texture
|
||||||
for (auto iter = aDstRegion.RectIter(); !iter.Done(); iter.Next()) {
|
for (auto iter = aDstRegion.RectIter(); !iter.Done(); iter.Next()) {
|
||||||
const IntRect& rect = iter.Get();
|
const IntRect& rect = iter.Get();
|
||||||
|
if (!CheckUploadBounds(rect.Size(), aDataSize, rect.TopLeft())) {
|
||||||
|
return SurfaceFormat::UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
const unsigned char* rectData =
|
const unsigned char* rectData =
|
||||||
aData + DataOffset(rect.TopLeft(), aStride, aFormat);
|
aData + DataOffset(rect.TopLeft(), aStride, aFormat);
|
||||||
|
|
||||||
|
|
@ -534,10 +556,17 @@ UploadSurfaceToTexture(GLContext* gl,
|
||||||
|
|
||||||
int32_t stride = aSurface->Stride();
|
int32_t stride = aSurface->Stride();
|
||||||
SurfaceFormat format = aSurface->GetFormat();
|
SurfaceFormat format = aSurface->GetFormat();
|
||||||
|
gfx::IntSize size = aSurface->GetSize();
|
||||||
|
if (!CheckUploadBounds(aSize, size, aSrcPoint)) {
|
||||||
|
return SurfaceFormat::UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char* data = aSurface->GetData() +
|
unsigned char* data = aSurface->GetData() +
|
||||||
DataOffset(aSrcPoint, stride, format);
|
DataOffset(aSrcPoint, stride, format);
|
||||||
|
size.width -= aSrcPoint.x;
|
||||||
|
size.height -= aSrcPoint.y;
|
||||||
|
|
||||||
return UploadImageDataToTexture(gl, data, stride, format,
|
return UploadImageDataToTexture(gl, data, size, stride, format,
|
||||||
aDstRegion, aTexture, aSize,
|
aDstRegion, aTexture, aSize,
|
||||||
aOutUploadSize, aNeedInit,
|
aOutUploadSize, aNeedInit,
|
||||||
aTextureUnit, aTextureTarget);
|
aTextureUnit, aTextureTarget);
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ class GLContext;
|
||||||
* \param gl The GL Context to use.
|
* \param gl The GL Context to use.
|
||||||
* \param aData Start of image data of surface to upload.
|
* \param aData Start of image data of surface to upload.
|
||||||
* Corresponds to the first pixel of the texture.
|
* Corresponds to the first pixel of the texture.
|
||||||
|
* \param aDataSize The image data's size.
|
||||||
* \param aStride The image data's stride.
|
* \param aStride The image data's stride.
|
||||||
* \param aFormat The image data's format.
|
* \param aFormat The image data's format.
|
||||||
* \param aDstRegion Region of the texture to upload.
|
* \param aDstRegion Region of the texture to upload.
|
||||||
|
|
@ -46,6 +47,7 @@ class GLContext;
|
||||||
gfx::SurfaceFormat
|
gfx::SurfaceFormat
|
||||||
UploadImageDataToTexture(GLContext* gl,
|
UploadImageDataToTexture(GLContext* gl,
|
||||||
unsigned char* aData,
|
unsigned char* aData,
|
||||||
|
const gfx::IntSize& aDataSize,
|
||||||
int32_t aStride,
|
int32_t aStride,
|
||||||
gfx::SurfaceFormat aFormat,
|
gfx::SurfaceFormat aFormat,
|
||||||
const nsIntRegion& aDstRegion,
|
const nsIntRegion& aDstRegion,
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,10 @@ TextureImageEGL::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion&
|
||||||
&uploadSize,
|
&uploadSize,
|
||||||
needInit,
|
needInit,
|
||||||
aFrom);
|
aFrom);
|
||||||
|
if (mTextureFormat == SurfaceFormat::UNKNOWN) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (uploadSize > 0) {
|
if (uploadSize > 0) {
|
||||||
UpdateUploadSize(uploadSize);
|
UpdateUploadSize(uploadSize);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -888,8 +888,7 @@ BufferTextureHost::Upload(nsIntRegion *aRegion)
|
||||||
mFirstSource = mCompositor->CreateDataTextureSource(mFlags|TextureFlags::RGB_FROM_YCBCR);
|
mFirstSource = mCompositor->CreateDataTextureSource(mFlags|TextureFlags::RGB_FROM_YCBCR);
|
||||||
mFirstSource->SetOwner(this);
|
mFirstSource->SetOwner(this);
|
||||||
}
|
}
|
||||||
mFirstSource->Update(surf, aRegion);
|
return mFirstSource->Update(surf, aRegion);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<DataTextureSource> srcY;
|
RefPtr<DataTextureSource> srcY;
|
||||||
|
|
|
||||||
|
|
@ -161,9 +161,7 @@ TextureImageTextureSourceOGL::Update(gfx::DataSourceSurface* aSurface,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mTexImage->UpdateFromDataSource(aSurface, aDestRegion, aSrcOffset);
|
return mTexImage->UpdateFromDataSource(aSurface, aDestRegion, aSrcOffset);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue