|
1 /* |
|
2 * Copyright (c) 2002 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: Graphics Extension Library source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "GfxColor.h" |
|
20 |
|
21 // -------------------------------------------------------------------------- |
|
22 // TGfxColor::TGfxColor( TUint32 aValue ) |
|
23 // --------------------------------------------------------------------------- |
|
24 TGfxColor::TGfxColor( TUint32 aValue ) |
|
25 { |
|
26 iColor = aValue; |
|
27 } |
|
28 |
|
29 // -------------------------------------------------------------------------- |
|
30 // TGfxColor::TGfxColor( TInt aRed, TInt aGreen, TInt aBlue ) |
|
31 // --------------------------------------------------------------------------- |
|
32 TGfxColor::TGfxColor( TInt aRed, TInt aGreen, TInt aBlue ) |
|
33 { |
|
34 iColor = (aRed<<16)|(aGreen<<8)|aBlue; |
|
35 } |
|
36 |
|
37 // -------------------------------------------------------------------------- |
|
38 // TUint32 TGfxColor::FlatColor() |
|
39 // --------------------------------------------------------------------------- |
|
40 TUint32 TGfxColor::GetColor() |
|
41 { |
|
42 return iColor; |
|
43 } |
|
44 |
|
45 TUint32 TGfxColor::GetARGB() |
|
46 { |
|
47 return iColor; |
|
48 } |
|
49 |
|
50 TUint32 TGfxColor::GetABGR() |
|
51 { |
|
52 return (iColor&0xFF000000) | |
|
53 ((iColor&0x00FF0000) >> 16) | |
|
54 (iColor&0x0000FF00) | |
|
55 ((iColor&0x000000FF) << 16); |
|
56 } |
|
57 |
|
58 |
|
59 |
|
60 // ========================================================================== |
|
61 // BGR888 -> RGB565 - needed for future consideration |
|
62 // ========================================================================== |
|
63 // -------------------------------------------------------------------------- |
|
64 // TUint16 TGfxColor::ColorRgb565() |
|
65 // --------------------------------------------------------------------------- |
|
66 TUint16 TGfxColor::ColorRgb565() |
|
67 { |
|
68 |
|
69 const TInt32 KRmask = 0xf800; |
|
70 const TInt32 KGmask = 0x07e0; |
|
71 const TInt32 KBmask = 0x001f; |
|
72 |
|
73 TUint32 r, g, b; |
|
74 TUint32 val = iColor; |
|
75 b = val << 8 & KRmask; |
|
76 g = val >> 5 & KGmask; |
|
77 r = val >> 19 & KBmask; |
|
78 return ( TUint16 ) ( r | g | b ); |
|
79 } |
|
80 |
|
81 |
|
82 // -------------------------------------------------------------------------- |
|
83 // TUint16 TGfxColor::ColorRgb444() |
|
84 // --------------------------------------------------------------------------- |
|
85 TUint16 TGfxColor::ColorRgb444() |
|
86 { |
|
87 const TInt32 KRmask = 0x0f00; |
|
88 const TInt32 KGmask = 0x00f0; |
|
89 const TInt32 KBmask = 0x000f; |
|
90 |
|
91 TUint32 r, g, b; |
|
92 TUint32 val = iColor; |
|
93 b = val << 4 & KRmask; |
|
94 g = val >> 8 & KGmask; |
|
95 r = val >> 20 & KBmask; |
|
96 return ( TUint16 ) ( r | g | b ); |
|
97 } |
|
98 |
|
99 // -------------------------------------------------------------------------- |
|
100 // TUint16 TGfxColor::ColorRgb() |
|
101 // --------------------------------------------------------------------------- |
|
102 TUint16 TGfxColor::ColorRgb() |
|
103 { |
|
104 return ColorRgb444(); // For EColor4K pixel format mode. |
|
105 |
|
106 } |
|
107 |
|
108 |
|
109 // -------------------------------------------------------------------------- |
|
110 // void TGfxColor::SetFill(VGPaint aFillPaint) |
|
111 // --------------------------------------------------------------------------- |
|
112 void TGfxColor::SetFill(VGPaint aFillPaint, TGfxRectangle2D& aBBox, TFloatFixPt aOpacity,void* aPseudo) |
|
113 { |
|
114 TGfxRectangle2D lBox = aBBox; |
|
115 CVGRenderer *iVgRenderer=(CVGRenderer*) aPseudo; |
|
116 if ( aFillPaint != VG_INVALID_HANDLE ) |
|
117 { |
|
118 iVgRenderer->vgSetParameteri( aFillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR );//pseudo |
|
119 TUint32 opacity = (TInt)(aOpacity * TFloatFixPt(255.0f)); |
|
120 iVgRenderer->vgSetColor( aFillPaint, iColor << 8 | opacity);//pseudo |
|
121 iVgRenderer->vgSetPaint( aFillPaint, VG_FILL_PATH );//pseudo |
|
122 } |
|
123 } |
|
124 |