@@ -228,25 +228,22 @@ void TextureCache::generateTexture(SkBitmap* bitmap, Texture* texture, bool rege
228228 texture->height = bitmap->height ();
229229
230230 glBindTexture (GL_TEXTURE_2D, texture->id );
231- if (!regenerate) {
232- glPixelStorei (GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel ());
233- }
234231
235232 switch (bitmap->getConfig ()) {
236233 case SkBitmap::kA8_Config :
237- if (!regenerate) {
238- glPixelStorei (GL_UNPACK_ALIGNMENT, 1 );
239- }
234+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1 );
240235 uploadToTexture (resize, GL_ALPHA, bitmap->rowBytesAsPixels (), texture->height ,
241236 GL_UNSIGNED_BYTE, bitmap->getPixels ());
242237 texture->blend = true ;
243238 break ;
244239 case SkBitmap::kRGB_565_Config :
240+ glPixelStorei (GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel ());
245241 uploadToTexture (resize, GL_RGB, bitmap->rowBytesAsPixels (), texture->height ,
246242 GL_UNSIGNED_SHORT_5_6_5, bitmap->getPixels ());
247243 texture->blend = false ;
248244 break ;
249245 case SkBitmap::kARGB_8888_Config :
246+ glPixelStorei (GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel ());
250247 uploadToTexture (resize, GL_RGBA, bitmap->rowBytesAsPixels (), texture->height ,
251248 GL_UNSIGNED_BYTE, bitmap->getPixels ());
252249 // Do this after calling getPixels() to make sure Skia's deferred
@@ -255,6 +252,7 @@ void TextureCache::generateTexture(SkBitmap* bitmap, Texture* texture, bool rege
255252 break ;
256253 case SkBitmap::kARGB_4444_Config :
257254 case SkBitmap::kIndex8_Config :
255+ glPixelStorei (GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel ());
258256 uploadLoFiTexture (resize, bitmap, texture->width , texture->height );
259257 texture->blend = !bitmap->isOpaque ();
260258 break ;
0 commit comments