|
1 // Copyright (c) 2010 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 // Client-side state information for Open VG handle based objects |
|
15 |
|
16 #include "vgstate.h" |
|
17 #include "remotefunctioncall.h" |
|
18 #include "openvgrfc.h" |
|
19 |
|
20 |
|
21 ///////////////////////////////////////////////////////////////////////////////////////////// |
|
22 // CVgFontInfo |
|
23 ///////////////////////////////////////////////////////////////////////////////////////////// |
|
24 |
|
25 CVgFontInfo* CVgFontInfo::New() |
|
26 { |
|
27 RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap(); |
|
28 CVgFontInfo* self = new CVgFontInfo(); |
|
29 CVghwUtils::SwitchFromVghwHeap(clientHeap); |
|
30 return self; |
|
31 } |
|
32 |
|
33 |
|
34 CVgFontInfo::~CVgFontInfo() |
|
35 {} |
|
36 |
|
37 |
|
38 CVgFontInfo::CVgFontInfo() : |
|
39 CVgHandleBase(EVgHandleForFont) |
|
40 {} |
|
41 |
|
42 |
|
43 TBool CVgFontInfo::DestroyObject(MVgContext& aVgContext) |
|
44 { |
|
45 VGPANIC_ASSERT_DEBUG(iIsDestroyed, EVgPanicTemp); |
|
46 OPENVG_TRACE(" CVgFontInfo::DestroyObject HostHandle=0x%x", iHostHandle); |
|
47 |
|
48 if (iHostHandle) |
|
49 { |
|
50 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
51 vgApiData.Init(OpenVgRFC::EvgDestroyFont, RemoteFunctionCallData::EOpRequest); |
|
52 vgApiData.AppendParam(iHostHandle); |
|
53 aVgContext.ExecuteVgCommand(vgApiData); |
|
54 } |
|
55 |
|
56 return ETrue; |
|
57 } |
|
58 |
|
59 |
|
60 VGint CVgFontInfo::GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType) |
|
61 { |
|
62 switch (aParamType) |
|
63 { |
|
64 case VG_FONT_NUM_GLYPHS: |
|
65 return 1; |
|
66 } |
|
67 |
|
68 // invalid ParamType |
|
69 aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); |
|
70 return 0; |
|
71 } |
|
72 |
|
73 |
|
74 void CVgFontInfo::SetGlyphToPath(MVgContext& aVgContext, VGuint aGlyphIndex, CVgPathInfo* aPathInfo, VGboolean aIsHinted, |
|
75 const VGfloat aGlyphOrigin [2], const VGfloat aEscapement[2]) |
|
76 { |
|
77 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
78 vgApiData.Init(OpenVgRFC::EvgSetGlyphToPath, RemoteFunctionCallData::EOpRequest); |
|
79 vgApiData.AppendParam(iHostHandle); |
|
80 vgApiData.AppendParam(aGlyphIndex); |
|
81 vgApiData.AppendParam( (aPathInfo == NULL) ? VG_INVALID_HANDLE : aPathInfo->HostHandle()); |
|
82 vgApiData.AppendParam(aIsHinted); |
|
83 vgApiData.AppendVector(aGlyphOrigin, 2); |
|
84 vgApiData.AppendVector(aEscapement, 2); |
|
85 aVgContext.ExecuteVgCommand(vgApiData); |
|
86 } |
|
87 |
|
88 |
|
89 void CVgFontInfo::SetGlyphToImage(MVgContext& aVgContext, VGuint aGlyphIndex, CVgImageInfo* aImageInfo, const VGfloat aGlyphOrigin [2], |
|
90 const VGfloat aEscapement[2]) |
|
91 { |
|
92 // ToDo track use of VG Images (esp SgImages) as Font Glyphs |
|
93 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
94 vgApiData.Init(OpenVgRFC::EvgSetGlyphToImage, RemoteFunctionCallData::EOpRequest); |
|
95 vgApiData.AppendParam(iHostHandle); |
|
96 vgApiData.AppendParam(aGlyphIndex); |
|
97 vgApiData.AppendParam( (aImageInfo == NULL) ? VG_INVALID_HANDLE : aImageInfo->HostHandle()); |
|
98 vgApiData.AppendVector(aGlyphOrigin, 2); |
|
99 vgApiData.AppendVector(aEscapement, 2); |
|
100 TUint64 sgId(0L); |
|
101 if (aImageInfo && aImageInfo->IsEglSibling()) |
|
102 { |
|
103 sgId = aImageInfo->SgImageId(); |
|
104 } |
|
105 vgApiData.AppendTUint64(sgId); |
|
106 aVgContext.ExecuteVgCommand(vgApiData); |
|
107 } |
|
108 |
|
109 |
|
110 void CVgFontInfo::ClearGlyph(MVgContext& aVgContext, VGuint aGlyphIndex) |
|
111 { |
|
112 // **** Desirable: verify aGlyphIndex, ToDo decrement SgImage reference count |
|
113 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
114 vgApiData.Init(OpenVgRFC::EvgClearGlyph, RemoteFunctionCallData::EOpRequest); |
|
115 vgApiData.AppendParam(iHostHandle); |
|
116 vgApiData.AppendParam(aGlyphIndex); |
|
117 aVgContext.ExecuteVgCommand(vgApiData); |
|
118 } |
|
119 |
|
120 |
|
121 void CVgFontInfo::DrawGlyph(MVgContext& aVgContext, VGuint aGlyphIndex, VGbitfield aPaintModes, VGboolean aAllowAutoHinting) |
|
122 { |
|
123 // **** Desirable: verify aGlyphIndex |
|
124 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
125 vgApiData.Init(OpenVgRFC::EvgDrawGlyph, RemoteFunctionCallData::EOpRequest); |
|
126 vgApiData.AppendParam(iHostHandle); |
|
127 vgApiData.AppendParam(aGlyphIndex); |
|
128 vgApiData.AppendParam(aPaintModes); |
|
129 vgApiData.AppendParam(aAllowAutoHinting); |
|
130 aVgContext.ExecuteVgCommand(vgApiData); |
|
131 } |
|
132 |
|
133 |
|
134 void CVgFontInfo::DrawGlyphs(MVgContext& aVgContext, VGint aGlyphCount, const VGuint * aGlyphIndices, const VGfloat * aAdjustmentsX, |
|
135 const VGfloat * aAdjustmentsY, VGbitfield aPaintModes, VGboolean aAllowAutoHinting) |
|
136 { |
|
137 // **** Desirable: verify glyph indices? |
|
138 if (aGlyphCount <= 0) |
|
139 { |
|
140 aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); |
|
141 } |
|
142 else |
|
143 { |
|
144 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
145 vgApiData.Init(OpenVgRFC::EvgDrawGlyphs, RemoteFunctionCallData::EOpRequest); |
|
146 vgApiData.AppendParam(iHostHandle); |
|
147 vgApiData.AppendParam(aGlyphCount); |
|
148 vgApiData.AppendVector(aGlyphIndices, aGlyphCount); |
|
149 vgApiData.AppendVector(aAdjustmentsX, (aAdjustmentsX == NULL) ? 0 : aGlyphCount); |
|
150 vgApiData.AppendVector(aAdjustmentsY, (aAdjustmentsY == NULL) ? 0 : aGlyphCount); |
|
151 vgApiData.AppendParam(aPaintModes); |
|
152 vgApiData.AppendParam(aAllowAutoHinting); |
|
153 aVgContext.ExecuteVgCommand(vgApiData); |
|
154 } |
|
155 } |
|
156 |
|
157 |
|
158 // end of file vgfont.cpp |