holdingarea/libEGL/inc/EGLSurface.h
branchbug235_bringup_0
changeset 20 d2d6724aef32
child 24 a3f46bb01be2
equal deleted inserted replaced
19:da7c1a80df0d 20:d2d6724aef32
       
     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 _EGLSURFACE_H_
       
    32 #define _EGLSURFACE_H_
       
    33 
       
    34 #include <EGL/egl.h>
       
    35 #include "eglInternal.h"
       
    36 #include "EGLStructs.h"
       
    37 #include "BufferContainer.h"
       
    38 #include "SurfaceDescriptor.h"
       
    39 
       
    40 class CEGLContext;
       
    41 class CEGLConfig;
       
    42 class CEGLThread;
       
    43 
       
    44 class CEGLSurface : public RefCountingObject
       
    45 {
       
    46 public:
       
    47     enum SurfaceType
       
    48         {
       
    49         WINDOW_SURFACE = 1,
       
    50         PBUFFER_SURFACE,
       
    51         PIXMAP_SURFACE
       
    52         };
       
    53 
       
    54 protected:
       
    55     CEGLSurface( CEGLSurface::SurfaceType type, EGLint colorSpace, EGLint alphaFormat, EGLint renderBuffer, CEGLConfig* config );
       
    56 
       
    57 public:
       
    58 	virtual ~CEGLSurface(void);
       
    59 
       
    60 public:
       
    61     void BindToContext( CEGLContext* context );
       
    62     inline CEGLContext* BoundContext() const { return m_boundContext; }
       
    63     inline void SetThread( CEGLThread* thread ) { m_thread = thread; }
       
    64     inline CEGLThread* Thread() const { return m_thread; }
       
    65     inline CEGLConfig* Config() const { return m_config; }
       
    66     inline CEGLSurface::SurfaceType Type() const { return m_type; }
       
    67     inline EGLint RenderBuffer() const { return m_renderBuffer; }
       
    68     inline EGLint AlphaFormat() const { return m_alphaFormat; }
       
    69     inline EGLint ColorSpace() const { return m_colorSpace; }
       
    70     inline EGLint MipmapLevel() const { return m_mipmapLevel; }
       
    71     inline EGLint MultisampleResolve() const { return m_multisampleResolve; };
       
    72     inline EGLint SwapBehavior() const { return m_swapBehavior; }
       
    73 	inline EGLITextureBinding& TextureBinding() { return m_textureBinding; }
       
    74     
       
    75     EGLint Width() const { return m_width; }
       
    76     EGLint Height() const { return m_height; }
       
    77     void SetStride( EGLint stride ) { m_stride = stride; }
       
    78     EGLint Stride() const { return m_stride; }
       
    79     bool Resize( EGLint width, EGLint height );
       
    80     void Size( int& width, int& height ) { width = m_width; height = m_height; }
       
    81 
       
    82     BufferContainer* VGBuffers() { return &m_vgBuffers; }
       
    83     BufferContainer* GLESBuffers() { return &m_glesBuffers; }
       
    84     void* VGColorBuffer() const { return m_vgBuffers.m_colorBuffer; }
       
    85     void* GLESColorBuffer() const { return m_glesBuffers.m_colorBuffer; }
       
    86     void* VGClientSurface() const { return m_vgBuffers.m_clientSurface; }
       
    87     void* GLESClientSurface() const { return m_glesBuffers.m_clientSurface; }
       
    88 
       
    89     SurfaceDescriptor* Descriptor();
       
    90 
       
    91     void SetAttribute( EGLint attrib, EGLint value );
       
    92     EGLint Attribute( EGLint attrib ) const;
       
    93 
       
    94     void Lock();
       
    95     void Unlock();
       
    96     bool IsLocked() const { return m_isLocked; }
       
    97     void SetVGDirty( bool dirty ) { m_vgDirty = dirty; }
       
    98     bool IsVGDirty() const { return m_vgDirty; }
       
    99     void SetGLES1Dirty( bool dirty ) { m_gles1Dirty = dirty; }
       
   100     bool IsGLES1Dirty() const { return m_gles1Dirty; }
       
   101     void SetGLES2Dirty( bool dirty ) { m_gles2Dirty = dirty; }
       
   102     bool IsGLES2Dirty() const { return m_gles2Dirty; }
       
   103 
       
   104 private:
       
   105 	SurfaceType     m_type;
       
   106     EGLint          m_colorSpace;
       
   107     EGLint          m_alphaFormat;
       
   108     EGLint          m_renderBuffer;
       
   109     CEGLConfig*     m_config; // not owned
       
   110     CEGLContext*    m_boundContext; // not owned
       
   111     CEGLThread*     m_thread; // not owned
       
   112 
       
   113 protected:
       
   114     EGLint              m_width;
       
   115     EGLint              m_height;
       
   116     EGLint              m_stride;
       
   117     BufferContainer     m_vgBuffers;
       
   118     BufferContainer     m_glesBuffers;
       
   119     SurfaceDescriptor   m_surfaceDescriptor;
       
   120     EGLint              m_mipmapLevel;
       
   121     EGLint              m_multisampleResolve;
       
   122     EGLint              m_swapBehavior;
       
   123 	EGLITextureBinding	m_textureBinding;
       
   124     EGLI_LOCK           m_lock;
       
   125     bool                m_vgDirty;
       
   126     bool                m_gles1Dirty;
       
   127     bool                m_gles2Dirty;
       
   128     bool                m_isLocked;
       
   129 };
       
   130 
       
   131 #endif //_EGLSURFACE_H_