b=328116, Start of Cairo-on-OSX for Thebes GFX; gfx and cairo pieces, r=pavlov
git-svn-id: svn://10.0.0.236/trunk@190777 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
1443
mozilla/configure
vendored
1443
mozilla/configure
vendored
File diff suppressed because it is too large
Load Diff
@@ -3944,7 +3944,9 @@ MOZ_ARG_HEADER(Toolkit Options)
|
||||
-o "$_DEFAULT_TOOLKIT" = "cocoa" \
|
||||
-o "$_DEFAULT_TOOLKIT" = "cairo-windows" \
|
||||
-o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
|
||||
-o "$_DEFAULT_TOOLKIT" = "cairo-xlib"
|
||||
-o "$_DEFAULT_TOOLKIT" = "cairo-xlib" \
|
||||
-o "$_DEFAULT_TOOLKIT" = "cairo-mac" \
|
||||
-o "$_DEFAULT_TOOLKIT" = "cairo-cocoa"
|
||||
then
|
||||
dnl nglayout only supports building with one toolkit,
|
||||
dnl so ignore everything after the first comma (",").
|
||||
@@ -4051,6 +4053,25 @@ cairo-xlib)
|
||||
TK_LIBS='$(MOZ_XLIB_LDFLAGS) $(MOZ_CAIRO_LIBS)'
|
||||
AC_DEFINE(MOZ_WIDGET_XLIB)
|
||||
;;
|
||||
cairo-mac|cairo-cocoa)
|
||||
if test "$MOZ_WIDGET_TOOLKIT" = "cairo-cocoa"; then
|
||||
MOZ_WIDGET_TOOLKIT=cocoa
|
||||
AC_DEFINE(MOZ_WIDGET_COCOA)
|
||||
MOZ_ENABLE_COCOA=1
|
||||
else
|
||||
MOZ_WIDGET_TOOLKIT=mac
|
||||
fi
|
||||
MOZ_ENABLE_CAIRO_GFX=1
|
||||
MOZ_GFX_TOOLKIT=cairo
|
||||
MOZ_USER_DIR="Mozilla"
|
||||
AC_DEFINE(XP_MACOSX)
|
||||
AC_DEFINE(TARGET_CARBON)
|
||||
AC_DEFINE(TARGET_API_MAC_CARBON)
|
||||
TK_LIBS='-framework Carbon'
|
||||
TK_CFLAGS="-I${MACOS_SDK_DIR}/Developer/Headers/FlatCarbon"
|
||||
CFLAGS="$CFLAGS $TK_CFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test "$MOZ_ENABLE_XREMOTE"; then
|
||||
@@ -6717,6 +6738,7 @@ if test "$MOZ_SVG_RENDERER_CAIRO" -o "$MOZ_ENABLE_CANVAS" -o "$MOZ_ENABLE_CAIRO_
|
||||
fi
|
||||
if test "$MOZ_WIDGET_TOOLKIT" = "mac" -o "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
|
||||
QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
|
||||
QUARTZGL_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZGL_SURFACE 1"
|
||||
ATSUI_FONT_FEATURE="#define CAIRO_HAS_ATSUI_FONT 1"
|
||||
fi
|
||||
if test "$MOZ_WIDGET_TOOLKIT" = "windows"; then
|
||||
@@ -6755,6 +6777,7 @@ if test "$MOZ_SVG_RENDERER_CAIRO" -o "$MOZ_ENABLE_CANVAS" -o "$MOZ_ENABLE_CAIRO_
|
||||
AC_SUBST(SVG_SURFACE_FEATURE)
|
||||
AC_SUBST(XLIB_SURFACE_FEATURE)
|
||||
AC_SUBST(QUARTZ_SURFACE_FEATURE)
|
||||
AC_SUBST(QUARTZGL_SURFACE_FEATURE)
|
||||
AC_SUBST(XCB_SURFACE_FEATURE)
|
||||
AC_SUBST(WIN32_SURFACE_FEATURE)
|
||||
AC_SUBST(OS2_SURFACE_FEATURE)
|
||||
|
||||
@@ -43,6 +43,8 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
SUBMAKEFILES += cairo-features.h
|
||||
|
||||
VISIBILITY_FLAGS =
|
||||
|
||||
MODULE = cairo
|
||||
@@ -109,8 +111,9 @@ endif
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
CSRCS += cairo-quartz-surface.c \
|
||||
cairo-quartz2-surface.c \
|
||||
cairo-atsui-font.c
|
||||
EXPORTS += cairo-quartz.h cairo-atsui.h
|
||||
EXPORTS += cairo-quartz.h cairo-quartz2.h cairo-atsui.h
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),beos)
|
||||
|
||||
@@ -307,9 +307,12 @@ _cairo_atsui_font_create_toy(cairo_toy_font_face_t *toy_face,
|
||||
kFontNoLanguageCode, &fontID);
|
||||
}
|
||||
|
||||
/* Need to specify more tags, e.g. kATSUHangingInhibitFactorTag */
|
||||
/* Should use ATSU Variations to exactly specify weight and slant */
|
||||
ATSUAttributeTag styleTags[] =
|
||||
{ kATSUQDItalicTag, kATSUQDBoldfaceTag, kATSUFontTag };
|
||||
ATSUAttributeValuePtr styleValues[] = { &isItalic, &isBold, &fontID };
|
||||
ATSUAttributeValuePtr styleValues[] =
|
||||
{ &isItalic, &isBold, &fontID };
|
||||
ByteCount styleSizes[] =
|
||||
{ sizeof(Boolean), sizeof(Boolean), sizeof(ATSUFontID) };
|
||||
|
||||
@@ -317,7 +320,6 @@ _cairo_atsui_font_create_toy(cairo_toy_font_face_t *toy_face,
|
||||
sizeof(styleTags) / sizeof(styleTags[0]),
|
||||
styleTags, styleSizes, styleValues);
|
||||
|
||||
|
||||
return _cairo_atsui_font_create_scaled (&toy_face->base, fontID, style,
|
||||
font_matrix, ctm, options, font_out);
|
||||
}
|
||||
@@ -336,6 +338,28 @@ _cairo_atsui_font_fini(void *abstract_font)
|
||||
ATSUDisposeStyle(font->unscaled_style);
|
||||
}
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_scaled_font_is_atsui (cairo_scaled_font_t *sfont)
|
||||
{
|
||||
return (sfont->backend == &cairo_atsui_scaled_font_backend);
|
||||
}
|
||||
|
||||
ATSUStyle
|
||||
_cairo_atsui_scaled_font_get_atsu_style (cairo_scaled_font_t *sfont)
|
||||
{
|
||||
cairo_atsui_font_t *afont = (cairo_atsui_font_t *) sfont;
|
||||
|
||||
return afont->style;
|
||||
}
|
||||
|
||||
ATSUFontID
|
||||
_cairo_atsui_scaled_font_get_atsu_font_id (cairo_scaled_font_t *sfont)
|
||||
{
|
||||
cairo_atsui_font_t *afont = (cairo_atsui_font_t *) sfont;
|
||||
|
||||
return afont->fontID;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_atsui_font_init_glyph_metrics (cairo_atsui_font_t *font,
|
||||
cairo_scaled_glyph_t *scaled_glyph)
|
||||
@@ -565,7 +589,7 @@ _cairo_atsui_font_old_show_glyphs (void *abstract_font,
|
||||
CGContextRef myBitmapContext;
|
||||
CGColorSpaceRef colorSpace;
|
||||
cairo_image_surface_t *destImageSurface;
|
||||
int i;
|
||||
int i, bits_per_comp, alpha;
|
||||
void *extra = NULL;
|
||||
|
||||
cairo_rectangle_t rect = {dest_x, dest_y, width, height};
|
||||
@@ -576,15 +600,34 @@ _cairo_atsui_font_old_show_glyphs (void *abstract_font,
|
||||
&extra);
|
||||
|
||||
// Create a CGBitmapContext for the dest surface for drawing into
|
||||
colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
if (destImageSurface->depth == 1) {
|
||||
colorSpace = CGColorSpaceCreateDeviceGray();
|
||||
bits_per_comp = 1;
|
||||
alpha = kCGImageAlphaNone;
|
||||
} else if (destImageSurface->depth == 8) {
|
||||
colorSpace = CGColorSpaceCreateDeviceGray();
|
||||
bits_per_comp = 8;
|
||||
alpha = kCGImageAlphaNone;
|
||||
} else if (destImageSurface->depth == 24) {
|
||||
colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
bits_per_comp = 8;
|
||||
alpha = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host;
|
||||
} else if (destImageSurface->depth == 32) {
|
||||
colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
bits_per_comp = 8;
|
||||
alpha = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host;
|
||||
} else {
|
||||
// not reached
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
myBitmapContext = CGBitmapContextCreate(destImageSurface->data,
|
||||
destImageSurface->width,
|
||||
destImageSurface->height,
|
||||
destImageSurface->depth / 4,
|
||||
bits_per_comp,
|
||||
destImageSurface->stride,
|
||||
colorSpace,
|
||||
kCGImageAlphaPremultipliedFirst);
|
||||
alpha);
|
||||
CGContextTranslateCTM(myBitmapContext, 0, destImageSurface->height);
|
||||
CGContextScaleCTM(myBitmapContext, 1.0f, -1.0f);
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@
|
||||
|
||||
@QUARTZ_SURFACE_FEATURE@
|
||||
|
||||
@QUARTZGL_SURFACE_FEATURE@
|
||||
|
||||
@XCB_SURFACE_FEATURE@
|
||||
|
||||
@WIN32_SURFACE_FEATURE@
|
||||
|
||||
@@ -58,4 +58,13 @@ typedef struct cairo_quartz_surface {
|
||||
cairo_bool_t
|
||||
_cairo_surface_is_quartz (cairo_surface_t *surface);
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_scaled_font_is_atsui (cairo_scaled_font_t *sfont);
|
||||
|
||||
ATSUStyle
|
||||
_cairo_atsui_scaled_font_get_atsu_style (cairo_scaled_font_t *sfont);
|
||||
|
||||
ATSUFontID
|
||||
_cairo_atsui_scaled_font_get_atsu_font_id (cairo_scaled_font_t *sfont);
|
||||
|
||||
#endif /* CAIRO_QUARTZ_PRIVATE_H */
|
||||
|
||||
1611
mozilla/gfx/cairo/cairo/src/cairo-quartz2-surface.c
Normal file
1611
mozilla/gfx/cairo/cairo/src/cairo-quartz2-surface.c
Normal file
File diff suppressed because it is too large
Load Diff
76
mozilla/gfx/cairo/cairo/src/cairo-quartz2.h
Normal file
76
mozilla/gfx/cairo/cairo/src/cairo-quartz2.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2006 Mozilla Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@mozilla.com>
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_QUARTZGL_H
|
||||
#define CAIRO_QUARTZGL_H
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
#if CAIRO_HAS_QUARTZGL_SURFACE
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
#include <AGL/agl.h>
|
||||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
cairo_surface_t *
|
||||
cairo_quartzgl_surface_create (cairo_format_t format,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
cairo_bool_t y_grows_down);
|
||||
|
||||
cairo_surface_t *
|
||||
cairo_quartzgl_surface_create_for_agl_context (AGLContext aglContext,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
cairo_bool_t y_grows_down);
|
||||
|
||||
cairo_surface_t *
|
||||
cairo_quartzgl_surface_create_for_cg_context (CGContextRef cgContext,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
cairo_bool_t y_grows_down);
|
||||
|
||||
cairo_bool_t
|
||||
cairo_surface_is_quartzgl (cairo_surface_t *surf);
|
||||
|
||||
CAIRO_END_DECLS
|
||||
|
||||
#else /* CAIRO_HAS_QUARTZGL_SURFACE */
|
||||
# error Cairo was not compiled with support for the quartzgl backend
|
||||
#endif /* CAIRO_HAS_QUARTZGL_SURFACE */
|
||||
|
||||
#endif /* CAIRO_QUARTZGL_H */
|
||||
@@ -84,6 +84,10 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
DIRS += wgl
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(MOZ_GFX_TOOLKIT),mac cocoa))
|
||||
DIRS += agl
|
||||
endif
|
||||
|
||||
FORCE_STATIC_LIB = 1
|
||||
FORCE_USE_PIC = 1
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ glitz_agl_query_formats (glitz_agl_thread_info_t *thread_info)
|
||||
|
||||
format.types = GLITZ_DRAWABLE_TYPE_WINDOW_MASK;
|
||||
format.d.id = 0;
|
||||
format.color.fourcc = GLITZ_FOURCC_RGB;
|
||||
format.d.color.fourcc = GLITZ_FOURCC_RGB;
|
||||
|
||||
n_attribs_list = sizeof (_attribs_list) / sizeof (GLint *);
|
||||
|
||||
|
||||
@@ -71,10 +71,6 @@ ifdef MOZ_ENABLE_POSTSCRIPT
|
||||
DIRS += psshared ps
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_GFX_TOOLKIT),cocoa)
|
||||
DIRS += mac
|
||||
endif
|
||||
|
||||
# Build xlibrgb only for X toolkits and/or Xprint
|
||||
ifneq (,$(filter xlib,$(MOZ_WIDGET_TOOLKIT))$(MOZ_ENABLE_XLIB)$(MOZ_ENABLE_XPRINT))
|
||||
DIRS += xlibrgb
|
||||
@@ -102,13 +98,12 @@ else
|
||||
ifdef MOZ_ENABLE_PHOTON
|
||||
DIRS += photon
|
||||
endif
|
||||
ifeq ($(MOZ_GFX_TOOLKIT),windows)
|
||||
DIRS += windows
|
||||
ifeq ($(MOZ_GFX_TOOLKIT),cocoa)
|
||||
DIRS += mac
|
||||
endif
|
||||
ifneq (,$(filter beos os2 mac,$(MOZ_GFX_TOOLKIT)))
|
||||
ifneq (,$(filter windows beos os2 mac,$(MOZ_GFX_TOOLKIT)))
|
||||
DIRS += $(MOZ_GFX_TOOLKIT)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
CPPSRCS = \
|
||||
|
||||
@@ -97,14 +97,8 @@ EXTRA_DSO_LIBS = gkgfx thebes
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
|
||||
CPPSRCS += nsSystemFontsGTK2.cpp
|
||||
|
||||
ifdef MOZ_ENABLE_PANGO
|
||||
#CPPSRCS += nsFontMetricsPango.cpp \
|
||||
# mozilla-decoder.cpp \
|
||||
# $(NULL)
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_GLITZ
|
||||
REQUIRES += glitzglx
|
||||
REQUIRES += glitzglx
|
||||
endif
|
||||
|
||||
endif
|
||||
@@ -119,6 +113,14 @@ _OS_LIBS = usp10
|
||||
OS_LIBS += $(call EXPAND_LIBNAME,$(_OS_LIBS))
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(MOZ_GFX_TOOLKIT),mac cocoa))
|
||||
CPPSRCS += nsSystemFontsMac.cpp
|
||||
ifdef MOZ_ENABLE_GLITZ
|
||||
REQUIRES += glitzagl
|
||||
EXTRA_DSO_LDOPTS += -lmozglitzagl -framework OpenGL -framework AGL
|
||||
endif
|
||||
endif
|
||||
|
||||
EXPORTS += nsIThebesRenderingContext.h
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
|
||||
@@ -196,3 +196,41 @@ GetXftDPI(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSystemFontsGTK2::GetSystemFont(nsSystemFontID anID, nsFont *aFont) const
|
||||
{
|
||||
switch (anID) {
|
||||
case eSystemFont_Menu: // css2
|
||||
case eSystemFont_PullDownMenu: // css3
|
||||
*aFont = mMenuFont;
|
||||
break;
|
||||
|
||||
case eSystemFont_Field: // css3
|
||||
case eSystemFont_List: // css3
|
||||
*aFont = mFieldFont;
|
||||
break;
|
||||
|
||||
case eSystemFont_Button: // css3
|
||||
*aFont = mButtonFont;
|
||||
break;
|
||||
|
||||
case eSystemFont_Caption: // css2
|
||||
case eSystemFont_Icon: // css2
|
||||
case eSystemFont_MessageBox: // css2
|
||||
case eSystemFont_SmallCaption: // css2
|
||||
case eSystemFont_StatusBar: // css2
|
||||
case eSystemFont_Window: // css3
|
||||
case eSystemFont_Document: // css3
|
||||
case eSystemFont_Workspace: // css3
|
||||
case eSystemFont_Desktop: // css3
|
||||
case eSystemFont_Info: // css3
|
||||
case eSystemFont_Dialog: // css3
|
||||
case eSystemFont_Tooltips: // moz
|
||||
case eSystemFont_Widget: // moz
|
||||
*aFont = mDefaultFont;
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ class nsSystemFontsGTK2
|
||||
public:
|
||||
nsSystemFontsGTK2(float aPixelsToTwips);
|
||||
|
||||
nsresult GetSystemFont(nsSystemFontID anID, nsFont *aFont) const;
|
||||
|
||||
const nsFont& GetDefaultFont() { return mDefaultFont; }
|
||||
const nsFont& GetMenuFont() { return mMenuFont; }
|
||||
const nsFont& GetFieldFont() { return mFieldFont; }
|
||||
|
||||
56
mozilla/gfx/src/thebes/nsSystemFontsMac.cpp
Normal file
56
mozilla/gfx/src/thebes/nsSystemFontsMac.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSystemFontsMac.h"
|
||||
|
||||
nsSystemFontsMac::nsSystemFontsMac(float aPixelsToTwips)
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSystemFontsMac::GetSystemFont(nsSystemFontID anID, nsFont *aFont) const
|
||||
{
|
||||
// hack for now
|
||||
aFont->style = NS_FONT_STYLE_NORMAL;
|
||||
aFont->weight = NS_FONT_WEIGHT_NORMAL;
|
||||
aFont->decorations = NS_FONT_DECORATION_NONE;
|
||||
|
||||
aFont->name.AssignLiteral("sans-serif");
|
||||
aFont->size = NSToCoordRound(aFont->size * 0.875f);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
52
mozilla/gfx/src/thebes/nsSystemFontsMac.h
Normal file
52
mozilla/gfx/src/thebes/nsSystemFontsMac.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _NS_SYSTEMFONTSMAC_H_
|
||||
#define _NS_SYSTEMFONTSMAC_H_
|
||||
|
||||
#include <nsFont.h>
|
||||
#include <nsIDeviceContext.h>
|
||||
|
||||
class nsSystemFontsMac
|
||||
{
|
||||
public:
|
||||
nsSystemFontsMac(float aPixelsToTwips);
|
||||
|
||||
nsresult GetSystemFont(nsSystemFontID anID, nsFont *aFont) const;
|
||||
};
|
||||
|
||||
#endif /* _NS_SYSTEMFONTSMAC_H_ */
|
||||
@@ -59,11 +59,6 @@
|
||||
#include <pango/pango.h>
|
||||
#include <pango/pangox.h>
|
||||
#include <pango/pango-fontmap.h>
|
||||
|
||||
|
||||
#ifdef MOZ_ENABLE_GLITZ
|
||||
#include "glitz-glx.h"
|
||||
#endif /* GLITZ */
|
||||
#endif /* GTK2 */
|
||||
|
||||
#ifdef MOZ_ENABLE_GTK2
|
||||
@@ -77,6 +72,9 @@ static nsSystemFontsGTK2 *gSystemFonts = nsnull;
|
||||
#include "gfxWindowsSurface.h"
|
||||
static nsSystemFontsWin *gSystemFonts = nsnull;
|
||||
#include <Usp10.h>
|
||||
#elif XP_MACOSX
|
||||
#include "nsSystemFontsMac.h"
|
||||
static nsSystemFontsMac *gSystemFonts = nsnull;
|
||||
#else
|
||||
#error Need to declare gSystemFonts!
|
||||
#endif
|
||||
@@ -388,49 +386,14 @@ nsThebesDeviceContext::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const
|
||||
gSystemFonts = new nsSystemFontsGTK2(mPixelsToTwips);
|
||||
#elif XP_WIN
|
||||
gSystemFonts = new nsSystemFontsWin(mPixelsToTwips);
|
||||
#elif XP_MACOSX
|
||||
gSystemFonts = new nsSystemFontsMac(mPixelsToTwips);
|
||||
#else
|
||||
#error Need to know how to create gSystemFonts, fix me!
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
gSystemFonts->GetSystemFont(aID, aFont);
|
||||
return NS_OK;
|
||||
|
||||
#else
|
||||
switch (aID) {
|
||||
case eSystemFont_Menu: // css2
|
||||
case eSystemFont_PullDownMenu: // css3
|
||||
*aFont = gSystemFonts->GetMenuFont();
|
||||
break;
|
||||
|
||||
case eSystemFont_Field: // css3
|
||||
case eSystemFont_List: // css3
|
||||
*aFont = gSystemFonts->GetFieldFont();
|
||||
break;
|
||||
|
||||
case eSystemFont_Button: // css3
|
||||
*aFont = gSystemFonts->GetButtonFont();
|
||||
break;
|
||||
|
||||
case eSystemFont_Caption: // css2
|
||||
case eSystemFont_Icon: // css2
|
||||
case eSystemFont_MessageBox: // css2
|
||||
case eSystemFont_SmallCaption: // css2
|
||||
case eSystemFont_StatusBar: // css2
|
||||
case eSystemFont_Window: // css3
|
||||
case eSystemFont_Document: // css3
|
||||
case eSystemFont_Workspace: // css3
|
||||
case eSystemFont_Desktop: // css3
|
||||
case eSystemFont_Info: // css3
|
||||
case eSystemFont_Dialog: // css3
|
||||
case eSystemFont_Tooltips: // moz
|
||||
case eSystemFont_Widget: // moz
|
||||
*aFont = gSystemFonts->GetDefaultFont();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return status;
|
||||
return gSystemFonts->GetSystemFont(aID, aFont);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -759,6 +722,10 @@ nsThebesDeviceContext::FindScreen(nsIScreen** outScreen)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// ???
|
||||
#endif
|
||||
|
||||
mScreenManager->GetPrimaryScreen(outScreen);
|
||||
|
||||
}
|
||||
|
||||
@@ -141,10 +141,8 @@ nsThebesDrawingSurface::Init (nsThebesDeviceContext *aDC,
|
||||
return rv;
|
||||
|
||||
mSurface = imgSurf;
|
||||
#elif XP_WIN
|
||||
// XXX writeme
|
||||
#else
|
||||
#error Write me!
|
||||
NS_ERROR ("nsThebesDrawingSurface init from black/white pixmaps; either implement this or fix the caller");
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "nsString.h"
|
||||
#include "nsAutoBuffer.h"
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsThebesFontMetrics, nsIFontMetrics)
|
||||
|
||||
@@ -52,6 +51,8 @@ NS_IMPL_ISUPPORTS1(nsThebesFontMetrics, nsIFontMetrics)
|
||||
#include "gfxWindowsFonts.h"
|
||||
#elif defined(MOZ_ENABLE_GTK2)
|
||||
#include "gfxPangoFonts.h"
|
||||
#elif defined(XP_MACOSX)
|
||||
#include "gfxAtsuiFonts.h"
|
||||
#endif
|
||||
|
||||
nsThebesFontMetrics::nsThebesFontMetrics()
|
||||
@@ -97,6 +98,8 @@ nsThebesFontMetrics::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
mFontGroup = new gfxWindowsFontGroup(aFont.name, mFontStyle, (HDC)mDeviceContext->GetHDC());
|
||||
#elif defined(MOZ_ENABLE_GTK2)
|
||||
mFontGroup = new gfxPangoFontGroup(aFont.name, mFontStyle);
|
||||
#elif defined(XP_MACOSX)
|
||||
mFontGroup = new gfxAtsuiFontGroup(aFont.name, mFontStyle);
|
||||
#else
|
||||
#error implement me
|
||||
#endif
|
||||
|
||||
@@ -139,7 +139,13 @@ nsThebesRenderingContext::Init(nsIDeviceContext* aContext, nsIWidget *aWidget)
|
||||
mWidget = aWidget;
|
||||
|
||||
mLocalDrawingSurface = new nsThebesDrawingSurface();
|
||||
mLocalDrawingSurface->Init(thebesDC, aWidget);
|
||||
|
||||
nsRefPtr<gfxASurface> surface(aWidget->GetThebesSurface());
|
||||
if (surface) {
|
||||
mLocalDrawingSurface->Init(thebesDC, surface);
|
||||
} else {
|
||||
mLocalDrawingSurface->Init(thebesDC, aWidget);
|
||||
}
|
||||
mDrawingSurface = mLocalDrawingSurface;
|
||||
|
||||
mThebes = new gfxContext(mLocalDrawingSurface->GetThebesSurface());
|
||||
@@ -839,7 +845,11 @@ nsThebesRenderingContext::DrawNativeWidgetPixmap(void* aSrcSurfaceBlack,
|
||||
NS_IMETHODIMP
|
||||
nsThebesRenderingContext::UseBackbuffer(PRBool* aUseBackbuffer)
|
||||
{
|
||||
#ifndef XP_MACOSX
|
||||
*aUseBackbuffer = PR_TRUE;
|
||||
#else
|
||||
*aUseBackbuffer = PR_FALSE;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,4 +50,15 @@ REQUIRES += glitzglx
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(MOZ_GFX_TOOLKIT),mac cocoa))
|
||||
EXPORTS += gfxPlatformMac.h \
|
||||
gfxQuartzSurface.h \
|
||||
gfxAtsuiFonts.h \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_EABLE_GLITZ
|
||||
REQUIRES += glitzagl
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -90,6 +90,18 @@ public:
|
||||
virtual nsresult BeginPage() { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
virtual nsresult EndPage() { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
void SetData(const cairo_user_data_key_t *key,
|
||||
void *user_data,
|
||||
cairo_destroy_func_t destroy)
|
||||
{
|
||||
cairo_surface_set_user_data (mSurface, key, user_data, destroy);
|
||||
}
|
||||
|
||||
void *GetData(const cairo_user_data_key_t *key)
|
||||
{
|
||||
return cairo_surface_get_user_data (mSurface, key);
|
||||
}
|
||||
|
||||
protected:
|
||||
void Init(cairo_surface_t* surface) {
|
||||
mDestroyed = PR_FALSE;
|
||||
|
||||
109
mozilla/gfx/thebes/public/gfxAtsuiFonts.h
Normal file
109
mozilla/gfx/thebes/public/gfxAtsuiFonts.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is thebes gfx code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef GFX_ATSUIFONTS_H
|
||||
#define GFX_ATSUIFONTS_H
|
||||
|
||||
#include "gfxTypes.h"
|
||||
#include "gfxFont.h"
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
class gfxAtsuiFontGroup;
|
||||
|
||||
class gfxAtsuiFont : public gfxFont {
|
||||
public:
|
||||
gfxAtsuiFont(ATSUFontID fontID,
|
||||
gfxAtsuiFontGroup *fontGroup);
|
||||
virtual ~gfxAtsuiFont();
|
||||
|
||||
virtual const gfxFont::Metrics& GetMetrics();
|
||||
|
||||
ATSUFontID GetATSUFontID() { return mATSUFontID; }
|
||||
|
||||
cairo_font_face_t *CairoFontFace() { return mFontFace; }
|
||||
cairo_scaled_font_t *CairoScaledFont() { return mScaledFont; }
|
||||
|
||||
protected:
|
||||
ATSUFontID mATSUFontID;
|
||||
|
||||
const gfxAtsuiFontGroup *mFontGroup;
|
||||
const gfxFontStyle *mFontStyle;
|
||||
|
||||
cairo_font_face_t *mFontFace;
|
||||
cairo_scaled_font_t *mScaledFont;
|
||||
|
||||
gfxFont::Metrics mMetrics;
|
||||
};
|
||||
|
||||
class NS_EXPORT gfxAtsuiFontGroup : public gfxFontGroup {
|
||||
public:
|
||||
gfxAtsuiFontGroup(const nsAString& families,
|
||||
const gfxFontStyle *aStyle);
|
||||
virtual ~gfxAtsuiFontGroup();
|
||||
|
||||
virtual gfxTextRun *MakeTextRun(const nsAString& aString);
|
||||
|
||||
ATSUFontFallbacks *GetATSUFontFallbacks() { return &mFallbacks; }
|
||||
|
||||
protected:
|
||||
static PRBool FindATSUFont(const nsAString& aName,
|
||||
const nsAString& aGenericName,
|
||||
void *closure);
|
||||
|
||||
ATSUFontFallbacks mFallbacks;
|
||||
};
|
||||
|
||||
class NS_EXPORT gfxAtsuiTextRun : public gfxTextRun {
|
||||
THEBES_DECL_ISUPPORTS_INHERITED
|
||||
public:
|
||||
gfxAtsuiTextRun(const nsAString& aString, gfxAtsuiFontGroup *aFontGroup);
|
||||
~gfxAtsuiTextRun();
|
||||
|
||||
virtual void DrawString(gfxContext *aContext, gfxPoint pt);
|
||||
virtual gfxFloat MeasureString(gfxContext *aContext);
|
||||
|
||||
private:
|
||||
nsString mString;
|
||||
gfxAtsuiFontGroup *mGroup;
|
||||
|
||||
ATSUStyle mATSUStyle;
|
||||
|
||||
ATSUTextLayout mATSULayout;
|
||||
};
|
||||
|
||||
#endif /* GFX_ATSUIFONTS_H */
|
||||
@@ -111,6 +111,10 @@ struct NS_EXPORT gfxFontStyle {
|
||||
// rendering or measuring a string. A value of 0 means no adjustment
|
||||
// needs to be done.
|
||||
float sizeAdjust;
|
||||
|
||||
static void ComputeWeightAndOffset (const PRUint16 inWeight,
|
||||
PRInt16 *outBaseWeight,
|
||||
PRInt16 *outOffset);
|
||||
};
|
||||
|
||||
|
||||
|
||||
56
mozilla/gfx/thebes/public/gfxPlatformMac.h
Normal file
56
mozilla/gfx/thebes/public/gfxPlatformMac.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Foundation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef GFX_PLATFORM_MAC_H
|
||||
#define GFX_PLATFORM_MAC_H
|
||||
|
||||
#include "gfxPlatform.h"
|
||||
|
||||
class NS_EXPORT gfxPlatformMac : public gfxPlatform {
|
||||
public:
|
||||
gfxPlatformMac();
|
||||
|
||||
static gfxPlatformMac *GetPlatform() {
|
||||
return (gfxPlatformMac*) gfxPlatform::GetPlatform();
|
||||
}
|
||||
|
||||
gfxASurface *CreateOffscreenSurface(PRUint32 width,
|
||||
PRUint32 height,
|
||||
gfxASurface::gfxImageFormat imageFormat);
|
||||
};
|
||||
|
||||
#endif /* GFX_PLATFORM_MAC_H */
|
||||
67
mozilla/gfx/thebes/public/gfxQuartzSurface.h
Normal file
67
mozilla/gfx/thebes/public/gfxQuartzSurface.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef GFX_QUARTZSURFACE_H
|
||||
#define GFX_QUARTZSURFACE_H
|
||||
|
||||
#include "gfxASurface.h"
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
class NS_EXPORT gfxQuartzSurface : public gfxASurface {
|
||||
THEBES_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
public:
|
||||
gfxQuartzSurface(gfxImageFormat format,
|
||||
int width, int height,
|
||||
PRBool y_grows_down = PR_TRUE);
|
||||
gfxQuartzSurface(CGContextRef context,
|
||||
int width, int height,
|
||||
PRBool y_grows_down = PR_TRUE);
|
||||
|
||||
virtual ~gfxQuartzSurface();
|
||||
|
||||
unsigned long Width() { return mWidth; }
|
||||
unsigned long Height() { return mHeight; }
|
||||
|
||||
CGContextRef GetCGContext() { return mCGContext; }
|
||||
protected:
|
||||
CGContextRef mCGContext;
|
||||
unsigned long mWidth, mHeight;
|
||||
};
|
||||
#endif /* GFX_QUARTZSURFACE_H */
|
||||
@@ -56,6 +56,14 @@ CPPSRCS += gfxPDFSurface.cpp gfxPSSurface.cpp
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_PANGO_LIBS) $(ZLIB_LIBS)
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(MOZ_GFX_TOOLKIT),mac cocoa))
|
||||
CPPSRCS += gfxQuartzSurface.cpp gfxPlatformMac.cpp gfxAtsuiFonts.cpp
|
||||
#CPPSRCS += gfxPDFSurface.cpp
|
||||
|
||||
# Always link with OpenGL/AGL
|
||||
EXTRA_DSO_LDOPTS += -framework OpenGL -framework AGL
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_GLITZ
|
||||
REQUIRES += glitz
|
||||
CPPSRCS += gfxGlitzSurface.cpp
|
||||
@@ -66,6 +74,11 @@ ifeq ($(MOZ_GFX_TOOLKIT),gtk2)
|
||||
REQUIRES += glitzglx
|
||||
SHARED_LIBRARY_LIBS += $(DIST)/lib/$(LIB_PREFIX)mozglitzglx.$(LIB_SUFFIX)
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(MOZ_GFX_TOOLKIT),mac cocoa))
|
||||
REQUIRES += glitzagl
|
||||
SHARED_LIBRARY_LIBS += $(DIST)/lib/$(LIB_PREFIX)mozglitzagl.$(LIB_SUFFIX)
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
|
||||
434
mozilla/gfx/thebes/src/gfxAtsuiFonts.cpp
Normal file
434
mozilla/gfx/thebes/src/gfxAtsuiFonts.cpp
Normal file
@@ -0,0 +1,434 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "prmem.h"
|
||||
#include "gfxTypes.h"
|
||||
|
||||
#include "nsPromiseFlatString.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
#include "gfxAtsuiFonts.h"
|
||||
|
||||
#include "cairo-atsui.h"
|
||||
|
||||
gfxAtsuiFont::gfxAtsuiFont(ATSUFontID fontID,
|
||||
gfxAtsuiFontGroup *fontGroup)
|
||||
: mATSUFontID(fontID), mFontGroup(fontGroup)
|
||||
{
|
||||
ATSFontRef fontRef = FMGetATSFontRefFromFont(fontID);
|
||||
|
||||
mFontStyle = mFontGroup->GetStyle();
|
||||
|
||||
ATSFontMetrics atsMetrics;
|
||||
ATSFontGetHorizontalMetrics(fontRef, kATSOptionFlagsDefault,
|
||||
&atsMetrics);
|
||||
|
||||
gfxFloat size = mFontStyle->size;
|
||||
|
||||
mMetrics.emHeight = size;
|
||||
|
||||
mMetrics.maxAscent = atsMetrics.ascent * size;
|
||||
mMetrics.maxDescent = - (atsMetrics.descent * size);
|
||||
mMetrics.height = mMetrics.maxAscent + mMetrics.maxDescent;
|
||||
|
||||
mMetrics.internalLeading = atsMetrics.leading * size;
|
||||
mMetrics.externalLeading = 0.0;
|
||||
|
||||
mMetrics.maxHeight = mMetrics.height;
|
||||
mMetrics.emAscent = mMetrics.maxAscent * mMetrics.emHeight / mMetrics.height;
|
||||
mMetrics.emDescent = mMetrics.emHeight - mMetrics.emAscent;
|
||||
|
||||
mMetrics.maxAdvance = atsMetrics.maxAdvanceWidth * size;
|
||||
mMetrics.xHeight = atsMetrics.xHeight * size;
|
||||
|
||||
if (atsMetrics.avgAdvanceWidth != 0.0)
|
||||
mMetrics.aveCharWidth = atsMetrics.avgAdvanceWidth * size;
|
||||
else
|
||||
mMetrics.aveCharWidth = mMetrics.maxAdvance;
|
||||
|
||||
mMetrics.underlineOffset = atsMetrics.underlinePosition * size;
|
||||
mMetrics.underlineSize = atsMetrics.underlineThickness * size;
|
||||
|
||||
mMetrics.subscriptOffset = mMetrics.xHeight;
|
||||
mMetrics.superscriptOffset = mMetrics.xHeight;
|
||||
|
||||
mMetrics.strikeoutOffset = mMetrics.xHeight / 2.0;
|
||||
mMetrics.strikeoutSize = mMetrics.underlineSize;
|
||||
|
||||
mMetrics.spaceWidth = mMetrics.aveCharWidth;
|
||||
|
||||
#if 0
|
||||
fprintf (stderr, "Font: %p size: %f", this, size);
|
||||
fprintf (stderr, " emHeight: %f emAscent: %f emDescent: %f\n", mMetrics.emHeight, mMetrics.emAscent, mMetrics.emDescent);
|
||||
fprintf (stderr, " maxAscent: %f maxDescent: %f maxAdvance: %f\n", mMetrics.maxAscent, mMetrics.maxDescent, mMetrics.maxAdvance);
|
||||
fprintf (stderr, " height: %f internalLeading: %f externalLeading: %f\n", mMetrics.height, mMetrics.externalLeading, mMetrics.internalLeading);
|
||||
fprintf (stderr, " spaceWidth: %f aveCharWidth: %f xHeight: %f\n", mMetrics.spaceWidth, mMetrics.aveCharWidth, mMetrics.xHeight);
|
||||
fprintf (stderr, " uOff: %f uSize: %f stOff: %f stSize: %f suOff: %f suSize: %f\n", mMetrics.underlineOffset, mMetrics.underlineSize, mMetrics.strikeoutOffset, mMetrics.strikeoutSize, mMetrics.superscriptOffset, mMetrics.subscriptOffset);
|
||||
#endif
|
||||
|
||||
mFontFace = cairo_atsui_font_face_create_for_atsu_font_id(mATSUFontID);
|
||||
|
||||
cairo_matrix_t sizeMatrix, ctm;
|
||||
cairo_matrix_init_identity(&ctm);
|
||||
cairo_matrix_init_scale(&sizeMatrix, size, size);
|
||||
|
||||
cairo_font_options_t *fontOptions = cairo_font_options_create();
|
||||
mScaledFont = cairo_scaled_font_create(mFontFace, &sizeMatrix, &ctm, fontOptions);
|
||||
cairo_font_options_destroy(fontOptions);
|
||||
}
|
||||
|
||||
gfxAtsuiFont::~gfxAtsuiFont()
|
||||
{
|
||||
cairo_scaled_font_destroy(mScaledFont);
|
||||
cairo_font_face_destroy(mFontFace);
|
||||
}
|
||||
|
||||
const gfxFont::Metrics&
|
||||
gfxAtsuiFont::GetMetrics()
|
||||
{
|
||||
return mMetrics;
|
||||
}
|
||||
|
||||
gfxAtsuiFontGroup::gfxAtsuiFontGroup(const nsAString& families,
|
||||
const gfxFontStyle *aStyle)
|
||||
: gfxFontGroup(families, aStyle)
|
||||
{
|
||||
ForEachFont(FindATSUFont, this);
|
||||
|
||||
// Create the fallback structure
|
||||
ATSUCreateFontFallbacks(&mFallbacks);
|
||||
|
||||
#define NUM_STATIC_FIDS 16
|
||||
ATSUFontID static_fids[NUM_STATIC_FIDS];
|
||||
ATSUFontID *fids;
|
||||
if (mFonts.size() > NUM_STATIC_FIDS)
|
||||
fids = (ATSUFontID *) PR_Malloc(sizeof(ATSUFontID) * mFonts.size());
|
||||
else
|
||||
fids = static_fids;
|
||||
|
||||
for (unsigned int i = 0; i < mFonts.size(); i++)
|
||||
fids[i] = ((gfxAtsuiFont*)(mFonts[i]))->GetATSUFontID();
|
||||
|
||||
ATSUSetObjFontFallbacks(mFallbacks,
|
||||
mFonts.size(),
|
||||
fids,
|
||||
kATSUSequentialFallbacksPreferred /* kATSUSequentialFallbacksExclusive? */);
|
||||
|
||||
if (fids != static_fids)
|
||||
PR_Free(fids);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will /really/ want to just keep a hash lookup table
|
||||
* based on name and style attributes that we compute; doing stuff with
|
||||
* Pascal strings and whatnot is /so/ 1980's.
|
||||
*/
|
||||
|
||||
/*
|
||||
06:19 < AngryLuke> vlad, which method in NSFontManager does what you want?
|
||||
06:21 < vlad_> ideally fontWithFamily:traits:weight:size:, but I really need to
|
||||
just iterate through all the fonts in a particular family
|
||||
06:21 < vlad_> and examine their traits
|
||||
06:22 < AngryLuke> vlad, NSFontManager is using the private FontObject APIs for
|
||||
this it seems
|
||||
06:22 < vlad_> AngryLuke: fun
|
||||
06:22 < vlad_> AngryLuke: so what's the "right" way of doing this?
|
||||
06:23 < AngryLuke> vlad, crying ;) I ended up just using the FontManager,
|
||||
despite the fact it is deprecated. But that won't work for
|
||||
Unicode fonts with no FOND
|
||||
06:23 < AngryLuke> ATS has no functions for this
|
||||
06:23 < AngryLuke> and NSFontManager is the only other way that is public.
|
||||
*/
|
||||
|
||||
PRBool
|
||||
gfxAtsuiFontGroup::FindATSUFont(const nsAString& aName,
|
||||
const nsAString& aGenericName,
|
||||
void *closure)
|
||||
{
|
||||
OSStatus status;
|
||||
gfxAtsuiFontGroup *fontGroup = (gfxAtsuiFontGroup*) closure;
|
||||
const gfxFontStyle *fontStyle = fontGroup->GetStyle();
|
||||
|
||||
PRInt16 baseWeight, offsetWeight;
|
||||
gfxFontStyle::ComputeWeightAndOffset(fontStyle->weight, &baseWeight, &offsetWeight);
|
||||
baseWeight += offsetWeight;
|
||||
baseWeight = PR_MIN(9, PR_MAX(0, baseWeight));
|
||||
|
||||
Boolean isBold = (baseWeight >= 7) ? TRUE : FALSE;
|
||||
Boolean isItalic = ((fontStyle->style & FONT_STYLE_ITALIC) != 0) ? TRUE : FALSE;
|
||||
|
||||
#if 0
|
||||
|
||||
Str255 pascalName;
|
||||
CopyCStringToPascalString(nsPromiseFlatCString(NS_ConvertUTF16toUTF8(aName)).get(),
|
||||
pascalName);
|
||||
|
||||
FMFontFamily fmFamily = FMGetFontFamilyFromName(pascalName);
|
||||
if (fmFamily == kInvalidFontFamily)
|
||||
return PR_TRUE;
|
||||
|
||||
FMFontFamilyInstanceIterator famFontIterator;
|
||||
status = FMCreateFontFamilyInstanceIterator(fmFamily, &famFontIterator);
|
||||
if (status != noErr) {
|
||||
fprintf(stderr, "FMCreateFontFamilyInstanceIterator returned error %d\n", (int) status);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
FMFont famFont;
|
||||
FMFontStyle famFontStyle;
|
||||
FMFontSize famFontSize;
|
||||
|
||||
while ((status = FMGetNextFontFamilyInstance(famFontIterator,
|
||||
&famFont,
|
||||
&famFontStyle,
|
||||
&famFontSize)) == noErr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (status != kFMIterationCompleted) {
|
||||
fprintf (stderr, "FMGetNextFontFamilyInstance returned error %d\n", (int) status);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
FMDisposeFontFamilyInstanceIterator(&familyFontIterator);
|
||||
#else
|
||||
ATSUFontID fontID;
|
||||
|
||||
status = ATSUFindFontFromName(NS_ConvertUTF16toUTF8(aName).get(), aName.Length(),
|
||||
/* nsPromiseFlatString(aName).get(),
|
||||
aName.Length() * 2,*/
|
||||
kFontFamilyName,
|
||||
kFontNoPlatformCode /* kFontUnicodePlatform */,
|
||||
kFontNoScriptCode,
|
||||
kFontNoLanguageCode,
|
||||
&fontID);
|
||||
|
||||
//fprintf (stderr, "FindATSUFont: %s -> %d (status: %d)\n", NS_ConvertUTF16toUTF8(aName).get(), (int) fontID, (int) status);
|
||||
|
||||
if (fontID != kATSUInvalidFontID)
|
||||
fontGroup->mFonts.push_back(new gfxAtsuiFont(fontID, fontGroup));
|
||||
#endif
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
gfxAtsuiFontGroup::~gfxAtsuiFontGroup()
|
||||
{
|
||||
ATSUDisposeFontFallbacks(mFallbacks);
|
||||
}
|
||||
|
||||
gfxTextRun*
|
||||
gfxAtsuiFontGroup::MakeTextRun(const nsAString& aString)
|
||||
{
|
||||
return new gfxAtsuiTextRun(aString, this);
|
||||
}
|
||||
|
||||
/**
|
||||
** gfxAtsuiTextRun
|
||||
**/
|
||||
|
||||
THEBES_IMPL_REFCOUNTING(gfxAtsuiTextRun)
|
||||
|
||||
gfxAtsuiTextRun::gfxAtsuiTextRun(const nsAString& aString, gfxAtsuiFontGroup *aGroup)
|
||||
: mString(aString), mGroup(aGroup)
|
||||
{
|
||||
OSStatus status;
|
||||
const gfxFontStyle *fontStyle = mGroup->GetStyle();
|
||||
|
||||
PRInt16 baseWeight, offsetWeight;
|
||||
gfxFontStyle::ComputeWeightAndOffset(fontStyle->weight, &baseWeight, &offsetWeight);
|
||||
baseWeight += offsetWeight;
|
||||
if (baseWeight < 0) baseWeight = 0;
|
||||
else if (baseWeight > 9) baseWeight = 9;
|
||||
|
||||
// we can't do kerning until layout draws what it measures, instead of splitting things up
|
||||
ATSUAttributeTag styleTags[] = {
|
||||
kATSUFontTag,
|
||||
kATSUSizeTag,
|
||||
kATSUKerningInhibitFactorTag,
|
||||
kATSUQDBoldfaceTag,
|
||||
kATSUQDItalicTag,
|
||||
};
|
||||
|
||||
ByteCount styleArgSizes[] = {
|
||||
sizeof(ATSUFontID),
|
||||
sizeof(Fixed),
|
||||
sizeof(Fract),
|
||||
sizeof(Boolean),
|
||||
sizeof(Boolean)
|
||||
};
|
||||
|
||||
//fprintf (stderr, "string: '%s', size: %f\n", NS_ConvertUTF16toUTF8(aString).get(), aGroup->GetStyle()->size);
|
||||
|
||||
// fSize is in points (72dpi)
|
||||
Fixed fSize = FloatToFixed(aGroup->GetStyle()->size);
|
||||
ATSUFontID fid = ((gfxAtsuiFont*)(mGroup->GetFontList()[0]))->GetATSUFontID();
|
||||
Fract inhibitKerningFactor = FloatToFract(1.0);
|
||||
/* Why am I even setting these? the fid font will end up being used no matter what;
|
||||
* need smarter font selection earlier on...
|
||||
*/
|
||||
Boolean isBold = (baseWeight >= 7) ? TRUE : FALSE;
|
||||
Boolean isItalic = ((fontStyle->style & FONT_STYLE_ITALIC) != 0) ? TRUE : FALSE;
|
||||
|
||||
|
||||
//fprintf (stderr, " bold: %d italic: %d\n", isBold, isItalic);
|
||||
|
||||
ATSUAttributeValuePtr styleArgs[] = {
|
||||
&fid,
|
||||
&fSize,
|
||||
&inhibitKerningFactor,
|
||||
&isBold,
|
||||
&isItalic
|
||||
};
|
||||
|
||||
status = ATSUCreateStyle(&mATSUStyle);
|
||||
status = ATSUSetAttributes(mATSUStyle,
|
||||
sizeof(styleTags)/sizeof(ATSUAttributeTag),
|
||||
styleTags,
|
||||
styleArgSizes,
|
||||
styleArgs);
|
||||
if (status != noErr)
|
||||
fprintf (stderr, "ATUSetAttributes gave error: %d\n", (int) status);
|
||||
|
||||
UniCharCount runLengths = kATSUToTextEnd;
|
||||
|
||||
status = ATSUCreateTextLayoutWithTextPtr
|
||||
(nsPromiseFlatString(mString).get(),
|
||||
kATSUFromTextBeginning,
|
||||
kATSUToTextEnd,
|
||||
mString.Length(),
|
||||
1,
|
||||
&runLengths,
|
||||
&mATSUStyle,
|
||||
&mATSULayout);
|
||||
|
||||
// Set up our font fallbacks
|
||||
ATSUAttributeTag lineTags[] = { kATSULineFontFallbacksTag };
|
||||
ByteCount lineArgSizes[] = { sizeof(ATSUFontFallbacks) };
|
||||
ATSUAttributeValuePtr lineArgs[] = { mGroup->GetATSUFontFallbacks() };
|
||||
status = ATSUSetLineControls(mATSULayout,
|
||||
0,
|
||||
sizeof(lineTags) / sizeof(ATSUAttributeTag),
|
||||
lineTags,
|
||||
lineArgSizes,
|
||||
lineArgs);
|
||||
if (status != noErr)
|
||||
fprintf(stderr, "ATSUSetLineControls gave error: %d\n", (int) status);
|
||||
|
||||
ATSUSetTransientFontMatching(mATSULayout, true);
|
||||
}
|
||||
|
||||
gfxAtsuiTextRun::~gfxAtsuiTextRun()
|
||||
{
|
||||
ATSUDisposeTextLayout(mATSULayout);
|
||||
ATSUDisposeStyle(mATSUStyle);
|
||||
}
|
||||
|
||||
void
|
||||
gfxAtsuiTextRun::DrawString(gfxContext *aContext, gfxPoint pt)
|
||||
{
|
||||
cairo_t *cr = aContext->GetCairo();
|
||||
cairo_set_font_face(cr, ((gfxAtsuiFont*)(mGroup->GetFontList()[0]))->CairoFontFace());
|
||||
cairo_set_font_size(cr, mGroup->GetStyle()->size);
|
||||
|
||||
ItemCount cnt;
|
||||
ATSLayoutRecord *layoutRecords = nsnull;
|
||||
OSStatus status = ATSUDirectGetLayoutDataArrayPtrFromTextLayout
|
||||
(mATSULayout,
|
||||
kATSUFromTextBeginning,
|
||||
kATSUDirectDataLayoutRecordATSLayoutRecordCurrent,
|
||||
(void**)&layoutRecords,
|
||||
&cnt);
|
||||
|
||||
if (status != noErr) {
|
||||
fprintf(stderr, "ATSUDirectGetLayoutDataArrayPtrFromTextLayout failed, %d\n", noErr);
|
||||
return;
|
||||
}
|
||||
|
||||
cairo_glyph_t *cglyphs = (cairo_glyph_t *) PR_Malloc (cnt * sizeof(cairo_glyph_t));
|
||||
if (!cglyphs)
|
||||
return;
|
||||
|
||||
//fprintf (stderr, "String: '%s'\n", NS_ConvertUTF16toUTF8(mString).get());
|
||||
|
||||
PRUint32 cgindex = 0;
|
||||
for (PRUint32 i = 0; i < cnt; i++) {
|
||||
//fprintf(stderr, "[%d 0x%04x %f] ", i, layoutRecords[i].glyphID, FixedToFloat(layoutRecords[i].realPos));
|
||||
if (!(layoutRecords[i].flags & kATSGlyphInfoIsWhiteSpace)) {
|
||||
cglyphs[cgindex].index = layoutRecords[i].glyphID;
|
||||
cglyphs[cgindex].x = pt.x + FixedToFloat(layoutRecords[i].realPos);
|
||||
cglyphs[cgindex].y = pt.y;
|
||||
cgindex++;
|
||||
}
|
||||
}
|
||||
//fprintf (stderr, "\n");
|
||||
|
||||
ATSUDirectReleaseLayoutDataArrayPtr(NULL,
|
||||
kATSUDirectDataLayoutRecordATSLayoutRecordCurrent,
|
||||
(void**)&layoutRecords);
|
||||
|
||||
cairo_show_glyphs(cr, cglyphs, cgindex);
|
||||
|
||||
PR_Free(cglyphs);
|
||||
}
|
||||
|
||||
gfxFloat
|
||||
gfxAtsuiTextRun::MeasureString(gfxContext *aContext)
|
||||
{
|
||||
OSStatus status;
|
||||
ATSTrapezoid trap;
|
||||
ItemCount numBounds;
|
||||
|
||||
status = ATSUGetGlyphBounds(mATSULayout,
|
||||
FloatToFixed(0.0),
|
||||
FloatToFixed(0.0),
|
||||
kATSUFromTextBeginning,
|
||||
kATSUToTextEnd,
|
||||
kATSUseFractionalOrigins,
|
||||
1,
|
||||
&trap,
|
||||
&numBounds);
|
||||
if (status != noErr)
|
||||
fprintf(stderr, "ATSUGetGlyphBounds returned error %d!\n", (int) status);
|
||||
|
||||
float f = FixedToFloat(PR_MAX(trap.upperRight.x, trap.lowerRight.x)) - FixedToFloat(PR_MIN(trap.upperLeft.x, trap.lowerLeft.x));
|
||||
|
||||
//fprintf (stderr, "measured: %f\n", f);
|
||||
return f;
|
||||
}
|
||||
@@ -161,3 +161,19 @@ gfxFontGroup::ForEachFont(FontCreationCallback fc,
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gfxFontStyle::ComputeWeightAndOffset (const PRUint16 inWeight, PRInt16 *outBaseWeight, PRInt16 *outOffset)
|
||||
{
|
||||
PRInt16 baseWeight = (inWeight + 50) / 100;
|
||||
PRInt16 offset = inWeight - baseWeight * 100;
|
||||
|
||||
if (baseWeight < 0)
|
||||
baseWeight = 0;
|
||||
if (baseWeight > 9)
|
||||
baseWeight = 9;
|
||||
|
||||
if (outBaseWeight)
|
||||
*outBaseWeight = baseWeight;
|
||||
if (outOffset)
|
||||
*outOffset = offset;
|
||||
}
|
||||
|
||||
133
mozilla/gfx/thebes/src/gfxPlatformMac.cpp
Normal file
133
mozilla/gfx/thebes/src/gfxPlatformMac.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is thebes gfx code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "gfxPlatformMac.h"
|
||||
|
||||
#include "gfxImageSurface.h"
|
||||
#include "gfxQuartzSurface.h"
|
||||
|
||||
#ifdef MOZ_ENABLE_GLITZ
|
||||
#include "gfxGlitzSurface.h"
|
||||
#include "glitz-agl.h"
|
||||
#endif
|
||||
|
||||
gfxPlatformMac::gfxPlatformMac()
|
||||
{
|
||||
#ifdef MOZ_ENABLE_GLITZ
|
||||
if (UseGlitz())
|
||||
glitz_agl_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
gfxASurface*
|
||||
gfxPlatformMac::CreateOffscreenSurface(PRUint32 width,
|
||||
PRUint32 height,
|
||||
gfxASurface::gfxImageFormat imageFormat)
|
||||
{
|
||||
gfxASurface *newSurface = nsnull;
|
||||
|
||||
if (!UseGlitz()) {
|
||||
newSurface = new gfxQuartzSurface(imageFormat, width, height);
|
||||
} else {
|
||||
#ifdef MOZ_ENABLE_GLITZ
|
||||
int bpp, glitzf;
|
||||
switch (imageFormat) {
|
||||
case gfxASurface::ImageFormatARGB32:
|
||||
bpp = 32;
|
||||
glitzf = 0; // GLITZ_STANDARD_ARGB32;
|
||||
break;
|
||||
case gfxASurface::ImageFormatRGB24:
|
||||
bpp = 24;
|
||||
glitzf = 1; // GLITZ_STANDARD_RGB24;
|
||||
break;
|
||||
case gfxASurface::ImageFormatA8:
|
||||
bpp = 8;
|
||||
glitzf = 2; // GLITZ_STANDARD_A8;
|
||||
case gfxASurface::ImageFormatA1:
|
||||
bpp = 1;
|
||||
glitzf = 3; // GLITZ_STANDARD_A1;
|
||||
break;
|
||||
default:
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
// XXX look for the right kind of format based on bpp
|
||||
glitz_drawable_format_t templ;
|
||||
memset(&templ, 0, sizeof(templ));
|
||||
templ.color.red_size = 8;
|
||||
templ.color.green_size = 8;
|
||||
templ.color.blue_size = 8;
|
||||
if (bpp == 32)
|
||||
templ.color.alpha_size = 8;
|
||||
else
|
||||
templ.color.alpha_size = 0;
|
||||
templ.doublebuffer = FALSE;
|
||||
templ.samples = 1;
|
||||
|
||||
unsigned long mask =
|
||||
GLITZ_FORMAT_RED_SIZE_MASK |
|
||||
GLITZ_FORMAT_GREEN_SIZE_MASK |
|
||||
GLITZ_FORMAT_BLUE_SIZE_MASK |
|
||||
GLITZ_FORMAT_ALPHA_SIZE_MASK |
|
||||
GLITZ_FORMAT_SAMPLES_MASK |
|
||||
GLITZ_FORMAT_DOUBLEBUFFER_MASK;
|
||||
|
||||
glitz_drawable_format_t *gdformat =
|
||||
glitz_agl_find_pbuffer_format(mask, &templ, 0);
|
||||
|
||||
glitz_drawable_t *gdraw =
|
||||
glitz_agl_create_pbuffer_drawable(gdformat, width, height);
|
||||
|
||||
glitz_format_t *gformat =
|
||||
glitz_find_standard_format(gdraw, (glitz_format_name_t) glitzf);
|
||||
|
||||
glitz_surface_t *gsurf =
|
||||
glitz_surface_create(gdraw,
|
||||
gformat,
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
glitz_surface_attach(gsurf, gdraw, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
|
||||
|
||||
newSurface = new gfxGlitzSurface(gdraw, gsurf, PR_TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
return newSurface;
|
||||
}
|
||||
72
mozilla/gfx/thebes/src/gfxQuartzSurface.cpp
Normal file
72
mozilla/gfx/thebes/src/gfxQuartzSurface.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "gfxQuartzSurface.h"
|
||||
|
||||
#include "cairo-quartz2.h"
|
||||
|
||||
THEBES_IMPL_REFCOUNTING(gfxQuartzSurface)
|
||||
|
||||
gfxQuartzSurface::gfxQuartzSurface(gfxImageFormat format,
|
||||
int width, int height,
|
||||
PRBool y_grows_down)
|
||||
: mWidth(width), mHeight(height)
|
||||
{
|
||||
mCGContext = nsnull;
|
||||
|
||||
cairo_surface_t *surf = cairo_quartzgl_surface_create
|
||||
((cairo_format_t) format, width, height, y_grows_down);
|
||||
|
||||
Init(surf);
|
||||
}
|
||||
|
||||
gfxQuartzSurface::gfxQuartzSurface(CGContextRef context,
|
||||
int width, int height,
|
||||
PRBool y_grows_down)
|
||||
: mCGContext(context), mWidth(width), mHeight(height)
|
||||
{
|
||||
cairo_surface_t *surf = cairo_quartzgl_surface_create_for_cg_context
|
||||
(context, width, height, y_grows_down);
|
||||
//printf ("+++ gfxQuartzSurface[%p] %p %d %d -> %p\n", this, context, width, height, surf);
|
||||
Init(surf);
|
||||
}
|
||||
|
||||
gfxQuartzSurface::~gfxQuartzSurface()
|
||||
{
|
||||
//printf ("--- ~gfxQuartzSurface[%p] %p %p\n", this, CairoSurface(), mCGContext);
|
||||
Destroy();
|
||||
}
|
||||
Reference in New Issue
Block a user