os/graphics/graphicsdeviceinterface/directgdiadaptation/hwsrc/directgdiimagesourceimpl.cpp
Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "directgdiadapter.h"
17 #include "directgdiimagesourceimpl.h"
18 #include "directgdidriverimpl.h"
19 #include "directgdidriverprocessstate.h"
20 #include <graphics/sgimage.h>
23 Constructs a CDirectGdiImageSourceImpl.
24 @param aDriver The driver implementation which created this target.
26 CDirectGdiImageSourceImpl::CDirectGdiImageSourceImpl(CDirectGdiDriverImpl& aDriver) :
28 iVgImage(VG_INVALID_HANDLE)
35 @post The associated VgImage (if any) is destroyed by the process state.
36 This image is removed from the associated driver's list of source images.
38 CDirectGdiImageSourceImpl::~CDirectGdiImageSourceImpl()
40 GRAPHICS_LOG_DEBUG("Destroying CDirectGdiImageSourceImpl");
41 if (iVgImage != VG_INVALID_HANDLE)
43 iDriver.ProcessState().DestroyVgImage(iDriver.EglDisplay(), iVgImage);
45 iDriver.UnregisterSourceImage(*this);
49 Two-phase construction of a CDirectGdiImageSourceImpl object.
50 @param aImage On success, holds a pointer to the newly-created image.
51 @param aDriver The driver to register this image with.
52 @param aSgImage The RSgImage which this image will be based upon.
53 @return KErrNone if successful, KErrNoMemory if not enough memory could be allocated, otherwise a return
54 value from Construct().
56 TInt CDirectGdiImageSourceImpl::New(CDirectGdiImageSourceImpl*& aImage, CDirectGdiDriverImpl& aDriver, const RSgImage& aSgImage)
58 CDirectGdiImageSourceImpl* image = new CDirectGdiImageSourceImpl(aDriver);
61 TInt err = image->Construct(aSgImage);
70 Gets the supplied image structure and sets the internal data.
71 Registers itself with the driver.
73 @param aSgImage The RSgImage to create the source image from.
74 @return KErrNone if successful, otherwise an error from CDirectGdiImageRef::Construct().
76 TInt CDirectGdiImageSourceImpl::Construct(const RSgImage& aSgImage)
78 TInt err = CDirectGdiImageRef::Construct(aSgImage);
82 // Let the process state create the VGImage as EGLImages and their associated VGImages
83 // are shared across all threads in this process. (Only one EGLImage can be created per RSgImage
85 err = iDriver.ProcessState().CreateVgImage(iDriver.EglDisplay(), iVgImage, iSgImage);
90 err = iDriver.RegisterSourceImage(*this);