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
15 * The Original Code is thebes gfx code.
17 * The Initial Developer of the Original Code is Mozilla Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 2006
19 * the Initial Developer. All Rights Reserved.
22 * Vladimir Vukicevic <vladimir@pobox.com>
23 * Masayuki Nakano <masayuki@d-toybox.com>
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.
37 * ***** END LICENSE BLOCK ***** */
39 #include "gfxPlatformMac.h"
41 #include "gfxImageSurface.h"
42 #include "gfxQuartzSurface.h"
44 #include "gfxQuartzFontCache.h"
45 #include "gfxAtsuiFonts.h"
47 #ifdef MOZ_ENABLE_GLITZ
48 #include "gfxGlitzSurface.h"
49 #include "glitz-agl.h"
54 gfxPlatformMac::gfxPlatformMac()
56 #ifdef MOZ_ENABLE_GLITZ
62 already_AddRefed
<gfxASurface
>
63 gfxPlatformMac::CreateOffscreenSurface(const gfxIntSize
& size
,
64 gfxASurface::gfxImageFormat imageFormat
)
66 gfxASurface
*newSurface
= nsnull
;
69 newSurface
= new gfxQuartzSurface(size
, imageFormat
);
71 #ifdef MOZ_ENABLE_GLITZ
73 switch (imageFormat
) {
74 case gfxASurface::ImageFormatARGB32
:
76 glitzf
= 0; // GLITZ_STANDARD_ARGB32;
78 case gfxASurface::ImageFormatRGB24
:
80 glitzf
= 1; // GLITZ_STANDARD_RGB24;
82 case gfxASurface::ImageFormatA8
:
84 glitzf
= 2; // GLITZ_STANDARD_A8;
85 case gfxASurface::ImageFormatA1
:
87 glitzf
= 3; // GLITZ_STANDARD_A1;
93 // XXX look for the right kind of format based on bpp
94 glitz_drawable_format_t templ
;
95 memset(&templ
, 0, sizeof(templ
));
96 templ
.color
.red_size
= 8;
97 templ
.color
.green_size
= 8;
98 templ
.color
.blue_size
= 8;
100 templ
.color
.alpha_size
= 8;
102 templ
.color
.alpha_size
= 0;
103 templ
.doublebuffer
= FALSE
;
107 GLITZ_FORMAT_RED_SIZE_MASK
|
108 GLITZ_FORMAT_GREEN_SIZE_MASK
|
109 GLITZ_FORMAT_BLUE_SIZE_MASK
|
110 GLITZ_FORMAT_ALPHA_SIZE_MASK
|
111 GLITZ_FORMAT_SAMPLES_MASK
|
112 GLITZ_FORMAT_DOUBLEBUFFER_MASK
;
114 glitz_drawable_format_t
*gdformat
=
115 glitz_agl_find_pbuffer_format(mask
, &templ
, 0);
117 glitz_drawable_t
*gdraw
=
118 glitz_agl_create_pbuffer_drawable(gdformat
, width
, height
);
120 glitz_format_t
*gformat
=
121 glitz_find_standard_format(gdraw
, (glitz_format_name_t
) glitzf
);
123 glitz_surface_t
*gsurf
=
124 glitz_surface_create(gdraw
,
131 glitz_surface_attach(gsurf
, gdraw
, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR
);
133 newSurface
= new gfxGlitzSurface(gdraw
, gsurf
, PR_TRUE
);
137 NS_IF_ADDREF(newSurface
);
142 gfxPlatformMac::ResolveFontName(const nsAString
& aFontName
,
143 FontResolverCallback aCallback
,
144 void *aClosure
, PRBool
& aAborted
)
146 nsAutoString resolvedName
;
147 if (!gfxQuartzFontCache::SharedFontCache()->
148 ResolveFontName(aFontName
, resolvedName
)) {
152 aAborted
= !(*aCallback
)(resolvedName
, aClosure
);
157 gfxPlatformMac::CreateFontGroup(const nsAString
&aFamilies
,
158 const gfxFontStyle
*aStyle
)
160 return new gfxAtsuiFontGroup(aFamilies
, aStyle
);
164 gfxPlatformMac::GetFontList(const nsACString
& aLangGroup
,
165 const nsACString
& aGenericFamily
,
166 nsStringArray
& aListOfFonts
)
168 gfxQuartzFontCache::SharedFontCache()->
169 GetFontList(aLangGroup
, aGenericFamily
, aListOfFonts
);
174 gfxPlatformMac::UpdateFontList()
176 gfxQuartzFontCache::SharedFontCache()->UpdateFontList();
181 gfxPlatformMac::GetPlatformCMSOutputProfile()
183 CMProfileLocation device
;
184 CMError err
= CMGetDeviceProfile(cmDisplayDeviceClass
,
191 cmsHPROFILE profile
= nsnull
;
192 switch (device
.locType
) {
193 case cmFileBasedProfile
: {
195 if (!FSpMakeFSRef(&device
.u
.fileLoc
.spec
, &fsRef
)) {
197 if (!FSRefMakePath(&fsRef
, (UInt8
*)(path
), sizeof(path
))) {
198 profile
= cmsOpenProfileFromFile(path
, "r");
202 "ICM profile read from %s fileLoc successfully\n", path
);
208 case cmPathBasedProfile
:
209 profile
= cmsOpenProfileFromFile(device
.u
.pathLoc
.path
, "r");
213 "ICM profile read from %s pathLoc successfully\n",
214 device
.u
.pathLoc
.path
);
219 fprintf(stderr
, "Unhandled ColorSync profile location\n");