Bug 1293845 - Repair texture bindings->internals glue. - r=mtseng

MozReview-Commit-ID: CUDQGwhPTuU
This commit is contained in:
Jeff Gilbert 2016-08-09 17:16:09 -07:00
Родитель 959a28cd66
Коммит 34aa7ab5f7
8 изменённых файлов: 134 добавлений и 145 удалений

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

@ -52,15 +52,12 @@ private:
public: public:
void GetBufferSubData(GLenum target, GLintptr offset, void GetBufferSubData(GLenum target, GLintptr offset,
const dom::Nullable<dom::ArrayBuffer>& maybeData); const dom::ArrayBufferView& dstData);
void GetBufferSubData(GLenum target, GLintptr offset,
const dom::SharedArrayBuffer& data);
void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, WebGLsizeiptr offset, ErrorResult& out_error); GLenum type, WebGLsizeiptr offset, ErrorResult& out_error);
void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum format, GLenum type, GLenum type, const dom::ArrayBufferView& pixels,
const dom::Nullable<dom::ArrayBufferView>& pixels,
ErrorResult& out_error) ErrorResult& out_error)
{ {
WebGLContext::ReadPixels(x, y, width, height, format, type, pixels, out_error); WebGLContext::ReadPixels(x, y, width, height, format, type, pixels, out_error);
@ -102,39 +99,28 @@ public:
GLsizei height); GLsizei height);
void TexStorage3D(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, void TexStorage3D(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width,
GLsizei height, GLsizei depth); GLsizei height, GLsizei depth);
void TexImage3D(GLenum target, GLint level, GLenum internalFormat, GLsizei width, void TexImage3D(GLenum target, GLint level, GLenum internalFormat, GLsizei width,
GLsizei height, GLsizei depth, GLint border, GLenum unpackFormat, GLsizei height, GLsizei depth, GLint border, GLenum unpackFormat,
GLenum unpackType, GLenum unpackType, const dom::Nullable<dom::ArrayBufferView>& data);
const dom::Nullable<dom::ArrayBufferView>& pixels);
void TexSubImage3D(GLenum target, GLint level, GLint xOffset, GLint yOffset, void TexSubImage3D(GLenum target, GLint level, GLint xOffset, GLint yOffset,
GLint zOffset, GLsizei width, GLsizei height, GLsizei depth, GLint zOffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum unpackFormat, GLenum unpackType, GLenum unpackFormat, GLenum unpackType,
const dom::Nullable<dom::ArrayBufferView>& pixels, const dom::ArrayBufferView& data, ErrorResult&);
ErrorResult& out_rv);
void TexSubImage3D(GLenum target, GLint level, GLint xOffset, GLint yOffset, void TexSubImage3D(GLenum target, GLint level, GLint xOffset, GLint yOffset,
GLint zOffset, GLenum unpackFormat, GLenum unpackType, GLint zOffset, GLenum unpackFormat, GLenum unpackType,
dom::ImageData* data, ErrorResult& out_rv); const dom::ImageData& data, ErrorResult&);
protected:
void TexSubImage3D(GLenum target, GLint level, GLint xOffset, GLint yOffset, void TexSubImage3D(GLenum target, GLint level, GLint xOffset, GLint yOffset,
GLint zOffset, GLenum unpackFormat, GLenum unpackType, GLint zOffset, GLenum unpackFormat, GLenum unpackType,
dom::Element* elem, ErrorResult* const out_rv); const dom::Element& elem, ErrorResult& out_error);
public:
template<class T>
inline void
TexSubImage3D(GLenum target, GLint level, GLint xOffset, GLint yOffset, GLint zOffset,
GLenum unpackFormat, GLenum unpackType, T& any, ErrorResult& out_rv)
{
TexSubImage3D(target, level, xOffset, yOffset, zOffset, unpackFormat, unpackType,
&any, &out_rv);
}
void CopyTexSubImage3D(GLenum target, GLint level, GLint xOffset, GLint yOffset, void CopyTexSubImage3D(GLenum target, GLint level, GLint xOffset, GLint yOffset,
GLint zOffset, GLint x, GLint y, GLsizei width, GLint zOffset, GLint x, GLint y, GLsizei width,
GLsizei height); GLsizei height);
void CompressedTexImage3D(GLenum target, GLint level, GLenum internalFormat, void CompressedTexImage3D(GLenum target, GLint level, GLenum internalFormat,
GLsizei width, GLsizei height, GLsizei depth, GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLint border, const dom::ArrayBufferView& data);
const dom::ArrayBufferView& data);
void CompressedTexSubImage3D(GLenum target, GLint level, GLint xOffset, GLint yOffset, void CompressedTexSubImage3D(GLenum target, GLint level, GLint xOffset, GLint yOffset,
GLint zOffset, GLsizei width, GLsizei height, GLint zOffset, GLsizei width, GLsizei height,
GLsizei depth, GLenum sizedUnpackFormat, GLsizei depth, GLenum sizedUnpackFormat,
@ -175,7 +161,7 @@ public:
template<typename T> template<typename T>
void void
TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat, TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat,
GLenum unpackFormat, GLenum unpackType, T& any, ErrorResult& out_rv) GLenum unpackFormat, GLenum unpackType, const T& any, ErrorResult& out_rv)
{ {
WebGLContext::TexImage2D(texImageTarget, level, internalFormat, unpackFormat, WebGLContext::TexImage2D(texImageTarget, level, internalFormat, unpackFormat,
unpackType, any, out_rv); unpackType, any, out_rv);
@ -184,16 +170,17 @@ public:
void void
TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset, TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset,
GLsizei width, GLsizei height, GLenum unpackFormat, GLenum unpackType, GLsizei width, GLsizei height, GLenum unpackFormat, GLenum unpackType,
const dom::Nullable<dom::ArrayBufferView>& pixels, ErrorResult& out_rv) const dom::ArrayBufferView& view, ErrorResult&)
{ {
WebGLContext::TexSubImage2D(texImageTarget, level, xOffset, yOffset, width, WebGLContext::TexSubImage2D(texImageTarget, level, xOffset, yOffset, width,
height, unpackFormat, unpackType, pixels, out_rv); height, unpackFormat, unpackType, view);
} }
template<typename T> template<typename T>
inline void inline void
TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset, TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset,
GLenum unpackFormat, GLenum unpackType, T& any, ErrorResult& out_rv) GLenum unpackFormat, GLenum unpackType, const T& any,
ErrorResult& out_rv)
{ {
WebGLContext::TexSubImage2D(texImageTarget, level, xOffset, yOffset, unpackFormat, WebGLContext::TexSubImage2D(texImageTarget, level, xOffset, yOffset, unpackFormat,
unpackType, any, out_rv); unpackType, any, out_rv);

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

@ -140,12 +140,9 @@ WebGL2Context::CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
} }
} }
// BufferT may be one of
// const dom::ArrayBuffer&
// const dom::SharedArrayBuffer&
template<typename BufferT>
void void
WebGL2Context::GetBufferSubDataT(GLenum target, GLintptr offset, const BufferT& data) WebGL2Context::GetBufferSubData(GLenum target, GLintptr offset,
const dom::ArrayBufferView& data)
{ {
const char funcName[] = "getBufferSubData"; const char funcName[] = "getBufferSubData";
if (IsContextLost()) if (IsContextLost())
@ -235,26 +232,4 @@ WebGL2Context::GetBufferSubDataT(GLenum target, GLintptr offset, const BufferT&
} }
} }
void
WebGL2Context::GetBufferSubData(GLenum target, GLintptr offset,
const dom::Nullable<dom::ArrayBuffer>& maybeData)
{
// If returnedData is null then an INVALID_VALUE error is
// generated.
if (maybeData.IsNull()) {
ErrorInvalidValue("getBufferSubData: returnedData is null");
return;
}
const dom::ArrayBuffer& data = maybeData.Value();
GetBufferSubDataT(target, offset, data);
}
void
WebGL2Context::GetBufferSubData(GLenum target, GLintptr offset,
const dom::SharedArrayBuffer& data)
{
GetBufferSubDataT(target, offset, data);
}
} // namespace mozilla } // namespace mozilla

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

@ -58,21 +58,25 @@ WebGL2Context::TexImage3D(GLenum rawTexImageTarget, GLint level, GLenum internal
return; return;
} }
const dom::ArrayBufferView* view = nullptr;
if (!maybeView.IsNull()) {
view = &maybeView.Value();
}
const bool isSubImage = false; const bool isSubImage = false;
const GLint xOffset = 0; const GLint xOffset = 0;
const GLint yOffset = 0; const GLint yOffset = 0;
const GLint zOffset = 0; const GLint zOffset = 0;
tex->TexOrSubImage(isSubImage, funcName, target, level, internalFormat, xOffset, tex->TexOrSubImage(isSubImage, funcName, target, level, internalFormat, xOffset,
yOffset, zOffset, width, height, depth, border, unpackFormat, yOffset, zOffset, width, height, depth, border, unpackFormat,
unpackType, maybeView); unpackType, view);
} }
void void
WebGL2Context::TexSubImage3D(GLenum rawTexImageTarget, GLint level, GLint xOffset, WebGL2Context::TexSubImage3D(GLenum rawTexImageTarget, GLint level, GLint xOffset,
GLint yOffset, GLint zOffset, GLsizei width, GLsizei height, GLint yOffset, GLint zOffset, GLsizei width, GLsizei height,
GLsizei depth, GLenum unpackFormat, GLenum unpackType, GLsizei depth, GLenum unpackFormat, GLenum unpackType,
const dom::Nullable<dom::ArrayBufferView>& maybeView, const dom::ArrayBufferView& view, ErrorResult&)
ErrorResult& /*out_rv*/)
{ {
const char funcName[] = "texSubImage3D"; const char funcName[] = "texSubImage3D";
const uint8_t funcDims = 3; const uint8_t funcDims = 3;
@ -90,14 +94,14 @@ WebGL2Context::TexSubImage3D(GLenum rawTexImageTarget, GLint level, GLint xOffse
const GLint border = 0; const GLint border = 0;
tex->TexOrSubImage(isSubImage, funcName, target, level, internalFormat, xOffset, tex->TexOrSubImage(isSubImage, funcName, target, level, internalFormat, xOffset,
yOffset, zOffset, width, height, depth, border, unpackFormat, yOffset, zOffset, width, height, depth, border, unpackFormat,
unpackType, maybeView); unpackType, &view);
} }
void void
WebGL2Context::TexSubImage3D(GLenum rawTexImageTarget, GLint level, GLint xOffset, WebGL2Context::TexSubImage3D(GLenum rawTexImageTarget, GLint level, GLint xOffset,
GLint yOffset, GLint zOffset, GLenum unpackFormat, GLint yOffset, GLint zOffset, GLenum unpackFormat,
GLenum unpackType, dom::ImageData* imageData, GLenum unpackType, const dom::ImageData& imageData,
ErrorResult& /*out_rv*/) ErrorResult&)
{ {
const char funcName[] = "texSubImage3D"; const char funcName[] = "texSubImage3D";
const uint8_t funcDims = 3; const uint8_t funcDims = 3;
@ -119,8 +123,8 @@ WebGL2Context::TexSubImage3D(GLenum rawTexImageTarget, GLint level, GLint xOffse
void void
WebGL2Context::TexSubImage3D(GLenum rawTexImageTarget, GLint level, GLint xOffset, WebGL2Context::TexSubImage3D(GLenum rawTexImageTarget, GLint level, GLint xOffset,
GLint yOffset, GLint zOffset, GLenum unpackFormat, GLint yOffset, GLint zOffset, GLenum unpackFormat,
GLenum unpackType, dom::Element* elem, GLenum unpackType, const dom::Element& elem,
ErrorResult* const out_rv) ErrorResult& out_rv)
{ {
const char funcName[] = "texSubImage3D"; const char funcName[] = "texSubImage3D";
const uint8_t funcDims = 3; const uint8_t funcDims = 3;
@ -136,7 +140,7 @@ WebGL2Context::TexSubImage3D(GLenum rawTexImageTarget, GLint level, GLint xOffse
const bool isSubImage = true; const bool isSubImage = true;
const GLenum internalFormat = 0; const GLenum internalFormat = 0;
tex->TexOrSubImage(isSubImage, funcName, target, level, internalFormat, xOffset, tex->TexOrSubImage(isSubImage, funcName, target, level, internalFormat, xOffset,
yOffset, zOffset, unpackFormat, unpackType, elem, out_rv); yOffset, zOffset, unpackFormat, unpackType, elem, &out_rv);
} }
void void

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

@ -552,10 +552,20 @@ protected:
GLenum destType, void* dest, uint32_t dataLen, GLenum destType, void* dest, uint32_t dataLen,
uint32_t rowStride); uint32_t rowStride);
public: public:
void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum format, GLenum type, GLenum type, const dom::Nullable<dom::ArrayBufferView>& maybeView,
const dom::Nullable<dom::ArrayBufferView>& pixels, ErrorResult& rv)
ErrorResult& rv); {
const char funcName[] = "readPixels";
if (maybeView.IsNull()) {
ErrorInvalidValue("%s: `pixels` must not be null.", funcName);
return;
}
ReadPixels(x, y, width, height, format, type, maybeView.Value(), rv);
}
void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, const dom::ArrayBufferView& pixels, ErrorResult& rv);
void RenderbufferStorage(GLenum target, GLenum internalFormat, void RenderbufferStorage(GLenum target, GLenum internalFormat,
GLsizei width, GLsizei height); GLsizei width, GLsizei height);
protected: protected:
@ -852,48 +862,77 @@ public:
GLint yOffset, GLint x, GLint y, GLsizei width, GLint yOffset, GLint x, GLint y, GLsizei width,
GLsizei height); GLsizei height);
////
void TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat, void TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat,
GLsizei width, GLsizei height, GLint border, GLenum unpackFormat, GLsizei width, GLsizei height, GLint border, GLenum unpackFormat,
GLenum unpackType, GLenum unpackType,
const dom::Nullable<dom::ArrayBufferView>& maybeView, const dom::Nullable<dom::ArrayBufferView>& maybeView,
ErrorResult&); ErrorResult&);
protected:
void TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat, void TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat,
GLenum unpackFormat, GLenum unpackType, dom::ImageData* imageData, GLenum unpackFormat, GLenum unpackType,
ErrorResult&); const dom::ImageData& imageData, ErrorResult& out_error);
public:
void TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat, void TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat,
GLenum unpackFormat, GLenum unpackType, dom::Element* elem, GLenum unpackFormat, GLenum unpackType, const dom::Element& elem,
ErrorResult* const out_error); ErrorResult& out_error);
////
protected:
void TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset,
GLsizei width, GLsizei height, GLenum unpackFormat,
GLenum unpackType, const dom::ArrayBufferView& view);
void TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset,
GLenum unpackFormat, GLenum unpackType,
const dom::ImageData& imageData, ErrorResult& out_error);
public:
void TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset,
GLenum unpackFormat, GLenum unpackType, const dom::Element& elem,
ErrorResult& out_error);
////////////////
// Pseudo-nullable WebGL1 entrypoints
void TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat,
GLenum unpackFormat, GLenum unpackType,
const dom::ImageData* imageData, ErrorResult& out_error)
{
const char funcName[] = "texImage2D";
if (!imageData) {
ErrorInvalidValue("%s: `data` must not be null.", funcName);
return;
}
TexImage2D(texImageTarget, level, internalFormat, unpackFormat, unpackType,
*imageData, out_error);
}
void TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset, void TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset,
GLsizei width, GLsizei height, GLenum unpackFormat, GLsizei width, GLsizei height, GLenum unpackFormat,
GLenum unpackType, GLenum unpackType,
const dom::Nullable<dom::ArrayBufferView>& maybeView, const dom::Nullable<dom::ArrayBufferView>& maybeView, ErrorResult&)
ErrorResult&);
void TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset,
GLenum unpackFormat, GLenum unpackType, dom::ImageData* imageData,
ErrorResult&);
void TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset,
GLenum unpackFormat, GLenum unpackType, dom::Element* elem,
ErrorResult* const out_error);
// Allow whatever element unpackTypes the bindings are willing to pass
// us in Tex(Sub)Image2D
template<typename T>
inline void
TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat,
GLenum unpackFormat, GLenum unpackType, T& elem, ErrorResult& out_error)
{ {
TexImage2D(texImageTarget, level, internalFormat, unpackFormat, unpackType, &elem, const char funcName[] = "texSubImage2D";
&out_error); if (maybeView.IsNull()) {
ErrorInvalidValue("%s: `data` must not be null.", funcName);
return;
}
TexSubImage2D(texImageTarget, level, xOffset, yOffset, width, height,
unpackFormat, unpackType, maybeView.Value());
} }
template<typename T> void TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset,
inline void GLenum unpackFormat, GLenum unpackType,
TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset, const dom::ImageData* imageData, ErrorResult& out_error)
GLenum unpackFormat, GLenum unpackType, T& elem, ErrorResult& out_error)
{ {
const char funcName[] = "texSubImage2D";
if (!imageData) {
ErrorInvalidValue("%s: `data` must not be null.", funcName);
return;
}
TexSubImage2D(texImageTarget, level, xOffset, yOffset, unpackFormat, unpackType, TexSubImage2D(texImageTarget, level, xOffset, yOffset, unpackFormat, unpackType,
&elem, &out_error); *imageData, out_error);
} }
////// //////

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

@ -1503,8 +1503,7 @@ WebGLContext::ValidatePackSize(const char* funcName, uint32_t width, uint32_t he
void void
WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLenum type, const dom::ArrayBufferView& view,
const dom::Nullable<dom::ArrayBufferView>& pixels,
ErrorResult& out_error) ErrorResult& out_error)
{ {
if (!ReadPixels_SharedPrecheck(&out_error)) if (!ReadPixels_SharedPrecheck(&out_error))
@ -1517,15 +1516,6 @@ WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
////// //////
if (pixels.IsNull()) {
ErrorInvalidValue("readPixels: null destination buffer");
return;
}
const auto& view = pixels.Value();
//////
js::Scalar::Type reqScalarType; js::Scalar::Type reqScalarType;
if (!GetJSScalarFromGLType(type, &reqScalarType)) { if (!GetJSScalarFromGLType(type, &reqScalarType)) {
ErrorInvalidEnum("readPixels: Bad `type`."); ErrorInvalidEnum("readPixels: Bad `type`.");

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

@ -342,6 +342,11 @@ WebGLContext::TexImage2D(GLenum rawTexImageTarget, GLint level, GLenum internalF
return; return;
} }
const dom::ArrayBufferView* view = nullptr;
if (!maybeView.IsNull()) {
view = &maybeView.Value();
}
const bool isSubImage = false; const bool isSubImage = false;
const GLint xOffset = 0; const GLint xOffset = 0;
const GLint yOffset = 0; const GLint yOffset = 0;
@ -349,13 +354,13 @@ WebGLContext::TexImage2D(GLenum rawTexImageTarget, GLint level, GLenum internalF
const GLsizei depth = 1; const GLsizei depth = 1;
tex->TexOrSubImage(isSubImage, funcName, target, level, internalFormat, xOffset, tex->TexOrSubImage(isSubImage, funcName, target, level, internalFormat, xOffset,
yOffset, zOffset, width, height, depth, border, unpackFormat, yOffset, zOffset, width, height, depth, border, unpackFormat,
unpackType, maybeView); unpackType, view);
} }
void void
WebGLContext::TexImage2D(GLenum rawTexImageTarget, GLint level, GLenum internalFormat, WebGLContext::TexImage2D(GLenum rawTexImageTarget, GLint level, GLenum internalFormat,
GLenum unpackFormat, GLenum unpackType, GLenum unpackFormat, GLenum unpackType,
dom::ImageData* imageData, ErrorResult&) const dom::ImageData& imageData, ErrorResult&)
{ {
const char funcName[] = "texImage2D"; const char funcName[] = "texImage2D";
const uint8_t funcDims = 2; const uint8_t funcDims = 2;
@ -378,8 +383,8 @@ WebGLContext::TexImage2D(GLenum rawTexImageTarget, GLint level, GLenum internalF
void void
WebGLContext::TexImage2D(GLenum rawTexImageTarget, GLint level, GLenum internalFormat, WebGLContext::TexImage2D(GLenum rawTexImageTarget, GLint level, GLenum internalFormat,
GLenum unpackFormat, GLenum unpackType, dom::Element* elem, GLenum unpackFormat, GLenum unpackType, const dom::Element& elem,
ErrorResult* const out_error) ErrorResult& out_error)
{ {
const char funcName[] = "texImage2D"; const char funcName[] = "texImage2D";
const uint8_t funcDims = 2; const uint8_t funcDims = 2;
@ -397,7 +402,7 @@ WebGLContext::TexImage2D(GLenum rawTexImageTarget, GLint level, GLenum internalF
const GLint yOffset = 0; const GLint yOffset = 0;
const GLint zOffset = 0; const GLint zOffset = 0;
tex->TexOrSubImage(isSubImage, funcName, target, level, internalFormat, xOffset, tex->TexOrSubImage(isSubImage, funcName, target, level, internalFormat, xOffset,
yOffset, zOffset, unpackFormat, unpackType, elem, out_error); yOffset, zOffset, unpackFormat, unpackType, elem, &out_error);
} }
//////////////////////////////////////// ////////////////////////////////////////
@ -407,8 +412,7 @@ void
WebGLContext::TexSubImage2D(GLenum rawTexImageTarget, GLint level, GLint xOffset, WebGLContext::TexSubImage2D(GLenum rawTexImageTarget, GLint level, GLint xOffset,
GLint yOffset, GLsizei width, GLsizei height, GLint yOffset, GLsizei width, GLsizei height,
GLenum unpackFormat, GLenum unpackType, GLenum unpackFormat, GLenum unpackType,
const dom::Nullable<dom::ArrayBufferView>& maybeView, const dom::ArrayBufferView& view)
ErrorResult&)
{ {
const char funcName[] = "texSubImage2D"; const char funcName[] = "texSubImage2D";
const uint8_t funcDims = 2; const uint8_t funcDims = 2;
@ -428,13 +432,13 @@ WebGLContext::TexSubImage2D(GLenum rawTexImageTarget, GLint level, GLint xOffset
const GLint border = 0; const GLint border = 0;
tex->TexOrSubImage(isSubImage, funcName, target, level, internalFormat, xOffset, tex->TexOrSubImage(isSubImage, funcName, target, level, internalFormat, xOffset,
yOffset, zOffset, width, height, depth, border, unpackFormat, yOffset, zOffset, width, height, depth, border, unpackFormat,
unpackType, maybeView); unpackType, &view);
} }
void void
WebGLContext::TexSubImage2D(GLenum rawTexImageTarget, GLint level, GLint xOffset, WebGLContext::TexSubImage2D(GLenum rawTexImageTarget, GLint level, GLint xOffset,
GLint yOffset, GLenum unpackFormat, GLenum unpackType, GLint yOffset, GLenum unpackFormat, GLenum unpackType,
dom::ImageData* imageData, ErrorResult&) const dom::ImageData& imageData, ErrorResult&)
{ {
const char funcName[] = "texSubImage2D"; const char funcName[] = "texSubImage2D";
const uint8_t funcDims = 2; const uint8_t funcDims = 2;
@ -457,7 +461,7 @@ WebGLContext::TexSubImage2D(GLenum rawTexImageTarget, GLint level, GLint xOffset
void void
WebGLContext::TexSubImage2D(GLenum rawTexImageTarget, GLint level, GLint xOffset, WebGLContext::TexSubImage2D(GLenum rawTexImageTarget, GLint level, GLint xOffset,
GLint yOffset, GLenum unpackFormat, GLenum unpackType, GLint yOffset, GLenum unpackFormat, GLenum unpackType,
dom::Element* elem, ErrorResult* const out_error) const dom::Element& elem, ErrorResult& out_error)
{ {
const char funcName[] = "texSubImage2D"; const char funcName[] = "texSubImage2D";
const uint8_t funcDims = 2; const uint8_t funcDims = 2;
@ -474,7 +478,7 @@ WebGLContext::TexSubImage2D(GLenum rawTexImageTarget, GLint level, GLint xOffset
const GLenum internalFormat = 0; const GLenum internalFormat = 0;
const GLint zOffset = 0; const GLint zOffset = 0;
tex->TexOrSubImage(isSubImage, funcName, target, level, internalFormat, xOffset, tex->TexOrSubImage(isSubImage, funcName, target, level, internalFormat, xOffset,
yOffset, zOffset, unpackFormat, unpackType, elem, out_error); yOffset, zOffset, unpackFormat, unpackType, elem, &out_error);
} }
//////////////////////////////////////// ////////////////////////////////////////

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

@ -236,17 +236,17 @@ public:
GLint level, GLenum internalFormat, GLint xOffset, GLint yOffset, GLint level, GLenum internalFormat, GLint xOffset, GLint yOffset,
GLint zOffset, GLsizei width, GLsizei height, GLsizei depth, GLint zOffset, GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum unpackFormat, GLenum unpackType, GLint border, GLenum unpackFormat, GLenum unpackType,
const dom::Nullable<dom::ArrayBufferView>& maybeView); const dom::ArrayBufferView* view);
void TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarget target, void TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarget target,
GLint level, GLenum internalFormat, GLint xOffset, GLint yOffset, GLint level, GLenum internalFormat, GLint xOffset, GLint yOffset,
GLint zOffset, GLenum unpackFormat, GLenum unpackType, GLint zOffset, GLenum unpackFormat, GLenum unpackType,
dom::ImageData* imageData); const dom::ImageData& imageData);
void TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarget target, void TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarget target,
GLint level, GLenum internalFormat, GLint xOffset, GLint yOffset, GLint level, GLenum internalFormat, GLint xOffset, GLint yOffset,
GLint zOffset, GLenum unpackFormat, GLenum unpackType, GLint zOffset, GLenum unpackFormat, GLenum unpackType,
dom::Element* elem, ErrorResult* const out_error); const dom::Element& elem, ErrorResult* const out_error);
void TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarget target, void TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarget target,
GLint level, GLenum internalFormat, GLint xOffset, GLint yOffset, GLint level, GLenum internalFormat, GLint xOffset, GLint yOffset,

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

@ -227,7 +227,7 @@ WebGLTexture::TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarge
GLint yOffset, GLint zOffset, GLsizei rawWidth, GLint yOffset, GLint zOffset, GLsizei rawWidth,
GLsizei rawHeight, GLsizei rawDepth, GLint border, GLsizei rawHeight, GLsizei rawDepth, GLint border,
GLenum unpackFormat, GLenum unpackType, GLenum unpackFormat, GLenum unpackType,
const dom::Nullable<dom::ArrayBufferView>& maybeView) const dom::ArrayBufferView* view)
{ {
uint32_t width, height, depth; uint32_t width, height, depth;
if (!ValidateExtents(mContext, funcName, rawWidth, rawHeight, rawDepth, border, if (!ValidateExtents(mContext, funcName, rawWidth, rawHeight, rawDepth, border,
@ -246,22 +246,17 @@ WebGLTexture::TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarge
const uint8_t* bytes = nullptr; const uint8_t* bytes = nullptr;
uint32_t byteCount = 0; uint32_t byteCount = 0;
if (!maybeView.IsNull()) { if (view) {
const auto& view = maybeView.Value(); view->ComputeLengthAndData();
bytes = view->DataAllowShared();
byteCount = view->LengthAllowShared();
const auto jsType = JS_GetArrayBufferViewType(view.Obj()); const auto& jsType = view->Type();
if (!DoesJSTypeMatchUnpackType(pi.type, jsType)) { if (!DoesJSTypeMatchUnpackType(pi.type, jsType)) {
mContext->ErrorInvalidOperation("%s: `pixels` not compatible with `type`.", mContext->ErrorInvalidOperation("%s: `pixels` not compatible with `type`.",
funcName); funcName);
return; return;
} }
if (width && height && depth) {
view.ComputeLengthAndData();
bytes = view.DataAllowShared();
byteCount = view.LengthAllowShared();
}
} else if (isSubImage) { } else if (isSubImage) {
mContext->ErrorInvalidValue("%s: `pixels` must not be null.", funcName); mContext->ErrorInvalidValue("%s: `pixels` must not be null.", funcName);
return; return;
@ -336,16 +331,16 @@ WebGLTexture::TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarge
static already_AddRefed<gfx::DataSourceSurface> static already_AddRefed<gfx::DataSourceSurface>
FromImageData(WebGLContext* webgl, const char* funcName, GLenum unpackType, FromImageData(WebGLContext* webgl, const char* funcName, GLenum unpackType,
dom::ImageData* imageData, dom::Uint8ClampedArray* scopedArr) const dom::ImageData& imageData, dom::Uint8ClampedArray* scopedArr)
{ {
DebugOnly<bool> inited = scopedArr->Init(imageData->GetDataObject()); DebugOnly<bool> inited = scopedArr->Init(imageData.GetDataObject());
MOZ_ASSERT(inited); MOZ_ASSERT(inited);
scopedArr->ComputeLengthAndData(); scopedArr->ComputeLengthAndData();
const DebugOnly<size_t> dataSize = scopedArr->Length(); const DebugOnly<size_t> dataSize = scopedArr->Length();
const void* const data = scopedArr->Data(); const void* const data = scopedArr->Data();
const gfx::IntSize size(imageData->Width(), imageData->Height()); const gfx::IntSize size(imageData.Width(), imageData.Height());
const size_t stride = size.width * 4; const size_t stride = size.width * 4;
const gfx::SurfaceFormat surfFormat = gfx::SurfaceFormat::R8G8B8A8; const gfx::SurfaceFormat surfFormat = gfx::SurfaceFormat::R8G8B8A8;
@ -370,22 +365,16 @@ void
WebGLTexture::TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarget target, WebGLTexture::TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarget target,
GLint level, GLenum internalFormat, GLint xOffset, GLint level, GLenum internalFormat, GLint xOffset,
GLint yOffset, GLint zOffset, GLenum unpackFormat, GLint yOffset, GLint zOffset, GLenum unpackFormat,
GLenum unpackType, dom::ImageData* imageData) GLenum unpackType, const dom::ImageData& imageData)
{ {
const bool usePBOs = false; const bool usePBOs = false;
webgl::PackingInfo pi; webgl::PackingInfo pi;
if (!mContext->ValidateUnpackInfo(funcName, usePBOs, unpackFormat, unpackType, &pi)) if (!mContext->ValidateUnpackInfo(funcName, usePBOs, unpackFormat, unpackType, &pi))
return; return;
if (!imageData) {
// Spec says to generate an INVALID_VALUE error
mContext->ErrorInvalidValue("%s: Null ImageData.", funcName);
return;
}
// Eventually, these will be args. // Eventually, these will be args.
const uint32_t width = imageData->Width(); const uint32_t width = imageData.Width();
const uint32_t height = imageData->Height(); const uint32_t height = imageData.Height();
const uint32_t depth = 1; const uint32_t depth = 1;
dom::RootedTypedArray<dom::Uint8ClampedArray> scopedArr(dom::RootingCx()); dom::RootedTypedArray<dom::Uint8ClampedArray> scopedArr(dom::RootingCx());
@ -403,7 +392,7 @@ WebGLTexture::TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarge
webgl::TexUnpackSurface blob(mContext, target, width, height, depth, surf, webgl::TexUnpackSurface blob(mContext, target, width, height, depth, surf,
isAlphaPremult); isAlphaPremult);
const uint32_t fullRows = imageData->Height(); const uint32_t fullRows = imageData.Height();
const uint32_t tailPixels = 0; const uint32_t tailPixels = 0;
if (!mContext->ValidateUnpackPixels(funcName, fullRows, tailPixels, &blob)) if (!mContext->ValidateUnpackPixels(funcName, fullRows, tailPixels, &blob))
return; return;
@ -419,7 +408,7 @@ void
WebGLTexture::TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarget target, WebGLTexture::TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarget target,
GLint level, GLenum internalFormat, GLint xOffset, GLint level, GLenum internalFormat, GLint xOffset,
GLint yOffset, GLint zOffset, GLenum unpackFormat, GLint yOffset, GLint zOffset, GLenum unpackFormat,
GLenum unpackType, dom::Element* elem, GLenum unpackType, const dom::Element& elem,
ErrorResult* const out_error) ErrorResult* const out_error)
{ {
const bool usePBOs = false; const bool usePBOs = false;
@ -439,7 +428,8 @@ WebGLTexture::TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarge
flags |= nsLayoutUtils::SFE_PREFER_NO_PREMULTIPLY_ALPHA; flags |= nsLayoutUtils::SFE_PREFER_NO_PREMULTIPLY_ALPHA;
RefPtr<gfx::DrawTarget> idealDrawTarget = nullptr; // Don't care for now. RefPtr<gfx::DrawTarget> idealDrawTarget = nullptr; // Don't care for now.
auto sfer = nsLayoutUtils::SurfaceFromElement(elem, flags, idealDrawTarget); auto sfer = nsLayoutUtils::SurfaceFromElement(const_cast<dom::Element*>(&elem), flags,
idealDrawTarget);
////// //////