os/graphics/graphicsdeviceinterface/directgdiadaptation/hwsrc/directgdidriverprocessstate.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// directhdidriverprocessstate.h
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#ifndef _DIRECTGDIDRIVERPROCESSSTATE_H_
sl@0
    19
#define _DIRECTGDIDRIVERPROCESSSTATE_H_
sl@0
    20
sl@0
    21
/**
sl@0
    22
@file
sl@0
    23
@internalComponent
sl@0
    24
*/
sl@0
    25
sl@0
    26
#include "directgdiadapter.h"
sl@0
    27
#include <graphics/sgimage.h>
sl@0
    28
#include <EGL/egl.h>
sl@0
    29
#include <VG/openvg.h>
sl@0
    30
#include <e32base.h>
sl@0
    31
sl@0
    32
sl@0
    33
/**
sl@0
    34
Function pointers for use with eglGetProcAddress for creation and deletion of EGLImages and creation of VGImages
sl@0
    35
 */
sl@0
    36
typedef EGLImageKHR (*TeglCreateImageKHRTypefPtr) (EGLDisplay dpy, EGLContext ctx, EGLenum aTarget, EGLClientBuffer buffer, EGLint*attrib_list);
sl@0
    37
typedef EGLBoolean (*TeglDestroyImageKHRTypefPtr) (EGLDisplay dpy, EGLImageKHR image);
sl@0
    38
typedef EGLBoolean (*TvgCreateEGLImageTargetKHRTypefPtr) (VGeglImageKHR image);
sl@0
    39
sl@0
    40
/**
sl@0
    41
Helper class used by CDirectGdiDriverProcessState to group together related EGL and VG images.
sl@0
    42
 */
sl@0
    43
NONSHARABLE_CLASS(CImageSourceData): public CBase
sl@0
    44
	{
sl@0
    45
public:
sl@0
    46
	CImageSourceData(const TSgDrawableId& aSgImageId, EGLImageKHR aEglImage, VGImage aVgImage);
sl@0
    47
	virtual ~CImageSourceData();
sl@0
    48
	
sl@0
    49
	inline const TSgDrawableId& SgImageId() const; 
sl@0
    50
	inline EGLImageKHR EglImage() const;
sl@0
    51
	inline VGImage VgImage() const;
sl@0
    52
	inline TInt Open();
sl@0
    53
	inline TInt Close();	
sl@0
    54
	
sl@0
    55
private:
sl@0
    56
	TSgDrawableId iSgImageId;
sl@0
    57
	EGLImageKHR iEglImage;
sl@0
    58
	VGImage iVgImage;
sl@0
    59
	TInt iRefCount;	
sl@0
    60
	};
sl@0
    61
sl@0
    62
sl@0
    63
sl@0
    64
/**
sl@0
    65
Class for storing the state of CDirectGdiDriver objects within the current process. This class is 
sl@0
    66
responsible for maintaining an instance count of the number of drivers open in this process. There may 
sl@0
    67
be more than one thread that creates and opens a driver in this process. This class initializes EGL and  
sl@0
    68
terminates it using an instance count, as EGL terminate should not be called until all drivers in this 
sl@0
    69
process have been closed, not when each thread closes as another thread may be using EGL in the same
sl@0
    70
process.
sl@0
    71
sl@0
    72
This class is also responsible for storing a list of all EGLImageKHR objects and associated RSgImage IDs
sl@0
    73
created in this process, as there is a restriction that an EGLImageKHR can only be created
sl@0
    74
from a particular RSgImage once per process. This allows EGL images that have already been created
sl@0
    75
from RSgImages to be shared among threads. The list of EGL images is created on a shared process heap
sl@0
    76
so that it can be shared between all threads.
sl@0
    77
sl@0
    78
Users of this class should call CreateVGImageFromSgImage
sl@0
    79
 */
sl@0
    80
NONSHARABLE_CLASS(XDirectGdiDriverProcessState): public CBase
sl@0
    81
	{
sl@0
    82
public:
sl@0
    83
	XDirectGdiDriverProcessState();	
sl@0
    84
	virtual ~XDirectGdiDriverProcessState();
sl@0
    85
		
sl@0
    86
	TInt Initialize(EGLDisplay aDisplay);
sl@0
    87
	TInt CreateVgImage(EGLDisplay aDisplay, VGImage& aVgImageRet, const RSgImage& aSgImage);
sl@0
    88
	TInt DestroyVgImage(EGLDisplay aDisplay, VGImage aVgImage);
sl@0
    89
	
sl@0
    90
	void OpenDriver();
sl@0
    91
	void CloseDriver(EGLDisplay& aDriverEglDisplay);
sl@0
    92
	
sl@0
    93
	inline TInt MutexCreationStatus() const;
sl@0
    94
	
sl@0
    95
private:	
sl@0
    96
	TInt CheckAllEglExtensions(EGLDisplay aDisplay) const ;
sl@0
    97
	TInt CheckForEglExtension(EGLDisplay aDisplay, const TDesC8& aExtensionString) const;
sl@0
    98
	
sl@0
    99
	// Always use the mutex iImagesMutex around the following methods
sl@0
   100
	TBool ImageExists(const RSgImage& aSgImage, VGImage& aVgImageRet);
sl@0
   101
	CImageSourceData* FindImage(const RSgImage& aSgImage);
sl@0
   102
	TInt AddImage(const RSgImage& aSgImage, EGLImageKHR aEglImage, VGImage aVgImage);
sl@0
   103
	TInt RemoveImage(EGLDisplay aDisplay, VGImage aVgImage);
sl@0
   104
		
sl@0
   105
	TInt iDriverInstanceCount;
sl@0
   106
	RHeap* iLocalHeap;		
sl@0
   107
	RPointerArray<CImageSourceData> iImages;
sl@0
   108
	RMutex iMutex;
sl@0
   109
	// Holds the error state for creating the mutex in the constructor, so that it can be reported
sl@0
   110
	// outside of the constructor.
sl@0
   111
	TInt iCreateMutexErr;	
sl@0
   112
	TBool iCheckedExtensionsAvailable;
sl@0
   113
	
sl@0
   114
	// Function pointers for creation and destruction of EGLImageKHR and creation of VGImage
sl@0
   115
	TeglCreateImageKHRTypefPtr iPfnEglCreateImageKHR;
sl@0
   116
	TeglDestroyImageKHRTypefPtr iPfnEglDestroyImageKHR;
sl@0
   117
	TvgCreateEGLImageTargetKHRTypefPtr iPfnVgCreateImageTargetKHR;
sl@0
   118
	};
sl@0
   119
sl@0
   120
sl@0
   121
#include "directgdidriverprocessstate.inl"
sl@0
   122
sl@0
   123
#endif // _DIRECTGDIDRIVERPROCESSSTATE_H_