LCOV - code coverage report
Current view: directory - objdir/dist/include - nsRenderingContext.h (source / functions) Found Hit Coverage
Test: app.info Lines: 22 0 0.0 %
Date: 2012-06-02 Functions: 13 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is thebes gfx
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * mozilla.org.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2005
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Vladimir Vukicevic <vladimir@pobox.com>
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef NSRENDERINGCONTEXT__H__
      40                 : #define NSRENDERINGCONTEXT__H__
      41                 : 
      42                 : #include "nsAutoPtr.h"
      43                 : #include "nsDeviceContext.h"
      44                 : #include "nsFontMetrics.h"
      45                 : #include "nsColor.h"
      46                 : #include "nsCoord.h"
      47                 : #include "gfxContext.h"
      48                 : #include "mozilla/gfx/UserData.h"
      49                 : 
      50                 : struct nsPoint;
      51                 : class nsIntRegion;
      52                 : 
      53                 : typedef enum {
      54                 :     nsLineStyle_kNone   = 0,
      55                 :     nsLineStyle_kSolid  = 1,
      56                 :     nsLineStyle_kDashed = 2,
      57                 :     nsLineStyle_kDotted = 3
      58                 : } nsLineStyle;
      59                 : 
      60                 : class nsRenderingContext
      61               0 : {
      62                 :     typedef mozilla::gfx::UserData UserData;
      63                 :     typedef mozilla::gfx::UserDataKey UserDataKey;
      64                 : 
      65                 : public:
      66               0 :     nsRenderingContext() : mP2A(0.) {}
      67                 :     // ~nsRenderingContext() {}
      68                 : 
      69               0 :     NS_INLINE_DECL_REFCOUNTING(nsRenderingContext)
      70                 : 
      71                 :     void Init(nsDeviceContext* aContext, gfxASurface* aThebesSurface);
      72                 :     void Init(nsDeviceContext* aContext, gfxContext* aThebesContext);
      73                 : 
      74                 :     // These accessors will never return null.
      75               0 :     gfxContext *ThebesContext() { return mThebes; }
      76               0 :     nsDeviceContext *DeviceContext() { return mDeviceContext; }
      77               0 :     PRUint32 AppUnitsPerDevPixel() { return NSToIntRound(mP2A); }
      78                 : 
      79                 :     // Graphics state
      80                 : 
      81                 :     void PushState(void);
      82                 :     void PopState(void);
      83                 :     void IntersectClip(const nsRect& aRect);
      84                 :     void SetClip(const nsIntRegion& aRegion);
      85                 :     void SetLineStyle(nsLineStyle aLineStyle);
      86                 :     void SetColor(nscolor aColor);
      87                 :     void Translate(const nsPoint& aPt);
      88                 :     void Scale(float aSx, float aSy);
      89                 : 
      90                 :     class AutoPushTranslation {
      91                 :         nsRenderingContext* mCtx;
      92                 :     public:
      93               0 :         AutoPushTranslation(nsRenderingContext* aCtx, const nsPoint& aPt)
      94               0 :             : mCtx(aCtx) {
      95               0 :             mCtx->PushState();
      96               0 :             mCtx->Translate(aPt);
      97               0 :         }
      98               0 :         ~AutoPushTranslation() {
      99               0 :             mCtx->PopState();
     100               0 :         }
     101                 :     };
     102                 : 
     103                 :     // Shapes
     104                 : 
     105                 :     void DrawLine(const nsPoint& aStartPt, const nsPoint& aEndPt);
     106                 :     void DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
     107                 :     void DrawRect(const nsRect& aRect);
     108                 :     void DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
     109                 :     void DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
     110                 : 
     111                 :     void FillRect(const nsRect& aRect);
     112                 :     void FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
     113                 :     void FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
     114                 : 
     115                 :     void FillEllipse(const nsRect& aRect);
     116                 :     void FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
     117                 : 
     118                 :     void InvertRect(const nsRect& aRect);
     119                 : 
     120                 :     // Text
     121                 : 
     122                 :     void SetFont(nsFontMetrics *aFontMetrics);
     123               0 :     nsFontMetrics *FontMetrics() { return mFontMetrics; } // may be null
     124                 : 
     125                 :     void SetTextRunRTL(bool aIsRTL);
     126                 : 
     127                 :     nscoord GetWidth(char aC);
     128                 :     nscoord GetWidth(PRUnichar aC);
     129                 :     nscoord GetWidth(const nsString& aString);
     130                 :     nscoord GetWidth(const char* aString);
     131                 :     nscoord GetWidth(const char* aString, PRUint32 aLength);
     132                 :     nscoord GetWidth(const PRUnichar *aString, PRUint32 aLength);
     133                 : 
     134                 :     nsBoundingMetrics GetBoundingMetrics(const PRUnichar *aString,
     135                 :                                          PRUint32 aLength);
     136                 : 
     137                 :     void DrawString(const nsString& aString, nscoord aX, nscoord aY);
     138                 :     void DrawString(const char *aString, PRUint32 aLength,
     139                 :                     nscoord aX, nscoord aY);
     140                 :     void DrawString(const PRUnichar *aString, PRUint32 aLength,
     141                 :                     nscoord aX, nscoord aY);
     142                 : 
     143               0 :     void AddUserData(UserDataKey *key, void *userData, void (*destroy)(void*)) {
     144               0 :       mUserData.Add(key, userData, destroy);
     145               0 :     }
     146               0 :     void *GetUserData(UserDataKey *key) {
     147               0 :       return mUserData.Get(key);
     148                 :     }
     149               0 :     void *RemoveUserData(UserDataKey *key) {
     150               0 :       return mUserData.Remove(key);
     151                 :     }
     152                 : 
     153                 : protected:
     154                 :     PRInt32 GetMaxChunkLength();
     155                 : 
     156                 :     nsRefPtr<gfxContext> mThebes;
     157                 :     nsRefPtr<nsDeviceContext> mDeviceContext;
     158                 :     nsRefPtr<nsFontMetrics> mFontMetrics;
     159                 : 
     160                 :     double mP2A; // cached app units per device pixel value
     161                 : 
     162                 :     UserData mUserData;
     163                 : };
     164                 : 
     165                 : #endif  // NSRENDERINGCONTEXT__H__

Generated by: LCOV version 1.7