Back to index

lightning-sunbird  0.9+nobinonly
nsIDrawingSurface.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef nsIDrawingSurface_h___
00039 #define nsIDrawingSurface_h___
00040 
00041 #include "nscore.h"
00042 #include "nsISupports.h"
00043 
00044 // a memory area that can be rendered to
00045 
00046 typedef struct
00047 {
00048   PRUint32  mRedZeroMask;     //red color mask in zero position
00049   PRUint32  mGreenZeroMask;   //green color mask in zero position
00050   PRUint32  mBlueZeroMask;    //blue color mask in zero position
00051   PRUint32  mAlphaZeroMask;   //alpha data mask in zero position
00052   PRUint32  mRedMask;         //red color mask
00053   PRUint32  mGreenMask;       //green color mask
00054   PRUint32  mBlueMask;        //blue color mask
00055   PRUint32  mAlphaMask;       //alpha data mask
00056   PRUint8   mRedCount;        //number of red color bits
00057   PRUint8   mGreenCount;      //number of green color bits
00058   PRUint8   mBlueCount;       //number of blue color bits
00059   PRUint8   mAlphaCount;      //number of alpha data bits
00060   PRUint8   mRedShift;        //number to shift value into red position
00061   PRUint8   mGreenShift;      //number to shift value into green position
00062   PRUint8   mBlueShift;       //number to shift value into blue position
00063   PRUint8   mAlphaShift;      //number to shift value into alpha position
00064 } nsPixelFormat;
00065 
00066 #define RASWIDTH(width, bpp) ((((width) * (bpp) + 31) >> 5) << 2)
00067 
00068 #define NS_IDRAWING_SURFACE_IID   \
00069 { 0x61cc77e0, 0xcaac, 0x11d2, \
00070 { 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
00071 
00072 class nsIDrawingSurface : public nsISupports
00073 {
00074 public:
00075   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDRAWING_SURFACE_IID)
00093   NS_IMETHOD Lock(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
00094                   void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
00095                   PRUint32 aFlags) = 0;
00096 
00103   NS_IMETHOD Unlock(void) = 0;
00104 
00112   NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight) = 0;
00113 
00123   NS_IMETHOD IsOffscreen(PRBool *aOffScreen) = 0;
00124 
00137   NS_IMETHOD IsPixelAddressable(PRBool *aAddressable) = 0;
00138 
00146   NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat) = 0;
00147 };
00148 
00149 //when creating a drawing surface, you can use this
00150 //to tell the drawing surface that you anticipate
00151 //the need to get to the actual bits of the drawing
00152 //surface at some point during it's lifetime. typically
00153 //used when creating bitmaps to be operated on by the
00154 //nsIBlender implementations.
00155 #define NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS  0x0001
00156 
00157 //flag to say that this drawing surface is shortlived,
00158 //which may affect how the OS allocates it. Used for
00159 //tiling, grouting etc.
00160 #define NS_CREATEDRAWINGSURFACE_SHORTLIVED        0x0002
00161 
00162 //when locking a drawing surface, use these flags to
00163 //control how the data in the surface should be accessed
00164 #define NS_LOCK_SURFACE_READ_ONLY       0x0001
00165 #define NS_LOCK_SURFACE_WRITE_ONLY      0x0002
00166 
00167 #endif  // nsIDrawingSurface_h___