Skip to content

Commit 55d0aa3

Browse files
committed
Merge pull request #3263 from ntrrgc/premultiplied-fix-branch
Use premultiplied alpha in textures loaded from DOM
2 parents 5ccd392 + c2a17cf commit 55d0aa3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: cocos2d/core/textures/TexturesWebGL.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,9 @@ cc._tmp.WebGLTexture2D = function () {
421421
this._webTextureObj = cc._renderContext.createTexture();
422422
this._htmlElementObj = element;
423423
this._textureLoaded = true;
424+
// Textures should be loaded with premultiplied alpha in order to avoid gray bleeding
425+
// when semitransparent textures are interpolated (e.g. when scaled).
426+
this._hasPremultipliedAlpha = true;
424427
},
425428

426429
/**
@@ -444,8 +447,11 @@ cc._tmp.WebGLTexture2D = function () {
444447
* @param {Boolean} [premultiplied=false]
445448
*/
446449
handleLoadedTexture: function (premultiplied) {
447-
premultiplied = (premultiplied === undefined) ? false : premultiplied;
448450
var self = this;
451+
premultiplied =
452+
(premultiplied !== undefined)
453+
? premultiplied
454+
: self._hasPremultipliedAlpha;
449455
// Not sure about this ! Some texture need to be updated even after loaded
450456
if (!cc.game._rendererInitialized)
451457
return;

0 commit comments

Comments
 (0)