Skip to content

Commit 9e8ddd0

Browse files
fix constant blend func validation
1 parent f01f120 commit 9e8ddd0

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/javascript/webgl-rendering-context.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,18 @@ class WebGLRenderingContextHelper extends NativeWebGLRenderingContext {
293293
return null
294294
}
295295

296-
_isConstantBlendFunc (factor) {
296+
_isConstantColorBlendFunc (factor) {
297297
return (
298298
factor === this.CONSTANT_COLOR ||
299-
factor === this.ONE_MINUS_CONSTANT_COLOR ||
299+
factor === this.ONE_MINUS_CONSTANT_COLOR
300+
)
301+
}
302+
303+
_isConstantAlphaBlendFunc (factor) {
304+
return (
300305
factor === this.CONSTANT_ALPHA ||
301-
factor === this.ONE_MINUS_CONSTANT_ALPHA)
306+
factor === this.ONE_MINUS_CONSTANT_ALPHA
307+
)
302308
}
303309

304310
_isObject (object, method, Wrapper) {
@@ -868,7 +874,8 @@ class WebGLRenderingContextHelper extends NativeWebGLRenderingContext {
868874
this.setError(this.INVALID_ENUM)
869875
return
870876
}
871-
if (this._isConstantBlendFunc(sfactor) && this._isConstantBlendFunc(dfactor)) {
877+
if (this._isConstantColorBlendFunc(sfactor) && this._isConstantAlphaBlendFunc(dfactor) ||
878+
this._isConstantColorBlendFunc(dfactor) && this._isConstantAlphaBlendFunc(sfactor)) {
872879
this.setError(this.INVALID_OPERATION)
873880
return
874881
}
@@ -893,8 +900,8 @@ class WebGLRenderingContextHelper extends NativeWebGLRenderingContext {
893900
return
894901
}
895902

896-
if ((this._isConstantBlendFunc(srcRGB) && this._isConstantBlendFunc(dstRGB)) ||
897-
(this._isConstantBlendFunc(srcAlpha) && this._isConstantBlendFunc(dstAlpha))) {
903+
if ((this._isConstantColorBlendFunc(srcRGB) && this._isConstantAlphaBlendFunc(dstRGB)) ||
904+
(this._isConstantColorBlendFunc(dstRGB) && this._isConstantAlphaBlendFunc(srcRGB))) {
898905
this.setError(this.INVALID_OPERATION)
899906
return
900907
}

0 commit comments

Comments
 (0)