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 "directgdiadapter.h"
|
sl@0
|
17 |
#include "directgdiimagesourceimpl.h"
|
sl@0
|
18 |
#include "directgdidriverimpl.h"
|
sl@0
|
19 |
#include "directgdidriverprocessstate.h"
|
sl@0
|
20 |
#include <graphics/sgimage.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
/**
|
sl@0
|
23 |
Constructs a CDirectGdiImageSourceImpl.
|
sl@0
|
24 |
@param aDriver The driver implementation which created this target.
|
sl@0
|
25 |
*/
|
sl@0
|
26 |
CDirectGdiImageSourceImpl::CDirectGdiImageSourceImpl(CDirectGdiDriverImpl& aDriver) :
|
sl@0
|
27 |
iDriver(aDriver),
|
sl@0
|
28 |
iVgImage(VG_INVALID_HANDLE)
|
sl@0
|
29 |
{
|
sl@0
|
30 |
}
|
sl@0
|
31 |
|
sl@0
|
32 |
/**
|
sl@0
|
33 |
Destructor.
|
sl@0
|
34 |
|
sl@0
|
35 |
@post The associated VgImage (if any) is destroyed by the process state.
|
sl@0
|
36 |
This image is removed from the associated driver's list of source images.
|
sl@0
|
37 |
*/
|
sl@0
|
38 |
CDirectGdiImageSourceImpl::~CDirectGdiImageSourceImpl()
|
sl@0
|
39 |
{
|
sl@0
|
40 |
GRAPHICS_LOG_DEBUG("Destroying CDirectGdiImageSourceImpl");
|
sl@0
|
41 |
if (iVgImage != VG_INVALID_HANDLE)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
iDriver.ProcessState().DestroyVgImage(iDriver.EglDisplay(), iVgImage);
|
sl@0
|
44 |
}
|
sl@0
|
45 |
iDriver.UnregisterSourceImage(*this);
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
/**
|
sl@0
|
49 |
Two-phase construction of a CDirectGdiImageSourceImpl object.
|
sl@0
|
50 |
@param aImage On success, holds a pointer to the newly-created image.
|
sl@0
|
51 |
@param aDriver The driver to register this image with.
|
sl@0
|
52 |
@param aSgImage The RSgImage which this image will be based upon.
|
sl@0
|
53 |
@return KErrNone if successful, KErrNoMemory if not enough memory could be allocated, otherwise a return
|
sl@0
|
54 |
value from Construct().
|
sl@0
|
55 |
*/
|
sl@0
|
56 |
TInt CDirectGdiImageSourceImpl::New(CDirectGdiImageSourceImpl*& aImage, CDirectGdiDriverImpl& aDriver, const RSgImage& aSgImage)
|
sl@0
|
57 |
{
|
sl@0
|
58 |
CDirectGdiImageSourceImpl* image = new CDirectGdiImageSourceImpl(aDriver);
|
sl@0
|
59 |
if (!image)
|
sl@0
|
60 |
return KErrNoMemory;
|
sl@0
|
61 |
TInt err = image->Construct(aSgImage);
|
sl@0
|
62 |
if (err == KErrNone)
|
sl@0
|
63 |
aImage = image;
|
sl@0
|
64 |
else
|
sl@0
|
65 |
delete image;
|
sl@0
|
66 |
return err;
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
/**
|
sl@0
|
70 |
Gets the supplied image structure and sets the internal data.
|
sl@0
|
71 |
Registers itself with the driver.
|
sl@0
|
72 |
|
sl@0
|
73 |
@param aSgImage The RSgImage to create the source image from.
|
sl@0
|
74 |
@return KErrNone if successful, otherwise an error from CDirectGdiImageRef::Construct().
|
sl@0
|
75 |
*/
|
sl@0
|
76 |
TInt CDirectGdiImageSourceImpl::Construct(const RSgImage& aSgImage)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
TInt err = CDirectGdiImageRef::Construct(aSgImage);
|
sl@0
|
79 |
|
sl@0
|
80 |
if (err == KErrNone)
|
sl@0
|
81 |
{
|
sl@0
|
82 |
// Let the process state create the VGImage as EGLImages and their associated VGImages
|
sl@0
|
83 |
// are shared across all threads in this process. (Only one EGLImage can be created per RSgImage
|
sl@0
|
84 |
// in a process).
|
sl@0
|
85 |
err = iDriver.ProcessState().CreateVgImage(iDriver.EglDisplay(), iVgImage, iSgImage);
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
if (err == KErrNone)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
err = iDriver.RegisterSourceImage(*this);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
if (err == KErrNone)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
Open();
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
return err;
|
sl@0
|
99 |
}
|
sl@0
|
100 |
|