windowing/windowserver/inc/Graphics/wsdrawresource.h
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2008-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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @publishedPartner
       
    18  @prototype
       
    19 */
       
    20 
       
    21 #ifndef __WSDRAWRESOURCE_H__
       
    22 #define __WSDRAWRESOURCE_H__
       
    23 
       
    24 #include <w32std.h>
       
    25 #include <graphics/sgresource.h>
       
    26 
       
    27 class RWsDrawableSource;
       
    28 
       
    29 /**
       
    30 The UID for MWsDrawResource.
       
    31 @see MWsDrawResource
       
    32 @see CWindowGc::Interface
       
    33 @publishedPartner
       
    34 @prototype
       
    35 */
       
    36 static const TUid KMWsDrawResourceInterfaceUid = { 0x102864E9 };
       
    37 
       
    38 /**
       
    39 An extension interface for CWindowGc and CRemoteGc to draw RWsDrawableSources.
       
    40 
       
    41 Usage:
       
    42 @code
       
    43 MWsDrawResource* gcDrawResource = static_cast<MWsDrawResource*>(gc->Interface(KMWsDrawResourceInterfaceUid));
       
    44 if(gcDrawResource)
       
    45 	{
       
    46 	gcDrawResource->DrawResource(TPoint(5,5), drawableSource);
       
    47 	}
       
    48 @endcode
       
    49 @see RWsDrawableSource
       
    50 @see CWindowGc::Interface
       
    51 @publishedPartner
       
    52 @prototype
       
    53 */
       
    54 class MWsDrawResource
       
    55 	{
       
    56 public:
       
    57 	/**
       
    58 	Draws an image based resource which may be generated using non-native rendering API such as OpenGL ES 
       
    59 	or OpenVG. The resource will be drawn at the specified position in its original size with orientation 
       
    60 	according to the specified rotation parameter. The current clipping region applies. 
       
    61 
       
    62 	@see RWsDrawableSource
       
    63 
       
    64 	@param	aPos		The position of the top-left corner on a window.
       
    65 	@param	aSource		The resource to be drawn.
       
    66 	@param	aRotation	The rotation to be applied to the resource before it is drawn. The default value is CWindowGc::EGraphicsRotationNone.
       
    67 
       
    68 	@pre	Drawing context has been activated on a window. The drawable source has been created.
       
    69 	@post	Request to draw resource has been accepted. There is no guarantee that the request has been completed 
       
    70 			when this method returns.
       
    71 	*/
       
    72 	virtual void DrawResource(const TPoint& aPos, const RWsDrawableSource& aSource, CWindowGc::TGraphicsRotation aRotation=CWindowGc::EGraphicsRotationNone) = 0;
       
    73 
       
    74 	/**
       
    75 	Draws an image based resource. The resource will be rendered to the given destination rectangle on 
       
    76 	the window in its original dimensions with orientation according to the specified rotation parameter. 
       
    77 	Drawing will be clipped to the given destination rectangle. The current clipping region applies. The resource can be
       
    78 	drawn rotated using the CWindowGc::TGraphicsRotation enum which defines possible rotation values in 
       
    79 	clockwise degrees.
       
    80 
       
    81 	@see RWsDrawableSource
       
    82 
       
    83 	@param	aDestRect	Destination rectangle to which the resource will be rendered.
       
    84 	@param	aSource		The resource to be drawn.
       
    85 	@param	aRotation	The rotation to be applied to the resource before it is drawn. The default value is CWindowGc::EGraphicsRotationNone.
       
    86 
       
    87 	@pre	Drawing context has been activated on a window. The drawable source has been created.
       
    88 	@post	Request to draw resource has been accepted. There is no guarantee that the request has been completed 
       
    89 			when this method returns.
       
    90 	*/
       
    91 	virtual void DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, CWindowGc::TGraphicsRotation aRotation=CWindowGc::EGraphicsRotationNone) = 0;
       
    92 
       
    93 	/**
       
    94 	Draws an image based resource. The resource is rendered into the given destination rectangle on a window.
       
    95 	Scaling (stretching or compression) applies if the destination rectangle is different from the
       
    96 	source rectangle. The resource orientation is set based on the specified rotation parameter
       
    97 	before scaling and drawing operations are performed.
       
    98 
       
    99 	@see RWsDrawableSource
       
   100 
       
   101 	@param	aDestRect	The destination rectangle to which the resource will be rendered on a window.
       
   102 	@param	aSource		The resource to draw.
       
   103 	@param	aSrcRect	The source rectangle specifying the area/sub-area of the resource to be rendered.
       
   104 	@param	aRotation	Rotation to be applied to the resource before it is drawn. The default value is CWindowGc::EGraphicsRotationNone.
       
   105 
       
   106 	@pre	Drawing context has been activated on a window. The drawable source has been created.
       
   107 	@post	Request to draw an image based resource has been accepted. There is no guarantee that the
       
   108 			request has been completed when this method returns.
       
   109 	*/
       
   110 	virtual void DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, const TRect& aSrcRect, CWindowGc::TGraphicsRotation aRotation=CWindowGc::EGraphicsRotationNone) = 0;
       
   111 
       
   112 	/**
       
   113 	Draws a non-image based resource. The resource will be rendered into the given destination rectangle on a window.
       
   114 	The current clipping region applies. The adaptation is free to interpret the parameter aParam and may define
       
   115 	its own rules on how to handle the rendering of a non-image based resource.
       
   116 
       
   117 	@see RWsDrawableSource
       
   118 
       
   119 	@param	aDestRect	The destination rectangle to which the resource will be rendered on a window.
       
   120 	@param	aSource		The resource.
       
   121 	@param	aParam		Parameters specifying how to draw the resource. 
       
   122 
       
   123 	@pre	Drawing context has been activated on a window. The drawable source has been created.
       
   124 	@post	Request to draw a non-image based resource has been accepted. 
       
   125 			There is no guarantee that the request has been completed when this method returns.
       
   126 	*/
       
   127 	virtual void DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, const TDesC8& aParam) = 0;
       
   128 	};
       
   129 
       
   130 
       
   131 /**
       
   132 The intention of this class is to enable drawing of drawables (RSgDrawable and RSgImage)
       
   133 using CWindowGc and CRemoteGc.
       
   134 
       
   135 You have to use the extension interface MWsDrawResource in order to use this class with
       
   136 CWindowGc and CRemoteGc.
       
   137 
       
   138 @publishedPartner
       
   139 @prototype
       
   140 @see RSgDrawable
       
   141 @see RSgImage
       
   142 @see MWsDrawResource
       
   143 */
       
   144 class RWsDrawableSource : public MWsClientClass
       
   145 	{
       
   146 public:
       
   147 	IMPORT_C RWsDrawableSource();
       
   148 	IMPORT_C RWsDrawableSource(RWsSession& aWs);
       
   149 	IMPORT_C TInt Create(const RSgDrawable& aDrawable);
       
   150 	IMPORT_C TInt Create(const RSgDrawable& aDrawable, TInt aScreenNumber);
       
   151 	IMPORT_C const TSgDrawableId& DrawableId() const;
       
   152 	IMPORT_C TInt ScreenNumber() const;
       
   153 	IMPORT_C void Close();
       
   154 private:
       
   155 	TSgDrawableId iDrawableId;
       
   156 	TInt iScreenNumber;
       
   157 	TInt iReserved; // reserved for use by Symbian
       
   158 	};
       
   159 
       
   160 #endif //__WSDRAWRESOURCE_H__
       
   161