LCOV - code coverage report
Current view: directory - gfx/2d - Types.h (source / functions) Found Hit Coverage
Test: app.info Lines: 6 0 0.0 %
Date: 2012-06-02 Functions: 3 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       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 Mozilla Corporation code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is Mozilla Foundation.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2011
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *   Bas Schouten <bschouten@mozilla.com>
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      26                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #ifndef MOZILLA_GFX_TYPES_H_
      39                 : #define MOZILLA_GFX_TYPES_H_
      40                 : 
      41                 : #include "mozilla/StandardInteger.h"
      42                 : 
      43                 : #include <stddef.h>
      44                 : 
      45                 : namespace mozilla {
      46                 : namespace gfx {
      47                 : 
      48                 : typedef float Float;
      49                 : 
      50                 : enum SurfaceType
      51                 : {
      52                 :   SURFACE_DATA, /* Data surface - bitmap in memory */
      53                 :   SURFACE_D2D1_BITMAP, /* Surface wrapping a ID2D1Bitmap */
      54                 :   SURFACE_D2D1_DRAWTARGET, /* Surface made from a D2D draw target */
      55                 :   SURFACE_CAIRO, /* Surface wrapping a cairo surface */
      56                 :   SURFACE_CAIRO_IMAGE, /* Data surface wrapping a cairo image surface */
      57                 :   SURFACE_COREGRAPHICS_IMAGE, /* Surface wrapping a CoreGraphics Image */
      58                 :   SURFACE_COREGRAPHICS_CGCONTEXT, /* Surface wrapping a CG context */
      59                 :   SURFACE_SKIA /* Surface wrapping a Skia bitmap */
      60                 : };
      61                 : 
      62                 : enum SurfaceFormat
      63                 : {
      64                 :   FORMAT_B8G8R8A8,
      65                 :   FORMAT_B8G8R8X8,
      66                 :   FORMAT_R5G6B5,
      67                 :   FORMAT_A8
      68                 : };
      69                 : 
      70                 : enum BackendType
      71                 : {
      72                 :   BACKEND_NONE,
      73                 :   BACKEND_DIRECT2D,
      74                 :   BACKEND_COREGRAPHICS,
      75                 :   BACKEND_CAIRO,
      76                 :   BACKEND_SKIA
      77                 : };
      78                 : 
      79                 : enum FontType
      80                 : {
      81                 :   FONT_DWRITE,
      82                 :   FONT_GDI,
      83                 :   FONT_MAC,
      84                 :   FONT_SKIA,
      85                 :   FONT_CAIRO,
      86                 :   FONT_COREGRAPHICS
      87                 : };
      88                 : 
      89                 : enum NativeSurfaceType
      90                 : {
      91                 :   NATIVE_SURFACE_D3D10_TEXTURE,
      92                 :   NATIVE_SURFACE_CAIRO_SURFACE,
      93                 :   NATIVE_SURFACE_CGCONTEXT
      94                 : };
      95                 : 
      96                 : enum NativeFontType
      97                 : {
      98                 :   NATIVE_FONT_DWRITE_FONT_FACE,
      99                 :   NATIVE_FONT_GDI_FONT_FACE,
     100                 :   NATIVE_FONT_MAC_FONT_FACE,
     101                 :   NATIVE_FONT_SKIA_FONT_FACE,
     102                 :   NATIVE_FONT_CAIRO_FONT_FACE
     103                 : };
     104                 : 
     105                 : enum CompositionOp { OP_OVER, OP_ADD, OP_ATOP, OP_OUT, OP_IN, OP_SOURCE, OP_DEST_IN, OP_DEST_OUT, OP_DEST_OVER, OP_DEST_ATOP, OP_XOR, OP_COUNT };
     106                 : enum ExtendMode { EXTEND_CLAMP, EXTEND_REPEAT, EXTEND_REFLECT };
     107                 : enum FillRule { FILL_WINDING, FILL_EVEN_ODD };
     108                 : enum AntialiasMode { AA_NONE, AA_GRAY, AA_SUBPIXEL };
     109                 : enum Snapping { SNAP_NONE, SNAP_ALIGNED };
     110                 : enum Filter { FILTER_LINEAR, FILTER_POINT };
     111                 : enum PatternType { PATTERN_COLOR, PATTERN_SURFACE, PATTERN_LINEAR_GRADIENT, PATTERN_RADIAL_GRADIENT };
     112                 : enum JoinStyle { JOIN_BEVEL, JOIN_ROUND, JOIN_MITER, JOIN_MITER_OR_BEVEL };
     113                 : enum CapStyle { CAP_BUTT, CAP_ROUND, CAP_SQUARE };
     114                 : enum SamplingBounds { SAMPLING_UNBOUNDED, SAMPLING_BOUNDED };
     115                 : 
     116                 : /* Color is stored in non-premultiplied form */
     117                 : struct Color
     118                 : {
     119                 : public:
     120               0 :   Color()
     121               0 :     : r(0.0f), g(0.0f), b(0.0f), a(0.0f)
     122               0 :   {}
     123                 :   Color(Float aR, Float aG, Float aB, Float aA)
     124                 :     : r(aR), g(aG), b(aB), a(aA)
     125                 :   {}
     126                 :   Color(Float aR, Float aG, Float aB)
     127                 :     : r(aR), g(aG), b(aB), a(1.0f)
     128                 :   {}
     129                 : 
     130                 :   static Color FromABGR(uint32_t aColor)
     131                 :   {
     132                 :     Color newColor(((aColor >> 0) & 0xff) * (1.0f / 255.0f),
     133                 :                    ((aColor >> 8) & 0xff) * (1.0f / 255.0f),
     134                 :                    ((aColor >> 16) & 0xff) * (1.0f / 255.0f),
     135                 :                    ((aColor >> 24) & 0xff) * (1.0f / 255.0f));
     136                 : 
     137                 :     return newColor;
     138                 :   }
     139                 : 
     140                 :   Float r, g, b, a;
     141                 : };
     142                 : 
     143                 : struct GradientStop
     144               0 : {
     145               0 :   bool operator<(const GradientStop& aOther) const {
     146               0 :     return offset < aOther.offset;
     147                 :   }
     148                 : 
     149                 :   Float offset;
     150                 :   Color color;
     151                 : };
     152                 : 
     153                 : }
     154                 : }
     155                 : 
     156                 : // Side constants for use in various places
     157                 : namespace mozilla {
     158                 :   namespace css {
     159                 :     enum Side {eSideTop, eSideRight, eSideBottom, eSideLeft};
     160                 :   }
     161                 : }
     162                 : 
     163                 : // XXX - These don't really belong here. But for now this is where they go.
     164                 : #define NS_SIDE_TOP     mozilla::css::eSideTop
     165                 : #define NS_SIDE_RIGHT   mozilla::css::eSideRight
     166                 : #define NS_SIDE_BOTTOM  mozilla::css::eSideBottom
     167                 : #define NS_SIDE_LEFT    mozilla::css::eSideLeft
     168                 : 
     169                 : #endif /* MOZILLA_GFX_TYPES_H_ */

Generated by: LCOV version 1.7