hostsupport/inc/ColorDescriptor.h
branchbug235_bringup_0
changeset 53 c2ef9095503a
parent 24 a3f46bb01be2
equal deleted inserted replaced
52:39e5f73667ba 53:c2ef9095503a
       
     1 /* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     2  *
       
     3  * Permission is hereby granted, free of charge, to any person obtaining a
       
     4  * copy of this software and /or associated documentation files
       
     5  * (the "Materials "), to deal in the Materials without restriction,
       
     6  * including without limitation the rights to use, copy, modify, merge,
       
     7  * publish, distribute, sublicense, and/or sell copies of the Materials,
       
     8  * and to permit persons to whom the Materials are furnished to do so,
       
     9  * subject to the following conditions:
       
    10  *
       
    11  * The above copyright notice and this permission notice shall be included
       
    12  * in all copies or substantial portions of the Materials.
       
    13  *
       
    14  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
       
    15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
       
    16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
       
    17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
       
    18  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
       
    19  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
       
    20  * THE USE OR OTHER DEALINGS IN THE MATERIALS.
       
    21  *
       
    22  * Initial Contributors:
       
    23  * Nokia Corporation - initial contribution.
       
    24  *
       
    25  * Contributors:
       
    26  *
       
    27  * Description:
       
    28  *
       
    29  */
       
    30 
       
    31 #ifndef _COLORDESCRIPTOR_H_
       
    32 #define _COLORDESCRIPTOR_H_
       
    33 
       
    34 class CColorDescriptor
       
    35 {
       
    36 public:
       
    37 
       
    38     enum ColorFormat {
       
    39         lRGBA			= 0,
       
    40         sRGBA			= 1,
       
    41         lRGBA_PRE		= 2,
       
    42         sRGBA_PRE		= 3,
       
    43         lLA				= 4,
       
    44         sLA				= 5,
       
    45         lLA_PRE			= 6,
       
    46         sLA_PRE			= 7
       
    47     };
       
    48 
       
    49     enum ColorFormatBits
       
    50     {
       
    51         NONLINEAR		= (1<<0),
       
    52         PREMULTIPLIED	= (1<<1),
       
    53         LUMINANCE		= (1<<2)
       
    54     };
       
    55 
       
    56     CColorDescriptor(void) {
       
    57         m_bpp           = 0;
       
    58         m_redSize       = 0;
       
    59         m_greenSize     = 0;
       
    60         m_blueSize      = 0;
       
    61         m_luminanceSize = 0;
       
    62         m_alphaSize     = 0;
       
    63         m_alphaMaskSize = 0;
       
    64         m_format        = lRGBA_PRE;
       
    65         }
       
    66 
       
    67 	CColorDescriptor(int red, int green, int blue, 
       
    68                      int luminance, bool nonlinear, int alpha, bool premultiplied,
       
    69                      int alphaMask, int bpp);
       
    70     ~CColorDescriptor(void) {};
       
    71 
       
    72     void Set( int red, int green, int blue, int luminance, bool nonlinear, int alpha,
       
    73         bool premultiplied, int alphaMask, int bpp);
       
    74 
       
    75     void SetAttribute( int attribute, int value );
       
    76     int GetAttribute( int attribute ) const;
       
    77     inline int Bpp() const { return m_bpp; }
       
    78     inline int RedSize() const { return m_redSize; }
       
    79     inline int GreenSize() const { return m_greenSize; }
       
    80     inline int BlueSize() const { return m_blueSize; }
       
    81     inline int LuminanceSize() const { return m_luminanceSize; }
       
    82     inline int AlphaSize() const { return m_alphaSize; }
       
    83     inline int AlphaMaskSize() const { return m_alphaMaskSize; }
       
    84     inline bool isLuminance() const { return (m_format & LUMINANCE) != 0; }
       
    85     inline bool isNonlinear() const { return (m_format & NONLINEAR) != 0; }
       
    86     inline bool isPremultiplied() const { return (m_format & PREMULTIPLIED) != 0; }
       
    87     ColorFormat Format() const { return m_format; }
       
    88 
       
    89     int GetSurfaceType() const;
       
    90     void SetSurfaceType(int surfaceType);
       
    91     void SetSurfaceType(int colorSpace, int alphaFormat);
       
    92     void SetColorBufferType( int colorBufferType );
       
    93 
       
    94     CColorDescriptor& operator=( const CColorDescriptor& rhs );
       
    95     bool operator==( const CColorDescriptor& rhs ) const;
       
    96     bool operator!=( const CColorDescriptor& rhs ) const;
       
    97     bool MatchBitDepth( const CColorDescriptor& desc ) const;
       
    98 
       
    99 public:
       
   100     int  m_bpp;            /* Bits per pixel */
       
   101 	int  m_redSize;        /* EGL_RED_SIZE */
       
   102     int  m_greenSize;      /* EGL_GREEN_SIZE */
       
   103     int  m_blueSize;       /* EGL_BLUE_SIZE */
       
   104     int  m_luminanceSize;  /* EGL_LUMINANCE_SIZE */
       
   105     int  m_alphaSize;      /* EGL_ALPHA_SIZE */
       
   106     int  m_alphaMaskSize;  /* EGL_ALPHA_MASK_SIZE */
       
   107     ColorFormat  m_format; /* Color format */
       
   108 };
       
   109 #endif //_COLORDESCRIPTOR_H_