javauis/lcdui_akn/lcdgr/inc/CMIDGraphics.h
branchRCL_3
changeset 19 04becd199f91
child 60 6c158198356e
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2005 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 "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 #ifndef CMIDGRAPHICS_H
       
    19 #define CMIDGRAPHICS_H
       
    20 
       
    21 #include <lcdgr.h>
       
    22 
       
    23 class CFbsBitmap;
       
    24 class CMIDSprite;
       
    25 class CMIDTiledLayer;
       
    26 class CMIDProxyMap;
       
    27 class CLcdGraphics;
       
    28 
       
    29 /**
       
    30  * Proxy to native peer to javax.microedition.lcdui.Graphics.
       
    31  *
       
    32  * Presents MMIDGraphics interface for compatability.
       
    33  */
       
    34 NONSHARABLE_CLASS(CMIDGraphics) : public CBase
       
    35         , public MMIDGraphics
       
    36         , public MMIDBufferProcessor
       
    37 {
       
    38 public:
       
    39 #ifdef RD_JAVA_NGA_ENABLED
       
    40     /**
       
    41      * Constructor
       
    42      * @param aProxyMap
       
    43      *      - a proxy
       
    44      * @param aGraphics
       
    45      *      - a graphics implementation
       
    46      * @param aIsImageTarget
       
    47      *      - true if an image is the target
       
    48      */
       
    49     CMIDGraphics(
       
    50         CMIDProxyMap& aProxyMap, CLcdGraphics* aGraphics,
       
    51         TBool aIsImageTarget, MMIDCanvas* aTarget = NULL);
       
    52 
       
    53 #else RD_JAVA_NGA_ENABLED
       
    54 
       
    55     /**
       
    56      * Constructor
       
    57      * @param aProxyMap a proxy
       
    58      * @param aGraphics a graphics implementation
       
    59      * @param aIsImageTarget true if an image is the target
       
    60      */
       
    61     CMIDGraphics(
       
    62         CMIDProxyMap& aProxyMap, CLcdGraphics* aGraphics,
       
    63         TBool aIsImageTarget);
       
    64 #endif // RD_JAVA_NGA_ENABLED
       
    65 
       
    66     /**
       
    67      * Dtor
       
    68      */
       
    69     ~CMIDGraphics();
       
    70 
       
    71     /**
       
    72      * From MMIDComponent
       
    73      */
       
    74     virtual TType Type() const;
       
    75     virtual void Dispose();
       
    76     virtual MMIDBufferProcessor* Processor();
       
    77 
       
    78     /**
       
    79      * From MMIDBufferProcessor
       
    80      */
       
    81 #ifdef RD_JAVA_NGA_ENABLED
       
    82     virtual TBool ProcessL(
       
    83         const TMIDBufferOp*& aRead, const TMIDBufferOp* aEnd,
       
    84         TInt& aCycles, java::util::Monitor* aMonitor);
       
    85 #else
       
    86     virtual TBool   ProcessL(
       
    87         const TMIDBufferOp*& aRead, const TMIDBufferOp* aEnd,
       
    88         TInt& aCycles, TRequestStatus* aStatus = NULL);
       
    89 #endif
       
    90     virtual void    AbortAsync();
       
    91 
       
    92 
       
    93     /**
       
    94      *@return aColor quantized to device palette.
       
    95      */
       
    96     virtual TUint32 DisplayColor(TUint32 aColor);
       
    97 
       
    98     /**
       
    99      * From MMIDGraphics
       
   100      */
       
   101     virtual TInt DrawPixels(
       
   102         TInt    aType,          // pixel data type
       
   103         TUint8* aAddress,       // pixel data array
       
   104         TInt    aLength,        // pixel array length (bytes)
       
   105         TInt    aScanLength,    // (bytes) always positive - vertical reflection handled by point/size
       
   106         TBool   aAlpha,         // true if pixel data contains alpha
       
   107         const TRect& aRect,     // destination rect
       
   108         TInt    aTransform      // transform to apply
       
   109     );
       
   110 
       
   111     /**
       
   112      *@return bitmap handle if rendering to bitmap
       
   113      */
       
   114     virtual CFbsBitmap* Bitmap() const;
       
   115 
       
   116     /**
       
   117      *@return alpha bitmap handle or NULL if there is none
       
   118      */
       
   119     inline CFbsBitmap*  BitmapAlpha() const;
       
   120 
       
   121     /**
       
   122      *@return window handle if rendering to window.
       
   123      */
       
   124     virtual RWindow* Window() const;
       
   125 
       
   126     /**
       
   127      *@return drawing surface viewport
       
   128      */
       
   129     virtual TRect ViewPort() const;
       
   130 
       
   131     /**
       
   132      *@return ETrue for mutable off-screen images (not for canvas/GameCanvas framebuffer)
       
   133      * or EFalse for canvas/GameCanvas framebuffer
       
   134      */
       
   135     TBool IsImageTarget() const;
       
   136 
       
   137 #ifdef RD_JAVA_NGA_ENABLED
       
   138 
       
   139 public: // from MMIDComponentNgaExtension
       
   140     /**
       
   141      * @see MMIDComponentNgaExtension#UpdateEglContent()
       
   142      * @since S60 9.2
       
   143      */
       
   144     virtual void UpdateEglContent();
       
   145 
       
   146     /**
       
   147      * @see MMIDComponentNgaExtension#IsEglAvailable()
       
   148      * @since S60 9.2
       
   149      */
       
   150     virtual TBool IsEglAvailable();
       
   151 
       
   152     /**
       
   153      * @see MMIDComponentNgaExtension#BindEglSurface()
       
   154      * @since S60 9.2
       
   155      */
       
   156     virtual EGLSurface BindEglSurface();
       
   157 
       
   158     /**
       
   159      * @see MMIDComponentNgaExtension#ReleaseEglSurface()
       
   160      * @since S60 9.2
       
   161      */
       
   162     virtual void ReleaseEglSurface();
       
   163 
       
   164     /**
       
   165      * @see MMIDComponentNgaExtension#UpdateOffScreenBitmapL()
       
   166      * @since S60 9.2
       
   167      */
       
   168     virtual void UpdateOffScreenBitmapL(TBool aForced);
       
   169 
       
   170     /**
       
   171      * @see MMIDComponentNgaExtension#FillEglSurface()
       
   172      * @since S60 9.2
       
   173      */
       
   174     virtual TBool FillEglSurface(const TRect& aRect, const TRgb& aColor);
       
   175 
       
   176     /**
       
   177      * @see MMIDGraphics#TargetSize()
       
   178      * @since S60 9.2
       
   179      */
       
   180     virtual TSize CanvasTargetSize() const;
       
   181 
       
   182     /**
       
   183      * @see MMIDGraphics#GetTargetCanvas()
       
   184      * @since S60 9.2
       
   185      */
       
   186     virtual MMIDCanvas* GetTargetCanvas() const;
       
   187 
       
   188 private:
       
   189     /**
       
   190      * Merges aRect to member variable TRects that are used for
       
   191      * tracking the area that is updated with 2D content.
       
   192      * @param aRect TRect that contains new area that has been updated
       
   193      *              with 2D content.
       
   194      */
       
   195     void UpdateRect(const TRect& aRect);
       
   196 
       
   197     /**
       
   198      * Calculate bounding box for text.
       
   199      * @param aTextPtr a text to be drawn
       
   200      * @param aP a start point
       
   201      * @param aAnchor an anchor that effects to text's start point.
       
   202      */
       
   203     void UpdateTextRect(TPtrC& aTextPtr, const TPoint& aP, TInt aAnchor);
       
   204 
       
   205     /**
       
   206      * Finds the minimum of three integers
       
   207      * @param aX -
       
   208      * @param aY -
       
   209      * @param aZ -
       
   210      * @return the min of the three attributes
       
   211      */
       
   212     inline TInt Min3(TInt aX, TInt aY, TInt aZ);
       
   213 
       
   214     /**
       
   215      * Finds the maximum of three integers
       
   216      * @param aX -
       
   217      * @param aY -
       
   218      * @param aZ -
       
   219      * @return the max of the three attributes
       
   220      */
       
   221     inline TInt Max3(TInt aX, TInt aY, TInt aZ);
       
   222 
       
   223 private:
       
   224     /**
       
   225      * Target Canvas of this graphics object.
       
   226      * NULL, when this is not canvas graphics.
       
   227      */
       
   228     MMIDCanvas* iCanvasTarget;
       
   229 #endif // RD_JAVA_NGA_ENABLED
       
   230 
       
   231 private:
       
   232     CMIDProxyMap& iProxyMap;
       
   233     CLcdGraphics* iGraphics;
       
   234     // this flag is for mutable off-screen images (not for canvas/GameCanvas framebuffer)
       
   235     TBool iIsImageTarget;
       
   236 };
       
   237 
       
   238 inline CFbsBitmap* CMIDGraphics::BitmapAlpha() const
       
   239 {
       
   240     return NULL;
       
   241 }
       
   242 
       
   243 #ifdef RD_JAVA_NGA_ENABLED
       
   244 // ---------------------------------------------------------------------------
       
   245 // CMIDGraphics::Min3
       
   246 // ---------------------------------------------------------------------------
       
   247 //
       
   248 inline TInt CMIDGraphics::Min3(TInt aX, TInt aY, TInt aZ)
       
   249 {
       
   250     return Min(Min(aX, aY), aZ);
       
   251 }
       
   252 
       
   253 // ---------------------------------------------------------------------------
       
   254 // CMIDGraphics::Max3
       
   255 // ---------------------------------------------------------------------------
       
   256 //
       
   257 inline TInt CMIDGraphics::Max3(TInt aX, TInt aY, TInt aZ)
       
   258 {
       
   259     return Max(Max(aX, aY), aZ);
       
   260 }
       
   261 #endif // RD_JAVA_NGA_ENABLED
       
   262 
       
   263 #endif // CMIDGRAPHICS_H
       
   264