@@ -442,8 +442,10 @@ cc._tmp.WebGLTexture2D = function () {
442
442
443
443
/**
444
444
* handler of texture loaded event
445
+ * @param {Boolean } [premultipled=false]
445
446
*/
446
- handleLoadedTexture : function ( ) {
447
+ handleLoadedTexture : function ( premultipled ) {
448
+ premultipled = ( premultipled === undefined ) ?false : premultipled ;
447
449
var self = this ;
448
450
// Not sure about this ! Some texture need to be updated even after loaded
449
451
if ( ! cc . _rendererInitialized )
@@ -462,6 +464,8 @@ cc._tmp.WebGLTexture2D = function () {
462
464
cc . glBindTexture2D ( self ) ;
463
465
464
466
gl . pixelStorei ( gl . UNPACK_ALIGNMENT , 4 ) ;
467
+ if ( premultipled )
468
+ gl . pixelStorei ( gl . UNPACK_PREMULTIPLY_ALPHA_WEBGL , 1 ) ;
465
469
466
470
// Specify OpenGL texture image
467
471
gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , gl . RGBA , gl . UNSIGNED_BYTE , self . _htmlElementObj ) ;
@@ -473,6 +477,8 @@ cc._tmp.WebGLTexture2D = function () {
473
477
474
478
self . shaderProgram = cc . shaderCache . programForKey ( cc . SHADER_POSITION_TEXTURE ) ;
475
479
cc . glBindTexture2D ( null ) ;
480
+ if ( premultipled )
481
+ gl . pixelStorei ( gl . UNPACK_PREMULTIPLY_ALPHA_WEBGL , 0 ) ;
476
482
477
483
var pixelsWide = self . _htmlElementObj . width ;
478
484
var pixelsHigh = self . _htmlElementObj . height ;
@@ -483,7 +489,7 @@ cc._tmp.WebGLTexture2D = function () {
483
489
self . maxS = 1 ;
484
490
self . maxT = 1 ;
485
491
486
- self . _hasPremultipliedAlpha = false ;
492
+ self . _hasPremultipliedAlpha = premultipled ;
487
493
self . _hasMipmaps = false ;
488
494
489
495
//dispatch load event to listener.
0 commit comments