|
94
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2000 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 the License "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:
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
#include <e32def.h> // First to avoid NULL redefine warning (no #ifndef NULL).
|
|
|
19 |
#include "nw_image_epoc32simpleimagei.h"
|
|
|
20 |
#include "Epoc32ImageDecoder.h"
|
|
|
21 |
#include "nw_lmgr_rootbox.h"
|
|
|
22 |
#include "nw_hed_documentroot.h"
|
|
|
23 |
#include "HEDDocumentListener.h"
|
|
|
24 |
#include "nw_hed_contenthandler.h"
|
|
|
25 |
#include "nw_image_iimageobserver.h"
|
|
|
26 |
#include "nw_adt_resizablevector.h"
|
|
|
27 |
#include "GDIDeviceContext.h"
|
|
|
28 |
|
|
|
29 |
#include "nw_gdi_types.h"
|
|
|
30 |
|
|
|
31 |
#include <fbs.h>
|
|
|
32 |
#include <bitdev.h>
|
|
|
33 |
#include "BrsrStatusCodes.h"
|
|
|
34 |
#include "nwx_logger.h"
|
|
|
35 |
#include <MemoryManager.h>
|
|
|
36 |
|
|
|
37 |
// Forward declaration which can't be put inside header file without breaking
|
|
|
38 |
// compilation of OOC files.
|
|
|
39 |
|
|
|
40 |
TBrowserStatusCode
|
|
|
41 |
scaleBitmap( CFbsBitmap* bitmap, CFbsBitmap** scaledBitmap, TRect* rect );
|
|
|
42 |
|
|
|
43 |
void
|
|
|
44 |
_NW_Image_Epoc32SimpleImage_ImageOpened( NW_Image_AbstractImage_t* aAbstractImage, NW_Bool aFailed,
|
|
|
45 |
NW_Int16 aSuppressDupReformats )
|
|
|
46 |
{
|
|
|
47 |
// add the image to out of view list
|
|
|
48 |
NW_Image_Epoc32Simple_t* thisObj = NW_Image_Epoc32SimpleOf (aAbstractImage);
|
|
|
49 |
|
|
|
50 |
if (thisObj->docNodeList)
|
|
|
51 |
{
|
|
|
52 |
NW_HED_DocumentNode_t* docNode =
|
|
|
53 |
*(NW_HED_DocumentNode_t**)NW_ADT_Vector_ElementAt(thisObj->docNodeList, 0);
|
|
|
54 |
NW_ASSERT(docNode);
|
|
|
55 |
NW_HED_DocumentRoot_t* docRoot = (NW_HED_DocumentRoot_t*)NW_HED_DocumentNode_GetRootNode(docNode);
|
|
|
56 |
NW_LMgr_RootBox_t* rootBox = NW_HED_DocumentRoot_GetRootBox(docRoot);
|
|
|
57 |
NW_LMgr_RootBox_AddToOutOfViewList(rootBox, aAbstractImage);
|
|
|
58 |
}
|
|
|
59 |
_NW_Image_AbstractImage_ImageOpened(aAbstractImage, aFailed, aSuppressDupReformats );
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
/* ------------------------------------------------------------------------- *
|
|
|
63 |
class definition
|
|
|
64 |
* ------------------------------------------------------------------------- */
|
|
|
65 |
|
|
|
66 |
/* ------------------------------------------------------------------------- */
|
|
|
67 |
const
|
|
|
68 |
NW_Image_Epoc32Simple_Class_t NW_Image_Epoc32Simple_Class = {
|
|
|
69 |
{ /* NW_Object_Core */
|
|
|
70 |
/* super */ &NW_Image_AbstractImage_Class,
|
|
|
71 |
/* queryInterface */ _NW_Object_Base_QueryInterface
|
|
|
72 |
},
|
|
|
73 |
{ /* NW_Object_Base */
|
|
|
74 |
/* interfaceList */ NULL
|
|
|
75 |
},
|
|
|
76 |
{ /* NW_Object_Dynamic */
|
|
|
77 |
/* instanceSize */ sizeof (NW_Image_Epoc32Simple_t),
|
|
|
78 |
/* construct */ _NW_Image_Epoc32Simple_Construct,
|
|
|
79 |
/* destruct */ _NW_Image_Epoc32Simple_Destruct
|
|
|
80 |
},
|
|
|
81 |
{ /* NW_Image_Abstract */
|
|
|
82 |
/* getSize */ _NW_Image_Epoc32Simple_GetSize,
|
|
|
83 |
/* draw */ _NW_Image_Epoc32Simple_Draw,
|
|
|
84 |
/* drawScaled */ _NW_Image_Epoc32Simple_DrawScaled,
|
|
|
85 |
/* drawInRect */ _NW_Image_Epoc32Simple_DrawInRect,
|
|
|
86 |
/* incrementImage */ _NW_Image_Epoc32Simple_IncrementImage,
|
|
|
87 |
/* getLoopCount */ _NW_Image_AbstractImage_GetLoopCount,
|
|
|
88 |
/* setLoopCount */ _NW_Image_AbstractImage_SetLoopCount,
|
|
|
89 |
/* getDelay */ _NW_Image_AbstractImage_GetDelay,
|
|
|
90 |
/* isAnimated */ _NW_Image_AbstractImage_IsAnimated,
|
|
|
91 |
/* setImageObserver */ _NW_Image_AbstractImage_SetImageObserver,
|
|
|
92 |
/* removeImageObserver */ _NW_Image_AbstractImage_RemoveImageObserver,
|
|
|
93 |
/* imageOpened */ _NW_Image_Epoc32SimpleImage_ImageOpened,
|
|
|
94 |
/* imageSizeChanged */ _NW_Image_AbstractImage_ImageSizeChanged,
|
|
|
95 |
/* imageDecoded */ _NW_Image_AbstractImage_ImageDecoded,
|
|
|
96 |
/* imageOpenStarted */ _NW_Image_AbstractImage_ImageOpenStarted,
|
|
|
97 |
/* forceImageDecode */ _NW_Image_Epoc32Simple_ForceImageDecode
|
|
|
98 |
},
|
|
|
99 |
{ /* NW_Image_Simple */
|
|
|
100 |
/* partialNextChunk */ _NW_Image_Epoc32Simple_PartialNextChunk
|
|
|
101 |
}
|
|
|
102 |
};
|
|
|
103 |
|
|
|
104 |
/* ------------------------------------------------------------------------- *
|
|
|
105 |
virtual methods
|
|
|
106 |
* ------------------------------------------------------------------------- */
|
|
|
107 |
|
|
|
108 |
/* ------------------------------------------------------------------------- */
|
|
|
109 |
|
|
|
110 |
TBrowserStatusCode
|
|
|
111 |
_NW_Image_Epoc32Simple_Construct (NW_Object_Dynamic_t* dynamicObject, va_list *argp)
|
|
|
112 |
{
|
|
|
113 |
NW_TRY(status)
|
|
|
114 |
{
|
|
|
115 |
NW_Image_Epoc32Simple_t* thisObj;
|
|
|
116 |
NW_HED_DocumentNode_t* documentNode;
|
|
|
117 |
|
|
|
118 |
// parameter assertion block
|
|
|
119 |
NW_ASSERT(NW_Object_IsInstanceOf(dynamicObject, &NW_Image_Epoc32Simple_Class));
|
|
|
120 |
NW_ASSERT(argp != NULL);
|
|
|
121 |
|
|
|
122 |
// for convenience
|
|
|
123 |
thisObj = NW_Image_Epoc32SimpleOf (dynamicObject);
|
|
|
124 |
|
|
|
125 |
// initialize the member variables
|
|
|
126 |
// Won't know if image is animated until after it is opened by decoder
|
|
|
127 |
NW_Image_AbstractImageOf(thisObj)->isAnimated = NW_FALSE;
|
|
|
128 |
thisObj->prevFlags = 0;
|
|
|
129 |
thisObj->needsDecode = NW_FALSE;
|
|
|
130 |
thisObj->imageDecoding = NW_FALSE;
|
|
|
131 |
|
|
|
132 |
NW_GDI_Dimension3D_t size = va_arg (*argp, NW_GDI_Dimension3D_t);
|
|
|
133 |
thisObj->size = size;
|
|
|
134 |
|
|
|
135 |
const void* bitmap = va_arg (*argp, const void*);
|
|
|
136 |
thisObj->bitmap = bitmap;
|
|
|
137 |
|
|
|
138 |
const void* mask = va_arg (*argp, const void*);
|
|
|
139 |
thisObj->mask = mask;
|
|
|
140 |
|
|
|
141 |
thisObj->invertedMask = (NW_Bool)va_arg (*argp, NW_Uint32);
|
|
|
142 |
|
|
|
143 |
// "isTransparent" doesn't appear to be used by any Epoc code
|
|
|
144 |
NW_Bool isTransparent = (NW_Bool)va_arg (*argp, NW_Uint32);
|
|
|
145 |
(void)isTransparent;
|
|
|
146 |
|
|
|
147 |
// Do we have a image type that isn't recognized by Symbian, but we handle
|
|
|
148 |
thisObj->imageType = (TImageType)va_arg (*argp, NW_Uint32);
|
|
|
149 |
|
|
|
150 |
// in order to make sure that we take rawData ownership,
|
|
|
151 |
// the code should not leave before this point.
|
|
|
152 |
thisObj->rawData = va_arg (*argp, void*);
|
|
|
153 |
thisObj->rawDataLength = va_arg (*argp, NW_Int32);
|
|
|
154 |
|
|
|
155 |
documentNode = va_arg (*argp, NW_HED_DocumentNode_t*);
|
|
|
156 |
if (documentNode)
|
|
|
157 |
{
|
|
|
158 |
thisObj->docNodeList = (NW_ADT_DynamicVector_t*)
|
|
|
159 |
NW_ADT_ResizableVector_New(sizeof(void*), 10, 5 );
|
|
|
160 |
// OOM check
|
|
|
161 |
NW_THROW_OOM_ON_NULL(thisObj->docNodeList, status);
|
|
|
162 |
|
|
|
163 |
NW_THROW_OOM_ON_NULL(NW_ADT_DynamicVector_InsertAt(thisObj->docNodeList,
|
|
|
164 |
&documentNode, NW_ADT_Vector_AtEnd), status);
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
// If the image is not provided, it needs to be converted from the raw data.
|
|
|
168 |
// Construct an image decoder to do this.
|
|
|
169 |
if (!thisObj->bitmap)
|
|
|
170 |
{
|
|
|
171 |
TRAPD(err, thisObj->decoder = CEpoc32ImageDecoder::NewL(thisObj));
|
|
|
172 |
if (err == KErrNoMemory)
|
|
|
173 |
{
|
|
|
174 |
NW_THROW_STATUS(status, KBrsrOutOfMemory);
|
|
|
175 |
}
|
|
|
176 |
else if (err != KErrNone)
|
|
|
177 |
{
|
|
|
178 |
NW_THROW_STATUS(status, KBrsrFailure);
|
|
|
179 |
}
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
thisObj->srcHeight = 0;
|
|
|
183 |
thisObj->srcWidth = 0;
|
|
|
184 |
|
|
|
185 |
// and finally invoke our superclass constructor
|
|
|
186 |
status = _NW_Image_AbstractImage_Construct(dynamicObject, argp);
|
|
|
187 |
|
|
|
188 |
_NW_THROW_ON_ERROR(status);
|
|
|
189 |
}
|
|
|
190 |
NW_CATCH(status)
|
|
|
191 |
{
|
|
|
192 |
}
|
|
|
193 |
NW_FINALLY
|
|
|
194 |
{
|
|
|
195 |
return status;
|
|
|
196 |
}
|
|
|
197 |
NW_END_TRY
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
/* ------------------------------------------------------------------------- */
|
|
|
201 |
void
|
|
|
202 |
_NW_Image_Epoc32Simple_Destruct (NW_Object_Dynamic_t* dynamicObject)
|
|
|
203 |
{
|
|
|
204 |
NW_Image_Epoc32Simple_t* thisObj;
|
|
|
205 |
|
|
|
206 |
/* parameter assertion block */
|
|
|
207 |
NW_ASSERT (NW_Object_IsInstanceOf (dynamicObject, &NW_Image_Epoc32Simple_Class));
|
|
|
208 |
|
|
|
209 |
/* for convenience */
|
|
|
210 |
thisObj = NW_Image_Epoc32SimpleOf (dynamicObject);
|
|
|
211 |
|
|
|
212 |
// first notify the observers on the destroy event
|
|
|
213 |
NW_Image_AbstractImage_ImageDestroyed( NW_Image_AbstractImageOf( thisObj ) );
|
|
|
214 |
|
|
|
215 |
/* Delete decoder, rawData & images */
|
|
|
216 |
CEpoc32ImageDecoder* decoder = STATIC_CAST(CEpoc32ImageDecoder*, thisObj->decoder);
|
|
|
217 |
delete decoder;
|
|
|
218 |
|
|
|
219 |
NW_Image_Epoc32Simple_DestroyRawData( thisObj );
|
|
|
220 |
|
|
|
221 |
if( thisObj->docNodeList )
|
|
|
222 |
{
|
|
|
223 |
NW_Object_Delete(thisObj->docNodeList);
|
|
|
224 |
}
|
|
|
225 |
|
|
|
226 |
// image ownership is transfered when decoding completes.
|
|
|
227 |
if( thisObj->imageDecoding == NW_FALSE )
|
|
|
228 |
{
|
|
|
229 |
CFbsBitmap* oldBitmap = CONST_CAST(CFbsBitmap*, (const CFbsBitmap*)thisObj->bitmap);
|
|
|
230 |
delete oldBitmap;
|
|
|
231 |
CFbsBitmap* oldMask = CONST_CAST(CFbsBitmap*, (const CFbsBitmap*)thisObj->mask);
|
|
|
232 |
delete oldMask;
|
|
|
233 |
}
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
|
|
|
237 |
|
|
|
238 |
/* ------------------------------------------------------------------------- */
|
|
|
239 |
TBrowserStatusCode
|
|
|
240 |
_NW_Image_Epoc32Simple_PartialNextChunk( NW_Image_AbstractImage_t* image,
|
|
|
241 |
NW_Buffer_t* nextChunk )
|
|
|
242 |
{
|
|
|
243 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
|
244 |
NW_Image_Epoc32Simple_t* thisObj;
|
|
|
245 |
|
|
|
246 |
NW_ASSERT( NW_Object_IsInstanceOf( image, &NW_Image_Epoc32Simple_Class ) );
|
|
|
247 |
|
|
|
248 |
thisObj = NW_Image_Epoc32SimpleOf( image );
|
|
|
249 |
NW_ASSERT( thisObj->decoder!= NULL );
|
|
|
250 |
|
|
|
251 |
// buffer chunks
|
|
|
252 |
void* tempBuffer;
|
|
|
253 |
tempBuffer = NW_Mem_Malloc( thisObj->rawDataLength + nextChunk->length );
|
|
|
254 |
if( tempBuffer != NULL )
|
|
|
255 |
{
|
|
|
256 |
// copy old buffer
|
|
|
257 |
NW_Mem_memcpy( tempBuffer, thisObj->rawData, thisObj->rawDataLength );
|
|
|
258 |
// free old buffer
|
|
|
259 |
NW_Mem_Free( thisObj->rawData );
|
|
|
260 |
// copy new chunk
|
|
|
261 |
NW_Mem_memcpy( ((NW_Byte*)tempBuffer) + thisObj->rawDataLength,
|
|
|
262 |
nextChunk->data, nextChunk->length );
|
|
|
263 |
// set new buffer`
|
|
|
264 |
thisObj->rawData = tempBuffer;
|
|
|
265 |
// update length info
|
|
|
266 |
thisObj->rawDataLength+= nextChunk->length;
|
|
|
267 |
|
|
|
268 |
#ifdef INCREMENTAL_IMAGE_ON
|
|
|
269 |
CEpoc32ImageDecoder* decoder = STATIC_CAST( CEpoc32ImageDecoder*, thisObj->decoder );
|
|
|
270 |
|
|
|
271 |
TRAPD( error, decoder->PartialNextChunkL( nextChunk ) );
|
|
|
272 |
|
|
|
273 |
if( error == KErrNoMemory )
|
|
|
274 |
{
|
|
|
275 |
status = KBrsrOutOfMemory;
|
|
|
276 |
}
|
|
|
277 |
else if( error != KErrNone )
|
|
|
278 |
{
|
|
|
279 |
status = KBrsrFailure;
|
|
|
280 |
}
|
|
|
281 |
#endif // INCREMENTAL_IMAGE_ON
|
|
|
282 |
|
|
|
283 |
}
|
|
|
284 |
else
|
|
|
285 |
{
|
|
|
286 |
status = KBrsrOutOfMemory;
|
|
|
287 |
}
|
|
|
288 |
// release chunk
|
|
|
289 |
NW_Buffer_Free( nextChunk );
|
|
|
290 |
|
|
|
291 |
return status;
|
|
|
292 |
}
|
|
|
293 |
|
|
|
294 |
/* ------------------------------------------------------------------------- */
|
|
|
295 |
TBrowserStatusCode
|
|
|
296 |
_NW_Image_Epoc32Simple_GetSize (const NW_Image_AbstractImage_t* image,
|
|
|
297 |
NW_GDI_Dimension3D_t* size)
|
|
|
298 |
{
|
|
|
299 |
/* parameter assertion block */
|
|
|
300 |
NW_ASSERT (NW_Object_IsInstanceOf (image, &NW_Image_Epoc32Simple_Class));
|
|
|
301 |
NW_ASSERT (size != NULL);
|
|
|
302 |
|
|
|
303 |
/* set the size and return */
|
|
|
304 |
*size = NW_Image_Epoc32SimpleOf (image)->size;
|
|
|
305 |
|
|
|
306 |
return KBrsrSuccess;
|
|
|
307 |
}
|
|
|
308 |
|
|
|
309 |
/* ------------------------------------------------------------------------- */
|
|
|
310 |
TBrowserStatusCode
|
|
|
311 |
_NW_Image_Epoc32Simple_Draw (NW_Image_AbstractImage_t* image,
|
|
|
312 |
CGDIDeviceContext* deviceContext,
|
|
|
313 |
const NW_GDI_Point2D_t* location)
|
|
|
314 |
{
|
|
|
315 |
return NW_Image_AbstractImage_DrawInRect (image, deviceContext, location, NULL, NULL);
|
|
|
316 |
}
|
|
|
317 |
|
|
|
318 |
/* ------------------------------------------------------------------------- */
|
|
|
319 |
TBrowserStatusCode
|
|
|
320 |
_NW_Image_Epoc32Simple_DrawScaled (NW_Image_AbstractImage_t* image,
|
|
|
321 |
CGDIDeviceContext* deviceContext,
|
|
|
322 |
const NW_GDI_Point2D_t* location,
|
|
|
323 |
const NW_GDI_Dimension3D_t* size)
|
|
|
324 |
{
|
|
|
325 |
return NW_Image_AbstractImage_DrawInRect (image, deviceContext, location, size, NULL);
|
|
|
326 |
}
|
|
|
327 |
|
|
|
328 |
/* -------------------------------------------------------------------------
|
|
|
329 |
* Function: _NW_Image_Epoc32Simple_DrawInRect
|
|
|
330 |
* Description: Draw scaled image on a certain location within a rectangle.
|
|
|
331 |
*
|
|
|
332 |
* @param image: the simple image to be drawn
|
|
|
333 |
* @param deviceContext: the device context object.
|
|
|
334 |
* @param location: the top-left point to start drawing
|
|
|
335 |
* @param size: the size to scale the image to.
|
|
|
336 |
* @param rect: the rectangle to draw the image within
|
|
|
337 |
*
|
|
|
338 |
* note: Both the parameters size and rect could be NULL.
|
|
|
339 |
* If the size is NULL, the image is not scaled before being drawn.
|
|
|
340 |
* If the rect is NULL, draw the entire image.
|
|
|
341 |
*/
|
|
|
342 |
TBrowserStatusCode
|
|
|
343 |
_NW_Image_Epoc32Simple_DrawInRect (NW_Image_AbstractImage_t* image,
|
|
|
344 |
CGDIDeviceContext* deviceContext,
|
|
|
345 |
const NW_GDI_Point2D_t* location,
|
|
|
346 |
const NW_GDI_Dimension3D_t* size,
|
|
|
347 |
const NW_GDI_Rectangle_t* rect)
|
|
|
348 |
{
|
|
|
349 |
NW_Image_Epoc32Simple_t* thisObj;
|
|
|
350 |
NW_GDI_ImageBlock_t imageBlock;
|
|
|
351 |
NW_GDI_Rectangle_t cropRect;
|
|
|
352 |
NW_Bool imageScaled = NW_FALSE;
|
|
|
353 |
NW_Bool imageOverlapped = NW_FALSE;
|
|
|
354 |
NW_GDI_Rectangle_t overlap;
|
|
|
355 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
|
356 |
|
|
|
357 |
/* parameter assertion block */
|
|
|
358 |
NW_ASSERT (NW_Object_IsInstanceOf (image, &NW_Image_Epoc32Simple_Class));
|
|
|
359 |
NW_ASSERT (location != NULL);
|
|
|
360 |
|
|
|
361 |
/* for convenience */
|
|
|
362 |
thisObj = NW_Image_Epoc32SimpleOf (image);
|
|
|
363 |
CEpoc32ImageDecoder* decoder = STATIC_CAST(CEpoc32ImageDecoder*, thisObj->decoder);
|
|
|
364 |
|
|
|
365 |
/* If there is a decoder, then the image needs to be decoded before displaying
|
|
|
366 |
* if not done already, or if "needsDecode" (animated image has moved on to
|
|
|
367 |
* next frame). Also, image is to be decoded based on the state of the decoder
|
|
|
368 |
*/
|
|
|
369 |
if (decoder != NULL && (thisObj->bitmap == NULL || thisObj->needsDecode ||
|
|
|
370 |
(decoder->getDecoderState() != CEpoc32ImageDecoder::ID_DECODE_COMPLETE)&&
|
|
|
371 |
(decoder->getDecoderState() != CEpoc32ImageDecoder::ID_DECODING)))
|
|
|
372 |
{
|
|
|
373 |
decoder->Decode();
|
|
|
374 |
}
|
|
|
375 |
|
|
|
376 |
/* If there is already a bitmap, draw it. When the results of the decode operation
|
|
|
377 |
* come back this function will be called again; then there should be a bitmap.
|
|
|
378 |
*/
|
|
|
379 |
if( thisObj->bitmap )
|
|
|
380 |
{
|
|
|
381 |
imageBlock.colPalette.data = NULL;
|
|
|
382 |
imageBlock.conversionStatus = NW_GDI_Image_ConversionRequired;
|
|
|
383 |
imageBlock.size = thisObj->size;
|
|
|
384 |
imageBlock.data = thisObj->bitmap;
|
|
|
385 |
imageBlock.mask = thisObj->mask;
|
|
|
386 |
imageBlock.invertedMask = thisObj->invertedMask;
|
|
|
387 |
|
|
|
388 |
/* check if scaling required */
|
|
|
389 |
if( size )
|
|
|
390 |
{
|
|
|
391 |
// if the image is scaled for some reason, then we have to make sure
|
|
|
392 |
// that we are having the right size of it.
|
|
|
393 |
CFbsBitmap* realBitmap = CONST_CAST(CFbsBitmap*, (const CFbsBitmap*)thisObj->bitmap);
|
|
|
394 |
TSize bitmapRealSize = realBitmap->SizeInPixels();
|
|
|
395 |
|
|
|
396 |
if( thisObj->size.width != size->width || thisObj->size.height != size->height ||
|
|
|
397 |
bitmapRealSize.iWidth != size->width || bitmapRealSize.iHeight != size->height )
|
|
|
398 |
{
|
|
|
399 |
NW_GDI_ImageBlock_t scaledImageBlock;
|
|
|
400 |
|
|
|
401 |
// scale current data
|
|
|
402 |
status = deviceContext->ScaleImage ( size, &imageBlock, &scaledImageBlock);
|
|
|
403 |
|
|
|
404 |
if (status == KBrsrSuccess)
|
|
|
405 |
{
|
|
|
406 |
imageScaled = NW_TRUE;
|
|
|
407 |
imageBlock.data = scaledImageBlock.data;
|
|
|
408 |
imageBlock.mask = scaledImageBlock.mask;
|
|
|
409 |
imageBlock.size = *size;
|
|
|
410 |
}
|
|
|
411 |
}
|
|
|
412 |
}
|
|
|
413 |
|
|
|
414 |
/* if the parameter rect is NULL, we want to draw the entire image,
|
|
|
415 |
else we only want to draw the overlap of image and the showing rectangle */
|
|
|
416 |
if (rect == NULL)
|
|
|
417 |
{
|
|
|
418 |
cropRect.point.x = 0;
|
|
|
419 |
cropRect.point.y = 0;
|
|
|
420 |
cropRect.dimension.width = imageBlock.size.width;
|
|
|
421 |
cropRect.dimension.height = imageBlock.size.height;
|
|
|
422 |
}
|
|
|
423 |
else
|
|
|
424 |
{
|
|
|
425 |
/* now based on the overlap of imageblock and showing rectangle,
|
|
|
426 |
calculate the crop rectangle which is used to crop the image, the
|
|
|
427 |
difference between the overlap and crop image is: crop image's
|
|
|
428 |
coordinates are relative to image not absolute.
|
|
|
429 |
example (as x, y, width, height)
|
|
|
430 |
rect (10, 10, 50, 50)
|
|
|
431 |
image (30, 30, 40, 40)
|
|
|
432 |
overlap area (30, 30, 30, 30)
|
|
|
433 |
crop rectangle ( 0, 0, 30, 30)
|
|
|
434 |
*/
|
|
|
435 |
imageOverlapped = TRUE;
|
|
|
436 |
overlap.point.x = (location->x > rect->point.x) ? location->x : rect->point.x;
|
|
|
437 |
overlap.point.y = (location->y > rect->point.y) ? location->y : rect->point.y;
|
|
|
438 |
|
|
|
439 |
if (location->x + imageBlock.size.width > rect->point.x + rect->dimension.width)
|
|
|
440 |
overlap.dimension.width = rect->point.x + rect->dimension.width - overlap.point.x;
|
|
|
441 |
else
|
|
|
442 |
overlap.dimension.width = location->x + imageBlock.size.width - overlap.point.x;
|
|
|
443 |
|
|
|
444 |
if (location->y + imageBlock.size.height > rect->point.y + rect->dimension.height)
|
|
|
445 |
overlap.dimension.height = rect->point.y + rect->dimension.height - overlap.point.y;
|
|
|
446 |
else
|
|
|
447 |
overlap.dimension.height = location->y + imageBlock.size.height - overlap.point.y;
|
|
|
448 |
|
|
|
449 |
cropRect.point.x = overlap.point.x - location->x;
|
|
|
450 |
cropRect.point.y = overlap.point.y - location->y;
|
|
|
451 |
cropRect.dimension = overlap.dimension;
|
|
|
452 |
|
|
|
453 |
/* if the rectangle and the image location does not overlap, return*/
|
|
|
454 |
if (overlap.dimension.height <= 0 || overlap.dimension.width <= 0)
|
|
|
455 |
return KBrsrSuccess;
|
|
|
456 |
|
|
|
457 |
/* if the rectangle and the image location does not overlap, return
|
|
|
458 |
if (rect->point.x > location->x + imageBlock.size.width ||
|
|
|
459 |
rect->point.y > location->y + imageBlock.size.height ||
|
|
|
460 |
location->x > rect->point.x + rect->dimension.width ||
|
|
|
461 |
location->y > rect->point.y + rect->dimension.height)
|
|
|
462 |
return KBrsrSuccess;
|
|
|
463 |
|
|
|
464 |
if (rect->point.x < location->x)
|
|
|
465 |
{
|
|
|
466 |
cropRect.point.x = 0;
|
|
|
467 |
cropRect.dimension.width = rect->point.x + rect->dimension.width - location->x ;
|
|
|
468 |
}
|
|
|
469 |
else
|
|
|
470 |
{
|
|
|
471 |
cropRect.point.x = rect->point.x - location->x;
|
|
|
472 |
cropRect.dimension.width = location->x + imageBlock.size.width - rect->point.x;
|
|
|
473 |
}
|
|
|
474 |
if (rect->point.y < location->y)
|
|
|
475 |
{
|
|
|
476 |
cropRect.point.y = 0;
|
|
|
477 |
cropRect.dimension.height = rect->point.y + rect->dimension.height - location->y;
|
|
|
478 |
}
|
|
|
479 |
else
|
|
|
480 |
{
|
|
|
481 |
cropRect.point.y = rect->point.y - location->y;
|
|
|
482 |
cropRect.dimension.width = location->y + imageBlock.size.height - rect->->point.y;
|
|
|
483 |
}
|
|
|
484 |
}
|
|
|
485 |
*/
|
|
|
486 |
/* do the draw */
|
|
|
487 |
|
|
|
488 |
}
|
|
|
489 |
|
|
|
490 |
if (imageOverlapped)
|
|
|
491 |
deviceContext->DrawImage (&overlap.point,
|
|
|
492 |
&cropRect,
|
|
|
493 |
&imageBlock);
|
|
|
494 |
else
|
|
|
495 |
deviceContext->DrawImage (location,
|
|
|
496 |
&cropRect,
|
|
|
497 |
&imageBlock);
|
|
|
498 |
if (imageScaled)
|
|
|
499 |
{
|
|
|
500 |
CFbsBitmap* bitmap = CONST_CAST(CFbsBitmap*, (const CFbsBitmap*)imageBlock.data);
|
|
|
501 |
delete bitmap;
|
|
|
502 |
CFbsBitmap* mask = CONST_CAST(CFbsBitmap*, (const CFbsBitmap*)imageBlock.mask);
|
|
|
503 |
delete mask;
|
|
|
504 |
}
|
|
|
505 |
}
|
|
|
506 |
return status;
|
|
|
507 |
}
|
|
|
508 |
|
|
|
509 |
/* ------------------------------------------------------------------------- */
|
|
|
510 |
/* _NW_Image_Epoc32Simple_IncrementImage
|
|
|
511 |
*
|
|
|
512 |
* Called on an animated image to cause it to move on to the next image.
|
|
|
513 |
* Tells the decoder to go to the next image, and sets "needsDecode" to
|
|
|
514 |
* NW_TRUE so that the decode will be done on the next attempt to draw.
|
|
|
515 |
*/
|
|
|
516 |
TBrowserStatusCode
|
|
|
517 |
_NW_Image_Epoc32Simple_IncrementImage(NW_Image_AbstractImage_t* image)
|
|
|
518 |
{
|
|
|
519 |
NW_ASSERT (NW_Object_IsInstanceOf (image, &NW_Image_Epoc32Simple_Class));
|
|
|
520 |
|
|
|
521 |
NW_Bool startingFrameSequenceOver=NW_FALSE;
|
|
|
522 |
|
|
|
523 |
/* for convenience */
|
|
|
524 |
NW_Image_Epoc32Simple_t* thisObj = NW_Image_Epoc32SimpleOf (image);
|
|
|
525 |
|
|
|
526 |
CEpoc32ImageDecoder* decoder = STATIC_CAST(CEpoc32ImageDecoder*, thisObj->decoder);
|
|
|
527 |
|
|
|
528 |
if (decoder)
|
|
|
529 |
{
|
|
|
530 |
if (decoder->IncrementImage(startingFrameSequenceOver))
|
|
|
531 |
{
|
|
|
532 |
/* update loop count if starting frame sequence again */
|
|
|
533 |
if(startingFrameSequenceOver == NW_TRUE)
|
|
|
534 |
{
|
|
|
535 |
if(image->loopCount != -1)
|
|
|
536 |
{
|
|
|
537 |
image->loopCount--;
|
|
|
538 |
}
|
|
|
539 |
}
|
|
|
540 |
}
|
|
|
541 |
thisObj->needsDecode = NW_TRUE;
|
|
|
542 |
return KBrsrSuccess;
|
|
|
543 |
}
|
|
|
544 |
return KBrsrFailure;
|
|
|
545 |
}
|
|
|
546 |
|
|
|
547 |
/* ------------------------------------------------------------------------- */
|
|
|
548 |
TBrowserStatusCode
|
|
|
549 |
NW_Image_Epoc32Simple_AddDocNode(NW_Image_Epoc32Simple_t* thisObj,
|
|
|
550 |
NW_HED_DocumentNode_t* documentNode)
|
|
|
551 |
{
|
|
|
552 |
if (NW_ADT_DynamicVector_InsertAt(thisObj->docNodeList, &documentNode, NW_ADT_Vector_AtEnd) == NULL)
|
|
|
553 |
return KBrsrOutOfMemory;
|
|
|
554 |
return KBrsrSuccess;
|
|
|
555 |
}
|
|
|
556 |
|
|
|
557 |
|
|
|
558 |
/* ------------------------------------------------------------------------- */
|
|
|
559 |
TBrowserStatusCode
|
|
|
560 |
NW_Image_Epoc32Simple_Initialize( NW_Image_Epoc32Simple_t* thisObj )
|
|
|
561 |
{
|
|
|
562 |
TBrowserStatusCode status = KBrsrFailure;
|
|
|
563 |
|
|
|
564 |
NW_ASSERT( NW_Object_IsInstanceOf( thisObj, &NW_Image_Epoc32Simple_Class ) );
|
|
|
565 |
// let the decoder know that we've got all the raw data
|
|
|
566 |
if( thisObj->decoder )
|
|
|
567 |
{
|
|
|
568 |
CEpoc32ImageDecoder* decoder = STATIC_CAST( CEpoc32ImageDecoder*, thisObj->decoder );
|
|
|
569 |
decoder->ImageDataComplete();
|
|
|
570 |
status = KBrsrSuccess;
|
|
|
571 |
}
|
|
|
572 |
|
|
|
573 |
return status;
|
|
|
574 |
}
|
|
|
575 |
|
|
|
576 |
/* ------------------------------------------------------------------------- *
|
|
|
577 |
convenience functions
|
|
|
578 |
* ------------------------------------------------------------------------- */
|
|
|
579 |
|
|
|
580 |
/* ------------------------------------------------------------------------- */
|
|
|
581 |
NW_Image_Epoc32Simple_t*
|
|
|
582 |
NW_Image_Epoc32Simple_New (NW_GDI_Dimension3D_t size,
|
|
|
583 |
const void* data,
|
|
|
584 |
const void* mask,
|
|
|
585 |
NW_Bool invertedMask,
|
|
|
586 |
NW_Bool isTransparent,
|
|
|
587 |
TImageType imageType,
|
|
|
588 |
void* rawData,
|
|
|
589 |
NW_Int32 length,
|
|
|
590 |
NW_HED_DocumentNode_t* documentNode)
|
|
|
591 |
{
|
|
|
592 |
//lint -e{437} Passing struct to ellipsis
|
|
|
593 |
return (NW_Image_Epoc32Simple_t*) NW_Object_New (&NW_Image_Epoc32Simple_Class,
|
|
|
594 |
size,
|
|
|
595 |
data,
|
|
|
596 |
mask,
|
|
|
597 |
(NW_Uint32)invertedMask,
|
|
|
598 |
(NW_Uint32)isTransparent,
|
|
|
599 |
(NW_Uint32)imageType,
|
|
|
600 |
rawData,
|
|
|
601 |
length,
|
|
|
602 |
documentNode);
|
|
|
603 |
}
|
|
|
604 |
|
|
|
605 |
|
|
|
606 |
/* ------------------------------------------------------------------------- */
|
|
|
607 |
/* NW_Image_Epoc32Simple_SetSize
|
|
|
608 |
*
|
|
|
609 |
* Called when the image has been opened by the image decoder. Sets the
|
|
|
610 |
* (unscaled) image size.
|
|
|
611 |
*/
|
|
|
612 |
TBrowserStatusCode
|
|
|
613 |
NW_Image_Epoc32Simple_SetSize (NW_Image_AbstractImage_t* image,
|
|
|
614 |
NW_GDI_Dimension3D_t* aSize)
|
|
|
615 |
{
|
|
|
616 |
NW_Image_Epoc32Simple_t* thisObj;
|
|
|
617 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
|
618 |
|
|
|
619 |
/* parameter assertion block */
|
|
|
620 |
NW_ASSERT (NW_Object_IsInstanceOf (image, &NW_Image_Epoc32Simple_Class));
|
|
|
621 |
NW_ASSERT (aSize != NULL);
|
|
|
622 |
|
|
|
623 |
/* for convenience */
|
|
|
624 |
thisObj = NW_Image_Epoc32SimpleOf (image);
|
|
|
625 |
|
|
|
626 |
// we have to inform observers about the size change.
|
|
|
627 |
NW_GDI_Dimension3D_s oldSize = thisObj->size;
|
|
|
628 |
// set the size
|
|
|
629 |
thisObj->size = *aSize;
|
|
|
630 |
// first check if the previous size was valid.
|
|
|
631 |
if( oldSize.width != 0 && thisObj->size.height != 0 )
|
|
|
632 |
{
|
|
|
633 |
// check if the size has changed at all
|
|
|
634 |
if( oldSize.width != aSize->width ||
|
|
|
635 |
oldSize.height != aSize->height )
|
|
|
636 |
{
|
|
|
637 |
NW_Image_AbstractImage_ImageSizeChanged( NW_Image_AbstractImageOf( thisObj ) );
|
|
|
638 |
}
|
|
|
639 |
}
|
|
|
640 |
return status;
|
|
|
641 |
}
|
|
|
642 |
|
|
|
643 |
/* ------------------------------------------------------------------------- */
|
|
|
644 |
TBrowserStatusCode
|
|
|
645 |
_NW_Image_Epoc32Simple_ForceImageDecode( NW_Image_AbstractImage_t* epocImage )
|
|
|
646 |
{
|
|
|
647 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
|
648 |
NW_Image_Epoc32Simple_t* thisObj;
|
|
|
649 |
|
|
|
650 |
NW_ASSERT( epocImage != NULL );
|
|
|
651 |
NW_ASSERT( NW_Object_IsInstanceOf( epocImage, &NW_Image_Epoc32Simple_Class ) );
|
|
|
652 |
|
|
|
653 |
thisObj = NW_Image_Epoc32SimpleOf( epocImage );
|
|
|
654 |
|
|
|
655 |
CEpoc32ImageDecoder* decoder = STATIC_CAST( CEpoc32ImageDecoder*, thisObj->decoder );
|
|
|
656 |
status = decoder->Decode();
|
|
|
657 |
|
|
|
658 |
return status;
|
|
|
659 |
}
|
|
|
660 |
|
|
|
661 |
|
|
|
662 |
/* ------------------------------------------------------------------------- */
|
|
|
663 |
/* NW_Image_Epoc32Simple_SetAnimation
|
|
|
664 |
*
|
|
|
665 |
* Calling this function implies that the image is animated. It sets the delay
|
|
|
666 |
* time, and notes that the image is animated.
|
|
|
667 |
*/
|
|
|
668 |
TBrowserStatusCode
|
|
|
669 |
NW_Image_Epoc32Simple_SetAnimation(NW_Image_AbstractImage_t* image,
|
|
|
670 |
NW_Bool isAnimated,
|
|
|
671 |
NW_Uint32 delay )
|
|
|
672 |
{
|
|
|
673 |
image->isAnimated = isAnimated;
|
|
|
674 |
image->delay = delay;
|
|
|
675 |
return KBrsrSuccess;
|
|
|
676 |
}
|
|
|
677 |
|
|
|
678 |
/* ------------------------------------------------------------------------- */
|
|
|
679 |
/* NW_Image_Epoc32Simple_SetBitmapL
|
|
|
680 |
*
|
|
|
681 |
* Called by the image decoder when it has finished processing. Sets the bitmap
|
|
|
682 |
* data, then forces a redraw.
|
|
|
683 |
*
|
|
|
684 |
* Parameters:
|
|
|
685 |
* image: this object
|
|
|
686 |
* bitmap: new bitmap to display
|
|
|
687 |
* mask: new bitmap mask
|
|
|
688 |
* frameNum: Current frame number (if animated)
|
|
|
689 |
* frameInfo: Details about current frame
|
|
|
690 |
* frameIsReady: the frame is fully decoded
|
|
|
691 |
*/
|
|
|
692 |
static
|
|
|
693 |
void
|
|
|
694 |
NW_Image_Epoc32Simple_SetBitmapL(NW_Image_Epoc32Simple_t* image,
|
|
|
695 |
CFbsBitmap* bitmap,
|
|
|
696 |
CFbsBitmap* mask,
|
|
|
697 |
NW_Int32 frameNum,
|
|
|
698 |
TFrameInfo* frameInfo,
|
|
|
699 |
NW_Bool frameIsReady )
|
|
|
700 |
{
|
|
|
701 |
if( frameIsReady == NW_TRUE )
|
|
|
702 |
{
|
|
|
703 |
// if the image has just been decoded, then image->bitmap is same as bitmap
|
|
|
704 |
// init image->bitmap to NULL.
|
|
|
705 |
if( image->imageDecoding == NW_TRUE )
|
|
|
706 |
{
|
|
|
707 |
image->bitmap = NULL;
|
|
|
708 |
image->mask = NULL;
|
|
|
709 |
image->imageDecoding = NW_FALSE;
|
|
|
710 |
}
|
|
|
711 |
CFbsBitmap* existingBitmap = CONST_CAST(CFbsBitmap*, (const CFbsBitmap*)image->bitmap);
|
|
|
712 |
CFbsBitmap* existingMask = CONST_CAST(CFbsBitmap*, (const CFbsBitmap*)image->mask);
|
|
|
713 |
|
|
|
714 |
// If there is transparency but no disposal property defined, then assume
|
|
|
715 |
// the disposal property ELeaveInPlace.
|
|
|
716 |
if( (frameInfo->iFlags & TFrameInfo::ETransparencyPossible) &&
|
|
|
717 |
!(image->prevFlags & (TFrameInfo::ERestoreToBackground | TFrameInfo::ERestoreToPrevious)) )
|
|
|
718 |
{
|
|
|
719 |
image->prevFlags |= TFrameInfo::ELeaveInPlace;
|
|
|
720 |
}
|
|
|
721 |
|
|
|
722 |
// If there is an existing bitmap, then it must be animated. If the previous
|
|
|
723 |
// frame had the flag "ELeaveInPlace", then the new bitmap must be rendered
|
|
|
724 |
// on top of the old one for things to work properly. This does not apply to
|
|
|
725 |
// the first frame when the animation goes back to the start (frameNum == 0).
|
|
|
726 |
TPoint aStartPoint(0,0);
|
|
|
727 |
if (existingBitmap != NULL && (image->prevFlags & TFrameInfo::ELeaveInPlace) &&
|
|
|
728 |
(frameNum > 0 || frameInfo->iFrameCoordsInPixels.iTl != aStartPoint)){
|
|
|
729 |
// Push mask & bitmap on the cleanup stack to make sure they get deleted.
|
|
|
730 |
CleanupStack::PushL(mask);
|
|
|
731 |
CleanupStack::PushL(bitmap);
|
|
|
732 |
|
|
|
733 |
// Render new bitmap on top of old bitmap.
|
|
|
734 |
CFbsBitGc* bitmapContext=NULL;
|
|
|
735 |
CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(existingBitmap);
|
|
|
736 |
CleanupStack::PushL(bitmapDevice);
|
|
|
737 |
User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext));
|
|
|
738 |
CleanupStack::PushL(bitmapContext);
|
|
|
739 |
if(frameNum == 0)
|
|
|
740 |
bitmapContext->Clear();
|
|
|
741 |
if (mask == NULL)
|
|
|
742 |
bitmapContext->BitBlt(frameInfo->iFrameCoordsInPixels.iTl, bitmap, frameInfo->iFrameCoordsInPixels.Size());
|
|
|
743 |
else
|
|
|
744 |
bitmapContext->BitBltMasked(frameInfo->iFrameCoordsInPixels.iTl, bitmap, frameInfo->iFrameCoordsInPixels.Size(), mask, EFalse);
|
|
|
745 |
|
|
|
746 |
// Delete device, context & bitmap
|
|
|
747 |
CleanupStack::PopAndDestroy(3);
|
|
|
748 |
|
|
|
749 |
// If both masks exist, draw the new on top of the old.
|
|
|
750 |
if (existingMask != NULL && mask != NULL)
|
|
|
751 |
{
|
|
|
752 |
CFbsBitGc* maskContext=NULL;
|
|
|
753 |
CFbsBitmapDevice* maskDevice = CFbsBitmapDevice::NewL(existingMask);
|
|
|
754 |
CleanupStack::PushL(maskDevice);
|
|
|
755 |
User::LeaveIfError(maskDevice->CreateContext(maskContext));
|
|
|
756 |
CleanupStack::PushL(maskContext);
|
|
|
757 |
maskContext->BitBltMasked(frameInfo->iFrameCoordsInPixels.iTl, mask, frameInfo->iFrameCoordsInPixels.Size(), mask, EFalse);
|
|
|
758 |
CleanupStack::PopAndDestroy(2);
|
|
|
759 |
delete mask;
|
|
|
760 |
}
|
|
|
761 |
else if (mask != NULL)
|
|
|
762 |
{
|
|
|
763 |
// If the first image had no mask, then after that we would have to fill in the whole frame
|
|
|
764 |
// anyway, so there is no point keeping a mask.
|
|
|
765 |
delete mask;
|
|
|
766 |
}
|
|
|
767 |
// Pop mask from cleanup stack
|
|
|
768 |
CleanupStack::Pop();
|
|
|
769 |
}
|
|
|
770 |
else
|
|
|
771 |
{
|
|
|
772 |
// The new bitmap and mask have no dependancy on the old; just replace the old
|
|
|
773 |
// with the new.
|
|
|
774 |
if(image->bitmap && bitmap){
|
|
|
775 |
TInt bitmapHandle = bitmap->Handle();
|
|
|
776 |
CFbsBitmap* pBitmap = (CFbsBitmap*)image->bitmap;
|
|
|
777 |
pBitmap->Duplicate(bitmapHandle);
|
|
|
778 |
}
|
|
|
779 |
else{
|
|
|
780 |
image->bitmap = bitmap;
|
|
|
781 |
}
|
|
|
782 |
|
|
|
783 |
if(image->mask && mask){
|
|
|
784 |
TInt bitmapHandle = mask->Handle();
|
|
|
785 |
CFbsBitmap* pBitmask = (CFbsBitmap*)image->mask;
|
|
|
786 |
pBitmask->Duplicate(bitmapHandle);
|
|
|
787 |
}
|
|
|
788 |
else{
|
|
|
789 |
image->mask = mask;
|
|
|
790 |
}
|
|
|
791 |
}
|
|
|
792 |
image->needsDecode = NW_FALSE;
|
|
|
793 |
image->prevFlags = frameInfo->iFlags;
|
|
|
794 |
}
|
|
|
795 |
else
|
|
|
796 |
{
|
|
|
797 |
image->imageDecoding = NW_TRUE;
|
|
|
798 |
image->bitmap = bitmap;
|
|
|
799 |
image->mask = mask;
|
|
|
800 |
}
|
|
|
801 |
}
|
|
|
802 |
|
|
|
803 |
/* ------------------------------------------------------------------------- */
|
|
|
804 |
/* NW_Image_Epoc32Simple_DestroyRawData
|
|
|
805 |
*
|
|
|
806 |
*/
|
|
|
807 |
void NW_Image_Epoc32Simple_DestroyRawData( NW_Image_Epoc32Simple_t* aImage )
|
|
|
808 |
{
|
|
|
809 |
NW_ASSERT( aImage != NULL );
|
|
|
810 |
|
|
|
811 |
if( aImage->rawData )
|
|
|
812 |
{
|
|
|
813 |
delete aImage->rawData ;
|
|
|
814 |
aImage->rawData = NULL;
|
|
|
815 |
}
|
|
|
816 |
}
|
|
|
817 |
|
|
|
818 |
/* ------------------------------------------------------------------------- */
|
|
|
819 |
/* NW_Image_Epoc32Simple_SetBitmap
|
|
|
820 |
*
|
|
|
821 |
* Non-leaving version of function "NW_Image_Epoc32Simple_SetBitmap". Called by
|
|
|
822 |
* the image decoder when it has finished processing. Sets the bitmap data,
|
|
|
823 |
* then forces a redraw. Parameters are "void*" so that OOC files can include
|
|
|
824 |
* header file.
|
|
|
825 |
*
|
|
|
826 |
* Parameters:
|
|
|
827 |
* image: this object
|
|
|
828 |
* bitmap: new bitmap to display
|
|
|
829 |
* mask: new bitmap mask
|
|
|
830 |
* frameNum: Current frame number (if animated)
|
|
|
831 |
* frameInfo: Details about current frame
|
|
|
832 |
*/
|
|
|
833 |
void
|
|
|
834 |
NW_Image_Epoc32Simple_SetBitmap(NW_Image_Epoc32Simple_t* image,
|
|
|
835 |
void* bitmap,
|
|
|
836 |
void* mask,
|
|
|
837 |
NW_Int32 frameNum,
|
|
|
838 |
void* frameInfo,
|
|
|
839 |
NW_Bool frameIsReady )
|
|
|
840 |
{
|
|
|
841 |
TInt err;
|
|
|
842 |
TRAP(err, NW_Image_Epoc32Simple_SetBitmapL(image,
|
|
|
843 |
(CFbsBitmap*)bitmap,
|
|
|
844 |
(CFbsBitmap*)mask,
|
|
|
845 |
frameNum,
|
|
|
846 |
(TFrameInfo*)frameInfo,
|
|
|
847 |
frameIsReady));
|
|
|
848 |
}
|
|
|
849 |
|
|
|
850 |
// first we check if image is visible, we go through the observer list for that.
|
|
|
851 |
// Observer knows which image is visible. If image is not visible, then we
|
|
|
852 |
// delete the image which is out of view. In case that the decoding is still going on
|
|
|
853 |
// we cancel the decoding for out of view image
|
|
|
854 |
void
|
|
|
855 |
NW_Image_Epoc32Simple_OutOfView( NW_Image_Epoc32Simple_t* aEpocImage )
|
|
|
856 |
{
|
|
|
857 |
NW_Bool isVisible = NW_Image_AbstractImage_IsVisible(NW_Image_AbstractImageOf(aEpocImage));
|
|
|
858 |
if(( aEpocImage->imageDecoding == NW_FALSE ) && (aEpocImage->bitmap) && (!isVisible))
|
|
|
859 |
{
|
|
|
860 |
// delet the image bitmap
|
|
|
861 |
CFbsBitmap* oldBitmap = CONST_CAST(CFbsBitmap*, (const CFbsBitmap*)aEpocImage->bitmap);
|
|
|
862 |
delete oldBitmap;
|
|
|
863 |
aEpocImage->bitmap = NULL;
|
|
|
864 |
CFbsBitmap* oldMask = CONST_CAST(CFbsBitmap*, (const CFbsBitmap*)aEpocImage->mask);
|
|
|
865 |
delete oldMask;
|
|
|
866 |
aEpocImage->mask = NULL;
|
|
|
867 |
}
|
|
|
868 |
else if ( aEpocImage->imageDecoding )
|
|
|
869 |
{
|
|
|
870 |
// cancel decoding
|
|
|
871 |
CEpoc32ImageDecoder* decoder = STATIC_CAST(CEpoc32ImageDecoder*, aEpocImage->decoder);
|
|
|
872 |
decoder->Cancel();
|
|
|
873 |
}
|
|
|
874 |
}
|