Backed out changeset b88172246b66 due to Win32 debug failures.
[mozilla-central.git] / gfx / thebes / gfxTypes.h
blob1993f4298b3b4c50c54e414609bde97550d634d5
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
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/
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.
15 * The Original Code is Oracle Corporation code.
17 * The Initial Developer of the Original Code is Oracle Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 2005
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * Stuart Parmenter <pavlov@pavlov.net>
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.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef GFX_TYPES_H
39 #define GFX_TYPES_H
41 #include "prtypes.h"
42 #include "nsAtomicRefcnt.h"
44 /**
45 * Currently needs to be 'double' for Cairo compatibility. Could
46 * become 'float', perhaps, in some configurations.
48 typedef double gfxFloat;
50 #if defined(MOZ_STATIC_BUILD)
51 # define THEBES_API
52 #elif defined(IMPL_THEBES)
53 # define THEBES_API NS_EXPORT
54 #else
55 # define THEBES_API NS_IMPORT
56 #endif
58 /**
59 * gfx errors
62 /* nsIDeviceContext.h defines a set of printer errors */
63 #define NS_ERROR_GFX_GENERAL_BASE (50)
65 /* Font cmap is strangely structured - avoid this font! */
66 #define NS_ERROR_GFX_CMAP_MALFORMED \
67 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_GENERAL_BASE+1)
69 /**
70 * Priority of a line break opportunity.
72 * eNoBreak The line has no break opportunities
73 * eWordWrapBreak The line has a break opportunity only within a word. With
74 * word-wrap: break-word we will break at this point only if
75 * there are no other break opportunities in the line.
76 * eNormalBreak The line has a break opportunity determined by the standard
77 * line-breaking algorithm.
79 * Future expansion: split eNormalBreak into multiple priorities, e.g.
80 * punctuation break and whitespace break (bug 389710).
81 * As and when we implement it, text-wrap: unrestricted will
82 * mean that priorities are ignored and all line-break
83 * opportunities are equal.
85 * @see gfxTextRun::BreakAndMeasureText
86 * @see nsLineLayout::NotifyOptionalBreakPosition
88 enum gfxBreakPriority {
89 eNoBreak = 0,
90 eWordWrapBreak,
91 eNormalBreak
94 #define THEBES_INLINE_DECL_THREADSAFE_REFCOUNTING(_class) \
95 public: \
96 nsrefcnt AddRef(void) { \
97 NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt"); \
98 nsrefcnt count = NS_AtomicIncrementRefcnt(mRefCnt); \
99 NS_LOG_ADDREF(this, count, #_class, sizeof(*this)); \
100 return count; \
102 nsrefcnt Release(void) { \
103 NS_PRECONDITION(0 != mRefCnt, "dup release"); \
104 nsrefcnt count = NS_AtomicDecrementRefcnt(mRefCnt); \
105 NS_LOG_RELEASE(this, count, #_class); \
106 if (count == 0) { \
107 mRefCnt = 1; /* stabilize */ \
108 delete this; \
109 return 0; \
111 return count; \
113 protected: \
114 nsAutoRefCnt mRefCnt; \
115 public:
117 #endif /* GFX_TYPES_H */