os/graphics/graphicsdeviceinterface/directgdiadaptation/hwsrc/directgdidriverimpl.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
// Declaration of a Direct Graphics Device Interface (GDI) Driver implementation,
sl@0
    15
// this class actually implements the HAI.
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
sl@0
    20
#ifndef __DIRECTGDIDRIVERIMPL_H__
sl@0
    21
#define __DIRECTGDIDRIVERIMPL_H__
sl@0
    22
sl@0
    23
/**
sl@0
    24
@file
sl@0
    25
@internalComponent Reference implementation of Open VG hardware accelerated DirectGDI adaptation.
sl@0
    26
*/
sl@0
    27
#include "vgimagecache.h"
sl@0
    28
#include "directgdidrawableref.h"
sl@0
    29
#include "directgdiimageref.h"
sl@0
    30
#include "directgdidriverprocessstate.h"
sl@0
    31
#include "glyphimagecache.h"
sl@0
    32
#include <graphics/directgdidriverinternal.h>
sl@0
    33
#include <graphics/directgdiextensioninterfaces.h>
sl@0
    34
#include <e32hashtab.h>
sl@0
    35
#include <e32cmn.h>
sl@0
    36
#include <pls.h>
sl@0
    37
sl@0
    38
sl@0
    39
// Forward declarations.
sl@0
    40
//
sl@0
    41
class CDirectGdiImageTargetImpl;
sl@0
    42
class CDirectGdiImageSourceImpl;
sl@0
    43
class CVgEngine;
sl@0
    44
class CDirectGdiDrawableRef;
sl@0
    45
class RDirectGdiImageTarget;
sl@0
    46
sl@0
    47
/**
sl@0
    48
Represents the body part of CDirectGdiDriver that actually implements the HAI. Derives from the CDirectGdiDriverInternal class and implements all the 
sl@0
    49
interfaces to provide the functionality required by the generic layer.
sl@0
    50
*/
sl@0
    51
NONSHARABLE_CLASS(CDirectGdiDriverImpl): public CDirectGdiDriverInternal, public MDirectGdiDriverCacheSize
sl@0
    52
	{
sl@0
    53
public:
sl@0
    54
	static TInt New(CDirectGdiDriverInternal*& aInternal, RLibrary aLibrary);
sl@0
    55
	~CDirectGdiDriverImpl();
sl@0
    56
sl@0
    57
	// From CDirectGdiDriverInternal	
sl@0
    58
	void Flush();
sl@0
    59
	void Finish();	
sl@0
    60
	TInt GetError();
sl@0
    61
	void SetError(TInt aErr);
sl@0
    62
	TInt CreateDrawableSource(TInt& aHandleRet, const RSgDrawable& aSgDrawable);
sl@0
    63
	void CloseDrawableSource(TInt& aHandle) ;	
sl@0
    64
	TInt CreateImageTarget(TInt& aHandleRet, const RSgImage& aImageDestination);
sl@0
    65
	void CloseImageTarget(TInt& aHandle);
sl@0
    66
	TInt CreateEngine(MDirectGdiEngine*& aDirectGdiEngine);
sl@0
    67
	void DestroyEngine(MDirectGdiEngine* aDirectGdiEngine);
sl@0
    68
	TInt GetInterface(TUid aInterfaceId, TAny*& aInterface);
sl@0
    69
	
sl@0
    70
	// From MDirectGdiDriverCacheSize
sl@0
    71
	TInt SetMaxImageCacheSize(TInt aSize);	
sl@0
    72
	TInt MaxImageCacheSize() const;
sl@0
    73
	TInt SetMaxGlyphCacheSize(TInt aSize);
sl@0
    74
	TInt MaxGlyphCacheSize() const;
sl@0
    75
	
sl@0
    76
	void SetCurrentEngine(CVgEngine* aCurrentEngine);
sl@0
    77
	void SetCurrentTarget(CDirectGdiImageTargetImpl* aCurrentTarget);
sl@0
    78
	TBool IsCurrentEngine(const CVgEngine* aCurrentEngine) const;
sl@0
    79
	TBool IsCurrentTarget(const CDirectGdiImageTargetImpl* aCurrentTarget) const;
sl@0
    80
	void Activate(CDirectGdiImageTargetImpl* aRenderingTarget);
sl@0
    81
	void Reactivate(CDirectGdiImageTargetImpl* aRenderingTarget);
sl@0
    82
	void Deactivate(CDirectGdiImageTargetImpl* aRenderingTarget);
sl@0
    83
	CDirectGdiImageSourceImpl* GetImageSourceFromHandle(TInt aHandle) const;	
sl@0
    84
	CDirectGdiImageTargetImpl* GetImageTargetFromHandle(TInt aHandle) const;
sl@0
    85
	TBool IsImageSource(TInt aHandle) const;
sl@0
    86
	
sl@0
    87
	CFontGlyphImageStorage* FontGlyphImageStorage() const;
sl@0
    88
	TInt PreAllocateFontGlyphImages(); //images will be used to draw glyphs if the system runs out of memory
sl@0
    89
	CVgImageCache* VgImageCache() const;
sl@0
    90
sl@0
    91
	// VGImage cache commands
sl@0
    92
	VGImage GetVgImageFromCache(const CFbsBitmap& aBitmap, const TPoint& aOrigin) const;
sl@0
    93
	TBool AddVgImageToCache(const CFbsBitmap& aBitmap, VGImage& aImage, const TPoint& aOrigin);
sl@0
    94
	
sl@0
    95
	TInt RegisterSourceImage(const CDirectGdiImageSourceImpl& aImage);
sl@0
    96
	TInt RegisterTargetImage(const CDirectGdiImageTargetImpl& aImage);
sl@0
    97
	TInt UnregisterSourceImage(const CDirectGdiImageSourceImpl& aImage);
sl@0
    98
	TInt UnregisterTargetImage(const CDirectGdiImageTargetImpl& aImage);
sl@0
    99
	
sl@0
   100
	inline EGLDisplay EglDisplay() const;
sl@0
   101
	inline XDirectGdiDriverProcessState& ProcessState() const;
sl@0
   102
	
sl@0
   103
	static TInt GetVgError();
sl@0
   104
sl@0
   105
private:
sl@0
   106
	CDirectGdiDriverImpl(RLibrary aLibrary);
sl@0
   107
	TInt Construct();
sl@0
   108
	TInt InitializeEglConfigs(EGLDisplay display);
sl@0
   109
		
sl@0
   110
#ifdef _DEBUG
sl@0
   111
	void CheckSourceIsValid(TInt aHandle) const;
sl@0
   112
	void CheckTargetIsValid(TInt aHandle) const;
sl@0
   113
#endif // _DEBUG
sl@0
   114
sl@0
   115
private:
sl@0
   116
	TInt iErrorCode; 	/**< The first error code to occur in any CVgEngine instance.*/
sl@0
   117
	RHashMap<TInt, EGLContext> iPixelContextMap;
sl@0
   118
	RHashMap<TInt, EGLConfig> iPixelConfigMap;
sl@0
   119
	CVgEngine* iCurrentEngine;
sl@0
   120
	CDirectGdiImageTargetImpl* iCurrentTarget;
sl@0
   121
	EGLContext iSharedContext;
sl@0
   122
	EGLDisplay iDisplay;
sl@0
   123
	RPointerArray<CDirectGdiImageRef> iSourceArray;	/**< An array of pointers to all sources created and currently held open by this driver.*/
sl@0
   124
	RPointerArray<CDirectGdiImageRef> iTargetArray;	/**< An array of pointers to all targets created and currently held open by this driver.*/
sl@0
   125
	
sl@0
   126
	CFontGlyphImageStorage* iGlyphImageStorage;
sl@0
   127
	CVgImageCache* iVgImageCache;
sl@0
   128
sl@0
   129
#ifndef __WINS__
sl@0
   130
	static XDirectGdiDriverProcessState gProcessState;
sl@0
   131
#endif
sl@0
   132
	};
sl@0
   133
sl@0
   134
/**
sl@0
   135
@return A reference to the process state object.
sl@0
   136
*/
sl@0
   137
inline XDirectGdiDriverProcessState& CDirectGdiDriverImpl::ProcessState() const
sl@0
   138
	{
sl@0
   139
#ifdef __WINS__
sl@0
   140
	const TUid KDirectGdiAdapterUid = {0x102858E9};
sl@0
   141
	return *Pls<XDirectGdiDriverProcessState>(KDirectGdiAdapterUid);
sl@0
   142
#else
sl@0
   143
	return gProcessState;
sl@0
   144
#endif
sl@0
   145
	}
sl@0
   146
sl@0
   147
/**
sl@0
   148
@return A handle to the EGLDisplay associated with this driver.
sl@0
   149
*/
sl@0
   150
inline EGLDisplay CDirectGdiDriverImpl::EglDisplay() const 
sl@0
   151
	{
sl@0
   152
	return iDisplay; 
sl@0
   153
	}
sl@0
   154
sl@0
   155
#endif //__DIRECTGDIDRIVERIMPL_H__