Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37424b3d authored by Chris Craik's avatar Chris Craik
Browse files

Simplify and correct texture upload unpack alignment parameter

bug:18928352
Change-Id: I484dd225ef495394d5e4283345387647345c2a07
parent c82be5f2
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -302,19 +302,16 @@ void TextureCache::generateTexture(const SkBitmap* bitmap, Texture* texture, boo

    switch (bitmap->colorType()) {
    case kAlpha_8_SkColorType:
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
        uploadToTexture(resize, GL_ALPHA, bitmap->rowBytesAsPixels(), bitmap->bytesPerPixel(),
                texture->width, texture->height, GL_UNSIGNED_BYTE, bitmap->getPixels());
        texture->blend = true;
        break;
    case kRGB_565_SkColorType:
        glPixelStorei(GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel());
        uploadToTexture(resize, GL_RGB, bitmap->rowBytesAsPixels(), bitmap->bytesPerPixel(),
                texture->width, texture->height, GL_UNSIGNED_SHORT_5_6_5, bitmap->getPixels());
        texture->blend = false;
        break;
    case kN32_SkColorType:
        glPixelStorei(GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel());
        uploadToTexture(resize, GL_RGBA, bitmap->rowBytesAsPixels(), bitmap->bytesPerPixel(),
                texture->width, texture->height, GL_UNSIGNED_BYTE, bitmap->getPixels());
        // Do this after calling getPixels() to make sure Skia's deferred
@@ -323,7 +320,6 @@ void TextureCache::generateTexture(const SkBitmap* bitmap, Texture* texture, boo
        break;
    case kARGB_4444_SkColorType:
    case kIndex_8_SkColorType:
        glPixelStorei(GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel());
        uploadLoFiTexture(resize, bitmap, texture->width, texture->height);
        texture->blend = !bitmap->isOpaque();
        break;
@@ -360,6 +356,7 @@ void TextureCache::uploadLoFiTexture(bool resize, const SkBitmap* bitmap,

void TextureCache::uploadToTexture(bool resize, GLenum format, GLsizei stride, GLsizei bpp,
        GLsizei width, GLsizei height, GLenum type, const GLvoid * data) {
    glPixelStorei(GL_UNPACK_ALIGNMENT, bpp);
    const bool useStride = stride != width && Extensions::getInstance().hasUnpackRowLength();
    if ((stride == width) || useStride) {
        if (useStride) {