2011-06-24 21:41:16 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
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/. */
|
2011-06-24 21:41:16 +04:00
|
|
|
|
|
|
|
#include "2D.h"
|
|
|
|
|
|
|
|
#ifdef USE_CAIRO
|
|
|
|
#include "DrawTargetCairo.h"
|
2013-06-05 21:48:59 +04:00
|
|
|
#include "ScaledFontCairo.h"
|
2011-06-24 21:41:16 +04:00
|
|
|
#endif
|
|
|
|
|
2011-11-02 23:55:03 +04:00
|
|
|
#ifdef USE_SKIA
|
|
|
|
#include "DrawTargetSkia.h"
|
2012-01-09 22:54:44 +04:00
|
|
|
#include "ScaledFontBase.h"
|
2012-05-17 02:30:10 +04:00
|
|
|
#ifdef MOZ_ENABLE_FREETYPE
|
2013-06-05 21:48:59 +04:00
|
|
|
#define USE_SKIA_FREETYPE
|
|
|
|
#include "ScaledFontCairo.h"
|
2011-11-02 23:55:03 +04:00
|
|
|
#endif
|
2012-05-17 02:30:10 +04:00
|
|
|
#endif
|
2012-01-09 22:54:44 +04:00
|
|
|
|
2012-04-12 04:03:07 +04:00
|
|
|
#if defined(WIN32) && defined(USE_SKIA)
|
2011-11-18 08:00:37 +04:00
|
|
|
#include "ScaledFontWin.h"
|
|
|
|
#endif
|
2012-01-09 22:54:44 +04:00
|
|
|
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
#include "ScaledFontMac.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
#include "DrawTargetCG.h"
|
2011-11-02 23:55:03 +04:00
|
|
|
#endif
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
#ifdef WIN32
|
|
|
|
#include "DrawTargetD2D.h"
|
|
|
|
#include "ScaledFontDWrite.h"
|
|
|
|
#include <d3d10_1.h>
|
|
|
|
#endif
|
|
|
|
|
2012-04-04 00:25:52 +04:00
|
|
|
#include "DrawTargetDual.h"
|
2012-09-24 19:02:50 +04:00
|
|
|
#include "DrawTargetRecording.h"
|
2011-11-02 23:55:03 +04:00
|
|
|
|
2012-05-21 19:27:30 +04:00
|
|
|
#include "SourceSurfaceRawData.h"
|
|
|
|
|
2012-09-24 19:02:50 +04:00
|
|
|
#include "DrawEventRecorder.h"
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
#include "Logging.h"
|
|
|
|
|
|
|
|
#ifdef PR_LOGGING
|
2012-10-30 03:32:10 +04:00
|
|
|
PRLogModuleInfo *
|
|
|
|
GetGFX2DLog()
|
|
|
|
{
|
|
|
|
static PRLogModuleInfo *sLog;
|
|
|
|
if (!sLog)
|
|
|
|
sLog = PR_NewLogModule("gfx2d");
|
|
|
|
return sLog;
|
|
|
|
}
|
2011-06-24 21:41:16 +04:00
|
|
|
#endif
|
|
|
|
|
2012-05-10 08:31:14 +04:00
|
|
|
// The following code was largely taken from xpcom/glue/SSE.cpp and
|
|
|
|
// made a little simpler.
|
|
|
|
enum CPUIDRegister { eax = 0, ebx = 1, ecx = 2, edx = 3 };
|
|
|
|
|
|
|
|
#ifdef HAVE_CPUID_H
|
|
|
|
|
|
|
|
// cpuid.h is available on gcc 4.3 and higher on i386 and x86_64
|
|
|
|
#include <cpuid.h>
|
|
|
|
|
2013-02-17 12:45:10 +04:00
|
|
|
static inline bool
|
2012-05-10 08:31:14 +04:00
|
|
|
HasCPUIDBit(unsigned int level, CPUIDRegister reg, unsigned int bit)
|
|
|
|
{
|
|
|
|
unsigned int regs[4];
|
|
|
|
return __get_cpuid(level, ®s[0], ®s[1], ®s[2], ®s[3]) &&
|
|
|
|
(regs[reg] & bit);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define HAVE_CPU_DETECTION
|
|
|
|
#else
|
|
|
|
|
2012-05-16 12:40:51 +04:00
|
|
|
#if defined(_MSC_VER) && _MSC_VER >= 1600 && (defined(_M_IX86) || defined(_M_AMD64))
|
|
|
|
// MSVC 2005 or later supports __cpuid by intrin.h
|
|
|
|
// But it does't work on MSVC 2005 with SDK 7.1 (Bug 753772)
|
2012-05-10 08:31:14 +04:00
|
|
|
#include <intrin.h>
|
|
|
|
|
|
|
|
#define HAVE_CPU_DETECTION
|
|
|
|
#elif defined(__SUNPRO_CC) && (defined(__i386) || defined(__x86_64__))
|
|
|
|
|
|
|
|
// Define a function identical to MSVC function.
|
|
|
|
#ifdef __i386
|
|
|
|
static void
|
|
|
|
__cpuid(int CPUInfo[4], int InfoType)
|
|
|
|
{
|
|
|
|
asm (
|
|
|
|
"xchg %esi, %ebx\n"
|
|
|
|
"cpuid\n"
|
|
|
|
"movl %eax, (%edi)\n"
|
|
|
|
"movl %ebx, 4(%edi)\n"
|
|
|
|
"movl %ecx, 8(%edi)\n"
|
|
|
|
"movl %edx, 12(%edi)\n"
|
|
|
|
"xchg %esi, %ebx\n"
|
|
|
|
:
|
|
|
|
: "a"(InfoType), // %eax
|
|
|
|
"D"(CPUInfo) // %edi
|
|
|
|
: "%ecx", "%edx", "%esi"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static void
|
|
|
|
__cpuid(int CPUInfo[4], int InfoType)
|
|
|
|
{
|
|
|
|
asm (
|
|
|
|
"xchg %rsi, %rbx\n"
|
|
|
|
"cpuid\n"
|
|
|
|
"movl %eax, (%rdi)\n"
|
|
|
|
"movl %ebx, 4(%rdi)\n"
|
|
|
|
"movl %ecx, 8(%rdi)\n"
|
|
|
|
"movl %edx, 12(%rdi)\n"
|
|
|
|
"xchg %rsi, %rbx\n"
|
|
|
|
:
|
|
|
|
: "a"(InfoType), // %eax
|
|
|
|
"D"(CPUInfo) // %rdi
|
|
|
|
: "%ecx", "%edx", "%rsi"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define HAVE_CPU_DETECTION
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_CPU_DETECTION
|
2013-02-17 12:45:10 +04:00
|
|
|
static inline bool
|
2012-05-10 08:31:14 +04:00
|
|
|
HasCPUIDBit(unsigned int level, CPUIDRegister reg, unsigned int bit)
|
|
|
|
{
|
|
|
|
// Check that the level in question is supported.
|
|
|
|
volatile int regs[4];
|
|
|
|
__cpuid((int *)regs, level & 0x80000000u);
|
|
|
|
if (unsigned(regs[0]) < level)
|
|
|
|
return false;
|
|
|
|
__cpuid((int *)regs, level);
|
|
|
|
return !!(unsigned(regs[reg]) & bit);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
// XXX - Need to define an API to set this.
|
|
|
|
int sGfxLogLevel = LOG_DEBUG;
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
ID3D10Device1 *Factory::mD3D10Device;
|
|
|
|
#endif
|
|
|
|
|
2012-09-24 19:02:50 +04:00
|
|
|
DrawEventRecorder *Factory::mRecorder;
|
|
|
|
|
2012-05-10 08:31:14 +04:00
|
|
|
bool
|
|
|
|
Factory::HasSSE2()
|
|
|
|
{
|
2012-05-16 12:40:51 +04:00
|
|
|
#if defined(__SSE2__) || defined(_M_X64) || \
|
|
|
|
(defined(_M_IX86_FP) && _M_IX86_FP >= 2)
|
|
|
|
// gcc with -msse2 (default on OSX and x86-64)
|
|
|
|
// cl.exe with -arch:SSE2 (default on x64 compiler)
|
2012-05-10 08:31:14 +04:00
|
|
|
return true;
|
2012-05-16 12:40:51 +04:00
|
|
|
#elif defined(HAVE_CPU_DETECTION)
|
|
|
|
return HasCPUIDBit(1u, edx, (1u<<26));
|
2012-05-10 08:31:14 +04:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
TemporaryRef<DrawTarget>
|
|
|
|
Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat)
|
|
|
|
{
|
2012-09-24 19:02:50 +04:00
|
|
|
RefPtr<DrawTarget> retVal;
|
2011-06-24 21:41:16 +04:00
|
|
|
switch (aBackend) {
|
|
|
|
#ifdef WIN32
|
|
|
|
case BACKEND_DIRECT2D:
|
|
|
|
{
|
|
|
|
RefPtr<DrawTargetD2D> newTarget;
|
|
|
|
newTarget = new DrawTargetD2D();
|
|
|
|
if (newTarget->Init(aSize, aFormat)) {
|
2012-09-24 19:02:50 +04:00
|
|
|
retVal = newTarget;
|
2011-06-24 21:41:16 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-04-13 06:10:22 +04:00
|
|
|
#elif defined XP_MACOSX
|
|
|
|
case BACKEND_COREGRAPHICS:
|
2012-07-31 19:17:43 +04:00
|
|
|
case BACKEND_COREGRAPHICS_ACCELERATED:
|
2011-11-02 23:55:03 +04:00
|
|
|
{
|
2012-04-13 06:10:22 +04:00
|
|
|
RefPtr<DrawTargetCG> newTarget;
|
|
|
|
newTarget = new DrawTargetCG();
|
2012-07-31 19:17:43 +04:00
|
|
|
if (newTarget->Init(aBackend, aSize, aFormat)) {
|
2012-09-24 19:02:50 +04:00
|
|
|
retVal = newTarget;
|
2011-11-02 23:55:03 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-01-09 22:54:44 +04:00
|
|
|
#endif
|
2012-04-13 06:10:22 +04:00
|
|
|
#ifdef USE_SKIA
|
|
|
|
case BACKEND_SKIA:
|
2012-01-09 22:54:44 +04:00
|
|
|
{
|
2012-04-13 06:10:22 +04:00
|
|
|
RefPtr<DrawTargetSkia> newTarget;
|
|
|
|
newTarget = new DrawTargetSkia();
|
2012-01-09 22:54:44 +04:00
|
|
|
if (newTarget->Init(aSize, aFormat)) {
|
2012-09-24 19:02:50 +04:00
|
|
|
retVal = newTarget;
|
2012-01-09 22:54:44 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-06-24 21:41:16 +04:00
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
gfxDebug() << "Invalid draw target type specified.";
|
2012-08-14 22:06:12 +04:00
|
|
|
return nullptr;
|
2011-06-24 21:41:16 +04:00
|
|
|
}
|
|
|
|
|
2012-09-24 19:02:50 +04:00
|
|
|
if (mRecorder && retVal) {
|
|
|
|
RefPtr<DrawTarget> recordDT;
|
|
|
|
recordDT = new DrawTargetRecording(mRecorder, retVal);
|
|
|
|
return recordDT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!retVal) {
|
|
|
|
// Failed
|
|
|
|
gfxDebug() << "Failed to create DrawTarget, Type: " << aBackend << " Size: " << aSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<DrawTarget>
|
|
|
|
Factory::CreateRecordingDrawTarget(DrawEventRecorder *aRecorder, DrawTarget *aDT)
|
|
|
|
{
|
|
|
|
return new DrawTargetRecording(aRecorder, aDT);
|
2011-06-24 21:41:16 +04:00
|
|
|
}
|
|
|
|
|
2012-04-02 23:15:08 +04:00
|
|
|
TemporaryRef<DrawTarget>
|
|
|
|
Factory::CreateDrawTargetForData(BackendType aBackend,
|
|
|
|
unsigned char *aData,
|
|
|
|
const IntSize &aSize,
|
|
|
|
int32_t aStride,
|
|
|
|
SurfaceFormat aFormat)
|
|
|
|
{
|
2012-09-24 19:02:50 +04:00
|
|
|
RefPtr<DrawTarget> retVal;
|
|
|
|
|
2012-04-02 23:15:08 +04:00
|
|
|
switch (aBackend) {
|
|
|
|
#ifdef USE_SKIA
|
|
|
|
case BACKEND_SKIA:
|
|
|
|
{
|
|
|
|
RefPtr<DrawTargetSkia> newTarget;
|
|
|
|
newTarget = new DrawTargetSkia();
|
|
|
|
newTarget->Init(aData, aSize, aStride, aFormat);
|
2012-09-24 19:02:50 +04:00
|
|
|
retVal = newTarget;
|
2012-04-02 23:15:08 +04:00
|
|
|
}
|
2012-07-26 22:06:23 +04:00
|
|
|
#endif
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
case BACKEND_COREGRAPHICS:
|
|
|
|
{
|
|
|
|
RefPtr<DrawTargetCG> newTarget = new DrawTargetCG();
|
2012-07-31 19:17:43 +04:00
|
|
|
if (newTarget->Init(aBackend, aData, aSize, aStride, aFormat))
|
2012-07-26 22:06:23 +04:00
|
|
|
return newTarget;
|
|
|
|
break;
|
|
|
|
}
|
2012-04-02 23:15:08 +04:00
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
gfxDebug() << "Invalid draw target type specified.";
|
2012-08-14 22:06:12 +04:00
|
|
|
return nullptr;
|
2012-04-02 23:15:08 +04:00
|
|
|
}
|
|
|
|
|
2012-09-24 19:02:50 +04:00
|
|
|
if (mRecorder && retVal) {
|
|
|
|
RefPtr<DrawTarget> recordDT = new DrawTargetRecording(mRecorder, retVal);
|
|
|
|
return recordDT;
|
|
|
|
}
|
|
|
|
|
2012-04-02 23:15:08 +04:00
|
|
|
gfxDebug() << "Failed to create DrawTarget, Type: " << aBackend << " Size: " << aSize;
|
|
|
|
// Failed
|
2012-08-14 22:06:12 +04:00
|
|
|
return nullptr;
|
2012-04-02 23:15:08 +04:00
|
|
|
}
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
TemporaryRef<ScaledFont>
|
|
|
|
Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSize)
|
|
|
|
{
|
|
|
|
switch (aNativeFont.mType) {
|
|
|
|
#ifdef WIN32
|
|
|
|
case NATIVE_FONT_DWRITE_FONT_FACE:
|
|
|
|
{
|
|
|
|
return new ScaledFontDWrite(static_cast<IDWriteFontFace*>(aNativeFont.mFont), aSize);
|
|
|
|
}
|
2012-09-24 19:02:50 +04:00
|
|
|
#if defined(USE_CAIRO) || defined(USE_SKIA)
|
2012-07-24 14:18:38 +04:00
|
|
|
case NATIVE_FONT_GDI_FONT_FACE:
|
|
|
|
{
|
|
|
|
return new ScaledFontWin(static_cast<LOGFONT*>(aNativeFont.mFont), aSize);
|
|
|
|
}
|
2011-11-02 23:55:03 +04:00
|
|
|
#endif
|
2012-09-11 17:51:39 +04:00
|
|
|
#endif
|
2011-11-02 23:55:03 +04:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
case NATIVE_FONT_MAC_FONT_FACE:
|
|
|
|
{
|
|
|
|
return new ScaledFontMac(static_cast<CGFontRef>(aNativeFont.mFont), aSize);
|
|
|
|
}
|
2011-11-18 08:00:37 +04:00
|
|
|
#endif
|
2013-06-05 21:48:59 +04:00
|
|
|
#if defined(USE_CAIRO) || defined(USE_SKIA_FREETYPE)
|
2012-01-10 22:26:59 +04:00
|
|
|
case NATIVE_FONT_CAIRO_FONT_FACE:
|
|
|
|
{
|
2013-06-05 21:48:59 +04:00
|
|
|
return new ScaledFontCairo(static_cast<cairo_scaled_font_t*>(aNativeFont.mFont), aSize);
|
2012-01-10 22:26:59 +04:00
|
|
|
}
|
2012-01-27 22:08:46 +04:00
|
|
|
#endif
|
2011-06-24 21:41:16 +04:00
|
|
|
default:
|
|
|
|
gfxWarning() << "Invalid native font type specified.";
|
2012-08-14 22:06:12 +04:00
|
|
|
return nullptr;
|
2011-06-24 21:41:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-27 22:08:46 +04:00
|
|
|
TemporaryRef<ScaledFont>
|
2012-09-24 19:02:49 +04:00
|
|
|
Factory::CreateScaledFontForTrueTypeData(uint8_t *aData, uint32_t aSize,
|
|
|
|
uint32_t aFaceIndex, Float aGlyphSize,
|
|
|
|
FontType aType)
|
|
|
|
{
|
|
|
|
switch (aType) {
|
|
|
|
#ifdef WIN32
|
|
|
|
case FONT_DWRITE:
|
|
|
|
{
|
|
|
|
return new ScaledFontDWrite(aData, aSize, aFaceIndex, aGlyphSize);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
gfxWarning() << "Unable to create requested font type from truetype data";
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<ScaledFont>
|
2012-01-27 22:08:46 +04:00
|
|
|
Factory::CreateScaledFontWithCairo(const NativeFont& aNativeFont, Float aSize, cairo_scaled_font_t* aScaledFont)
|
|
|
|
{
|
|
|
|
#ifdef USE_CAIRO
|
|
|
|
// In theory, we could pull the NativeFont out of the cairo_scaled_font_t*,
|
|
|
|
// but that would require a lot of code that would be otherwise repeated in
|
|
|
|
// various backends.
|
|
|
|
// Therefore, we just reuse CreateScaledFontForNativeFont's implementation.
|
|
|
|
RefPtr<ScaledFont> font = CreateScaledFontForNativeFont(aNativeFont, aSize);
|
|
|
|
static_cast<ScaledFontBase*>(font.get())->SetCairoScaledFont(aScaledFont);
|
|
|
|
return font;
|
|
|
|
#else
|
2012-08-14 22:06:12 +04:00
|
|
|
return nullptr;
|
2012-01-27 22:08:46 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
#ifdef WIN32
|
|
|
|
TemporaryRef<DrawTarget>
|
|
|
|
Factory::CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat)
|
|
|
|
{
|
|
|
|
RefPtr<DrawTargetD2D> newTarget;
|
|
|
|
|
|
|
|
newTarget = new DrawTargetD2D();
|
|
|
|
if (newTarget->Init(aTexture, aFormat)) {
|
2012-09-24 19:02:50 +04:00
|
|
|
RefPtr<DrawTarget> retVal = newTarget;
|
|
|
|
|
|
|
|
if (mRecorder) {
|
|
|
|
retVal = new DrawTargetRecording(mRecorder, retVal);
|
|
|
|
}
|
|
|
|
|
|
|
|
return retVal;
|
2011-06-24 21:41:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxWarning() << "Failed to create draw target for D3D10 texture.";
|
|
|
|
|
|
|
|
// Failed
|
2012-08-14 22:06:12 +04:00
|
|
|
return nullptr;
|
2011-06-24 21:41:16 +04:00
|
|
|
}
|
|
|
|
|
2012-04-04 00:25:52 +04:00
|
|
|
TemporaryRef<DrawTarget>
|
|
|
|
Factory::CreateDualDrawTargetForD3D10Textures(ID3D10Texture2D *aTextureA,
|
|
|
|
ID3D10Texture2D *aTextureB,
|
|
|
|
SurfaceFormat aFormat)
|
|
|
|
{
|
|
|
|
RefPtr<DrawTargetD2D> newTargetA;
|
|
|
|
RefPtr<DrawTargetD2D> newTargetB;
|
|
|
|
|
|
|
|
newTargetA = new DrawTargetD2D();
|
|
|
|
if (!newTargetA->Init(aTextureA, aFormat)) {
|
|
|
|
gfxWarning() << "Failed to create draw target for D3D10 texture.";
|
2012-08-14 22:06:12 +04:00
|
|
|
return nullptr;
|
2012-04-04 00:25:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
newTargetB = new DrawTargetD2D();
|
|
|
|
if (!newTargetB->Init(aTextureB, aFormat)) {
|
|
|
|
gfxWarning() << "Failed to create draw target for D3D10 texture.";
|
2012-08-14 22:06:12 +04:00
|
|
|
return nullptr;
|
2012-04-04 00:25:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<DrawTarget> newTarget =
|
|
|
|
new DrawTargetDual(newTargetA, newTargetB);
|
|
|
|
|
2012-09-24 19:02:50 +04:00
|
|
|
RefPtr<DrawTarget> retVal = newTarget;
|
|
|
|
|
|
|
|
if (mRecorder) {
|
|
|
|
retVal = new DrawTargetRecording(mRecorder, retVal);
|
|
|
|
}
|
|
|
|
|
|
|
|
return retVal;
|
2012-04-04 00:25:52 +04:00
|
|
|
}
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
void
|
|
|
|
Factory::SetDirect3D10Device(ID3D10Device1 *aDevice)
|
|
|
|
{
|
|
|
|
mD3D10Device = aDevice;
|
|
|
|
}
|
|
|
|
|
|
|
|
ID3D10Device1*
|
|
|
|
Factory::GetDirect3D10Device()
|
|
|
|
{
|
|
|
|
return mD3D10Device;
|
|
|
|
}
|
|
|
|
|
2012-03-19 23:20:17 +04:00
|
|
|
TemporaryRef<GlyphRenderingOptions>
|
|
|
|
Factory::CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams)
|
|
|
|
{
|
|
|
|
RefPtr<GlyphRenderingOptions> options =
|
|
|
|
new GlyphRenderingOptionsDWrite(aParams);
|
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
2012-06-21 02:32:52 +04:00
|
|
|
uint64_t
|
|
|
|
Factory::GetD2DVRAMUsageDrawTarget()
|
|
|
|
{
|
|
|
|
return DrawTargetD2D::mVRAMUsageDT;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
Factory::GetD2DVRAMUsageSourceSurface()
|
|
|
|
{
|
|
|
|
return DrawTargetD2D::mVRAMUsageSS;
|
|
|
|
}
|
|
|
|
|
2012-11-25 23:00:31 +04:00
|
|
|
void
|
|
|
|
Factory::D2DCleanup()
|
|
|
|
{
|
|
|
|
DrawTargetD2D::CleanupD2D();
|
|
|
|
}
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
#endif // XP_WIN
|
|
|
|
|
2013-03-14 03:29:47 +04:00
|
|
|
#ifdef USE_SKIA_GPU
|
2012-12-01 03:58:00 +04:00
|
|
|
TemporaryRef<DrawTarget>
|
2013-05-29 22:04:25 +04:00
|
|
|
Factory::CreateSkiaDrawTargetForFBO(unsigned int aFBOID, GrContext* aGrContext, const IntSize &aSize, SurfaceFormat aFormat)
|
2012-12-01 03:58:00 +04:00
|
|
|
{
|
|
|
|
RefPtr<DrawTargetSkia> newTarget = new DrawTargetSkia();
|
|
|
|
newTarget->InitWithFBO(aFBOID, aGrContext, aSize, aFormat);
|
|
|
|
return newTarget;
|
|
|
|
}
|
2013-03-14 03:29:47 +04:00
|
|
|
#endif // USE_SKIA_GPU
|
2012-12-01 03:58:00 +04:00
|
|
|
|
2013-06-05 21:48:59 +04:00
|
|
|
#ifdef USE_SKIA_FREETYPE
|
|
|
|
TemporaryRef<GlyphRenderingOptions>
|
|
|
|
Factory::CreateCairoGlyphRenderingOptions(FontHinting aHinting, bool aAutoHinting)
|
|
|
|
{
|
|
|
|
RefPtr<GlyphRenderingOptionsCairo> options =
|
|
|
|
new GlyphRenderingOptionsCairo();
|
|
|
|
|
|
|
|
options->SetHinting(aHinting);
|
|
|
|
options->SetAutoHinting(aAutoHinting);
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
TemporaryRef<DrawTarget>
|
2012-07-24 14:18:38 +04:00
|
|
|
Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize)
|
2011-06-24 21:41:16 +04:00
|
|
|
{
|
2012-09-24 19:02:50 +04:00
|
|
|
RefPtr<DrawTarget> retVal;
|
|
|
|
|
2012-05-03 23:21:52 +04:00
|
|
|
#ifdef USE_CAIRO
|
2011-06-24 21:41:16 +04:00
|
|
|
RefPtr<DrawTargetCairo> newTarget = new DrawTargetCairo();
|
2012-09-24 19:02:50 +04:00
|
|
|
|
2012-07-24 14:18:38 +04:00
|
|
|
if (newTarget->Init(aSurface, aSize)) {
|
2012-09-24 19:02:50 +04:00
|
|
|
retVal = newTarget;
|
2011-06-24 21:41:16 +04:00
|
|
|
}
|
|
|
|
|
2012-09-24 19:02:50 +04:00
|
|
|
if (mRecorder && retVal) {
|
|
|
|
RefPtr<DrawTarget> recordDT = new DrawTargetRecording(mRecorder, retVal);
|
|
|
|
return recordDT;
|
|
|
|
}
|
2012-05-03 23:21:52 +04:00
|
|
|
#endif
|
2012-09-24 19:02:50 +04:00
|
|
|
return retVal;
|
2011-06-24 21:41:16 +04:00
|
|
|
}
|
|
|
|
|
2012-05-21 19:27:30 +04:00
|
|
|
TemporaryRef<DataSourceSurface>
|
|
|
|
Factory::CreateWrappingDataSourceSurface(uint8_t *aData, int32_t aStride,
|
|
|
|
const IntSize &aSize,
|
|
|
|
SurfaceFormat aFormat)
|
|
|
|
{
|
|
|
|
RefPtr<SourceSurfaceRawData> newSurf = new SourceSurfaceRawData();
|
|
|
|
|
|
|
|
if (newSurf->InitWrappingData(aData, aSize, aStride, aFormat, false)) {
|
|
|
|
return newSurf;
|
|
|
|
}
|
|
|
|
|
2012-08-14 22:06:12 +04:00
|
|
|
return nullptr;
|
2012-05-21 19:27:30 +04:00
|
|
|
}
|
|
|
|
|
2012-09-24 19:02:50 +04:00
|
|
|
TemporaryRef<DrawEventRecorder>
|
|
|
|
Factory::CreateEventRecorderForFile(const char *aFilename)
|
|
|
|
{
|
|
|
|
return new DrawEventRecorderFile(aFilename);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Factory::SetGlobalEventRecorder(DrawEventRecorder *aRecorder)
|
|
|
|
{
|
|
|
|
mRecorder = aRecorder;
|
|
|
|
}
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
}
|
|
|
|
}
|