Changeset 2550


Ignore:
Timestamp:
Mar 5, 2013, 4:09:18 PM (7 years ago)
Author:
sam
Message:

image: remove the Image::Format enum and use PixelFormat instead.

Location:
trunk/src
Files:
15 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r2540 r2550  
    4646    \
    4747    lol/image/all.h \
    48     lol/image/color.h \
     48    lol/image/color.h lol/image/image.h \
    4949    \
    5050    lol/gpu/all.h \
     
    9999    sys/threadbase.h \
    100100    \
    101     image/image.cpp image/image.h image/image-private.h \
     101    image/image.cpp image/image-private.h \
    102102    image/codec/gdiplus-image.cpp \
    103103    image/codec/ios-image.cpp \
  • trunk/src/core.h

    r2524 r2550  
    9595#include <lol/math/all.h>
    9696#include <lol/sys/all.h>
     97#include <lol/gpu/all.h>
    9798#include <lol/image/all.h>
    98 #include <lol/gpu/all.h>
    9999#include <lol/debug/all.h>
    100100
     
    131131#include "layer.h"
    132132#include "mesh/mesh.h"
    133 #include "image/image.h"
    134133#include "application/application.h"
    135134#include "easymesh/csgbsp.h"
  • trunk/src/gpu/texture.cpp

    r2506 r2550  
    8383        { D3DFMT_UNKNOWN, 0 },
    8484
    85         /* R8G8B8 */
     85        /* FIXME: this is all mixed up for the RGBA/ARGB combinations */
    8686#   if defined USE_D3D9
    87         { D3DFMT_R8G8B8, 3 },
     87        { D3DFMT_R8G8B8, 3 },   /* RGB_8 */
     88        { D3DFMT_UNKNOWN, 0 },  /* RGBA_8 */
     89        { D3DFMT_A8R8G8B8, 4 }, /* ARGB_8 */
     90        { D3DFMT_UNKNOWN, 0 },  /* ABGR_8 */
     91        { D3DFMT_L8, 1 },       /* Y8 */
    8892#   else
    8993        { D3DFMT_UNKNOWN, 0 },
    90 #   endif
    91 
    92         /* A8R8G8B8 */
    93 #   if defined USE_D3D9
    94         { D3DFMT_A8R8G8B8, 4 },
    95 #   else
     94        { D3DFMT_UNKNOWN, 0 },
    9695        /* By default the X360 will swizzle the texture. Ask for linear. */
    9796        { D3DFMT_LIN_A8R8G8B8, 4 },
    98 #   endif
    99 
    100         /* Y8 */
    101 #   if defined USE_D3D9
    102         { D3DFMT_L8, 1 },
    103 #   else
    104         /* By default the X360 will swizzle the texture. Ask for linear. */
     97        { D3DFMT_UNKNOWN, 0 },
    10598        { D3DFMT_LIN_L8, 1 },
    10699#   endif
     
    129122        { 0, 0, 0, 0 }, /* Unknown */
    130123
     124        /* FIXME: this is all mixed up for the RGBA/ARGB combinations */
    131125#if __CELLOS_LV2__
    132126        { GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, 3 },
     127        { GL_ARGB_SCE, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4 },
    133128        { GL_ARGB_SCE, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4 },
    134129        { GL_ARGB_SCE, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 4 },
     
    137132        { GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 3 },
    138133        { GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 4 },
     134        { GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 4 },
    139135        /* FIXME: if GL_RGBA is not available, we should advertise
    140136         * this format as "not available" on this platform. */
     
    144140        { GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, 3 }, /* RGB_8 */
    145141        /* Seems efficient for little endian textures */
     142        { GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 4 }, /* ARGB_8 */
    146143        { GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 4 }, /* ARGB_8 */
    147144        { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 4 }, /* ABGR_8 */
  • trunk/src/image/codec/android-image.cpp

    r2506 r2550  
    8484    /* Get image dimensions */
    8585    mid = env->GetMethodID(cls, "getWidth", "(Landroid/graphics/Bitmap;)I");
    86     size.x = env->CallIntMethod(g_activity, mid, bmp);
     86    m_size.x = env->CallIntMethod(g_activity, mid, bmp);
    8787    mid = env->GetMethodID(cls, "getHeight", "(Landroid/graphics/Bitmap;)I");
    88     size.y = env->CallIntMethod(g_activity, mid, bmp);
     88    m_size.y = env->CallIntMethod(g_activity, mid, bmp);
    8989
    9090    /* Get pixels */
    91     array = env->NewIntArray(size.x * size.y);
     91    array = env->NewIntArray(m_size.x * m_size.y);
    9292    env->NewGlobalRef(array);
    9393    mid = env->GetMethodID(cls, "getPixels", "(Landroid/graphics/Bitmap;[I)V");
     
    9595
    9696    pixels = env->GetIntArrayElements(array, 0);
    97     for (int n = 0; n < size.x * size.y; n++)
     97    for (int n = 0; n < m_size.x * m_size.y; n++)
    9898    {
    9999        uint32_t u = pixels[n];
     
    101101        pixels[n] = u;
    102102    }
    103     format = Image::FORMAT_RGBA;
     103    m_format = PixelFormat::RGBA_8;
    104104
    105105    return true;
  • trunk/src/image/codec/dummy-image.cpp

    r2480 r2550  
    4545    UNUSED(path);
    4646
    47     size = ivec2(256);
    48     format = Image::FORMAT_RGBA;
     47    m_size = ivec2(256);
     48    m_format = PixelFormat::RGBA_8;
    4949    pixels = (uint8_t *)malloc(256 * 256 * 4 * sizeof(*pixels));
    5050    uint8_t *parser = pixels;
  • trunk/src/image/codec/gdiplus-image.cpp

    r2506 r2550  
    110110    }
    111111
    112     size = ivec2(m_bitmap->GetWidth(), m_bitmap->GetHeight());
    113     format = Image::FORMAT_RGBA;
     112    m_size = ivec2(m_bitmap->GetWidth(), m_bitmap->GetHeight());
     113    m_format = PixelFormat::RGBA_8;
    114114
    115     Gdiplus::Rect rect(0, 0, size.x, size.y);
     115    Gdiplus::Rect rect(0, 0, m_size.x, m_size.y);
    116116    if(m_bitmap->LockBits(&rect, Gdiplus::ImageLockModeRead,
    117117                          PixelFormat32bppARGB, &m_bdata) != Gdiplus::Ok)
     
    128128     * this in the shader. */
    129129    uint8_t *p = static_cast<uint8_t *>(m_bdata.Scan0);
    130     for (int y = 0; y < size.y; y++)
    131         for (int x = 0; x < size.x; x++)
     130    for (int y = 0; y < m_size.y; y++)
     131        for (int x = 0; x < m_size.x; x++)
    132132        {
    133133            uint8_t tmp = p[2];
  • trunk/src/image/codec/ios-image.cpp

    r2529 r2550  
    6565    int w = CGImageGetWidth(image.CGImage);
    6666    int h = CGImageGetHeight(image.CGImage);
    67     size = ivec2(w, h);
    68     format = Image::FORMAT_RGBA;
     67    m_size = ivec2(w, h);
     68    m_format = PixelFormat::RGBA_8;
    6969
    7070    CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB();
  • trunk/src/image/codec/ps3-image.cpp

    r2512 r2550  
    138138
    139139    /* Decode image */
    140     size = ivec2(info.imageWidth, info.imageHeight);
    141     format = Image::FORMAT_RGBA;
     140    m_size = ivec2(info.imageWidth, info.imageHeight);
     141    m_format = PixelFormat::RGBA_8;
    142142    pixels = (uint8_t *)malloc(info.imageWidth * 4 * info.imageHeight);
    143143    CellPngDecDataCtrlParam data_ctrl_param;
  • trunk/src/image/codec/sdl-image.cpp

    r2506 r2550  
    7474    }
    7575
    76     size = ivec2(m_img->w, m_img->h);
     76    m_size = ivec2(m_img->w, m_img->h);
    7777
    7878    if (m_img->format->BytesPerPixel != 4)
    7979    {
    80         SDL_Surface *tmp = Create32BppSurface(size);
     80        SDL_Surface *tmp = Create32BppSurface(m_size);
    8181        SDL_BlitSurface(m_img, nullptr, tmp, nullptr);
    8282        SDL_FreeSurface(m_img);
     
    8484    }
    8585
    86     format = m_img->format->Amask ? Image::FORMAT_RGBA : Image::FORMAT_RGB;
     86    m_format = m_img->format->Amask ? PixelFormat::RGBA_8
     87                                    : PixelFormat::RGB_8;
    8788
    8889    return true;
  • trunk/src/image/image-private.h

    r2506 r2550  
    1616#if !defined __LOL_IMAGE_PRIVATE_H__
    1717#define __LOL_IMAGE_PRIVATE_H__
    18 
    19 #include "image.h"
    2018
    2119namespace lol
     
    8280
    8381protected:
    84     ivec2 size;
    85     Image::format_t format;
     82    ivec2 m_size;
     83    PixelFormat m_format;
    8684};
    8785
  • trunk/src/image/image.cpp

    r2480 r2550  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    5959    UNUSED(init);
    6060
    61     data = ImageLoader::Load(path);
     61    m_data = ImageLoader::Load(path);
    6262}
    6363
    6464ivec2 Image::GetSize() const
    6565{
    66     return data->size;
     66    return m_data->m_size;
    6767}
    6868
    69 Image::format_t Image::GetFormat() const
     69PixelFormat Image::GetFormat() const
    7070{
    71     return data->format;
     71    return m_data->m_format;
    7272}
    7373
    7474void * Image::GetData() const
    7575{
    76     return data->GetData();
     76    return m_data->GetData();
    7777}
    7878
    7979Image::~Image()
    8080{
    81     data->Close();
    82     delete data;
     81    m_data->Close();
     82    delete m_data;
    8383}
    8484
  • trunk/src/lol/gpu/texture.h

    r2354 r2550  
    2727        Unknown = 0,
    2828        RGB_8,
     29        RGBA_8,
    2930        ARGB_8,
    3031        ABGR_8,
  • trunk/src/lol/image/all.h

    r2524 r2550  
    1313
    1414#include <lol/image/color.h>
     15#include <lol/image/image.h>
    1516
    1617#endif // __LOL_IMAGE_ALL_H__
  • trunk/src/lol/image/image.h

    r2549 r2550  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    1414//
    1515
    16 #if !defined __LOL_IMAGE_H__
    17 #define __LOL_IMAGE_H__
     16#if !defined __LOL_IMAGE_IMAGE_H__
     17#define __LOL_IMAGE_IMAGE_H__
    1818
    19 #include "lol/math/vector.h"
     19#include <lol/math/vector.h>
    2020
    2121namespace lol
    2222{
    23 
    24 class ImageData;
    2523
    2624class Image
     
    3028    ~Image();
    3129
    32     typedef enum
    33     {
    34         FORMAT_RGBA = 0,
    35         FORMAT_RGB,
    36         FORMAT_UNKNOWN,
    37     }
    38     format_t;
    39 
    4030    ivec2 GetSize() const;
    41     format_t GetFormat() const;
     31    PixelFormat GetFormat() const;
    4232    void *GetData() const;
    4333
    4434private:
    45     ImageData *data;
     35    class ImageData *m_data;
    4636};
    4737
    4838} /* namespace lol */
    4939
    50 #endif // __LOL_IMAGE_H__
     40#endif // __LOL_IMAGE_IMAGE_H__
    5141
  • trunk/src/lolcore.vcxproj

    r2540 r2550  
    189189    <ClInclude Include="gradient.h" />
    190190    <ClInclude Include="image\image-private.h" />
    191     <ClInclude Include="image\image.h" />
    192191    <ClInclude Include="input\input.h" />
    193192    <ClInclude Include="input\keyboard.h" />
     
    216215    <ClInclude Include="lol\image\all.h" />
    217216    <ClInclude Include="lol\image\color.h" />
     217    <ClInclude Include="lol\image\image.h" />
    218218    <ClInclude Include="lol\math\all.h" />
    219219    <ClInclude Include="lol\math\functions.h" />
  • trunk/src/tileset.cpp

    r2546 r2550  
    116116    {
    117117        int planes;
    118         PixelFormat format = PixelFormat::Unknown;
    119 
    120         switch (data->img->GetFormat())
     118        PixelFormat format = data->img->GetFormat();
     119
     120        switch (format)
    121121        {
    122         case Image::FORMAT_RGB:
    123             format = PixelFormat::RGB_8;
     122        case PixelFormat::RGB_8:
    124123            planes = 3;
    125124            break;
    126         case Image::FORMAT_RGBA:
     125        case PixelFormat::RGBA_8:
     126        case PixelFormat::ARGB_8:
     127        case PixelFormat::ABGR_8:
    127128        default:
    128             format = PixelFormat::ARGB_8;
    129129            planes = 4;
    130130            break;
Note: See TracChangeset for help on using the changeset viewer.