|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Native side interface for DirectGraphics java class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMIDDIRECTGRAPHICS_H |
|
20 #define CMIDDIRECTGRAPHICS_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 |
|
25 #include "TMIDTriangleFiller.h" |
|
26 #include "TMIDInternalARGB.h" |
|
27 |
|
28 // CONSTANTS |
|
29 const TInt KDottedLine = 1; |
|
30 const TInt KDottedLineStep = 4; |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CPolygonFiller; |
|
34 class CMIDConvertFactory; |
|
35 class CMIDNativeConverter; |
|
36 class TMIDBitmapParameters; |
|
37 #ifdef RD_JAVA_NGA_ENABLED |
|
38 class MMIDCanvas; |
|
39 #endif |
|
40 |
|
41 // CLASS DEFINITION |
|
42 /** |
|
43 * This class is native side interface for DirectGraphics java class. |
|
44 * |
|
45 */ |
|
46 NONSHARABLE_CLASS(CMIDDirectGraphics): public CBase |
|
47 { |
|
48 public: // polygon drawing parameter |
|
49 class TPolygonParameters |
|
50 { |
|
51 public: |
|
52 |
|
53 TInt* aXPoints; |
|
54 TInt aXPointsLength; |
|
55 TInt aXOffset; |
|
56 TInt aTransX; |
|
57 TInt* aYPoints; |
|
58 TInt aYPointsLength; |
|
59 TInt aYOffset; |
|
60 TInt aTransY; |
|
61 TInt aNumberOfPoints; |
|
62 TInt aARGBColor; |
|
63 TBool aFill; |
|
64 }; |
|
65 |
|
66 public: // Construction |
|
67 static CMIDDirectGraphics* NewL(CMIDGraphics* aGraphics, |
|
68 MMIDImage* aImage); |
|
69 |
|
70 public: // Destruction |
|
71 ~CMIDDirectGraphics(); |
|
72 |
|
73 public: // New methods |
|
74 |
|
75 // Sets clip rect. This method is normally called from CMIDGraphics |
|
76 void SetClippingRect(TRect aRect); |
|
77 |
|
78 // Sets specified color to image. Includes transparency |
|
79 void SetColorL(TUint32 aColor, TInt aImageHandle); |
|
80 |
|
81 // Drawing and getting bitmaps |
|
82 void DrawBitmapL(TMIDBitmapParameters* aParams); |
|
83 void GetBitmapL(TMIDBitmapParameters* aParams); |
|
84 |
|
85 // Polygon drawing |
|
86 void DrawPolygonL(TPolygonParameters* aParams); |
|
87 |
|
88 // Triangle drawing |
|
89 void DrawTriangle(const TInt aX1, const TInt aY1, const TInt aX2, const TInt aY2, |
|
90 const TInt aX3, const TInt aY3, |
|
91 const TUint32 aColor); |
|
92 void FillTriangle(const TInt aX1, const TInt aY1, const TInt aX2, const TInt aY2, |
|
93 const TInt aX3, const TInt aY3, |
|
94 const TUint32 aColor); |
|
95 // Native pixel format |
|
96 inline TInt GetNativePixelFormat() |
|
97 { |
|
98 return iNativePixelFormat; |
|
99 } |
|
100 |
|
101 protected: |
|
102 // protected construction |
|
103 CMIDDirectGraphics(); |
|
104 void ConstructL(CMIDGraphics* aGraphics, MMIDImage* aImage); |
|
105 |
|
106 private: |
|
107 void DrawLine(const TPoint& aPointA, const TPoint& aPointB, |
|
108 const TMIDInternalARGB& aColor); |
|
109 |
|
110 TInt CalculateScanLength(const TInt aWidth, |
|
111 const TDisplayMode aDisplayMode); |
|
112 |
|
113 private: // data |
|
114 // screen size |
|
115 TSize iScreenSize; |
|
116 |
|
117 // clipping rect |
|
118 TRect iClipRect; |
|
119 |
|
120 // converter to bitmap |
|
121 CMIDNativeConverter* iNativeConverter; |
|
122 |
|
123 CPolygonFiller* iPolygonFiller; |
|
124 TBool iDottedLine; |
|
125 |
|
126 // not owned |
|
127 CMIDGraphics* iGraphics; |
|
128 |
|
129 TInt iNativePixelFormat; |
|
130 CMIDConvertFactory* iConverterFactory; |
|
131 |
|
132 #ifdef RD_JAVA_NGA_ENABLED |
|
133 MMIDCanvas* iCanvasTarget; |
|
134 #endif |
|
135 }; |
|
136 |
|
137 |
|
138 |
|
139 #endif // CMIDDIRECTGRAPHICS_H |