mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Fix canvas and GL uses of DataSourceSurface::GetData. (bug 1405390 part 2, r=jgilbert)
--HG-- extra : rebase_source : eb4dcdfe9374e317a3a1e426bf35999ea50b074d
This commit is contained in:
parent
32e1584385
commit
3f697bb27d
@ -6015,6 +6015,7 @@ CanvasRenderingContext2D::PutImageData_explicit(int32_t aX, int32_t aY, uint32_t
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DataSourceSurface::MappedSurface map;
|
||||||
RefPtr<DataSourceSurface> sourceSurface;
|
RefPtr<DataSourceSurface> sourceSurface;
|
||||||
uint8_t* lockedBits = nullptr;
|
uint8_t* lockedBits = nullptr;
|
||||||
uint8_t* dstData;
|
uint8_t* dstData;
|
||||||
@ -6036,11 +6037,15 @@ CanvasRenderingContext2D::PutImageData_explicit(int32_t aX, int32_t aY, uint32_t
|
|||||||
if (!sourceSurface) {
|
if (!sourceSurface) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
dstData = sourceSurface->GetData();
|
if (!sourceSurface->Map(DataSourceSurface::READ_WRITE, &map)) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
dstData = map.mData;
|
||||||
if (!dstData) {
|
if (!dstData) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
dstStride = sourceSurface->Stride();
|
dstStride = map.mStride;
|
||||||
dstFormat = sourceSurface->GetFormat();
|
dstFormat = sourceSurface->GetFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6055,6 +6060,7 @@ CanvasRenderingContext2D::PutImageData_explicit(int32_t aX, int32_t aY, uint32_t
|
|||||||
if (lockedBits) {
|
if (lockedBits) {
|
||||||
mTarget->ReleaseBits(lockedBits);
|
mTarget->ReleaseBits(lockedBits);
|
||||||
} else if (sourceSurface) {
|
} else if (sourceSurface) {
|
||||||
|
sourceSurface->Unmap();
|
||||||
mTarget->CopySurface(sourceSurface, dirtyRect - dirtyRect.TopLeft(), dirtyRect.TopLeft());
|
mTarget->CopySurface(sourceSurface, dirtyRect - dirtyRect.TopLeft(), dirtyRect.TopLeft());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,8 +390,10 @@ ReadPixelsIntoDataSurface(GLContext* gl, DataSourceSurface* dest)
|
|||||||
|
|
||||||
readSurf = tempSurf;
|
readSurf = tempSurf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DataSourceSurface::ScopedMap map(readSurf, DataSourceSurface::READ_WRITE);
|
||||||
MOZ_ASSERT(readAlignment);
|
MOZ_ASSERT(readAlignment);
|
||||||
MOZ_ASSERT(reinterpret_cast<uintptr_t>(readSurf->GetData()) % readAlignment == 0);
|
MOZ_ASSERT(reinterpret_cast<uintptr_t>(map.GetData()) % readAlignment == 0);
|
||||||
|
|
||||||
GLsizei width = dest->GetSize().width;
|
GLsizei width = dest->GetSize().width;
|
||||||
GLsizei height = dest->GetSize().height;
|
GLsizei height = dest->GetSize().height;
|
||||||
@ -403,7 +405,7 @@ ReadPixelsIntoDataSurface(GLContext* gl, DataSourceSurface* dest)
|
|||||||
gl->fReadPixels(0, 0,
|
gl->fReadPixels(0, 0,
|
||||||
width, height,
|
width, height,
|
||||||
readFormat, readType,
|
readFormat, readType,
|
||||||
readSurf->GetData());
|
map.GetData());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (readSurf != dest) {
|
if (readSurf != dest) {
|
||||||
@ -475,7 +477,8 @@ ReadBackSurface(GLContext* gl, GLuint aTexture, bool aYInvert, SurfaceFormat aFo
|
|||||||
gl->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, 4);
|
gl->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl->fGetTexImage(LOCAL_GL_TEXTURE_2D, 0, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE, surf->GetData());
|
DataSourceSurface::ScopedMap map(surf, DataSourceSurface::READ);
|
||||||
|
gl->fGetTexImage(LOCAL_GL_TEXTURE_2D, 0, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE, map.GetData());
|
||||||
|
|
||||||
if (currentPackAlignment != 4) {
|
if (currentPackAlignment != 4) {
|
||||||
gl->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, currentPackAlignment);
|
gl->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, currentPackAlignment);
|
||||||
|
@ -539,10 +539,10 @@ UploadSurfaceToTexture(GLContext* gl,
|
|||||||
GLenum aTextureUnit,
|
GLenum aTextureUnit,
|
||||||
GLenum aTextureTarget)
|
GLenum aTextureTarget)
|
||||||
{
|
{
|
||||||
|
DataSourceSurface::ScopedMap map(aSurface, DataSourceSurface::READ);
|
||||||
int32_t stride = aSurface->Stride();
|
int32_t stride = map.GetStride();
|
||||||
SurfaceFormat format = aSurface->GetFormat();
|
SurfaceFormat format = aSurface->GetFormat();
|
||||||
unsigned char* data = aSurface->GetData() +
|
unsigned char* data = map.GetData() +
|
||||||
DataOffset(aSrcPoint, stride, format);
|
DataOffset(aSrcPoint, stride, format);
|
||||||
|
|
||||||
return UploadImageDataToTexture(gl, data, stride, format,
|
return UploadImageDataToTexture(gl, data, stride, format,
|
||||||
|
Loading…
Reference in New Issue
Block a user