os/graphics/graphicsdeviceinterface/directgdiadaptation/hwsrc/directgdidriverimpl.h
First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Declaration of a Direct Graphics Device Interface (GDI) Driver implementation,
15 // this class actually implements the HAI.
20 #ifndef __DIRECTGDIDRIVERIMPL_H__
21 #define __DIRECTGDIDRIVERIMPL_H__
25 @internalComponent Reference implementation of Open VG hardware accelerated DirectGDI adaptation.
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>
39 // Forward declarations.
41 class CDirectGdiImageTargetImpl;
42 class CDirectGdiImageSourceImpl;
44 class CDirectGdiDrawableRef;
45 class RDirectGdiImageTarget;
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.
51 NONSHARABLE_CLASS(CDirectGdiDriverImpl): public CDirectGdiDriverInternal, public MDirectGdiDriverCacheSize
54 static TInt New(CDirectGdiDriverInternal*& aInternal, RLibrary aLibrary);
55 ~CDirectGdiDriverImpl();
57 // From CDirectGdiDriverInternal
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);
70 // From MDirectGdiDriverCacheSize
71 TInt SetMaxImageCacheSize(TInt aSize);
72 TInt MaxImageCacheSize() const;
73 TInt SetMaxGlyphCacheSize(TInt aSize);
74 TInt MaxGlyphCacheSize() const;
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;
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;
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);
95 TInt RegisterSourceImage(const CDirectGdiImageSourceImpl& aImage);
96 TInt RegisterTargetImage(const CDirectGdiImageTargetImpl& aImage);
97 TInt UnregisterSourceImage(const CDirectGdiImageSourceImpl& aImage);
98 TInt UnregisterTargetImage(const CDirectGdiImageTargetImpl& aImage);
100 inline EGLDisplay EglDisplay() const;
101 inline XDirectGdiDriverProcessState& ProcessState() const;
103 static TInt GetVgError();
106 CDirectGdiDriverImpl(RLibrary aLibrary);
108 TInt InitializeEglConfigs(EGLDisplay display);
111 void CheckSourceIsValid(TInt aHandle) const;
112 void CheckTargetIsValid(TInt aHandle) const;
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;
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.*/
126 CFontGlyphImageStorage* iGlyphImageStorage;
127 CVgImageCache* iVgImageCache;
130 static XDirectGdiDriverProcessState gProcessState;
135 @return A reference to the process state object.
137 inline XDirectGdiDriverProcessState& CDirectGdiDriverImpl::ProcessState() const
140 const TUid KDirectGdiAdapterUid = {0x102858E9};
141 return *Pls<XDirectGdiDriverProcessState>(KDirectGdiAdapterUid);
143 return gProcessState;
148 @return A handle to the EGLDisplay associated with this driver.
150 inline EGLDisplay CDirectGdiDriverImpl::EglDisplay() const
155 #endif //__DIRECTGDIDRIVERIMPL_H__