2005-11-29 23:29:45 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2005-11-29 23:29:45 +03:00
|
|
|
|
2006-04-18 19:21:42 +04:00
|
|
|
#define PANGO_ENABLE_BACKEND
|
|
|
|
#define PANGO_ENABLE_ENGINE
|
|
|
|
|
2005-11-29 23:29:45 +03:00
|
|
|
#include "gfxPlatformGtk.h"
|
2013-06-21 01:32:04 +04:00
|
|
|
#include "prenv.h"
|
2005-11-29 23:29:45 +03:00
|
|
|
|
2009-09-09 19:35:08 +04:00
|
|
|
#include "nsUnicharUtils.h"
|
2012-03-09 07:38:01 +04:00
|
|
|
#include "nsUnicodeProperties.h"
|
2014-02-09 12:04:38 +04:00
|
|
|
#include "gfx2DGlue.h"
|
2007-01-30 11:20:29 +03:00
|
|
|
#include "gfxFontconfigUtils.h"
|
2007-04-16 02:22:58 +04:00
|
|
|
#include "gfxPangoFonts.h"
|
2008-07-14 01:40:16 +04:00
|
|
|
#include "gfxContext.h"
|
2008-12-06 02:19:27 +03:00
|
|
|
#include "gfxUserFontSet.h"
|
2014-06-24 02:48:59 +04:00
|
|
|
#include "gfxUtils.h"
|
2012-05-17 02:30:10 +04:00
|
|
|
#include "gfxFT2FontBase.h"
|
2006-01-10 23:26:40 +03:00
|
|
|
|
2012-01-26 04:54:31 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
|
|
|
|
2007-01-27 05:14:19 +03:00
|
|
|
#include "cairo.h"
|
2005-11-29 23:29:45 +03:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "gfxImageSurface.h"
|
2008-08-07 00:48:55 +04:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
#include <gdk/gdkx.h>
|
2005-11-29 23:29:45 +03:00
|
|
|
#include "gfxXlibSurface.h"
|
2008-08-19 07:22:42 +04:00
|
|
|
#include "cairo-xlib.h"
|
2012-04-18 18:27:32 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2009-04-20 20:36:37 +04:00
|
|
|
|
|
|
|
/* Undefine the Status from Xlib since it will conflict with system headers on OSX */
|
|
|
|
#if defined(__APPLE__) && defined(Status)
|
|
|
|
#undef Status
|
|
|
|
#endif
|
|
|
|
|
2008-08-07 00:48:55 +04:00
|
|
|
#endif /* MOZ_X11 */
|
2005-11-29 23:29:45 +03:00
|
|
|
|
2006-01-10 23:26:40 +03:00
|
|
|
#include <fontconfig/fontconfig.h>
|
2006-11-21 09:31:04 +03:00
|
|
|
|
2007-03-03 01:41:06 +03:00
|
|
|
#include "nsMathUtils.h"
|
2006-04-18 19:21:42 +04:00
|
|
|
|
2008-11-10 02:39:41 +03:00
|
|
|
#define GDK_PIXMAP_SIZE_MAX 32767
|
|
|
|
|
2012-01-26 04:54:31 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::gfx;
|
2012-03-09 07:10:05 +04:00
|
|
|
using namespace mozilla::unicode;
|
2012-01-26 04:54:31 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
gfxFontconfigUtils *gfxPlatformGtk::sFontconfigUtils = nullptr;
|
2006-01-10 23:26:40 +03:00
|
|
|
|
2014-04-09 04:23:00 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2008-08-19 07:22:42 +04:00
|
|
|
static cairo_user_data_key_t cairo_gdk_drawable_key;
|
2014-04-09 04:23:00 +04:00
|
|
|
#endif
|
2007-11-27 03:22:39 +03:00
|
|
|
|
2012-04-18 18:27:32 +04:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
bool gfxPlatformGtk::sUseXRender = true;
|
|
|
|
#endif
|
|
|
|
|
2005-11-29 23:29:45 +03:00
|
|
|
gfxPlatformGtk::gfxPlatformGtk()
|
|
|
|
{
|
2007-01-30 11:20:29 +03:00
|
|
|
if (!sFontconfigUtils)
|
|
|
|
sFontconfigUtils = gfxFontconfigUtils::GetFontconfigUtils();
|
2012-04-18 18:27:32 +04:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
sUseXRender = mozilla::Preferences::GetBool("gfx.xrender.enabled");
|
|
|
|
#endif
|
2007-10-06 11:26:13 +04:00
|
|
|
|
2014-01-10 23:06:16 +04:00
|
|
|
uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
|
|
|
|
uint32_t contentMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
|
|
|
|
InitBackendPrefs(canvasMask, BackendType::CAIRO,
|
|
|
|
contentMask, BackendType::CAIRO);
|
2005-11-29 23:29:45 +03:00
|
|
|
}
|
|
|
|
|
2007-03-20 02:16:15 +03:00
|
|
|
gfxPlatformGtk::~gfxPlatformGtk()
|
|
|
|
{
|
|
|
|
gfxFontconfigUtils::Shutdown();
|
2012-07-30 18:20:58 +04:00
|
|
|
sFontconfigUtils = nullptr;
|
2007-04-16 02:22:58 +04:00
|
|
|
|
2008-09-27 04:21:55 +04:00
|
|
|
gfxPangoFontGroup::Shutdown();
|
2007-03-20 02:16:15 +03:00
|
|
|
}
|
|
|
|
|
2006-03-25 03:34:48 +03:00
|
|
|
already_AddRefed<gfxASurface>
|
2014-02-09 12:04:38 +04:00
|
|
|
gfxPlatformGtk::CreateOffscreenSurface(const IntSize& size,
|
2013-09-25 00:45:13 +04:00
|
|
|
gfxContentType contentType)
|
2005-11-29 23:29:45 +03:00
|
|
|
{
|
2010-11-19 19:56:05 +03:00
|
|
|
nsRefPtr<gfxASurface> newSurface;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool needsClear = true;
|
2013-09-25 00:45:13 +04:00
|
|
|
gfxImageFormat imageFormat = OptimalFormatForContent(contentType);
|
2008-08-07 00:48:55 +04:00
|
|
|
#ifdef MOZ_X11
|
2006-02-23 03:45:55 +03:00
|
|
|
// XXX we really need a different interface here, something that passes
|
|
|
|
// in more context, including the display and/or target surface type that
|
|
|
|
// we should try to match
|
2010-07-02 07:55:24 +04:00
|
|
|
GdkScreen *gdkScreen = gdk_screen_get_default();
|
|
|
|
if (gdkScreen) {
|
2014-09-26 21:07:06 +04:00
|
|
|
// When forcing PaintedLayers to use image surfaces for content,
|
2014-07-23 03:04:47 +04:00
|
|
|
// force creation of gfxImageSurface surfaces.
|
|
|
|
if (UseXRender() && !UseImageOffscreenSurfaces()) {
|
2010-09-24 05:00:06 +04:00
|
|
|
Screen *screen = gdk_x11_screen_get_xscreen(gdkScreen);
|
|
|
|
XRenderPictFormat* xrenderFormat =
|
|
|
|
gfxXlibSurface::FindRenderFormat(DisplayOfScreen(screen),
|
|
|
|
imageFormat);
|
|
|
|
|
|
|
|
if (xrenderFormat) {
|
2014-02-09 12:04:38 +04:00
|
|
|
newSurface = gfxXlibSurface::Create(screen, xrenderFormat,
|
|
|
|
ThebesIntSize(size));
|
2010-09-24 05:00:06 +04:00
|
|
|
}
|
2012-09-17 07:23:00 +04:00
|
|
|
} else {
|
|
|
|
// We're not going to use XRender, so we don't need to
|
|
|
|
// search for a render format
|
2014-02-09 12:04:38 +04:00
|
|
|
newSurface = new gfxImageSurface(ThebesIntSize(size), imageFormat);
|
2012-09-17 07:23:00 +04:00
|
|
|
// The gfxImageSurface ctor zeroes this for us, no need to
|
|
|
|
// waste time clearing again
|
|
|
|
needsClear = false;
|
2006-03-22 04:15:23 +03:00
|
|
|
}
|
2008-09-30 21:53:38 +04:00
|
|
|
}
|
2008-08-07 00:48:55 +04:00
|
|
|
#endif
|
2005-11-29 23:29:45 +03:00
|
|
|
|
2008-11-10 02:39:41 +03:00
|
|
|
if (!newSurface) {
|
|
|
|
// We couldn't create a native surface for whatever reason;
|
2010-07-02 07:55:24 +04:00
|
|
|
// e.g., no display, no RENDER, bad size, etc.
|
2008-11-10 02:39:41 +03:00
|
|
|
// Fall back to image surface for the data.
|
2014-02-09 12:04:38 +04:00
|
|
|
newSurface = new gfxImageSurface(ThebesIntSize(size), imageFormat);
|
2008-11-10 02:39:41 +03:00
|
|
|
}
|
|
|
|
|
2010-11-19 19:56:05 +03:00
|
|
|
if (newSurface->CairoStatus()) {
|
2012-07-30 18:20:58 +04:00
|
|
|
newSurface = nullptr; // surface isn't valid for some reason
|
2010-11-19 19:56:05 +03:00
|
|
|
}
|
|
|
|
|
2010-09-24 05:00:06 +04:00
|
|
|
if (newSurface && needsClear) {
|
2014-06-24 02:48:59 +04:00
|
|
|
gfxUtils::ClearThebesSurface(newSurface);
|
2008-07-14 01:40:16 +04:00
|
|
|
}
|
|
|
|
|
2007-11-27 04:40:03 +03:00
|
|
|
return newSurface.forget();
|
2005-11-29 23:29:45 +03:00
|
|
|
}
|
|
|
|
|
2006-01-10 23:26:40 +03:00
|
|
|
nsresult
|
2010-02-24 20:57:57 +03:00
|
|
|
gfxPlatformGtk::GetFontList(nsIAtom *aLangGroup,
|
2006-01-10 23:26:40 +03:00
|
|
|
const nsACString& aGenericFamily,
|
2009-01-18 23:14:14 +03:00
|
|
|
nsTArray<nsString>& aListOfFonts)
|
2006-01-10 23:26:40 +03:00
|
|
|
{
|
2007-01-30 11:20:29 +03:00
|
|
|
return sFontconfigUtils->GetFontList(aLangGroup, aGenericFamily,
|
|
|
|
aListOfFonts);
|
2006-11-21 09:31:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
gfxPlatformGtk::UpdateFontList()
|
|
|
|
{
|
2007-01-30 11:20:29 +03:00
|
|
|
return sFontconfigUtils->UpdateFontList();
|
2006-11-21 09:31:04 +03:00
|
|
|
}
|
|
|
|
|
2008-03-13 13:32:50 +03:00
|
|
|
nsresult
|
|
|
|
gfxPlatformGtk::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName)
|
|
|
|
{
|
|
|
|
return sFontconfigUtils->GetStandardFamilyName(aFontName, aFamilyName);
|
|
|
|
}
|
|
|
|
|
2007-04-02 23:06:16 +04:00
|
|
|
gfxFontGroup *
|
2014-06-06 10:09:23 +04:00
|
|
|
gfxPlatformGtk::CreateFontGroup(const FontFamilyList& aFontFamilyList,
|
2008-10-01 07:01:53 +04:00
|
|
|
const gfxFontStyle *aStyle,
|
|
|
|
gfxUserFontSet *aUserFontSet)
|
2007-04-02 23:06:16 +04:00
|
|
|
{
|
2014-06-06 10:09:23 +04:00
|
|
|
return new gfxPangoFontGroup(aFontFamilyList, aStyle, aUserFontSet);
|
2007-04-02 23:06:16 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 06:21:49 +03:00
|
|
|
gfxFontEntry*
|
2014-09-08 11:23:19 +04:00
|
|
|
gfxPlatformGtk::LookupLocalFont(const nsAString& aFontName,
|
|
|
|
uint16_t aWeight,
|
|
|
|
int16_t aStretch,
|
|
|
|
bool aItalic)
|
2009-01-03 06:21:49 +03:00
|
|
|
{
|
2014-09-08 11:23:19 +04:00
|
|
|
return gfxPangoFontGroup::NewFontEntry(aFontName, aWeight,
|
|
|
|
aStretch, aItalic);
|
2009-01-03 06:21:49 +03:00
|
|
|
}
|
|
|
|
|
2008-12-06 02:19:27 +03:00
|
|
|
gfxFontEntry*
|
2014-09-08 11:23:19 +04:00
|
|
|
gfxPlatformGtk::MakePlatformFont(const nsAString& aFontName,
|
|
|
|
uint16_t aWeight,
|
|
|
|
int16_t aStretch,
|
|
|
|
bool aItalic,
|
|
|
|
const uint8_t* aFontData,
|
|
|
|
uint32_t aLength)
|
2008-12-06 02:19:27 +03:00
|
|
|
{
|
2009-08-30 17:55:24 +04:00
|
|
|
// passing ownership of the font data to the new font entry
|
2014-09-08 11:23:19 +04:00
|
|
|
return gfxPangoFontGroup::NewFontEntry(aFontName, aWeight,
|
|
|
|
aStretch, aItalic,
|
2008-12-06 02:19:27 +03:00
|
|
|
aFontData, aLength);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
gfxPlatformGtk::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags)
|
2008-12-06 02:19:27 +03:00
|
|
|
{
|
2009-01-13 08:16:58 +03:00
|
|
|
// check for strange format flags
|
|
|
|
NS_ASSERTION(!(aFormatFlags & gfxUserFontSet::FLAG_FORMAT_NOT_USED),
|
|
|
|
"strange font format hint set");
|
2008-12-06 02:19:27 +03:00
|
|
|
|
2009-01-13 08:16:58 +03:00
|
|
|
// accept supported formats
|
2008-12-06 02:19:27 +03:00
|
|
|
// Pango doesn't apply features from AAT TrueType extensions.
|
|
|
|
// Assume that if this is the only SFNT format specified,
|
|
|
|
// then AAT extensions are required for complex script support.
|
2009-09-17 15:03:12 +04:00
|
|
|
if (aFormatFlags & (gfxUserFontSet::FLAG_FORMAT_WOFF |
|
|
|
|
gfxUserFontSet::FLAG_FORMAT_OPENTYPE |
|
2009-01-13 08:16:58 +03:00
|
|
|
gfxUserFontSet::FLAG_FORMAT_TRUETYPE)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-01-13 08:16:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// reject all other formats, known and unknown
|
|
|
|
if (aFormatFlags != 0) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2008-12-06 02:19:27 +03:00
|
|
|
}
|
|
|
|
|
2009-01-13 08:16:58 +03:00
|
|
|
// no format hint set, need to look at data
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2008-12-06 02:19:27 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t sDPI = 0;
|
2010-08-13 13:58:01 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
2010-08-13 13:58:01 +04:00
|
|
|
gfxPlatformGtk::GetDPI()
|
2006-04-18 19:21:42 +04:00
|
|
|
{
|
2010-08-13 13:58:01 +04:00
|
|
|
if (!sDPI) {
|
|
|
|
// Make sure init is run so we have a resolution
|
|
|
|
GdkScreen *screen = gdk_screen_get_default();
|
|
|
|
gtk_settings_get_for_screen(screen);
|
2012-08-22 19:56:38 +04:00
|
|
|
sDPI = int32_t(round(gdk_screen_get_resolution(screen)));
|
2010-08-13 13:58:01 +04:00
|
|
|
if (sDPI <= 0) {
|
|
|
|
// Fall back to something sane
|
|
|
|
sDPI = 96;
|
|
|
|
}
|
2006-04-18 19:21:42 +04:00
|
|
|
}
|
2010-08-13 13:58:01 +04:00
|
|
|
return sDPI;
|
2006-04-18 19:21:42 +04:00
|
|
|
}
|
2007-07-24 02:02:17 +04:00
|
|
|
|
2010-12-15 21:17:26 +03:00
|
|
|
gfxImageFormat
|
|
|
|
gfxPlatformGtk::GetOffscreenFormat()
|
|
|
|
{
|
2012-05-26 08:38:17 +04:00
|
|
|
// Make sure there is a screen
|
|
|
|
GdkScreen *screen = gdk_screen_get_default();
|
2012-06-28 04:15:32 +04:00
|
|
|
if (screen && gdk_visual_get_depth(gdk_visual_get_system()) == 16) {
|
2014-01-23 22:26:40 +04:00
|
|
|
return gfxImageFormat::RGB16_565;
|
2010-12-15 21:17:26 +03:00
|
|
|
}
|
|
|
|
|
2014-01-23 22:26:40 +04:00
|
|
|
return gfxImageFormat::RGB24;
|
2010-12-15 21:17:26 +03:00
|
|
|
}
|
|
|
|
|
2013-04-30 07:16:04 +04:00
|
|
|
static int sDepth = 0;
|
|
|
|
|
|
|
|
int
|
|
|
|
gfxPlatformGtk::GetScreenDepth() const
|
|
|
|
{
|
|
|
|
if (!sDepth) {
|
|
|
|
GdkScreen *screen = gdk_screen_get_default();
|
|
|
|
if (screen) {
|
|
|
|
sDepth = gdk_visual_get_depth(gdk_visual_get_system());
|
|
|
|
} else {
|
|
|
|
sDepth = 24;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return sDepth;
|
|
|
|
}
|
|
|
|
|
2013-11-07 14:20:08 +04:00
|
|
|
void
|
|
|
|
gfxPlatformGtk::GetPlatformCMSOutputProfile(void *&mem, size_t &size)
|
2007-07-24 02:02:17 +04:00
|
|
|
{
|
2013-11-07 14:20:08 +04:00
|
|
|
mem = nullptr;
|
|
|
|
size = 0;
|
|
|
|
|
2008-08-07 00:48:55 +04:00
|
|
|
#ifdef MOZ_X11
|
2007-07-24 02:02:17 +04:00
|
|
|
const char EDID1_ATOM_NAME[] = "XFree86_DDC_EDID1_RAWDATA";
|
|
|
|
const char ICC_PROFILE_ATOM_NAME[] = "_ICC_PROFILE";
|
|
|
|
|
|
|
|
Atom edidAtom, iccAtom;
|
2012-06-28 04:15:32 +04:00
|
|
|
Display *dpy = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
2013-03-22 07:12:30 +04:00
|
|
|
// In xpcshell tests, we never initialize X and hence don't have a Display.
|
|
|
|
// In this case, there's no output colour management to be done, so we just
|
2013-11-07 14:20:08 +04:00
|
|
|
// return with nullptr.
|
|
|
|
if (!dpy)
|
|
|
|
return;
|
|
|
|
|
2007-07-24 02:02:17 +04:00
|
|
|
Window root = gdk_x11_get_default_root_xwindow();
|
|
|
|
|
|
|
|
Atom retAtom;
|
|
|
|
int retFormat;
|
|
|
|
unsigned long retLength, retAfter;
|
|
|
|
unsigned char *retProperty ;
|
|
|
|
|
|
|
|
iccAtom = XInternAtom(dpy, ICC_PROFILE_ATOM_NAME, TRUE);
|
|
|
|
if (iccAtom) {
|
|
|
|
// read once to get size, once for the data
|
|
|
|
if (Success == XGetWindowProperty(dpy, root, iccAtom,
|
2012-07-19 05:09:13 +04:00
|
|
|
0, INT_MAX /* length */,
|
2007-07-24 02:02:17 +04:00
|
|
|
False, AnyPropertyType,
|
|
|
|
&retAtom, &retFormat, &retLength,
|
|
|
|
&retAfter, &retProperty)) {
|
2009-01-07 22:50:14 +03:00
|
|
|
|
2013-11-07 14:20:08 +04:00
|
|
|
if (retLength > 0) {
|
|
|
|
void *buffer = malloc(retLength);
|
|
|
|
if (buffer) {
|
|
|
|
memcpy(buffer, retProperty, retLength);
|
|
|
|
mem = buffer;
|
|
|
|
size = retLength;
|
|
|
|
}
|
|
|
|
}
|
2007-07-24 02:02:17 +04:00
|
|
|
|
|
|
|
XFree(retProperty);
|
2013-11-07 14:20:08 +04:00
|
|
|
if (size > 0) {
|
2007-07-24 02:02:17 +04:00
|
|
|
#ifdef DEBUG_tor
|
|
|
|
fprintf(stderr,
|
|
|
|
"ICM profile read from %s successfully\n",
|
|
|
|
ICC_PROFILE_ATOM_NAME);
|
|
|
|
#endif
|
2013-11-07 14:20:08 +04:00
|
|
|
return;
|
2007-07-24 02:02:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
edidAtom = XInternAtom(dpy, EDID1_ATOM_NAME, TRUE);
|
|
|
|
if (edidAtom) {
|
|
|
|
if (Success == XGetWindowProperty(dpy, root, edidAtom, 0, 32,
|
|
|
|
False, AnyPropertyType,
|
|
|
|
&retAtom, &retFormat, &retLength,
|
|
|
|
&retAfter, &retProperty)) {
|
|
|
|
double gamma;
|
2009-04-07 20:02:11 +04:00
|
|
|
qcms_CIE_xyY whitePoint;
|
|
|
|
qcms_CIE_xyYTRIPLE primaries;
|
2007-07-24 02:02:17 +04:00
|
|
|
|
|
|
|
if (retLength != 128) {
|
|
|
|
#ifdef DEBUG_tor
|
|
|
|
fprintf(stderr, "Short EDID data\n");
|
|
|
|
#endif
|
2013-11-07 14:20:08 +04:00
|
|
|
return;
|
2007-07-24 02:02:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Format documented in "VESA E-EDID Implementation Guide"
|
|
|
|
|
|
|
|
gamma = (100 + retProperty[0x17]) / 100.0;
|
|
|
|
whitePoint.x = ((retProperty[0x21] << 2) |
|
|
|
|
(retProperty[0x1a] >> 2 & 3)) / 1024.0;
|
|
|
|
whitePoint.y = ((retProperty[0x22] << 2) |
|
|
|
|
(retProperty[0x1a] >> 0 & 3)) / 1024.0;
|
|
|
|
whitePoint.Y = 1.0;
|
|
|
|
|
2009-04-07 20:02:11 +04:00
|
|
|
primaries.red.x = ((retProperty[0x1b] << 2) |
|
2007-07-24 02:02:17 +04:00
|
|
|
(retProperty[0x19] >> 6 & 3)) / 1024.0;
|
2009-04-07 20:02:11 +04:00
|
|
|
primaries.red.y = ((retProperty[0x1c] << 2) |
|
2007-07-24 02:02:17 +04:00
|
|
|
(retProperty[0x19] >> 4 & 3)) / 1024.0;
|
2009-04-07 20:02:11 +04:00
|
|
|
primaries.red.Y = 1.0;
|
2007-07-24 02:02:17 +04:00
|
|
|
|
2009-04-07 20:02:11 +04:00
|
|
|
primaries.green.x = ((retProperty[0x1d] << 2) |
|
2007-07-24 02:02:17 +04:00
|
|
|
(retProperty[0x19] >> 2 & 3)) / 1024.0;
|
2009-04-07 20:02:11 +04:00
|
|
|
primaries.green.y = ((retProperty[0x1e] << 2) |
|
2007-07-24 02:02:17 +04:00
|
|
|
(retProperty[0x19] >> 0 & 3)) / 1024.0;
|
2009-04-07 20:02:11 +04:00
|
|
|
primaries.green.Y = 1.0;
|
2007-07-24 02:02:17 +04:00
|
|
|
|
2009-04-07 20:02:11 +04:00
|
|
|
primaries.blue.x = ((retProperty[0x1f] << 2) |
|
2007-07-24 02:02:17 +04:00
|
|
|
(retProperty[0x1a] >> 6 & 3)) / 1024.0;
|
2009-04-07 20:02:11 +04:00
|
|
|
primaries.blue.y = ((retProperty[0x20] << 2) |
|
2007-07-24 02:02:17 +04:00
|
|
|
(retProperty[0x1a] >> 4 & 3)) / 1024.0;
|
2009-04-07 20:02:11 +04:00
|
|
|
primaries.blue.Y = 1.0;
|
2007-07-24 02:02:17 +04:00
|
|
|
|
|
|
|
XFree(retProperty);
|
|
|
|
|
|
|
|
#ifdef DEBUG_tor
|
|
|
|
fprintf(stderr, "EDID gamma: %f\n", gamma);
|
|
|
|
fprintf(stderr, "EDID whitepoint: %f %f %f\n",
|
|
|
|
whitePoint.x, whitePoint.y, whitePoint.Y);
|
|
|
|
fprintf(stderr, "EDID primaries: [%f %f %f] [%f %f %f] [%f %f %f]\n",
|
|
|
|
primaries.Red.x, primaries.Red.y, primaries.Red.Y,
|
|
|
|
primaries.Green.x, primaries.Green.y, primaries.Green.Y,
|
|
|
|
primaries.Blue.x, primaries.Blue.y, primaries.Blue.Y);
|
|
|
|
#endif
|
|
|
|
|
2013-11-07 14:20:08 +04:00
|
|
|
qcms_data_create_rgb_with_gamma(whitePoint, primaries, gamma, &mem, &size);
|
2007-07-24 02:02:17 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_tor
|
2013-11-07 14:20:08 +04:00
|
|
|
if (size > 0) {
|
2007-07-24 02:02:17 +04:00
|
|
|
fprintf(stderr,
|
|
|
|
"ICM profile read from %s successfully\n",
|
|
|
|
EDID1_ATOM_NAME);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2008-08-07 00:48:55 +04:00
|
|
|
#endif
|
2007-07-24 02:02:17 +04:00
|
|
|
}
|
2008-08-07 00:48:55 +04:00
|
|
|
|
|
|
|
|
2012-06-28 04:15:32 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2008-08-07 00:48:55 +04:00
|
|
|
void
|
2013-10-26 01:25:40 +04:00
|
|
|
gfxPlatformGtk::SetGdkDrawable(cairo_surface_t *target,
|
2008-08-07 00:48:55 +04:00
|
|
|
GdkDrawable *drawable)
|
|
|
|
{
|
2013-10-26 01:25:40 +04:00
|
|
|
if (cairo_surface_status(target))
|
2008-08-07 00:48:55 +04:00
|
|
|
return;
|
|
|
|
|
2009-02-02 20:49:58 +03:00
|
|
|
g_object_ref(drawable);
|
2008-08-19 07:22:42 +04:00
|
|
|
|
2013-10-26 01:25:40 +04:00
|
|
|
cairo_surface_set_user_data (target,
|
2008-08-07 00:48:55 +04:00
|
|
|
&cairo_gdk_drawable_key,
|
|
|
|
drawable,
|
2012-06-28 04:15:32 +04:00
|
|
|
g_object_unref);
|
2008-08-07 00:48:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GdkDrawable *
|
2013-10-26 01:25:40 +04:00
|
|
|
gfxPlatformGtk::GetGdkDrawable(cairo_surface_t *target)
|
2008-08-07 00:48:55 +04:00
|
|
|
{
|
2013-10-26 01:25:40 +04:00
|
|
|
if (cairo_surface_status(target))
|
2013-07-31 19:44:31 +04:00
|
|
|
return nullptr;
|
2008-08-07 00:48:55 +04:00
|
|
|
|
2008-08-19 07:22:42 +04:00
|
|
|
GdkDrawable *result;
|
|
|
|
|
2013-10-26 01:25:40 +04:00
|
|
|
result = (GdkDrawable*) cairo_surface_get_user_data (target,
|
2008-08-19 07:22:42 +04:00
|
|
|
&cairo_gdk_drawable_key);
|
|
|
|
if (result)
|
|
|
|
return result;
|
|
|
|
|
|
|
|
#ifdef MOZ_X11
|
2013-10-26 01:25:40 +04:00
|
|
|
if (cairo_surface_get_type(target) != CAIRO_SURFACE_TYPE_XLIB)
|
2013-07-31 19:44:31 +04:00
|
|
|
return nullptr;
|
2010-06-23 03:11:42 +04:00
|
|
|
|
|
|
|
// try looking it up in gdk's table
|
2013-10-26 01:25:40 +04:00
|
|
|
result = (GdkDrawable*) gdk_xid_table_lookup(cairo_xlib_surface_get_drawable(target));
|
2010-06-23 03:11:42 +04:00
|
|
|
if (result) {
|
|
|
|
SetGdkDrawable(target, result);
|
|
|
|
return result;
|
|
|
|
}
|
2010-07-02 08:04:09 +04:00
|
|
|
#endif
|
2008-08-19 07:22:42 +04:00
|
|
|
|
2013-07-31 19:44:31 +04:00
|
|
|
return nullptr;
|
2008-08-07 00:48:55 +04:00
|
|
|
}
|
2012-06-28 04:15:32 +04:00
|
|
|
#endif
|
2012-01-26 04:54:31 +04:00
|
|
|
|
2012-09-24 19:02:49 +04:00
|
|
|
TemporaryRef<ScaledFont>
|
2012-07-24 14:18:37 +04:00
|
|
|
gfxPlatformGtk::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
2012-01-26 04:54:31 +04:00
|
|
|
{
|
2014-01-30 11:01:16 +04:00
|
|
|
return GetScaledFontForFontWithCairoSkia(aTarget, aFont);
|
2012-07-26 10:48:24 +04:00
|
|
|
}
|