sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "swdirectgdiimagesourceimpl.h"
|
sl@0
|
17 |
#include "swdirectgdidriverimpl.h"
|
sl@0
|
18 |
#include <graphics/sgimage_sw.h>
|
sl@0
|
19 |
|
sl@0
|
20 |
/**
|
sl@0
|
21 |
Constructs a CSwDirectGdiImageTargetImpl
|
sl@0
|
22 |
@param aDriver The driver implementation which created this target.
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
CSwDirectGdiImageSourceImpl::CSwDirectGdiImageSourceImpl(CSwDirectGdiDriverImpl& aDriver) :
|
sl@0
|
25 |
iDriver(aDriver)
|
sl@0
|
26 |
{
|
sl@0
|
27 |
}
|
sl@0
|
28 |
|
sl@0
|
29 |
/**
|
sl@0
|
30 |
Destroys a CSwDirectGdiImageSourceImpl.
|
sl@0
|
31 |
|
sl@0
|
32 |
@post This image source is removed from the associated driver's list of source images.
|
sl@0
|
33 |
*/
|
sl@0
|
34 |
CSwDirectGdiImageSourceImpl::~CSwDirectGdiImageSourceImpl()
|
sl@0
|
35 |
{
|
sl@0
|
36 |
iDriver.UnregisterSourceImage(*this);
|
sl@0
|
37 |
}
|
sl@0
|
38 |
|
sl@0
|
39 |
/**
|
sl@0
|
40 |
Two-phase construction of a CDirectGdiImageSourceImpl object.
|
sl@0
|
41 |
@param aImage On success, holds a pointer to the newly-created image.
|
sl@0
|
42 |
@param aDriver The driver to register this image with.
|
sl@0
|
43 |
@param aSgImage The RSgImage which this image will be based upon.
|
sl@0
|
44 |
@return KErrNone if successful, KErrNoMemory if not enough memory could be allocated, otherwise a return
|
sl@0
|
45 |
value from Construct().
|
sl@0
|
46 |
*/
|
sl@0
|
47 |
TInt CSwDirectGdiImageSourceImpl::New(CSwDirectGdiImageSourceImpl*& aImage, CSwDirectGdiDriverImpl& aDriver, const RSgImage& aSgImage)
|
sl@0
|
48 |
{
|
sl@0
|
49 |
CSwDirectGdiImageSourceImpl* image = new CSwDirectGdiImageSourceImpl(aDriver);
|
sl@0
|
50 |
if (!image)
|
sl@0
|
51 |
return KErrNoMemory;
|
sl@0
|
52 |
TInt err = image->Construct(aSgImage);
|
sl@0
|
53 |
if (err == KErrNone)
|
sl@0
|
54 |
aImage = image;
|
sl@0
|
55 |
else
|
sl@0
|
56 |
delete image;
|
sl@0
|
57 |
return err;
|
sl@0
|
58 |
}
|
sl@0
|
59 |
|
sl@0
|
60 |
/**
|
sl@0
|
61 |
Gets the supplied image structure and sets the internal data.
|
sl@0
|
62 |
@param aSgImage The RSgImage to create the source image from.
|
sl@0
|
63 |
@return KErrNone if successful, KErrNotSupported if the RSgImage doesn't have the required interface,
|
sl@0
|
64 |
otherwise an error from CDirectGdiImageRef::Construct().
|
sl@0
|
65 |
*/
|
sl@0
|
66 |
TInt CSwDirectGdiImageSourceImpl::Construct(const RSgImage& aSgImage)
|
sl@0
|
67 |
{
|
sl@0
|
68 |
TInt err = CDirectGdiImageRef::Construct(aSgImage);
|
sl@0
|
69 |
|
sl@0
|
70 |
MSgImage_Sw* pImage = NULL;
|
sl@0
|
71 |
if (err == KErrNone)
|
sl@0
|
72 |
{
|
sl@0
|
73 |
RSgImage image = Image();
|
sl@0
|
74 |
err = image.GetInterface(pImage);
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
if (err == KErrNone)
|
sl@0
|
78 |
{
|
sl@0
|
79 |
err = iDriver.RegisterSourceImage(*this);
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
if (err == KErrNone)
|
sl@0
|
83 |
{
|
sl@0
|
84 |
iDataBuffer = pImage->DataAddress();
|
sl@0
|
85 |
iStride = pImage->DataStride();
|
sl@0
|
86 |
Open();
|
sl@0
|
87 |
}
|
sl@0
|
88 |
|
sl@0
|
89 |
return err;
|
sl@0
|
90 |
}
|