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