|
1 /* |
|
2 * Copyright (c) 2004-2006 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: Remote video handler. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "CVtEngDrawDP.h" |
|
22 #include "CVtEngEventManager.h" |
|
23 #include "CVtEngSettings.h" |
|
24 #include "VtEngUtils.h" |
|
25 #include "MVtEngFrameObserver.h" |
|
26 #include <videotelephonyvariant.hrh> |
|
27 #include <tdisplaysinkparamsdp.h> |
|
28 #include <cvtlogger.h> |
|
29 #include <posting_surface_factory.h> |
|
30 |
|
31 #include <cvtimagebitmap.h> |
|
32 |
|
33 // LOCAL CONSTANTS AND MACROS |
|
34 |
|
35 // YCbCr conversion constants |
|
36 |
|
37 // Luma |
|
38 static const TUint32 KYLut[ 256 ] = |
|
39 { |
|
40 0x00000000, 0x00400801, 0x00801002, 0x00C01803, |
|
41 0x01002004, 0x01402805, 0x01803006, 0x01C03807, |
|
42 0x02004008, 0x02404809, 0x0280500A, 0x02C0580B, |
|
43 0x0300600C, 0x0340680D, 0x0380700E, 0x03C0780F, |
|
44 0x04008010, 0x04408811, 0x04809012, 0x04C09813, |
|
45 0x0500A014, 0x0540A815, 0x0580B016, 0x05C0B817, |
|
46 0x0600C018, 0x0640C819, 0x0680D01A, 0x06C0D81B, |
|
47 0x0700E01C, 0x0740E81D, 0x0780F01E, 0x07C0F81F, |
|
48 0x08010020, 0x08410821, 0x08811022, 0x08C11823, |
|
49 0x09012024, 0x09412825, 0x09813026, 0x09C13827, |
|
50 0x0A014028, 0x0A414829, 0x0A81502A, 0x0AC1582B, |
|
51 0x0B01602C, 0x0B41682D, 0x0B81702E, 0x0BC1782F, |
|
52 0x0C018030, 0x0C418831, 0x0C819032, 0x0CC19833, |
|
53 0x0D01A034, 0x0D41A835, 0x0D81B036, 0x0DC1B837, |
|
54 0x0E01C038, 0x0E41C839, 0x0E81D03A, 0x0EC1D83B, |
|
55 0x0F01E03C, 0x0F41E83D, 0x0F81F03E, 0x0FC1F83F, |
|
56 0x10020040, 0x10420841, 0x10821042, 0x10C21843, |
|
57 0x11022044, 0x11422845, 0x11823046, 0x11C23847, |
|
58 0x12024048, 0x12424849, 0x1282504A, 0x12C2584B, |
|
59 0x1302604C, 0x1342684D, 0x1382704E, 0x13C2784F, |
|
60 0x14028050, 0x14428851, 0x14829052, 0x14C29853, |
|
61 0x1502A054, 0x1542A855, 0x1582B056, 0x15C2B857, |
|
62 0x1602C058, 0x1642C859, 0x1682D05A, 0x16C2D85B, |
|
63 0x1702E05C, 0x1742E85D, 0x1782F05E, 0x17C2F85F, |
|
64 0x18030060, 0x18430861, 0x18831062, 0x18C31863, |
|
65 0x19032064, 0x19432865, 0x19833066, 0x19C33867, |
|
66 0x1A034068, 0x1A434869, 0x1A83506A, 0x1AC3586B, |
|
67 0x1B03606C, 0x1B43686D, 0x1B83706E, 0x1BC3786F, |
|
68 0x1C038070, 0x1C438871, 0x1C839072, 0x1CC39873, |
|
69 0x1D03A074, 0x1D43A875, 0x1D83B076, 0x1DC3B877, |
|
70 0x1E03C078, 0x1E43C879, 0x1E83D07A, 0x1EC3D87B, |
|
71 0x1F03E07C, 0x1F43E87D, 0x1F83F07E, 0x1FC3F87F, |
|
72 0x20040080, 0x20440881, 0x20841082, 0x20C41883, |
|
73 0x21042084, 0x21442885, 0x21843086, 0x21C43887, |
|
74 0x22044088, 0x22444889, 0x2284508A, 0x22C4588B, |
|
75 0x2304608C, 0x2344688D, 0x2384708E, 0x23C4788F, |
|
76 0x24048090, 0x24448891, 0x24849092, 0x24C49893, |
|
77 0x2504A094, 0x2544A895, 0x2584B096, 0x25C4B897, |
|
78 0x2604C098, 0x2644C899, 0x2684D09A, 0x26C4D89B, |
|
79 0x2704E09C, 0x2744E89D, 0x2784F09E, 0x27C4F89F, |
|
80 0x280500A0, 0x284508A1, 0x288510A2, 0x28C518A3, |
|
81 0x290520A4, 0x294528A5, 0x298530A6, 0x29C538A7, |
|
82 0x2A0540A8, 0x2A4548A9, 0x2A8550AA, 0x2AC558AB, |
|
83 0x2B0560AC, 0x2B4568AD, 0x2B8570AE, 0x2BC578AF, |
|
84 0x2C0580B0, 0x2C4588B1, 0x2C8590B2, 0x2CC598B3, |
|
85 0x2D05A0B4, 0x2D45A8B5, 0x2D85B0B6, 0x2DC5B8B7, |
|
86 0x2E05C0B8, 0x2E45C8B9, 0x2E85D0BA, 0x2EC5D8BB, |
|
87 0x2F05E0BC, 0x2F45E8BD, 0x2F85F0BE, 0x2FC5F8BF, |
|
88 0x300600C0, 0x304608C1, 0x308610C2, 0x30C618C3, |
|
89 0x310620C4, 0x314628C5, 0x318630C6, 0x31C638C7, |
|
90 0x320640C8, 0x324648C9, 0x328650CA, 0x32C658CB, |
|
91 0x330660CC, 0x334668CD, 0x338670CE, 0x33C678CF, |
|
92 0x340680D0, 0x344688D1, 0x348690D2, 0x34C698D3, |
|
93 0x3506A0D4, 0x3546A8D5, 0x3586B0D6, 0x35C6B8D7, |
|
94 0x3606C0D8, 0x3646C8D9, 0x3686D0DA, 0x36C6D8DB, |
|
95 0x3706E0DC, 0x3746E8DD, 0x3786F0DE, 0x37C6F8DF, |
|
96 0x380700E0, 0x384708E1, 0x388710E2, 0x38C718E3, |
|
97 0x390720E4, 0x394728E5, 0x398730E6, 0x39C738E7, |
|
98 0x3A0740E8, 0x3A4748E9, 0x3A8750EA, 0x3AC758EB, |
|
99 0x3B0760EC, 0x3B4768ED, 0x3B8770EE, 0x3BC778EF, |
|
100 0x3C0780F0, 0x3C4788F1, 0x3C8790F2, 0x3CC798F3, |
|
101 0x3D07A0F4, 0x3D47A8F5, 0x3D87B0F6, 0x3DC7B8F7, |
|
102 0x3E07C0F8, 0x3E47C8F9, 0x3E87D0FA, 0x3EC7D8FB, |
|
103 0x3F07E0FC, 0x3F47E8FD, 0x3F87F0FE, 0x3FC7F8FF |
|
104 }; |
|
105 |
|
106 // Chroma1 (Cb) |
|
107 static const TUint32 KCbLut[ 256 ] = |
|
108 { |
|
109 0x0001531C, 0x00014B1E, 0x00014B20, 0x00014B22, |
|
110 0x00014324, 0x00014325, 0x00014327, 0x00013B29, |
|
111 0x00013B2B, 0x00013B2D, 0x0001332E, 0x00013330, |
|
112 0x00013332, 0x00012B34, 0x00012B35, 0x00012B37, |
|
113 0x00012339, 0x0001233B, 0x0001233D, 0x00011B3E, |
|
114 0x00011B40, 0x00011B42, 0x00011344, 0x00011345, |
|
115 0x00011347, 0x00010B49, 0x00010B4B, 0x00010B4D, |
|
116 0x0001034E, 0x00010350, 0x00010352, 0x0000FB54, |
|
117 0x0000FB55, 0x0000FB57, 0x0000F359, 0x0000F35B, |
|
118 0x0000F35D, 0x0000EB5E, 0x0000EB60, 0x0000EB62, |
|
119 0x0000E364, 0x0000E366, 0x0000E367, 0x0000DB69, |
|
120 0x0000DB6B, 0x0000DB6D, 0x0000D36E, 0x0000D370, |
|
121 0x0000D372, 0x0000CB74, 0x0000CB76, 0x0000CB77, |
|
122 0x0000C379, 0x0000C37B, 0x0000C37D, 0x0000BB7E, |
|
123 0x0000BB80, 0x0000BB82, 0x0000B384, 0x0000B386, |
|
124 0x0000B387, 0x0000AB89, 0x0000AB8B, 0x0000AB8D, |
|
125 0x0000AB8E, 0x0000A390, 0x0000A392, 0x0000A394, |
|
126 0x00009B96, 0x00009B97, 0x00009B99, 0x0000939B, |
|
127 0x0000939D, 0x0000939F, 0x00008BA0, 0x00008BA2, |
|
128 0x00008BA4, 0x000083A6, 0x000083A7, 0x000083A9, |
|
129 0x00007BAB, 0x00007BAD, 0x00007BAF, 0x000073B0, |
|
130 0x000073B2, 0x000073B4, 0x00006BB6, 0x00006BB7, |
|
131 0x00006BB9, 0x000063BB, 0x000063BD, 0x000063BF, |
|
132 0x00005BC0, 0x00005BC2, 0x00005BC4, 0x000053C6, |
|
133 0x000053C7, 0x000053C9, 0x00004BCB, 0x00004BCD, |
|
134 0x00004BCF, 0x000043D0, 0x000043D2, 0x000043D4, |
|
135 0x00003BD6, 0x00003BD8, 0x00003BD9, 0x000033DB, |
|
136 0x000033DD, 0x000033DF, 0x00002BE0, 0x00002BE2, |
|
137 0x00002BE4, 0x000023E6, 0x000023E8, 0x000023E9, |
|
138 0x00001BEB, 0x00001BED, 0x00001BEF, 0x000013F0, |
|
139 0x000013F2, 0x000013F4, 0x00000BF6, 0x00000BF8, |
|
140 0x00000BF9, 0x000003FB, 0x000003FD, 0x000003FF, |
|
141 0x00000000, 0x00000001, 0x00000003, 0x00000005, |
|
142 0x001FF807, 0x001FF808, 0x001FF80A, 0x001FF00C, |
|
143 0x001FF00E, 0x001FF010, 0x001FE811, 0x001FE813, |
|
144 0x001FE815, 0x001FE017, 0x001FE018, 0x001FE01A, |
|
145 0x001FD81C, 0x001FD81E, 0x001FD820, 0x001FD021, |
|
146 0x001FD023, 0x001FD025, 0x001FC827, 0x001FC828, |
|
147 0x001FC82A, 0x001FC02C, 0x001FC02E, 0x001FC030, |
|
148 0x001FB831, 0x001FB833, 0x001FB835, 0x001FB037, |
|
149 0x001FB039, 0x001FB03A, 0x001FA83C, 0x001FA83E, |
|
150 0x001FA840, 0x001FA041, 0x001FA043, 0x001FA045, |
|
151 0x001F9847, 0x001F9849, 0x001F984A, 0x001F904C, |
|
152 0x001F904E, 0x001F9050, 0x001F8851, 0x001F8853, |
|
153 0x001F8855, 0x001F8057, 0x001F8059, 0x001F805A, |
|
154 0x001F785C, 0x001F785E, 0x001F7860, 0x001F7061, |
|
155 0x001F7063, 0x001F7065, 0x001F6867, 0x001F6869, |
|
156 0x001F686A, 0x001F606C, 0x001F606E, 0x001F6070, |
|
157 0x001F5872, 0x001F5873, 0x001F5875, 0x001F5877, |
|
158 0x001F5079, 0x001F507A, 0x001F507C, 0x001F487E, |
|
159 0x001F4880, 0x001F4882, 0x001F4083, 0x001F4085, |
|
160 0x001F4087, 0x001F3889, 0x001F388A, 0x001F388C, |
|
161 0x001F308E, 0x001F3090, 0x001F3092, 0x001F2893, |
|
162 0x001F2895, 0x001F2897, 0x001F2099, 0x001F209A, |
|
163 0x001F209C, 0x001F189E, 0x001F18A0, 0x001F18A2, |
|
164 0x001F10A3, 0x001F10A5, 0x001F10A7, 0x001F08A9, |
|
165 0x001F08AB, 0x001F08AC, 0x001F00AE, 0x001F00B0, |
|
166 0x001F00B2, 0x001EF8B3, 0x001EF8B5, 0x001EF8B7, |
|
167 0x001EF0B9, 0x001EF0BB, 0x001EF0BC, 0x001EE8BE, |
|
168 0x001EE8C0, 0x001EE8C2, 0x001EE0C3, 0x001EE0C5, |
|
169 0x001EE0C7, 0x001ED8C9, 0x001ED8CB, 0x001ED8CC, |
|
170 0x001ED0CE, 0x001ED0D0, 0x001ED0D2, 0x001EC8D3, |
|
171 0x001EC8D5, 0x001EC8D7, 0x001EC0D9, 0x001EC0DB, |
|
172 0x001EC0DC, 0x001EB8DE, 0x001EB8E0, 0x001EB8E2 |
|
173 }; |
|
174 |
|
175 // Chroma1 (Cr) |
|
176 static const TUint32 KCrLut[ 256 ] = |
|
177 { |
|
178 0xD302D000, 0xD382C800, 0xD3C2C000, 0xD442B800, |
|
179 0xD482B800, 0xD502B000, 0xD542A800, 0xD582A800, |
|
180 0xD602A000, 0xD6429800, 0xD6C29000, 0xD7029000, |
|
181 0xD7428800, 0xD7C28000, 0xD8028000, 0xD8827800, |
|
182 0xD8C27000, 0xD9027000, 0xD9826800, 0xD9C26000, |
|
183 0xDA425800, 0xDA825800, 0xDAC25000, 0xDB424800, |
|
184 0xDB824800, 0xDC024000, 0xDC423800, 0xDC823800, |
|
185 0xDD023000, 0xDD422800, 0xDDC22000, 0xDE022000, |
|
186 0xDE421800, 0xDEC21000, 0xDF021000, 0xDF820800, |
|
187 0xDFC20000, 0xE041F800, 0xE081F800, 0xE0C1F000, |
|
188 0xE141E800, 0xE181E800, 0xE201E000, 0xE241D800, |
|
189 0xE281D800, 0xE301D000, 0xE341C800, 0xE3C1C000, |
|
190 0xE401C000, 0xE441B800, 0xE4C1B000, 0xE501B000, |
|
191 0xE581A800, 0xE5C1A000, 0xE601A000, 0xE6819800, |
|
192 0xE6C19000, 0xE7418800, 0xE7818800, 0xE7C18000, |
|
193 0xE8417800, 0xE8817800, 0xE9017000, 0xE9416800, |
|
194 0xE9816800, 0xEA016000, 0xEA415800, 0xEAC15000, |
|
195 0xEB015000, 0xEB814800, 0xEBC14000, 0xEC014000, |
|
196 0xEC813800, 0xECC13000, 0xED412800, 0xED812800, |
|
197 0xEDC12000, 0xEE411800, 0xEE811800, 0xEF011000, |
|
198 0xEF410800, 0xEF810800, 0xF0010000, 0xF040F800, |
|
199 0xF0C0F000, 0xF100F000, 0xF140E800, 0xF1C0E000, |
|
200 0xF200E000, 0xF280D800, 0xF2C0D000, 0xF300D000, |
|
201 0xF380C800, 0xF3C0C000, 0xF440B800, 0xF480B800, |
|
202 0xF4C0B000, 0xF540A800, 0xF580A800, 0xF600A000, |
|
203 0xF6409800, 0xF6C09000, 0xF7009000, 0xF7408800, |
|
204 0xF7C08000, 0xF8008000, 0xF8807800, 0xF8C07000, |
|
205 0xF9007000, 0xF9806800, 0xF9C06000, 0xFA405800, |
|
206 0xFA805800, 0xFAC05000, 0xFB404800, 0xFB804800, |
|
207 0xFC004000, 0xFC403800, 0xFC803800, 0xFD003000, |
|
208 0xFD402800, 0xFDC02000, 0xFE002000, 0xFE401800, |
|
209 0xFEC01000, 0xFF001000, 0xFF800800, 0xFFC00000, |
|
210 0x00000000, 0x00400000, 0x009FF800, 0x011FF000, |
|
211 0x015FF000, 0x01DFE800, 0x021FE000, 0x025FE000, |
|
212 0x02DFD800, 0x031FD000, 0x039FC800, 0x03DFC800, |
|
213 0x041FC000, 0x049FB800, 0x04DFB800, 0x055FB000, |
|
214 0x059FA800, 0x05DFA800, 0x065FA000, 0x069F9800, |
|
215 0x071F9000, 0x075F9000, 0x079F8800, 0x081F8000, |
|
216 0x085F8000, 0x08DF7800, 0x091F7000, 0x095F7000, |
|
217 0x09DF6800, 0x0A1F6000, 0x0A9F5800, 0x0ADF5800, |
|
218 0x0B5F5000, 0x0B9F4800, 0x0BDF4800, 0x0C5F4000, |
|
219 0x0C9F3800, 0x0D1F3000, 0x0D5F3000, 0x0D9F2800, |
|
220 0x0E1F2000, 0x0E5F2000, 0x0EDF1800, 0x0F1F1000, |
|
221 0x0F5F1000, 0x0FDF0800, 0x101F0000, 0x109EF800, |
|
222 0x10DEF800, 0x111EF000, 0x119EE800, 0x11DEE800, |
|
223 0x125EE000, 0x129ED800, 0x12DED800, 0x135ED000, |
|
224 0x139EC800, 0x141EC000, 0x145EC000, 0x149EB800, |
|
225 0x151EB000, 0x155EB000, 0x15DEA800, 0x161EA000, |
|
226 0x169E9800, 0x16DE9800, 0x171E9000, 0x179E8800, |
|
227 0x17DE8800, 0x185E8000, 0x189E7800, 0x18DE7800, |
|
228 0x195E7000, 0x199E6800, 0x1A1E6000, 0x1A5E6000, |
|
229 0x1A9E5800, 0x1B1E5000, 0x1B5E5000, 0x1BDE4800, |
|
230 0x1C1E4000, 0x1C5E4000, 0x1CDE3800, 0x1D1E3000, |
|
231 0x1D9E2800, 0x1DDE2800, 0x1E1E2000, 0x1E9E1800, |
|
232 0x1EDE1800, 0x1F5E1000, 0x1F9E0800, 0x1FDE0800, |
|
233 0x205E0000, 0x209DF800, 0x211DF000, 0x215DF000, |
|
234 0x21DDE800, 0x221DE000, 0x225DE000, 0x22DDD800, |
|
235 0x231DD000, 0x239DC800, 0x23DDC800, 0x241DC000, |
|
236 0x249DB800, 0x24DDB800, 0x255DB000, 0x259DA800, |
|
237 0x25DDA800, 0x265DA000, 0x269D9800, 0x271D9000, |
|
238 0x275D9000, 0x279D8800, 0x281D8000, 0x285D8000, |
|
239 0x28DD7800, 0x291D7000, 0x295D7000, 0x29DD6800, |
|
240 0x2A1D6000, 0x2A9D5800, 0x2ADD5800, 0x2B1D5000, |
|
241 0x2B9D4800, 0x2BDD4800, 0x2C5D4000, 0x2C9D3800 |
|
242 }; |
|
243 |
|
244 |
|
245 // Posting surface factory DLL's name |
|
246 _LIT( KDPAPIDLLName, "PostingSurfaceFactory.dll" ); |
|
247 |
|
248 // Reversed enumeration for the bitmaps. |
|
249 static const MDisplaySink::TBitmapNo KVtEngBitmapNoReversed[] = |
|
250 { |
|
251 MDisplaySink::ESecondBitmap, |
|
252 MDisplaySink::EFirstBitmap |
|
253 }; |
|
254 |
|
255 // Default posting format (if this or KDefaultPostingFormat420 is not |
|
256 // supported, BaseConstructL() will leave with KErrNotSupported) |
|
257 const CPostingSurface::TPostingFormat KDefaultPostingFormat422 = |
|
258 CPostingSurface::EYuv422LeBt601Range0; |
|
259 |
|
260 // Default posting format (if this or KDefaultPostingFormat422 is not |
|
261 // supported, BaseConstructL() will leave with KErrNotSupported) |
|
262 const CPostingSurface::TPostingFormat KDefaultPostingFormat420 = |
|
263 CPostingSurface::EYuv420PlanarBt601Range0; |
|
264 |
|
265 // Default posting buffering flags. |
|
266 const TUint KDefaultPostingBufferingFlags = |
|
267 // Double buffering |
|
268 CPostingSurface::EDoubleBuffering | |
|
269 // Progressive frames (no interlacing) |
|
270 CPostingSurface::EProgressiveFrames | |
|
271 // Do not allow frameskip |
|
272 CPostingSurface::EDisAllowFrameSkip | |
|
273 // Use internal buffers (allocated by DP) |
|
274 CPostingSurface::EInternalBuffers; |
|
275 |
|
276 // Default pixel aspect ratio num. Aspect ratio = Num/Denom. |
|
277 const TUint16 KDefaultPixelAspectRatioNum = 1; |
|
278 |
|
279 // Default pixel aspect ratio denom. Aspect ratio = Num/Denom. |
|
280 const TUint16 KDefaultPixelAspectRatioDenom = 1; |
|
281 |
|
282 // LOCAL METHODS |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // DoConvertYuv420toXRGB0888 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 inline void DoConvertYuv420toXRGB0888( |
|
289 TInt aWidth, // width in pixels |
|
290 const TUint8*& aSourceDataPtrY1, // pointer to Y data row 1 |
|
291 const TUint8*& aSourceDataPtrY2, // pointer to Y data row 2 |
|
292 const TUint8*& aSourceDataPtrU, // pointer to U data row |
|
293 const TUint8*& aSourceDataPtrV, // pointer to V data row |
|
294 TUint8* aDestDataPtr1, // pointer to destination row 1 |
|
295 TUint8* aDestDataPtr2 // pointer to destination row 2 |
|
296 ) |
|
297 { |
|
298 TUint32* destDataPtr1 = reinterpret_cast< TUint32* >( aDestDataPtr1 ); |
|
299 TUint32* destDataPtr2 = reinterpret_cast< TUint32* >( aDestDataPtr2 ); |
|
300 // width assumed to be even |
|
301 TInt pixelsLeft = aWidth / 2; |
|
302 |
|
303 TUint32 r, g, b; |
|
304 TUint32 LutY0, LutY1, LutC; |
|
305 TUint32 pixel; |
|
306 TUint32 OverflowMask = 0xC0180300U; |
|
307 |
|
308 // One scanline at the time |
|
309 while ( pixelsLeft-- ) |
|
310 { |
|
311 |
|
312 // row 1, 2 pixels |
|
313 |
|
314 LutY0 = KYLut[*aSourceDataPtrY1++]; |
|
315 LutY1 = KYLut[*aSourceDataPtrY1++]; |
|
316 LutC = KCbLut[*aSourceDataPtrU++]; |
|
317 LutC += KCrLut[*aSourceDataPtrV++]; |
|
318 |
|
319 pixel = LutY0 + LutC; |
|
320 |
|
321 if (pixel & OverflowMask) |
|
322 { |
|
323 if (pixel & 0xC0000000U) |
|
324 { |
|
325 if (pixel & 0x80000000U) |
|
326 { |
|
327 pixel &= ~0x3FC00000U; |
|
328 } |
|
329 else |
|
330 { |
|
331 pixel |= 0x3FC00000U; |
|
332 } |
|
333 } |
|
334 if (pixel & 0x00180000U) |
|
335 { |
|
336 if (pixel & 0x00100000U) |
|
337 { |
|
338 pixel &= ~0x0007F800U; |
|
339 } |
|
340 else |
|
341 { |
|
342 pixel |= 0x0007F800U; |
|
343 } |
|
344 } |
|
345 if (pixel & 0x00000300U) |
|
346 { |
|
347 if (pixel & 0x00000200U) |
|
348 { |
|
349 pixel &= ~0x000000FFU; |
|
350 } |
|
351 else |
|
352 { |
|
353 pixel |= 0x000000FFU; |
|
354 } |
|
355 } |
|
356 } |
|
357 |
|
358 r = (pixel >> 6) & 0xFF0000; |
|
359 g = (pixel >> 3) & 0x00FF00; |
|
360 b = pixel & 0x0000FF; |
|
361 |
|
362 *destDataPtr1++ = 0xFF000000 | r | g | b; |
|
363 |
|
364 pixel = LutY1 + LutC; |
|
365 |
|
366 if (pixel & OverflowMask) |
|
367 { |
|
368 if (pixel & 0xC0000000U) |
|
369 { |
|
370 if (pixel & 0x80000000U) |
|
371 { |
|
372 pixel &= ~0x3FC00000U; |
|
373 } |
|
374 else |
|
375 { |
|
376 pixel |= 0x3FC00000U; |
|
377 } |
|
378 } |
|
379 if (pixel & 0x00180000U) |
|
380 { |
|
381 if (pixel & 0x00100000U) |
|
382 { |
|
383 pixel &= ~0x0007F800U; |
|
384 } |
|
385 else |
|
386 { |
|
387 pixel |= 0x0007F800U; |
|
388 } |
|
389 } |
|
390 if (pixel & 0x00000300U) |
|
391 { |
|
392 if (pixel & 0x00000200U) |
|
393 { |
|
394 pixel &= ~0x000000FFU; |
|
395 } |
|
396 else |
|
397 { |
|
398 pixel |= 0x000000FFU; |
|
399 } |
|
400 } |
|
401 } |
|
402 |
|
403 r = (pixel >> 6) & 0xFF0000; |
|
404 g = (pixel >> 3) & 0x00FF00; |
|
405 b = pixel & 0x0000FF; |
|
406 |
|
407 *destDataPtr1++ = 0xFF000000 | r | g | b; |
|
408 |
|
409 // row, 2 pixels |
|
410 |
|
411 LutY0 = KYLut[*aSourceDataPtrY2++]; |
|
412 LutY1 = KYLut[*aSourceDataPtrY2++]; |
|
413 |
|
414 pixel = LutY0 + LutC; |
|
415 |
|
416 if (pixel & OverflowMask) |
|
417 { |
|
418 if (pixel & 0xC0000000U) |
|
419 { |
|
420 if (pixel & 0x80000000U) |
|
421 { |
|
422 pixel &= ~0x3FC00000U; |
|
423 } |
|
424 else |
|
425 { |
|
426 pixel |= 0x3FC00000U; |
|
427 } |
|
428 } |
|
429 if (pixel & 0x00180000U) |
|
430 { |
|
431 if (pixel & 0x00100000U) |
|
432 { |
|
433 pixel &= ~0x0007F800U; |
|
434 } |
|
435 else |
|
436 { |
|
437 pixel |= 0x0007F800U; |
|
438 } |
|
439 } |
|
440 if (pixel & 0x00000300U) |
|
441 { |
|
442 if (pixel & 0x00000200U) |
|
443 { |
|
444 pixel &= ~0x000000FFU; |
|
445 } |
|
446 else |
|
447 { |
|
448 pixel |= 0x000000FFU; |
|
449 } |
|
450 } |
|
451 } |
|
452 |
|
453 r = (pixel >> 6) & 0xFF0000; |
|
454 g = (pixel >> 3) & 0x00FF00; |
|
455 b = pixel & 0x0000FF; |
|
456 |
|
457 *destDataPtr2++ = 0xFF000000 | r | g | b; |
|
458 |
|
459 pixel = LutY1 + LutC; |
|
460 |
|
461 if (pixel & OverflowMask) |
|
462 { |
|
463 if (pixel & 0xC0000000U) |
|
464 { |
|
465 if (pixel & 0x80000000U) |
|
466 { |
|
467 pixel &= ~0x3FC00000U; |
|
468 } |
|
469 else |
|
470 { |
|
471 pixel |= 0x3FC00000U; |
|
472 } |
|
473 } |
|
474 if (pixel & 0x00180000U) |
|
475 { |
|
476 if (pixel & 0x00100000U) |
|
477 { |
|
478 pixel &= ~0x0007F800U; |
|
479 } |
|
480 else |
|
481 { |
|
482 pixel |= 0x0007F800U; |
|
483 } |
|
484 } |
|
485 if (pixel & 0x00000300U) |
|
486 { |
|
487 if (pixel & 0x00000200U) |
|
488 { |
|
489 pixel &= ~0x000000FFU; |
|
490 } |
|
491 else |
|
492 { |
|
493 pixel |= 0x000000FFU; |
|
494 } |
|
495 } |
|
496 } |
|
497 |
|
498 r = (pixel >> 6) & 0xFF0000; |
|
499 g = (pixel >> 3) & 0x00FF00; |
|
500 b = pixel & 0x0000FF; |
|
501 |
|
502 *destDataPtr2++ = 0xFF000000 | r | g | b; |
|
503 |
|
504 } |
|
505 } |
|
506 |
|
507 // ----------------------------------------------------------------------------- |
|
508 // DoConvertYuv422toXRGB0888 |
|
509 // ----------------------------------------------------------------------------- |
|
510 // |
|
511 inline void DoConvertYuv422toXRGB0888( |
|
512 TInt aWidth, // width in pixels |
|
513 const TUint8*& aSourceDataPtr, // pointer to source row |
|
514 TUint8* aDestDataPtr // pointer to destination row |
|
515 ) |
|
516 { |
|
517 TUint32* destDataPtr = reinterpret_cast< TUint32* >( aDestDataPtr ); |
|
518 // width assumed to be even |
|
519 TInt pixelsLeft = aWidth / 2; |
|
520 |
|
521 TUint32 r, g, b; |
|
522 TUint32 LutY0, LutY1, LutC; |
|
523 TUint32 pixel; |
|
524 TUint32 OverflowMask = 0xC0180300U; |
|
525 |
|
526 // One scanline at the time |
|
527 while ( pixelsLeft-- ) |
|
528 { |
|
529 |
|
530 LutC = KCbLut[*aSourceDataPtr++]; |
|
531 LutY0 = KYLut[*aSourceDataPtr++]; |
|
532 LutC += KCrLut[*aSourceDataPtr++]; |
|
533 LutY1 = KYLut[*aSourceDataPtr++]; |
|
534 |
|
535 pixel = LutY0 + LutC; |
|
536 |
|
537 if (pixel & OverflowMask) |
|
538 { |
|
539 if (pixel & 0xC0000000U) |
|
540 { |
|
541 if (pixel & 0x80000000U) |
|
542 { |
|
543 pixel &= ~0x3FC00000U; |
|
544 } |
|
545 else |
|
546 { |
|
547 pixel |= 0x3FC00000U; |
|
548 } |
|
549 } |
|
550 if (pixel & 0x00180000U) |
|
551 { |
|
552 if (pixel & 0x00100000U) |
|
553 { |
|
554 pixel &= ~0x0007F800U; |
|
555 } |
|
556 else |
|
557 { |
|
558 pixel |= 0x0007F800U; |
|
559 } |
|
560 } |
|
561 if (pixel & 0x00000300U) |
|
562 { |
|
563 if (pixel & 0x00000200U) |
|
564 { |
|
565 pixel &= ~0x000000FFU; |
|
566 } |
|
567 else |
|
568 { |
|
569 pixel |= 0x000000FFU; |
|
570 } |
|
571 } |
|
572 } |
|
573 |
|
574 r = (pixel >> 6) & 0xFF0000; |
|
575 g = (pixel >> 3) & 0x00FF00; |
|
576 b = pixel & 0x0000FF; |
|
577 |
|
578 *destDataPtr++ = 0xFF000000 | r | g | b; |
|
579 |
|
580 pixel = LutY1 + LutC; |
|
581 |
|
582 if (pixel & OverflowMask) |
|
583 { |
|
584 if (pixel & 0xC0000000U) |
|
585 { |
|
586 if (pixel & 0x80000000U) |
|
587 { |
|
588 pixel &= ~0x3FC00000U; |
|
589 } |
|
590 else |
|
591 { |
|
592 pixel |= 0x3FC00000U; |
|
593 } |
|
594 } |
|
595 if (pixel & 0x00180000U) |
|
596 { |
|
597 if (pixel & 0x00100000U) |
|
598 { |
|
599 pixel &= ~0x0007F800U; |
|
600 } |
|
601 else |
|
602 { |
|
603 pixel |= 0x0007F800U; |
|
604 } |
|
605 } |
|
606 if (pixel & 0x00000300U) |
|
607 { |
|
608 if (pixel & 0x00000200U) |
|
609 { |
|
610 pixel &= ~0x000000FFU; |
|
611 } |
|
612 else |
|
613 { |
|
614 pixel |= 0x000000FFU; |
|
615 } |
|
616 } |
|
617 } |
|
618 |
|
619 r = (pixel >> 6) & 0xFF0000; |
|
620 g = (pixel >> 3) & 0x00FF00; |
|
621 b = pixel & 0x0000FF; |
|
622 |
|
623 *destDataPtr++ = 0xFF000000 | r | g | b; |
|
624 } |
|
625 } |
|
626 |
|
627 // ----------------------------------------------------------------------------- |
|
628 // CVtEngDrawDP::NewL |
|
629 // Symbian 2nd phase constructor can leave. |
|
630 // ----------------------------------------------------------------------------- |
|
631 // |
|
632 CVtEngDrawDP* CVtEngDrawDP::NewL( |
|
633 MDisplaySinkObserver* aObserver ) |
|
634 { |
|
635 __VTPRINTENTER( "RVD(DP).NewL" ) |
|
636 CVtEngDrawDP* self = new ( ELeave ) CVtEngDrawDP( aObserver ); |
|
637 CleanupStack::PushL( self ); |
|
638 self->ConstructL( ); |
|
639 CleanupStack::Pop(); |
|
640 __VTPRINTEXIT( "RVD(DP).NewL" ) |
|
641 return self; |
|
642 } |
|
643 |
|
644 // ----------------------------------------------------------------------------- |
|
645 // CVtEngDrawDP::~CVtEngDrawDP |
|
646 // Destructor. Cannot leave. |
|
647 // ----------------------------------------------------------------------------- |
|
648 // |
|
649 CVtEngDrawDP::~CVtEngDrawDP() |
|
650 { |
|
651 __VTPRINTENTER( "RVD(DP).~" ) |
|
652 Cancel(); |
|
653 delete iFrameBuffer; |
|
654 delete iBufferWaiter; |
|
655 delete iPostingSurface; |
|
656 __VTPRINT( DEBUG_MEDIA , "RVD(DP).~ RRegion::Close()" ) |
|
657 iClipRegion.Close(); |
|
658 CloseDPLibrary(); |
|
659 |
|
660 delete iTarget; |
|
661 delete iSource; |
|
662 delete iImageScaler; |
|
663 __VTPRINTEXIT( "RVD(DP).~" ) |
|
664 } |
|
665 |
|
666 // ----------------------------------------------------------------------------- |
|
667 // CVtEngDrawDP::CVtEngDraw |
|
668 // C++ constructor. Cannot leave. |
|
669 // ----------------------------------------------------------------------------- |
|
670 // |
|
671 CVtEngDrawDP::CVtEngDrawDP( MDisplaySinkObserver* aObserver ) : |
|
672 CVtEngDraw( aObserver ), iClipRegion( 1 ), |
|
673 iPostingFormat( KDefaultPostingFormat422 ) |
|
674 { |
|
675 } |
|
676 |
|
677 // ----------------------------------------------------------------------------- |
|
678 // CVtEngDrawDP::BaseConstructL |
|
679 // Base construction. |
|
680 // ----------------------------------------------------------------------------- |
|
681 // |
|
682 void CVtEngDrawDP::BaseConstructL() |
|
683 { |
|
684 __VTPRINTENTER( "RVD(DP).BaseConstructL" ) |
|
685 if ( IsFlag( EFlagUIForeground ) ) |
|
686 { |
|
687 DoBaseConstructL(); |
|
688 } |
|
689 else |
|
690 { |
|
691 SetFlag( EBaseConstructCalled ); |
|
692 } |
|
693 __VTPRINTEXIT( "RVD(DP).BaseConstructL" ) |
|
694 } |
|
695 |
|
696 // ----------------------------------------------------------------------------- |
|
697 // CVtEngDrawDP::CreateSinkL |
|
698 // Instantiates display sink. |
|
699 // ----------------------------------------------------------------------------- |
|
700 // |
|
701 MDisplaySink* CVtEngDrawDP::CreateSinkL() |
|
702 { |
|
703 __VTPRINTENTER( "RVD(DP).CreateSinkL" ) |
|
704 TDisplaySinkParamsDP params; |
|
705 GetSinkParams( params ); |
|
706 MDisplaySink* sink = ::CreateSinkL( params, KNullDesC8 ); |
|
707 if ( IsFlag( EBaseConstructCalled ) ) |
|
708 { |
|
709 sink->Pause(); |
|
710 SetFlag( ESinkParamUpdateRequired | ESinkResumeRequired ); |
|
711 } |
|
712 __VTPRINTEXIT( "RVD(DP).CreateSinkL" ) |
|
713 return sink; |
|
714 } |
|
715 |
|
716 // ----------------------------------------------------------------------------- |
|
717 // CVtEngRemoteVideo::CVtEngDraw::BaseRefreshL |
|
718 // Draw a frame. |
|
719 // ----------------------------------------------------------------------------- |
|
720 // |
|
721 void CVtEngDrawDP::BaseRefreshL() |
|
722 { |
|
723 __VTPRINTENTER( "RVD(DP).BaseRefreshL" ) |
|
724 __VTPRINTEXIT( "RVD(DP).BaseRefreshL" ) |
|
725 } |
|
726 |
|
727 // ----------------------------------------------------------------------------- |
|
728 // CVtEngDrawDP::BaseRefreshBitmapsL |
|
729 // Refreshes bitmaps sizes and display mode if needed. |
|
730 // ----------------------------------------------------------------------------- |
|
731 // |
|
732 void CVtEngDrawDP::BaseRefreshBitmapsL() |
|
733 { |
|
734 __VTPRINTENTER( "RVD(DP).BaseRefreshBitmapsL" ) |
|
735 BaseConstructL(); |
|
736 InitializePostingSurfaceL(); |
|
737 // set the params for DS |
|
738 UpdateSinkParamsL(); |
|
739 ClearFlag( EFirstFrameReceived ); |
|
740 __VTPRINTEXIT( "RVD(DP).BaseRefreshBitmapsL" ) |
|
741 } |
|
742 |
|
743 // ----------------------------------------------------------------------------- |
|
744 // CVtEngDrawDP::BaseDoCancel |
|
745 // DoCancel for derived class. |
|
746 // ----------------------------------------------------------------------------- |
|
747 // |
|
748 void CVtEngDrawDP::BaseDoCancel() |
|
749 { |
|
750 __VTPRINTENTER( "RVD(DP).BaseDoCancel" ) |
|
751 __VTPRINTEXIT( "RVD(DP).BaseDoCancel" ) |
|
752 } |
|
753 |
|
754 // ----------------------------------------------------------------------------- |
|
755 // CVtEngDrawDP::BaseVerifyConfigL |
|
756 // Checks current configuration against DP implementation. |
|
757 // ----------------------------------------------------------------------------- |
|
758 // |
|
759 void CVtEngDrawDP::BaseVerifyConfigL() |
|
760 { |
|
761 __VTPRINTENTER( "RVD(DP).BaseVerifyConfigL" ) |
|
762 // Check support for requested size |
|
763 if ( !SupportsSize( iSourceSize ) ) |
|
764 { |
|
765 __VTPRINT( DEBUG_MEDIA , |
|
766 "RVD(DP).BaseVerifyConfigL Size NOT supported" ) |
|
767 User::Leave( KErrNotSupported ); |
|
768 } |
|
769 RecalculateClipRegionL(); |
|
770 __VTPRINTEXIT( "RVD(DP).BaseVerifyConfigL" ) |
|
771 } |
|
772 |
|
773 // ----------------------------------------------------------------------------- |
|
774 // CVtEngDrawDP::BaseRestartL |
|
775 // ----------------------------------------------------------------------------- |
|
776 // |
|
777 void CVtEngDrawDP::BaseRestartL() |
|
778 { |
|
779 __VTPRINTENTER( "RVD(DP).BaseRestartL" ) |
|
780 if ( IsFlag( EFlagUIForeground ) ) |
|
781 { |
|
782 RecalculateClipRegionL(); |
|
783 iBufferWaiter->FetchBuffer(); |
|
784 } |
|
785 __VTPRINTEXIT( "RVD(DP).BaseRestartL" ) |
|
786 } |
|
787 |
|
788 // ----------------------------------------------------------------------------- |
|
789 // CVtEngDrawDP::BaseAbortNow |
|
790 // ----------------------------------------------------------------------------- |
|
791 // |
|
792 void CVtEngDrawDP::BaseAbortNow() |
|
793 { |
|
794 __VTPRINTENTER( "RVD(DP).BaseAbortNow" ) |
|
795 UpdateVtFrame(); |
|
796 __VTPRINTEXIT( "RVD(DP).BaseAbortNow" ) |
|
797 } |
|
798 |
|
799 // ----------------------------------------------------------------------------- |
|
800 // CVtEngDrawDP::StartDrawL |
|
801 // Starts the drawing. |
|
802 // ----------------------------------------------------------------------------- |
|
803 // |
|
804 void CVtEngDrawDP::BaseStartDrawL() |
|
805 { |
|
806 __VTPRINTENTER( "RVD(DP).BaseStartDrawL" ) |
|
807 if ( IsFlag( EBaseConstructCalled ) ) |
|
808 { |
|
809 SetFlag( EBaseBaseStartDrawCalled ); |
|
810 } |
|
811 else |
|
812 { |
|
813 DoBaseStartDrawL(); |
|
814 } |
|
815 __VTPRINTEXIT( "RVD(DP).BaseStartDrawL" ) |
|
816 } |
|
817 |
|
818 // ----------------------------------------------------------------------------- |
|
819 // CVtEngDrawDP::BaseStopDraw |
|
820 // Stop the drawing. |
|
821 // ----------------------------------------------------------------------------- |
|
822 // |
|
823 void CVtEngDrawDP::BaseStopDraw() |
|
824 { |
|
825 // Cancel the timer in any case. |
|
826 __VTPRINTENTER( "RVD(DP).BaseStopDraw" ) |
|
827 ClearFlag( EBaseBaseStartDrawCalled ); |
|
828 iWatcher->Cancel(); |
|
829 if ( iDSA ) |
|
830 { |
|
831 ClearFlag( ERemoteVideoDrawing | EStarted ); |
|
832 iDSA->Cancel(); |
|
833 } |
|
834 iBufferWaiter->Cancel(); |
|
835 Cancel(); |
|
836 __VTPRINTEXIT( "RVD(DP).BaseStopDraw" ) |
|
837 } |
|
838 |
|
839 // ----------------------------------------------------------------------------- |
|
840 // CVtEngDrawDP::BaseSetConfigL |
|
841 // Sets new configuration. |
|
842 // ----------------------------------------------------------------------------- |
|
843 // |
|
844 void CVtEngDrawDP::BaseSetConfigL( const TVtEngRenderConfig& aConfig ) |
|
845 { |
|
846 __VTPRINTENTER( "RVD(DP).BaseSetConfigL" ) |
|
847 Mem::FillZ( &iConfig, sizeof( TVtEngRenderConfigDP ) ); |
|
848 iConfig = aConfig; |
|
849 if ( IsFlag( EBaseConstructCalled ) ) |
|
850 { |
|
851 SetFlag( EBaseSetConfigCalled ); |
|
852 } |
|
853 else |
|
854 { |
|
855 ConfigUpdatedL(); |
|
856 } |
|
857 __VTPRINTEXIT( "RVD(DP).BaseSetConfigL" ) |
|
858 } |
|
859 |
|
860 // ----------------------------------------------------------------------------- |
|
861 // CVtEngDrawDP::BaseSetUIForegroundL |
|
862 // Sets UI foreground status. |
|
863 // ----------------------------------------------------------------------------- |
|
864 // |
|
865 void CVtEngDrawDP::BaseSetUIForegroundL( TBool aForeground ) |
|
866 { |
|
867 __VTPRINTENTER( "RVD(DP).BaseSetUIForegroundL" ) |
|
868 if( aForeground ) |
|
869 { |
|
870 TBool wasSentToBackground( IsFlag( ESentToBackground ) ); |
|
871 SetFlag( EFlagUIForeground ); |
|
872 ClearFlag( ESentToBackground ); |
|
873 if( IsFlag( EDelayedCallsMask ) ) |
|
874 { |
|
875 HandleDelayedCallsL(); |
|
876 } |
|
877 if ( wasSentToBackground ) |
|
878 { |
|
879 BaseRefreshBitmapsL(); |
|
880 Restart( RDirectScreenAccess::ETerminateCancel ); |
|
881 BaseStartDrawL(); |
|
882 } |
|
883 } |
|
884 else |
|
885 { |
|
886 if ( !IsFlag( EBaseConstructCalled ) ) |
|
887 { |
|
888 BaseStopDraw(); |
|
889 delete iPostingSurface; |
|
890 iPostingSurface = 0; |
|
891 for ( TInt i = MDisplaySink::EFirstBitmap; |
|
892 i < MDisplaySink::EFirstBitmap + KVtEngMaxBuffers; i++ ) |
|
893 { |
|
894 iBuffers[ i ].UnSet(); |
|
895 } |
|
896 SetFlag( ESentToBackground ); |
|
897 } |
|
898 ClearFlag( EFlagUIForeground ); |
|
899 } |
|
900 __VTPRINTEXIT( "RVD(DP).BaseSetUIForegroundL" ) |
|
901 } |
|
902 |
|
903 // ----------------------------------------------------------------------------- |
|
904 // CVtEngDrawDP::BaseRequestLastFrame |
|
905 // Request update last remote video frame through MVtEngFrameObserver::vtSetFrame |
|
906 // ----------------------------------------------------------------------------- |
|
907 // |
|
908 void CVtEngDrawDP::BaseRequestLastFrame() |
|
909 { |
|
910 __VTPRINTENTER( "RVD(DP).BaseRequestLastFrame" ) |
|
911 UpdateVtFrame(); |
|
912 __VTPRINTEXIT( "RVD(DP).BaseRequestLastFrame" ) |
|
913 } |
|
914 |
|
915 // ----------------------------------------------------------------------------- |
|
916 // CVtEngDrawDP::BaseVideoFrameSizeChangedL |
|
917 // Called when incoming frame buffer size changes. |
|
918 // ----------------------------------------------------------------------------- |
|
919 // |
|
920 void CVtEngDrawDP::BaseVideoFrameSizeChangedL( const TSize& aTo ) |
|
921 { |
|
922 __VTPRINTENTER( "RVD(DP).BaseVideoFrameSizeChangedL" ) |
|
923 CreateFrameBufferL( aTo ); |
|
924 __VTPRINTEXIT( "RVD(DP).BaseVideoFrameSizeChangedL" ) |
|
925 } |
|
926 |
|
927 // ----------------------------------------------------------------------------- |
|
928 // CVtEngDrawDP::Config |
|
929 // Returns current configuration. |
|
930 // ----------------------------------------------------------------------------- |
|
931 // |
|
932 TVtEngRenderConfig& CVtEngDrawDP::Config() |
|
933 { |
|
934 return iConfig; |
|
935 } |
|
936 |
|
937 // ----------------------------------------------------------------------------- |
|
938 // CVtEngDrawDP::RunL |
|
939 // CActive heir execution method. |
|
940 // ----------------------------------------------------------------------------- |
|
941 // |
|
942 void CVtEngDrawDP::RunL() |
|
943 { |
|
944 __VTPRINTENTER( "RVD(DP).RunL" ) |
|
945 |
|
946 TInt bitmapNo( iStatus.Int() ); |
|
947 |
|
948 if ( bitmapNo < KErrNone ) |
|
949 { |
|
950 __VTPRINT( DEBUG_MEDIA, "RVD(DP).RunL notify rvd problem" ) |
|
951 CVtEngEventManager::NotifyEvent( KVtEngRemoteRenderingProblem ); |
|
952 return; |
|
953 } |
|
954 |
|
955 TVtEngBuffer& buffer = iBuffers[ bitmapNo ]; |
|
956 |
|
957 if ( !iDSUpdated ) |
|
958 { |
|
959 __VTPRINT( DEBUG_MEDIA, "RVD(DP).RunL !Updated" ) |
|
960 __VTPRINTEXIT( "RVD(DP).RunL" ) |
|
961 return; |
|
962 } |
|
963 else if ( !IsFlag( EFlagUIForeground ) ) |
|
964 { |
|
965 __VTPRINT( DEBUG_MEDIA, "RVD(DP).RunL !Flag( EFlagUIForeground )" ) |
|
966 __VTPRINTEXIT( "RVD(DP).RunL" ) |
|
967 if ( iPostingSurface ) |
|
968 { |
|
969 iPostingSurface->PostBuffer( buffer.Buffer() ); |
|
970 buffer.UnSet(); |
|
971 iBufferWaiter->FetchBuffer(); |
|
972 } |
|
973 return; |
|
974 } |
|
975 else if ( buffer.Buffer() == NULL ) |
|
976 { |
|
977 __VTPRINT( DEBUG_MEDIA, "RVD(DP).RunL signalled with NULL buffer" ) |
|
978 TInt result( iBufferWaiter->FetchBuffer() ); |
|
979 __VTPRINT2( DEBUG_MEDIA, |
|
980 "RVD(DP).RunL FetchBuffer %d", result ) |
|
981 User::LeaveIfError( result ); |
|
982 __VTPRINTEXIT( "RVD(DP).RunL" ) |
|
983 return; |
|
984 } |
|
985 |
|
986 // Image received, reset counter. |
|
987 iCheckpoint = KVtEngWatcherThreshold; |
|
988 |
|
989 StoreFrameBuffer( buffer.Buffer() ); |
|
990 __VTPRINT2( DEBUG_MEDIA, "RVD(DP).RunL flags=%d", iFlags ) |
|
991 TBool firstFrame( !IsFlag ( EFirstFrameReceived ) ); |
|
992 SetFlag( EFirstFrameReceived ); |
|
993 // Remote video is about to start? |
|
994 if ( !IsFlag( EStarted ) && IsFlag( EReadyInternal ) ) |
|
995 { |
|
996 if ( !iDSA->IsActive() ) |
|
997 { |
|
998 iDSA->StartL(); |
|
999 } |
|
1000 SetFlag( EStarted ); |
|
1001 if ( !iConfig.iClipRect.IsEmpty() ) |
|
1002 { |
|
1003 SetFlag( EReadyForeground ); |
|
1004 iDSA->Gc()->SetClippingRect( iConfig.iClipRect ); |
|
1005 RecalculateClipRegionL(); |
|
1006 } |
|
1007 __VTPRINT( DEBUG_MEDIA, "RVD(DP).RunL notify rvd start" ) |
|
1008 //CVtEngEventManager::NotifyEvent( KVtEngRemoteVideoStarted ); |
|
1009 } |
|
1010 if ( firstFrame ) |
|
1011 { |
|
1012 CVtEngEventManager::NotifyEvent( KVtEngRemoteVideoStarted ); |
|
1013 } |
|
1014 TRAPD( setClipRegResult, SetClipRegionL() ); |
|
1015 if ( setClipRegResult ) |
|
1016 { |
|
1017 __VTPRINT2( DEBUG_MEDIA, "RVD(DP).RunL SetClipRegionL failed %d", |
|
1018 setClipRegResult ); |
|
1019 } |
|
1020 __VTPRINT3( DEBUG_MEDIA, "RVD(DP).RunL received buffer %d $%x", |
|
1021 bitmapNo, |
|
1022 reinterpret_cast< TUint >( buffer.Buffer() ) ) |
|
1023 TInt result |
|
1024 ( iPostingSurface->PostBuffer( buffer.Buffer() ) ); |
|
1025 __VTPRINT2( DEBUG_MEDIA, "RVD(DP).RunL PostBuffer %d", result ) |
|
1026 buffer.UnSet(); |
|
1027 if ( iBuffers[ KVtEngBitmapNoReversed[ bitmapNo ] ].IsSet() ) |
|
1028 { |
|
1029 __VTPRINT2( DEBUG_MEDIA, "RVD(DP).RunL reactivating for buffer %d", |
|
1030 KVtEngBitmapNoReversed[ bitmapNo ] ) |
|
1031 Activate(); |
|
1032 DisplaySink().NextFrame(); |
|
1033 } |
|
1034 |
|
1035 if ( result == KErrNotReady ) |
|
1036 { |
|
1037 BaseRefreshBitmapsL(); |
|
1038 result = KErrNone; |
|
1039 } |
|
1040 |
|
1041 User::LeaveIfError( result ); |
|
1042 result = iBufferWaiter->FetchBuffer(); |
|
1043 __VTPRINT2( DEBUG_MEDIA, |
|
1044 "RVD(DP).RunL FetchBuffer %d", result ) |
|
1045 User::LeaveIfError( result ); |
|
1046 |
|
1047 __VTPRINTEXIT( "RVD(DP).RunL" ) |
|
1048 } |
|
1049 |
|
1050 // ----------------------------------------------------------------------------- |
|
1051 // CVtEngDrawDP::BufferReady |
|
1052 // BufferReady |
|
1053 // ----------------------------------------------------------------------------- |
|
1054 // |
|
1055 void CVtEngDrawDP::BufferReady( CPostingSurface::TPostingBuff* aBuffer ) |
|
1056 { |
|
1057 __VTPRINTENTER( "RVD(DP).BufferReady" ) |
|
1058 SetAvailableToSink( aBuffer ); |
|
1059 __VTPRINTEXIT( "RVD(DP).BufferReady" ) |
|
1060 } |
|
1061 |
|
1062 // ----------------------------------------------------------------------------- |
|
1063 // CVtEngDrawDP::FetchError |
|
1064 // Buffer fetching error |
|
1065 // ----------------------------------------------------------------------------- |
|
1066 // |
|
1067 void CVtEngDrawDP::FetchError( TInt ) |
|
1068 { |
|
1069 __VTPRINTENTER( "RVD(DP).FetchError" ) |
|
1070 CVtEngEventManager::NotifyEvent( KVtEngRemoteRenderingProblem ); |
|
1071 __VTPRINTEXIT( "RVD(DP).FetchError" ) |
|
1072 } |
|
1073 |
|
1074 // ----------------------------------------------------------------------------- |
|
1075 // CVtEngDrawDP::HandleDelayedCallsL |
|
1076 // |
|
1077 // ----------------------------------------------------------------------------- |
|
1078 // |
|
1079 void CVtEngDrawDP::HandleDelayedCallsL() |
|
1080 { |
|
1081 __VTPRINTENTER( "RVD(DP).HandleDelayedCallsL" ) |
|
1082 if ( IsFlag( EBaseConstructCalled ) ) |
|
1083 { |
|
1084 DoBaseConstructL(); |
|
1085 } |
|
1086 if ( IsFlag( EBaseSetConfigCalled ) ) |
|
1087 { |
|
1088 ConfigUpdatedL(); |
|
1089 ClearFlag( EBaseSetConfigCalled ); |
|
1090 } |
|
1091 if ( IsFlag( EInitializePostingSurfaceCalled ) ) |
|
1092 { |
|
1093 DoInitializePostingSurfaceL(); |
|
1094 } |
|
1095 if ( IsFlag( ESinkParamUpdateRequired ) ) |
|
1096 { |
|
1097 DoUpdateSinkParamsL(); |
|
1098 } |
|
1099 if ( IsFlag( EBaseBaseStartDrawCalled ) ) |
|
1100 { |
|
1101 DoBaseStartDrawL(); |
|
1102 } |
|
1103 __VTPRINTEXIT( "RVD(DP).HandleDelayedCallsL" ) |
|
1104 } |
|
1105 |
|
1106 // ----------------------------------------------------------------------------- |
|
1107 // CVtEngDrawDP::DoBaseConstructL |
|
1108 // Base construction implementation |
|
1109 // ----------------------------------------------------------------------------- |
|
1110 // |
|
1111 void CVtEngDrawDP::DoBaseConstructL() |
|
1112 { |
|
1113 __VTPRINTENTER( "RVD(DP).DoBaseConstructL" ) |
|
1114 |
|
1115 if ( !iImageScaler ) |
|
1116 { |
|
1117 iImageScaler = |
|
1118 CVtImageScaler::NewL( *this, CVtImageScaler::EBilinear ); |
|
1119 } |
|
1120 delete iBufferWaiter; |
|
1121 iBufferWaiter = NULL; |
|
1122 delete iPostingSurface; |
|
1123 iPostingSurface = NULL; |
|
1124 |
|
1125 // Load DP API library |
|
1126 LoadDPLibraryL(); |
|
1127 |
|
1128 // Create posting surface instance |
|
1129 iPostingSurface = CreatePostingSurfaceL(); |
|
1130 |
|
1131 CPostingSurface::TPostingFormat previousPostingFormat( iPostingFormat ); |
|
1132 |
|
1133 // Check support for format |
|
1134 if ( !SupportsFormat( KDefaultPostingFormat420 ) ) |
|
1135 { |
|
1136 if ( !SupportsFormat( KDefaultPostingFormat422 ) ) |
|
1137 { |
|
1138 __VTPRINT( DEBUG_MEDIA , |
|
1139 "RVD(DP).BaseConstructL Format NOT supported" ) |
|
1140 User::Leave( KErrNotSupported ); |
|
1141 } |
|
1142 else |
|
1143 { |
|
1144 __VTPRINT( DEBUG_MEDIA , "RVD(DP).BaseConstructL using 422" ) |
|
1145 iPostingFormat = KDefaultPostingFormat422; |
|
1146 } |
|
1147 } |
|
1148 else |
|
1149 { |
|
1150 __VTPRINT( DEBUG_MEDIA , "RVD(DP).BaseConstructL using 420" ) |
|
1151 iPostingFormat = KDefaultPostingFormat420; |
|
1152 } |
|
1153 iPostingSurface->GetCapabilities( iPostingCaps ); |
|
1154 iBufferWaiter = |
|
1155 new ( ELeave ) CVtEngBufferWaiter( *iPostingSurface, *this ); |
|
1156 for ( TInt i = MDisplaySink::EFirstBitmap; |
|
1157 i < MDisplaySink::EFirstBitmap + KVtEngMaxBuffers; i++ ) |
|
1158 { |
|
1159 iBuffers[ i ].UnSet(); |
|
1160 } |
|
1161 |
|
1162 // If posting for is different from previous, then free frame buffer |
|
1163 if ( ( previousPostingFormat != iPostingFormat ) || !iFrameBuffer ) |
|
1164 { |
|
1165 CreateFrameBufferL( iSourceSize ); |
|
1166 } |
|
1167 ClearFlag( EBaseConstructCalled ); |
|
1168 __VTPRINTEXIT( "RVD(DP).DoBaseConstructL" ) |
|
1169 } |
|
1170 |
|
1171 // ----------------------------------------------------------------------------- |
|
1172 // CVtEngDrawDP::UpdateSinkParamsL |
|
1173 // Updates sink params |
|
1174 // ----------------------------------------------------------------------------- |
|
1175 // |
|
1176 void CVtEngDrawDP::UpdateSinkParamsL() |
|
1177 { |
|
1178 __VTPRINTENTER( "RVD(DP).UpdateSinkParamsL" ) |
|
1179 if ( IsFlag( EBaseConstructCalled ) ) |
|
1180 { |
|
1181 SetFlag( ESinkParamUpdateRequired ); |
|
1182 } |
|
1183 else |
|
1184 { |
|
1185 DoUpdateSinkParamsL(); |
|
1186 } |
|
1187 __VTPRINTEXIT( "RVD(DP).UpdateSinkParamsL" ) |
|
1188 } |
|
1189 |
|
1190 // ----------------------------------------------------------------------------- |
|
1191 // CVtEngDrawDP::DoBaseStartDrawL |
|
1192 // |
|
1193 // ----------------------------------------------------------------------------- |
|
1194 // |
|
1195 void CVtEngDrawDP::DoBaseStartDrawL() |
|
1196 { |
|
1197 __VTPRINTENTER( "RVD(DP).DoBaseStartDrawL" ) |
|
1198 UpdateVtFrame(); |
|
1199 if ( iDSA ) |
|
1200 { |
|
1201 SetFlag( EReadyInternal ); |
|
1202 if ( !iWatcher->IsActive() ) |
|
1203 { |
|
1204 iWatcher->Start( KVtEngWatcherTimeout, KVtEngWatcherTimeout, |
|
1205 iCallback ); |
|
1206 } |
|
1207 User::LeaveIfError( iBufferWaiter->FetchBuffer() ); |
|
1208 SetFlag( ERemoteVideoDrawing ); |
|
1209 } |
|
1210 else |
|
1211 { |
|
1212 User::Leave( KErrNotReady ); |
|
1213 } |
|
1214 ClearFlag( EBaseBaseStartDrawCalled ); |
|
1215 __VTPRINTEXIT( "RVD(DP).DoBaseStartDrawL" ) |
|
1216 } |
|
1217 |
|
1218 // ----------------------------------------------------------------------------- |
|
1219 // CVtEngDrawDP::DoInitializePostingSurfaceL |
|
1220 // Initializes posting surface. |
|
1221 // ----------------------------------------------------------------------------- |
|
1222 // |
|
1223 void CVtEngDrawDP::DoInitializePostingSurfaceL() |
|
1224 { |
|
1225 __VTPRINTENTER( "RVD(DP).DoInitializePostingSurfaceL" ) |
|
1226 CPostingSurface::TPostingSourceParams postingSourceParams; |
|
1227 GetPostingSourceParams( postingSourceParams ); |
|
1228 CPostingSurface::TPostingParams postingParams; |
|
1229 GetPostingParams( postingParams ); |
|
1230 // Create and start DSA for getting access to DP |
|
1231 CreateAndStartDSAL(); |
|
1232 |
|
1233 /*S60 Display Posting API has a limitation that only one surface instance can be |
|
1234 created at a time. Unfortunately there's no way to check when posting is really |
|
1235 free. PostingSurface initialization maybe returns KErrInUse. |
|
1236 Please refer to TSW error EAKC-7R3TME. |
|
1237 The transition effect between landscape and portrait uses ATID to achieve smooth |
|
1238 transition. ATID and PostingSurface share the same buffers and cannot be used |
|
1239 simultaneously. PostingSurface initialization maybe returns KErrNotReady. |
|
1240 Please refer to TSW error EWXO-7P4DV3. |
|
1241 So it probably requires some kind of timer based retry to bypass these cases.*/ |
|
1242 TInt err; |
|
1243 while (1) |
|
1244 { |
|
1245 __VTPRINT( DEBUG_MEDIA, "RVD(DP).DoInitializePostingSurfaceL Initialize PostingSurface" ); |
|
1246 TRAP( err, iPostingSurface->InitializeL(postingSourceParams, postingParams) ); |
|
1247 if ( err == KErrNone) |
|
1248 { |
|
1249 break; |
|
1250 } |
|
1251 else |
|
1252 { |
|
1253 //time interval for each PostingSurface initialization is 0.2 second. |
|
1254 __VTPRINT2( DEBUG_MEDIA, "RVD(DP).DoInitializePostingSurfaceL InitPS error = %d", err ) |
|
1255 User::After(200000); |
|
1256 } |
|
1257 } |
|
1258 |
|
1259 delete iTarget; iTarget = NULL; |
|
1260 iTarget = CVtImageBitmap::NewL( |
|
1261 postingParams.iDisplayedRect.Size(), EColor16MU ); |
|
1262 if ( iSource ) |
|
1263 { |
|
1264 if ( IsFlag( EFrameBufferFilled ) && |
|
1265 !IsFlag( EFrameBufferNeedsConvertAndScale ) ) |
|
1266 { |
|
1267 iImageScaler->ScaleNowL( *iSource, *iTarget ); |
|
1268 Config().iObserver->vtSetFrame( |
|
1269 MVtEngFrameObserver::ERemoteVideoFrame, |
|
1270 &iTarget->Bitmap() ); |
|
1271 } |
|
1272 else |
|
1273 { |
|
1274 Config().iObserver->vtSetFrame( |
|
1275 MVtEngFrameObserver::ERemoteVideoFrame, NULL ); |
|
1276 } |
|
1277 } |
|
1278 else |
|
1279 { |
|
1280 //delete iSource; iSource = NULL; |
|
1281 iSource = CVtImageBitmap::NewL( iSourceSize, EColor16MU ); |
|
1282 Config().iObserver->vtSetFrame( MVtEngFrameObserver::ERemoteVideoFrame, |
|
1283 NULL ); |
|
1284 } |
|
1285 RecalculateClipRegionL(); |
|
1286 ClearFlag( EInitializePostingSurfaceCalled ); |
|
1287 __VTPRINTEXIT( "RVD(DP).DoInitializePostingSurfaceL" ) |
|
1288 } |
|
1289 |
|
1290 // ----------------------------------------------------------------------------- |
|
1291 // CVtEngDrawDP::DoUpdateSinkParamsL |
|
1292 // Updates sink params |
|
1293 // ----------------------------------------------------------------------------- |
|
1294 // |
|
1295 void CVtEngDrawDP::DoUpdateSinkParamsL() |
|
1296 { |
|
1297 __VTPRINTENTER( "RVD(DP).DoUpdateSinkParamsL" ) |
|
1298 TDisplaySinkParamsDP params; |
|
1299 GetSinkParams( params ); |
|
1300 DisplaySink().UpdateSinkParamsL( params, iDSUpdated ); |
|
1301 ClearFlag( ESinkParamUpdateRequired ); |
|
1302 if ( IsFlag( ESinkResumeRequired ) ) |
|
1303 { |
|
1304 DisplaySink().Resume(); |
|
1305 ClearFlag( ESinkResumeRequired ); |
|
1306 } |
|
1307 __VTPRINTEXIT( "RVD(DP).DoUpdateSinkParamsL" ) |
|
1308 } |
|
1309 |
|
1310 // ----------------------------------------------------------------------------- |
|
1311 // CVtEngDrawDP::IsAlphaTrashed |
|
1312 // Checks if the alpha has been trashed on screen buffer. |
|
1313 // ----------------------------------------------------------------------------- |
|
1314 // |
|
1315 TBool CVtEngDrawDP::IsAlphaTrashed() const |
|
1316 { |
|
1317 __VTPRINTENTER( "RVD(DP).IsAlphaTrashed" ) |
|
1318 TBool isTrashed( EFalse ); |
|
1319 const CFbsScreenDevice& sdev( *iDSA->ScreenDevice() ); |
|
1320 if ( sdev.DisplayMode() == EColor16MA ) |
|
1321 { |
|
1322 TRgb color; |
|
1323 TPoint point( iClipRegion.BoundingRect().Center() ); |
|
1324 sdev.GetPixel( color, point ); |
|
1325 isTrashed = ( color.Alpha() != 0 ); |
|
1326 } |
|
1327 __VTPRINTEXITR( "RVD(DP).IsAlphaTrashed %d", isTrashed ) |
|
1328 return isTrashed; |
|
1329 } |
|
1330 |
|
1331 // ----------------------------------------------------------------------------- |
|
1332 // CVtEngDrawDP::SetClipRegionL |
|
1333 // Sets clipping region for DP. |
|
1334 // ----------------------------------------------------------------------------- |
|
1335 // |
|
1336 void CVtEngDrawDP::SetClipRegionL() |
|
1337 { |
|
1338 __VTPRINTENTER( "RVD(DP).SetClipRegionL" ) |
|
1339 if ( iClipRegionUpdated || IsAlphaTrashed() ) |
|
1340 { |
|
1341 iClipRegionUpdated = EFalse; |
|
1342 CFbsBitGc* gc = iDSA->Gc(); |
|
1343 gc->SetClippingRegion( iDSA->DrawingRegion() ); |
|
1344 gc->SetDrawMode( CGraphicsContext::EDrawModeAND ); |
|
1345 gc->SetBrushColor( TRgb( 255, 255, 255, 0 ) ); |
|
1346 gc->Clear(); |
|
1347 iDSA->ScreenDevice()->Update(); |
|
1348 User::LeaveIfError( |
|
1349 iPostingSurface->SetClipRegion( iClipRegion ) ); |
|
1350 } |
|
1351 __VTPRINTEXIT( "RVD(DP).SetClipRegionL" ) |
|
1352 } |
|
1353 |
|
1354 // ----------------------------------------------------------------------------- |
|
1355 // CVtEngDrawDP::InitializePostingSurfaceL |
|
1356 // Initializes posting surface. |
|
1357 // ----------------------------------------------------------------------------- |
|
1358 // |
|
1359 void CVtEngDrawDP::InitializePostingSurfaceL() |
|
1360 { |
|
1361 __VTPRINTENTER( "RVD(DP).InitializePostingSurfaceL" ) |
|
1362 if ( IsFlag( EBaseConstructCalled ) ) |
|
1363 { |
|
1364 SetFlag( EInitializePostingSurfaceCalled ); |
|
1365 } |
|
1366 else |
|
1367 { |
|
1368 DoInitializePostingSurfaceL(); |
|
1369 } |
|
1370 __VTPRINTEXIT( "RVD(DP).InitializePostingSurfaceL" ) |
|
1371 } |
|
1372 |
|
1373 // ----------------------------------------------------------------------------- |
|
1374 // CVtEngDrawDP::GetPostingSourceParams |
|
1375 // Fills posting source params structure. |
|
1376 // ----------------------------------------------------------------------------- |
|
1377 // |
|
1378 void CVtEngDrawDP::GetPostingSourceParams( |
|
1379 CPostingSurface::TPostingSourceParams& aParams ) const |
|
1380 { |
|
1381 __VTPRINTENTER( "RVD(DP).GetPostingSourceParams" ) |
|
1382 Mem::FillZ( &aParams, sizeof( CPostingSurface::TPostingSourceParams ) ); |
|
1383 aParams.iPostingBuffering = KDefaultPostingBufferingFlags; |
|
1384 aParams.iBufferType = CPostingSurface::EStandardBuffer; |
|
1385 aParams.iPostingUsage = CPostingSurface::EVideoCapture; |
|
1386 aParams.iSourceImageSize = iSourceSize; |
|
1387 aParams.iPostingFormat = iPostingFormat; |
|
1388 aParams.iPixelAspectRatioNum = KDefaultPixelAspectRatioNum; |
|
1389 aParams.iPixelAspectRatioDenom = KDefaultPixelAspectRatioDenom; |
|
1390 aParams.iContentCopyRestricted = EFalse; |
|
1391 __VTPRINTEXIT( "RVD(DP).GetPostingSourceParams" ) |
|
1392 } |
|
1393 |
|
1394 // ----------------------------------------------------------------------------- |
|
1395 // CVtEngDrawDP::GetPostingParams |
|
1396 // Fills posting params structure. |
|
1397 // ----------------------------------------------------------------------------- |
|
1398 // |
|
1399 void CVtEngDrawDP::GetPostingParams( |
|
1400 CPostingSurface::TPostingParams& aParams ) const |
|
1401 { |
|
1402 __VTPRINTENTER( "RVD(DP).GetPostingParams" ) |
|
1403 Mem::FillZ( &aParams, sizeof( CPostingSurface::TPostingParams ) ); |
|
1404 |
|
1405 aParams.iDisplayedRect = iConfig.iClipRect; |
|
1406 |
|
1407 __VTPRINT3( DEBUG_MEDIA, "RVD(DP).GetPostingParams DRect.iTl (%d, %d)", |
|
1408 aParams.iDisplayedRect.iTl.iX, aParams.iDisplayedRect.iTl.iY ); |
|
1409 __VTPRINT3( DEBUG_MEDIA, "RVD(DP).GetPostingParams DRect.iBr (%d, %d)", |
|
1410 aParams.iDisplayedRect.iBr.iX, aParams.iDisplayedRect.iBr.iY ); |
|
1411 |
|
1412 TRect& dispRect( aParams.iDisplayedRect ); |
|
1413 dispRect.Move( iConfig.iOffset ); |
|
1414 FixRectForDP( dispRect ); |
|
1415 __VTPRINT3( DEBUG_MEDIA, "RVD(DP).GetPostingParams OffsDRect.iTl (%d, %d)", |
|
1416 dispRect.iTl.iX, dispRect.iTl.iY ); |
|
1417 __VTPRINT3( DEBUG_MEDIA, "RVD(DP).GetPostingParams OffsDRect.iBr (%d, %d)", |
|
1418 dispRect.iBr.iX, dispRect.iBr.iY ); |
|
1419 |
|
1420 aParams.iScaleToRect = TRect( aParams.iDisplayedRect.Size() ); |
|
1421 |
|
1422 aParams.iInputCrop = iSourceSize; |
|
1423 |
|
1424 __VTPRINT3( DEBUG_MEDIA, "RVD(DP).GetPostingParams InputCrop.iTl (%d, %d)", |
|
1425 aParams.iInputCrop.iTl.iX, aParams.iInputCrop.iTl.iY ); |
|
1426 __VTPRINT3( DEBUG_MEDIA, "RVD(DP).GetPostingParams InputCrop.iBr (%d, %d)", |
|
1427 aParams.iInputCrop.iBr.iX, aParams.iInputCrop.iBr.iY ); |
|
1428 |
|
1429 aParams.iBackGround = iConfig.iBackGround; |
|
1430 __VTPRINTEXIT( "RVD(DP).GetPostingParams" ) |
|
1431 } |
|
1432 |
|
1433 // ----------------------------------------------------------------------------- |
|
1434 // CVtEngDrawDP::SupportsFormat |
|
1435 // |
|
1436 // ----------------------------------------------------------------------------- |
|
1437 // |
|
1438 TBool CVtEngDrawDP::SupportsFormat( |
|
1439 const CPostingSurface::TPostingFormat& aFormat ) const |
|
1440 { |
|
1441 return iPostingSurface->FormatSupported( aFormat ); |
|
1442 } |
|
1443 |
|
1444 // ----------------------------------------------------------------------------- |
|
1445 // CVtEngDrawDP::SupportsSize |
|
1446 // |
|
1447 // ----------------------------------------------------------------------------- |
|
1448 // |
|
1449 TBool CVtEngDrawDP::SupportsSize( const TSize& aSize ) const |
|
1450 { |
|
1451 return ( iPostingCaps.iMaxPixelSize.iWidth >= aSize.iWidth ) && |
|
1452 ( iPostingCaps.iMaxPixelSize.iHeight >= aSize.iHeight ); |
|
1453 } |
|
1454 |
|
1455 // ----------------------------------------------------------------------------- |
|
1456 // CVtEngDrawDP::SupportsRotation |
|
1457 // |
|
1458 // ----------------------------------------------------------------------------- |
|
1459 // |
|
1460 TBool CVtEngDrawDP::SupportsRotation( |
|
1461 CPostingSurface::TRotationType aRotation ) const |
|
1462 { |
|
1463 return ( ( aRotation & iPostingCaps.iSupportedRotations ) == aRotation ); |
|
1464 } |
|
1465 |
|
1466 // ----------------------------------------------------------------------------- |
|
1467 // CVtEngDrawDP::SupportsMirroring |
|
1468 // |
|
1469 // ----------------------------------------------------------------------------- |
|
1470 // |
|
1471 TBool CVtEngDrawDP::SupportsMirroring() const |
|
1472 { |
|
1473 return iPostingCaps.iSupportsMirroring; |
|
1474 } |
|
1475 |
|
1476 // ----------------------------------------------------------------------------- |
|
1477 // CVtEngDrawDP::SupportsScaling |
|
1478 // |
|
1479 // ----------------------------------------------------------------------------- |
|
1480 // |
|
1481 TBool CVtEngDrawDP::SupportsScaling() const |
|
1482 { |
|
1483 return iPostingCaps.iSupportsScaling; |
|
1484 } |
|
1485 |
|
1486 // ----------------------------------------------------------------------------- |
|
1487 // CVtEngDrawDP::SupportsBrightness |
|
1488 // |
|
1489 // ----------------------------------------------------------------------------- |
|
1490 // |
|
1491 TBool CVtEngDrawDP::SupportsBrightness() const |
|
1492 { |
|
1493 return iPostingCaps.iSupportsBrightnessControl; |
|
1494 } |
|
1495 |
|
1496 // ----------------------------------------------------------------------------- |
|
1497 // CVtEngDrawDP::SupportsContrast |
|
1498 // |
|
1499 // ----------------------------------------------------------------------------- |
|
1500 // |
|
1501 TBool CVtEngDrawDP::SupportsContrast() const |
|
1502 { |
|
1503 return iPostingCaps.iSupportsContrastControl; |
|
1504 } |
|
1505 |
|
1506 // ----------------------------------------------------------------------------- |
|
1507 // CVtEngDrawDP::GetFrameBufferSize |
|
1508 // Returns size of frame buffer in bytes for given pixel size and current |
|
1509 // posting format. |
|
1510 // ----------------------------------------------------------------------------- |
|
1511 // |
|
1512 TInt CVtEngDrawDP::GetFrameBufferSize( const TSize& aSize ) const |
|
1513 { |
|
1514 TInt size( -1 ); |
|
1515 __VTPRINTENTER( "RVD(DP).GetFrameBufferSize" ) |
|
1516 switch( iPostingFormat ) |
|
1517 { |
|
1518 case KDefaultPostingFormat420: |
|
1519 size = ( aSize.iWidth * aSize.iHeight * 3 ) >> 1; |
|
1520 break; |
|
1521 |
|
1522 case KDefaultPostingFormat422: |
|
1523 size = ( aSize.iWidth * aSize.iHeight ) * 2; |
|
1524 break; |
|
1525 |
|
1526 default: |
|
1527 break; |
|
1528 } |
|
1529 __VTPRINTEXITR( "RVD(DP).GetFrameBufferSize %d", size ) |
|
1530 return size; |
|
1531 } |
|
1532 |
|
1533 // ----------------------------------------------------------------------------- |
|
1534 // CVtEngDrawDP::RecalculateClipRegionL |
|
1535 // Updates clipregion. |
|
1536 // ----------------------------------------------------------------------------- |
|
1537 // |
|
1538 void CVtEngDrawDP::RecalculateClipRegionL() |
|
1539 { |
|
1540 __VTPRINTENTER( "RVD(DP).RecalculateClipRegionL" ) |
|
1541 // Clip region needs to be updated |
|
1542 iClipRegionUpdated = ETrue; |
|
1543 iClipRegion.Clear(); |
|
1544 TRect clippingRect( iConfig.iClipRect ); |
|
1545 clippingRect.Move( iConfig.iOffset ); |
|
1546 FixRectForDP( clippingRect ); |
|
1547 iClipRegion.AddRect( clippingRect ); |
|
1548 if ( iClipRegion.CheckError() ) |
|
1549 { |
|
1550 __VTPRINT( DEBUG_MEDIA , |
|
1551 "RVD(DP).RecalculateClipRegionL failed to add cliprect" ) |
|
1552 User::Leave( KErrNoMemory ); |
|
1553 } |
|
1554 |
|
1555 if ( IsFlag( EStarted ) && iDSA && iDSA->DrawingRegion() ) |
|
1556 { |
|
1557 iClipRegion.Intersect( *iDSA->DrawingRegion() ); |
|
1558 if ( iClipRegion.CheckError() ) |
|
1559 { |
|
1560 __VTPRINT( DEBUG_MEDIA , |
|
1561 "RVD(DP).RecalculateClipRegionL failed to intersect" ) |
|
1562 User::Leave( KErrNoMemory ); |
|
1563 } |
|
1564 |
|
1565 #ifdef VTDEBUG |
|
1566 |
|
1567 TRect bRect( iClipRegion.BoundingRect() ); |
|
1568 __VTPRINT3( DEBUG_MEDIA, "RVD(DP).RecalculateClipRegionL BRect.iTl (%d, %d)", |
|
1569 bRect.iTl.iX, bRect.iTl.iY ); |
|
1570 __VTPRINT3( DEBUG_MEDIA, "RVD(DP).RecalculateClipRegionL BRect.iBr (%d, %d)", |
|
1571 bRect.iBr.iX, bRect.iBr.iY ); |
|
1572 #endif // VTDEBUG |
|
1573 } |
|
1574 __VTPRINTEXIT( "RVD(DP).RecalculateClipRegionL" ) |
|
1575 } |
|
1576 |
|
1577 // ----------------------------------------------------------------------------- |
|
1578 // CVtEngDrawDP::FixRectForDP |
|
1579 // Fixes rect for DP (i.e. width is made even and starting X coordinate is made |
|
1580 // even as well) |
|
1581 // ----------------------------------------------------------------------------- |
|
1582 // |
|
1583 void CVtEngDrawDP::FixRectForDP( TRect& aRect ) const |
|
1584 { |
|
1585 __VTPRINTENTER( "RVD(DP).FixRectForDP" ) |
|
1586 if ( aRect.iTl.iX & 1 ) |
|
1587 { |
|
1588 aRect.Move( 1, 0 ); |
|
1589 aRect.SetWidth( Max( 0, aRect.Width() - 1 ) ); |
|
1590 } |
|
1591 if ( aRect.Width() & 1 ) |
|
1592 { |
|
1593 aRect.SetWidth( aRect.Width() - 1 ); |
|
1594 } |
|
1595 __VTPRINTEXIT( "RVD(DP).FixRectForDP" ) |
|
1596 } |
|
1597 |
|
1598 // ----------------------------------------------------------------------------- |
|
1599 // CVtEngDrawDP::RecalculateClipRegionL |
|
1600 // Fills sink params. |
|
1601 // ----------------------------------------------------------------------------- |
|
1602 // |
|
1603 void CVtEngDrawDP::GetSinkParams( TDisplaySinkParamsDP& aSinkParams ) |
|
1604 { |
|
1605 __VTPRINTENTER( "RVD(DP).GetSinkParams" ) |
|
1606 Mem::FillZ( &aSinkParams, sizeof( TDisplaySinkParamsDP ) ); |
|
1607 aSinkParams.iThreadId = RThread().Id(); |
|
1608 aSinkParams.iRequestStatusPtr = &iStatus; |
|
1609 aSinkParams.iObserver = iObserver; |
|
1610 aSinkParams.iPostingBuffer1 = &iBuffers[ 0 ].Buffer(); |
|
1611 aSinkParams.iPostingBuffer2 = &iBuffers[ 1 ].Buffer(); |
|
1612 aSinkParams.iFrameSize = iSourceSize; |
|
1613 aSinkParams.iPostingFormat = iPostingFormat; |
|
1614 aSinkParams.iFlags = TDisplaySinkParams::EDisplaySinkDP; |
|
1615 __VTPRINTEXITR( "RVD(DP).GetSinkParams flags=%d", |
|
1616 (TInt) aSinkParams.iFlags ) |
|
1617 } |
|
1618 |
|
1619 // ----------------------------------------------------------------------------- |
|
1620 // CVtEngDrawDP::DisplaySink |
|
1621 // Returns reference to sink. |
|
1622 // ----------------------------------------------------------------------------- |
|
1623 // |
|
1624 MDisplaySink& CVtEngDrawDP::DisplaySink() |
|
1625 { |
|
1626 return *iDisplaySink; |
|
1627 } |
|
1628 |
|
1629 // ----------------------------------------------------------------------------- |
|
1630 // CVtEngDrawDP::StoreFrameBuffer |
|
1631 // Stores given frame buffer. |
|
1632 // ----------------------------------------------------------------------------- |
|
1633 // |
|
1634 void CVtEngDrawDP::StoreFrameBuffer( |
|
1635 CPostingSurface::TPostingBuff* aPostingBuffer ) |
|
1636 { |
|
1637 __VTPRINTENTER( "RVD(DP).StoreFrameBuffer" ) |
|
1638 if ( iPostingFormat == KDefaultPostingFormat422 ) |
|
1639 { |
|
1640 const TInt height( iSourceSize.iHeight ); |
|
1641 const TInt srcStride( aPostingBuffer->GetStride() ); |
|
1642 const TInt dstStride( iSourceSize.iWidth * 2 ); |
|
1643 TUint8* dst = |
|
1644 const_cast< TUint8* >( iFrameBuffer->Des().Ptr() ); |
|
1645 const TUint8* src = |
|
1646 reinterpret_cast< const TUint8* >( aPostingBuffer->GetBuffer() ); |
|
1647 for ( TInt y = height - 1; y >= 0; y-- ) |
|
1648 { |
|
1649 dst = Mem::Copy( dst, src, dstStride ); |
|
1650 src += srcStride; |
|
1651 } |
|
1652 } |
|
1653 else |
|
1654 { |
|
1655 TInt frameBufferSizeInBytes( GetFrameBufferSize( iSourceSize ) ); |
|
1656 TPtrC8 postingBufferDesC( |
|
1657 reinterpret_cast< const TUint8* >( aPostingBuffer->GetBuffer() ), |
|
1658 frameBufferSizeInBytes ); |
|
1659 *iFrameBuffer = postingBufferDesC; |
|
1660 } |
|
1661 SetFlag( EFrameBufferFilled | EFrameBufferNeedsConvertAndScale ); |
|
1662 __VTPRINTEXIT( "RVD(DP).StoreFrameBuffer" ) |
|
1663 } |
|
1664 |
|
1665 // ----------------------------------------------------------------------------- |
|
1666 // CVtEngDrawDP::CreateFrameBufferL |
|
1667 // Creates frame buffer. |
|
1668 // ----------------------------------------------------------------------------- |
|
1669 // |
|
1670 void CVtEngDrawDP::CreateFrameBufferL( const TSize& aSize ) |
|
1671 { |
|
1672 __VTPRINTENTER( "RVD(DP).CreateFrameBufferL" ) |
|
1673 delete iFrameBuffer; iFrameBuffer = NULL; |
|
1674 iFrameBuffer = HBufC8::NewL( GetFrameBufferSize( aSize ) ); |
|
1675 ClearFlag( EFrameBufferFilled | EFrameBufferNeedsConvertAndScale ); |
|
1676 __VTPRINTEXIT( "RVD(DP).CreateFrameBufferL" ) |
|
1677 } |
|
1678 |
|
1679 // ----------------------------------------------------------------------------- |
|
1680 // CVtEngDrawDP::SetAvailableToSink |
|
1681 // Sets posting buffer available to sink. |
|
1682 // ----------------------------------------------------------------------------- |
|
1683 // |
|
1684 void CVtEngDrawDP::SetAvailableToSink( CPostingSurface::TPostingBuff* aBuffer ) |
|
1685 { |
|
1686 __VTPRINTENTER( "RVD(DP).SetAvailableToSink" ) |
|
1687 for ( TInt i = MDisplaySink::EFirstBitmap; |
|
1688 i < MDisplaySink::EFirstBitmap + KVtEngMaxBuffers; i++ ) |
|
1689 { |
|
1690 if ( !iBuffers[ i ].IsSet() ) |
|
1691 { |
|
1692 __VTPRINT3( DEBUG_MEDIA, |
|
1693 "RVD(DP).SetAvailableToSink buffer %d: $%x", |
|
1694 i, reinterpret_cast< TUint >( aBuffer->GetBuffer() ) ); |
|
1695 iBuffers[ i ].Set( aBuffer ); |
|
1696 Activate(); |
|
1697 DisplaySink().SetBitmapAvailable( |
|
1698 static_cast< MDisplaySink::TBitmapNo >( i ) ); |
|
1699 break; |
|
1700 } |
|
1701 } |
|
1702 __VTPRINTEXIT( "RVD(DP).SetAvailableToSink" ) |
|
1703 } |
|
1704 |
|
1705 // ----------------------------------------------------------------------------- |
|
1706 // CVtEngDrawDP::SetAvailableToSink |
|
1707 // Sets posting buffer available to sink. |
|
1708 // ----------------------------------------------------------------------------- |
|
1709 // |
|
1710 CPostingSurface* CVtEngDrawDP::CreatePostingSurfaceL() |
|
1711 { |
|
1712 __VTPRINTENTER( "RVD(DP).CreatePostingSurfaceL" ) |
|
1713 CPostingSurface* postingSurface = NULL; |
|
1714 CPostingSurfaceFactory* ( *createFactoryL )() = |
|
1715 reinterpret_cast< CPostingSurfaceFactory*(*)() >( iDPLib->Lookup( 1 ) ); |
|
1716 if ( createFactoryL ) |
|
1717 { |
|
1718 CPostingSurfaceFactory* factory = createFactoryL(); |
|
1719 CleanupStack::PushL( factory ); |
|
1720 postingSurface = factory->NewPostingSurfaceL( EMainDisplay ); |
|
1721 CleanupStack::PopAndDestroy(); // factory |
|
1722 } |
|
1723 __VTPRINTEXIT( "RVD(DP).CreatePostingSurfaceL" ) |
|
1724 return postingSurface; |
|
1725 } |
|
1726 |
|
1727 // ----------------------------------------------------------------------------- |
|
1728 // CVtEngDrawDP::CloseDPLibrary |
|
1729 // Close the DP API library and free the allocated instance. |
|
1730 // ----------------------------------------------------------------------------- |
|
1731 // |
|
1732 void CVtEngDrawDP::CloseDPLibrary() |
|
1733 { |
|
1734 if ( iDPLib ) |
|
1735 { |
|
1736 iDPLib->Close(); |
|
1737 delete iDPLib; |
|
1738 iDPLib = NULL; |
|
1739 } |
|
1740 } |
|
1741 |
|
1742 // ----------------------------------------------------------------------------- |
|
1743 // CVtEngDrawDP::LoadDPLibraryL |
|
1744 // Loads DP API library. |
|
1745 // ----------------------------------------------------------------------------- |
|
1746 // |
|
1747 void CVtEngDrawDP::LoadDPLibraryL() |
|
1748 { |
|
1749 CloseDPLibrary(); |
|
1750 iDPLib = new ( ELeave ) RLibrary(); |
|
1751 TInt error( iDPLib->Load( KDPAPIDLLName() ) ); |
|
1752 if ( error ) |
|
1753 { |
|
1754 delete iDPLib; |
|
1755 iDPLib = NULL; |
|
1756 User::Leave( error ); |
|
1757 } |
|
1758 } |
|
1759 |
|
1760 // ----------------------------------------------------------------------------- |
|
1761 // CVtEngDrawDP::Convert420ToVtImg |
|
1762 // ----------------------------------------------------------------------------- |
|
1763 // |
|
1764 void CVtEngDrawDP::Convert420ToVtImg( HBufC8* aSource, |
|
1765 CVtImageBitmap& aTarget ) |
|
1766 { |
|
1767 __VTPRINTENTER( "RVD(DP).Convert420ToVtImg" ) |
|
1768 |
|
1769 CFbsBitmap& bitmap( aTarget.Bitmap() ); |
|
1770 TSize size( bitmap.SizeInPixels() ); |
|
1771 TInt height( size.iHeight ); |
|
1772 TInt width( size.iWidth ); |
|
1773 TInt bytes( bitmap.ScanLineLength( width, bitmap.DisplayMode() ) ); |
|
1774 |
|
1775 const TUint8* y1ptr = aSource->Ptr(); |
|
1776 const TUint8* y2ptr = y1ptr + width; |
|
1777 const TUint8* uptr = y1ptr + ( width * height ); |
|
1778 const TUint8* vptr = uptr + ( width * height ) / 4; |
|
1779 |
|
1780 bitmap.LockHeap(); |
|
1781 |
|
1782 TUint8* d1ptr = reinterpret_cast< TUint8* >( bitmap.DataAddress() ); |
|
1783 TUint8* d2ptr = d1ptr + bytes; |
|
1784 |
|
1785 height /= 2; // divide by 2 because we process to rows at time |
|
1786 bytes *= 2; // multiply by 2 so we don't need to do it in loop |
|
1787 |
|
1788 while ( height-- ) |
|
1789 { |
|
1790 DoConvertYuv420toXRGB0888( width, y1ptr, y2ptr, uptr, vptr, d1ptr, |
|
1791 d2ptr ); |
|
1792 y1ptr = y2ptr; |
|
1793 y2ptr += width; |
|
1794 d1ptr += bytes; |
|
1795 d2ptr += bytes; |
|
1796 } |
|
1797 |
|
1798 bitmap.UnlockHeap(); |
|
1799 |
|
1800 __VTPRINTEXIT( "RVD(DP).Convert420ToVtImg" ) |
|
1801 } |
|
1802 |
|
1803 // ----------------------------------------------------------------------------- |
|
1804 // CVtEngDrawDP::Convert422ToVtImg |
|
1805 // ----------------------------------------------------------------------------- |
|
1806 // |
|
1807 void CVtEngDrawDP::Convert422ToVtImg( HBufC8* aSource, CVtImageBitmap& aTarget ) |
|
1808 { |
|
1809 __VTPRINTENTER( "RVD(DP).Convert422ToVtImg" ) |
|
1810 CFbsBitmap& bitmap( aTarget.Bitmap() ); |
|
1811 TSize size( bitmap.SizeInPixels() ); |
|
1812 TInt height( size.iHeight ); |
|
1813 TInt width( size.iWidth ); |
|
1814 TInt bytes( bitmap.ScanLineLength( width, bitmap.DisplayMode() ) ); |
|
1815 |
|
1816 const TUint8* sptr = aSource->Ptr(); |
|
1817 |
|
1818 bitmap.LockHeap(); |
|
1819 |
|
1820 TUint8* dptr = reinterpret_cast< TUint8* >( bitmap.DataAddress() ); |
|
1821 while ( height-- ) |
|
1822 { |
|
1823 DoConvertYuv422toXRGB0888( width, sptr, dptr ); |
|
1824 dptr += bytes; |
|
1825 } |
|
1826 |
|
1827 bitmap.UnlockHeap(); |
|
1828 |
|
1829 __VTPRINTEXIT( "RVD(DP).Convert422ToVtImg" ) |
|
1830 } |
|
1831 |
|
1832 // ----------------------------------------------------------------------------- |
|
1833 // CVtEngDrawDP::UpdateVtFrame |
|
1834 // ----------------------------------------------------------------------------- |
|
1835 // |
|
1836 void CVtEngDrawDP::UpdateVtFrame() |
|
1837 { |
|
1838 __VTPRINTENTER( "RVD(DP).UpdateVtFrame" ) |
|
1839 if ( IsFlag( EFrameBufferFilled ) ) |
|
1840 { |
|
1841 CFbsBitmap* bitmap = NULL; |
|
1842 if ( IsFlag( EFrameBufferNeedsConvertAndScale ) ) |
|
1843 { |
|
1844 if ( iPostingFormat == KDefaultPostingFormat422 ) |
|
1845 { |
|
1846 Convert422ToVtImg( iFrameBuffer, *iSource ); |
|
1847 } |
|
1848 else |
|
1849 { |
|
1850 Convert420ToVtImg( iFrameBuffer, *iSource ); |
|
1851 } |
|
1852 TRAPD( error, iImageScaler->ScaleNowL( *iSource, *iTarget ) ); |
|
1853 if ( !error ) |
|
1854 { |
|
1855 bitmap = &iTarget->Bitmap(); |
|
1856 } |
|
1857 ClearFlag( EFrameBufferNeedsConvertAndScale ); |
|
1858 } |
|
1859 else |
|
1860 { |
|
1861 bitmap = &iTarget->Bitmap(); |
|
1862 } |
|
1863 Config().iObserver->vtSetFrame( MVtEngFrameObserver::ERemoteVideoFrame, |
|
1864 bitmap ); |
|
1865 } |
|
1866 __VTPRINTEXIT( "RVD(DP).UpdateVtFrame" ) |
|
1867 } |
|
1868 |
|
1869 // ----------------------------------------------------------------------------- |
|
1870 // CVtEngDrawDP::ScalingFinished |
|
1871 // ----------------------------------------------------------------------------- |
|
1872 // |
|
1873 void CVtEngDrawDP::ScalingFinished( TInt ) |
|
1874 { |
|
1875 } |
|
1876 |
|
1877 // Implementation for CVtEngDrawDP::TVtEngBuffer |
|
1878 |
|
1879 // ----------------------------------------------------------------------------- |
|
1880 // CVtEngDrawDP::TVtEngBuffer::TVtEngBuffer |
|
1881 // |
|
1882 // ----------------------------------------------------------------------------- |
|
1883 // |
|
1884 CVtEngDrawDP::TVtEngBuffer::TVtEngBuffer() |
|
1885 : iBuffer( 0 ) |
|
1886 { |
|
1887 __VTPRINTENTER( "RVD(DP).Buffer.Ctor" ) |
|
1888 __VTPRINTEXIT( "RVD(DP).Buffer.Ctor" ) |
|
1889 } |
|
1890 |
|
1891 // ----------------------------------------------------------------------------- |
|
1892 // CVtEngDrawDP::TVtEngBuffer::Set |
|
1893 // |
|
1894 // ----------------------------------------------------------------------------- |
|
1895 // |
|
1896 void CVtEngDrawDP::TVtEngBuffer::Set( CPostingSurface::TPostingBuff* aBuffer ) |
|
1897 { |
|
1898 __VTPRINTENTER( "RVD(DP).Buffer.Set" ) |
|
1899 __VTPRINT2( DEBUG_MEDIA, "RVD(DP).Buffer.Set $%x", |
|
1900 reinterpret_cast< TUint >( aBuffer->GetBuffer() ) ) |
|
1901 iBuffer = aBuffer; |
|
1902 __VTPRINTEXIT( "RVD(DP).Buffer.Set" ) |
|
1903 } |
|
1904 |
|
1905 // ----------------------------------------------------------------------------- |
|
1906 // CVtEngDrawDP::TVtEngBuffer::UnSet |
|
1907 // |
|
1908 // ----------------------------------------------------------------------------- |
|
1909 // |
|
1910 void CVtEngDrawDP::TVtEngBuffer::UnSet() |
|
1911 { |
|
1912 __VTPRINTENTER( "RVD(DP).Buffer.UnSet" ) |
|
1913 iBuffer = 0; |
|
1914 __VTPRINTEXIT( "RVD(DP).Buffer.UnSet" ) |
|
1915 } |
|
1916 |
|
1917 // ----------------------------------------------------------------------------- |
|
1918 // CVtEngDrawDP::TVtEngBuffer::IsSet |
|
1919 // |
|
1920 // ----------------------------------------------------------------------------- |
|
1921 // |
|
1922 TBool CVtEngDrawDP::TVtEngBuffer::IsSet() const |
|
1923 { |
|
1924 return ( iBuffer != 0 ); |
|
1925 } |
|
1926 |
|
1927 // ----------------------------------------------------------------------------- |
|
1928 // CVtEngDrawDP::TVtEngBuffer::Buffer |
|
1929 // |
|
1930 // ----------------------------------------------------------------------------- |
|
1931 // |
|
1932 CPostingSurface::TPostingBuff*& CVtEngDrawDP::TVtEngBuffer::Buffer() |
|
1933 { |
|
1934 return iBuffer; |
|
1935 } |
|
1936 |
|
1937 // Implementation for CVtEngDrawDP::CVtEngBufferWaiter |
|
1938 |
|
1939 // ----------------------------------------------------------------------------- |
|
1940 // CVtEngDrawDP::CVtEngBufferWaiter::CVtEngBufferWaiter |
|
1941 // ----------------------------------------------------------------------------- |
|
1942 // |
|
1943 CVtEngDrawDP::CVtEngBufferWaiter::CVtEngBufferWaiter |
|
1944 ( CPostingSurface& aPostingSurface, MVtEngBufferWaiterObserver& aObserver ) |
|
1945 : CActive( CActive::EPriorityStandard ), |
|
1946 iPostingSurface( &aPostingSurface ), iObserver( &aObserver ) |
|
1947 { |
|
1948 __VTPRINTENTER( "RVD(DP).BufferWaiter.Ctor" ) |
|
1949 CActiveScheduler::Add( this ); |
|
1950 __VTPRINTEXIT( "RVD(DP).BufferWaiter.Ctor" ) |
|
1951 } |
|
1952 |
|
1953 // ----------------------------------------------------------------------------- |
|
1954 // CVtEngDrawDP::CVtEngBufferWaiter::~CVtEngBufferWaiter |
|
1955 // ----------------------------------------------------------------------------- |
|
1956 // |
|
1957 CVtEngDrawDP::CVtEngBufferWaiter::~CVtEngBufferWaiter() |
|
1958 { |
|
1959 __VTPRINTENTER( "RVD(DP).BufferWaiter.~" ) |
|
1960 Cancel(); |
|
1961 __VTPRINTEXIT( "RVD(DP).BufferWaiter.~" ) |
|
1962 } |
|
1963 |
|
1964 // ----------------------------------------------------------------------------- |
|
1965 // CVtEngDrawDP::CVtEngBufferWaiter::Activate |
|
1966 // ----------------------------------------------------------------------------- |
|
1967 // |
|
1968 void CVtEngDrawDP::CVtEngBufferWaiter::Activate() |
|
1969 { |
|
1970 __VTPRINTENTER( "RVD(DP).BufferWaiter.Activate" ) |
|
1971 iStatus = KRequestPending; |
|
1972 SetActive(); |
|
1973 __VTPRINTEXIT( "RVD(DP).BufferWaiter.Activate" ) |
|
1974 } |
|
1975 |
|
1976 // ----------------------------------------------------------------------------- |
|
1977 // CVtEngDrawDP::CVtEngBufferWaiter::FetchBuffer |
|
1978 // ----------------------------------------------------------------------------- |
|
1979 // |
|
1980 TInt CVtEngDrawDP::CVtEngBufferWaiter::FetchBuffer() |
|
1981 { |
|
1982 __VTPRINTENTER( "RVD(DP).BufferWaiter.FetchBuffer" ) |
|
1983 // do nothing if we're already active |
|
1984 if ( IsActive() ) |
|
1985 { |
|
1986 __VTPRINTEXIT( "RVD(DP).BufferWaiter.FetchBuffer" ) |
|
1987 return KErrNone; |
|
1988 } |
|
1989 // else start fetching |
|
1990 Activate(); |
|
1991 __VTPRINTEXIT( "RVD(DP).BufferWaiter.FetchBuffer" ) |
|
1992 return iPostingSurface->WaitForNextBuffer( iStatus ); |
|
1993 } |
|
1994 |
|
1995 // ----------------------------------------------------------------------------- |
|
1996 // CVtEngDrawDP::CVtEngBufferWaiter::RunL |
|
1997 // ----------------------------------------------------------------------------- |
|
1998 // |
|
1999 void CVtEngDrawDP::CVtEngBufferWaiter::RunL() |
|
2000 { |
|
2001 __VTPRINTENTER( "RVD(DP).BufferWaiter.RunL" ) |
|
2002 __VTPRINT2( DEBUG_MEDIA, "RVD(DP).BufferWaiter.RunL %d", iStatus.Int() ); |
|
2003 TInt result( iStatus.Int() ); |
|
2004 if ( result == KErrNone ) |
|
2005 { |
|
2006 iObserver->BufferReady( iPostingSurface->NextBuffer() ); |
|
2007 } |
|
2008 else |
|
2009 { |
|
2010 iObserver->FetchError( result ); |
|
2011 } |
|
2012 __VTPRINTEXIT( "RVD(DP).BufferWaiter.RunL" ) |
|
2013 } |
|
2014 |
|
2015 // ----------------------------------------------------------------------------- |
|
2016 // CVtEngDrawDP::CVtEngBufferWaiter::DoCancel |
|
2017 // ----------------------------------------------------------------------------- |
|
2018 // |
|
2019 void CVtEngDrawDP::CVtEngBufferWaiter::DoCancel() |
|
2020 { |
|
2021 __VTPRINTENTER( "RVD(DP).BufferWaiter.DoCancel" ) |
|
2022 iPostingSurface->CancelBuffer(); |
|
2023 __VTPRINTEXIT( "RVD(DP).BufferWaiter.DoCancel" ) |
|
2024 } |
|
2025 |
|
2026 // End of File |