mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 699258 - Part 2: [Skia] Get Skia backend working on Windows.
This commit is contained in:
parent
dad1070375
commit
f70d384da0
@ -988,13 +988,7 @@ PRUint8 (*nsCanvasRenderingContext2DAzure::sPremultiplyTable)[256] = nsnull;
|
||||
nsresult
|
||||
NS_NewCanvasRenderingContext2DAzure(nsIDOMCanvasRenderingContext2D** aResult)
|
||||
{
|
||||
#ifdef XP_WIN
|
||||
if (gfxWindowsPlatform::GetPlatform()->GetRenderMode() !=
|
||||
gfxWindowsPlatform::RENDER_DIRECT2D ||
|
||||
!gfxWindowsPlatform::GetPlatform()->DWriteEnabled()) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
#elif !defined(XP_MACOSX) && !defined(ANDROID)
|
||||
#if !defined(XP_WIN) && !defined(XP_MACOSX) && !defined(ANDROID)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
#endif
|
||||
|
||||
|
@ -46,6 +46,9 @@
|
||||
#ifdef XP_MACOSX
|
||||
#include "ScaledFontMac.h"
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
#include "ScaledFontWin.h"
|
||||
#endif
|
||||
#include "ScaledFontSkia.h"
|
||||
#endif
|
||||
|
||||
@ -124,6 +127,12 @@ Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSiz
|
||||
{
|
||||
return new ScaledFontMac(static_cast<CGFontRef>(aNativeFont.mFont), aSize);
|
||||
}
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
case NATIVE_FONT_GDI_FONT_FACE:
|
||||
{
|
||||
return new ScaledFontWin(static_cast<gfxGDIFont*>(aNativeFont.mFont), aSize);
|
||||
}
|
||||
#endif
|
||||
case NATIVE_FONT_SKIA_FONT_FACE:
|
||||
{
|
||||
|
@ -107,9 +107,13 @@ CPPSRCS += \
|
||||
SourceSurfaceD2DTarget.cpp \
|
||||
PathD2D.cpp \
|
||||
ScaledFontDWrite.cpp \
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -DWIN32
|
||||
SourceSurfaceSkia.cpp \
|
||||
DrawTargetSkia.cpp \
|
||||
PathSkia.cpp \
|
||||
ScaledFontSkia.cpp \
|
||||
ScaledFontWin.cpp \
|
||||
$(NULL)
|
||||
DEFINES += -DWIN32 -DUSE_SKIA
|
||||
endif
|
||||
|
||||
#ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||
|
53
gfx/2d/ScaledFontWin.cpp
Normal file
53
gfx/2d/ScaledFontWin.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* ***** 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 Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Marco Castelluccio <mar.castelluccio@studenti.unina.it>
|
||||
*
|
||||
* 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 "ScaledFontWin.h"
|
||||
#include "skia/SkTypeface_win.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
ScaledFontWin::ScaledFontWin(gfxGDIFont* aFont, Float aSize)
|
||||
: ScaledFontSkia(aSize)
|
||||
{
|
||||
LOGFONT lf;
|
||||
GetObject(aFont->GetHFONT(), sizeof(LOGFONT), &lf);
|
||||
mTypeface = SkCreateTypefaceFromLOGFONT(lf);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
61
gfx/2d/ScaledFontWin.h
Normal file
61
gfx/2d/ScaledFontWin.h
Normal file
@ -0,0 +1,61 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* ***** 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 Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Marco Castelluccio <mar.castelluccio@studenti.unina.it>
|
||||
*
|
||||
* 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 MOZILLA_GFX_SCALEDFONTWIN_H_
|
||||
#define MOZILLA_GFX_SCALEDFONTWIN_H_
|
||||
|
||||
#include "ScaledFontSkia.h"
|
||||
#include "gfxGDIFont.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
class ScaledFontWin : public ScaledFontSkia
|
||||
{
|
||||
public:
|
||||
ScaledFontWin(gfxGDIFont* aFont, Float aSize);
|
||||
|
||||
virtual FontType GetType() const { return FONT_GDI; }
|
||||
|
||||
private:
|
||||
friend class DrawTargetSkia;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_GFX_SCALEDFONTWIN_H_ */
|
@ -43,7 +43,7 @@
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
bool
|
||||
static inline bool
|
||||
IsOperatorBoundByMask(CompositionOp aOp) {
|
||||
switch (aOp) {
|
||||
case OP_IN:
|
||||
|
@ -91,6 +91,7 @@ enum BackendType
|
||||
enum FontType
|
||||
{
|
||||
FONT_DWRITE,
|
||||
FONT_GDI,
|
||||
FONT_MAC,
|
||||
FONT_SKIA
|
||||
};
|
||||
@ -103,6 +104,7 @@ enum NativeSurfaceType
|
||||
enum NativeFontType
|
||||
{
|
||||
NATIVE_FONT_DWRITE_FONT_FACE,
|
||||
NATIVE_FONT_GDI_FONT_FACE,
|
||||
NATIVE_FONT_MAC_FONT_FACE,
|
||||
NATIVE_FONT_SKIA_FONT_FACE
|
||||
};
|
||||
|
@ -50,7 +50,7 @@ endif
|
||||
|
||||
DIRS += 2d ycbcr angle src qcms layers harfbuzz/src ots/src thebes ipc
|
||||
|
||||
ifeq (,$(filter-out cocoa android,$(MOZ_WIDGET_TOOLKIT)))
|
||||
ifeq (,$(filter-out cocoa android windows,$(MOZ_WIDGET_TOOLKIT)))
|
||||
DIRS += skia
|
||||
endif
|
||||
|
||||
|
@ -62,7 +62,11 @@ CanvasLayerD3D9::Initialize(const Data& aData)
|
||||
{
|
||||
NS_ASSERTION(mSurface == nsnull, "BasicCanvasLayer::Initialize called twice!");
|
||||
|
||||
if (aData.mSurface) {
|
||||
if (aData.mDrawTarget) {
|
||||
mDrawTarget = aData.mDrawTarget;
|
||||
mNeedsYFlip = false;
|
||||
mDataIsPremultiplied = true;
|
||||
} else if (aData.mSurface) {
|
||||
mSurface = aData.mSurface;
|
||||
NS_ASSERTION(aData.mGLContext == nsnull,
|
||||
"CanvasLayer can't have both surface and GLContext");
|
||||
@ -75,7 +79,7 @@ CanvasLayerD3D9::Initialize(const Data& aData)
|
||||
mDataIsPremultiplied = aData.mGLBufferIsPremultiplied;
|
||||
mNeedsYFlip = true;
|
||||
} else {
|
||||
NS_ERROR("CanvasLayer created without mSurface or mGLContext?");
|
||||
NS_ERROR("CanvasLayer created without mSurface, mGLContext or mDrawTarget?");
|
||||
}
|
||||
|
||||
mBounds.SetRect(0, 0, aData.mSize.width, aData.mSize.height);
|
||||
@ -150,7 +154,7 @@ CanvasLayerD3D9::UpdateSurface()
|
||||
}
|
||||
delete [] destination;
|
||||
}
|
||||
} else if (mSurface) {
|
||||
} else {
|
||||
RECT r;
|
||||
r.left = mBounds.x;
|
||||
r.top = mBounds.y;
|
||||
@ -166,11 +170,18 @@ CanvasLayerD3D9::UpdateSurface()
|
||||
D3DLOCKED_RECT lockedRect = textureLock.GetLockRect();
|
||||
|
||||
nsRefPtr<gfxImageSurface> sourceSurface;
|
||||
nsRefPtr<gfxASurface> tempSurface;
|
||||
if (mDrawTarget) {
|
||||
tempSurface = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mDrawTarget);
|
||||
}
|
||||
else {
|
||||
tempSurface = mSurface;
|
||||
}
|
||||
|
||||
if (mSurface->GetType() == gfxASurface::SurfaceTypeWin32) {
|
||||
sourceSurface = mSurface->GetAsImageSurface();
|
||||
} else if (mSurface->GetType() == gfxASurface::SurfaceTypeImage) {
|
||||
sourceSurface = static_cast<gfxImageSurface*>(mSurface.get());
|
||||
if (tempSurface->GetType() == gfxASurface::SurfaceTypeWin32) {
|
||||
sourceSurface = tempSurface->GetAsImageSurface();
|
||||
} else if (tempSurface->GetType() == gfxASurface::SurfaceTypeImage) {
|
||||
sourceSurface = static_cast<gfxImageSurface*>(tempSurface.get());
|
||||
if (sourceSurface->Format() != gfxASurface::ImageFormatARGB32 &&
|
||||
sourceSurface->Format() != gfxASurface::ImageFormatRGB24)
|
||||
{
|
||||
|
@ -85,6 +85,7 @@ protected:
|
||||
nsRefPtr<gfxASurface> mSurface;
|
||||
nsRefPtr<GLContext> mGLContext;
|
||||
nsRefPtr<IDirect3DTexture9> mTexture;
|
||||
RefPtr<gfx::DrawTarget> mDrawTarget;
|
||||
|
||||
PRUint32 mCanvasFramebuffer;
|
||||
|
||||
|
@ -58,6 +58,7 @@ LOCAL_INCLUDES += \
|
||||
-I$(srcdir)/src/core \
|
||||
-I$(srcdir)/include/images \
|
||||
-I$(srcdir)/include/utils/mac \
|
||||
-I$(srcdir)/include/utils/win \
|
||||
-I$(srcdir)/include/views \
|
||||
-I$(srcdir)/include/effects \
|
||||
$(NULL)
|
||||
@ -172,7 +173,6 @@ EXPORTS_skia = \
|
||||
include/effects/SkLayerDrawLooper.h \
|
||||
include/effects/SkLayerRasterizer.h \
|
||||
include/effects/SkDashPathEffect.h \
|
||||
include/ports/SkTypeface_mac.h \
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -DUSE_SKIA
|
||||
@ -230,7 +230,6 @@ CPPSRCS = \
|
||||
SkGlyphCache.cpp \
|
||||
SkGraphics.cpp \
|
||||
SkLineClipper.cpp \
|
||||
SkMMapStream.cpp \
|
||||
SkMallocPixelRef.cpp \
|
||||
SkMask.cpp \
|
||||
SkMaskFilter.cpp \
|
||||
@ -286,7 +285,6 @@ CPPSRCS = \
|
||||
SkGlobals_global.cpp \
|
||||
SkOSFile_stdio.cpp \
|
||||
SkThread_none.cpp \
|
||||
SkTime_Unix.cpp \
|
||||
SkGradientShader.cpp \
|
||||
SkBitmapCache.cpp \
|
||||
SkBlurDrawLooper.cpp \
|
||||
@ -308,6 +306,7 @@ CPPSRCS += \
|
||||
SkBlitRow_opts_SSE2.cpp \
|
||||
SkUtils_opts_SSE2.cpp \
|
||||
opts_check_SSE2.cpp \
|
||||
SkTime_Unix.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
@ -319,10 +318,27 @@ CPPSRCS += \
|
||||
SkFontHost_android.cpp \
|
||||
SkFontHost_gamma.cpp \
|
||||
SkUtils_opts_none.cpp \
|
||||
SkMMapStream.cpp \
|
||||
SkTime_Unix.cpp \
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -DSK_BUILD_FOR_ANDROID_NDK
|
||||
OS_CXXFLAGS += $(CAIRO_FT_CFLAGS)
|
||||
endif
|
||||
|
||||
ifeq (windows,$(MOZ_WIDGET_TOOLKIT))
|
||||
EXPORTS_skia += \
|
||||
include/config/sk_stdint.h \
|
||||
include/ports/SkTypeface_win.h \
|
||||
$(NULL)
|
||||
CPPSRCS += \
|
||||
SkFontHost_win.cpp \
|
||||
SkTime_win.cpp \
|
||||
SkBitmapProcState_opts_SSE2.cpp \
|
||||
SkBlitRow_opts_SSE2.cpp \
|
||||
SkUtils_opts_SSE2.cpp \
|
||||
opts_check_SSE2.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -59,6 +59,7 @@
|
||||
#define SK_RESTRICT __restrict
|
||||
#endif
|
||||
#include "sk_stdint.h"
|
||||
#define SK_IGNORE_STDINT_DOT_H
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -151,6 +151,11 @@ EXPORTS += \
|
||||
WGLLibrary.h \
|
||||
gfxDWriteFonts.h \
|
||||
gfxD2DSurface.h \
|
||||
gfxGDIFont.h \
|
||||
gfxGDIFontList.h \
|
||||
gfxPlatformFontList.h \
|
||||
gfxAtoms.h \
|
||||
gfxAtomList.h \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
|
@ -482,6 +482,11 @@ gfxWindowsPlatform::CreateOffscreenDrawTarget(const IntSize& aSize, SurfaceForma
|
||||
return Factory::CreateDrawTarget(BACKEND_DIRECT2D, aSize, aFormat);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Preferences::GetBool("gfx.canvas.azure.prefer-skia", false)) {
|
||||
return Factory::CreateDrawTarget(BACKEND_SKIA, aSize, aFormat);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -500,7 +505,13 @@ gfxWindowsPlatform::GetScaledFontForFont(gfxFont *aFont)
|
||||
return scaledFont;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
NativeFont nativeFont;
|
||||
nativeFont.mType = NATIVE_FONT_GDI_FONT_FACE;
|
||||
nativeFont.mFont = aFont;
|
||||
RefPtr<ScaledFont> scaledFont =
|
||||
Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
|
||||
|
||||
return scaledFont;
|
||||
}
|
||||
|
||||
already_AddRefed<gfxASurface>
|
||||
|
@ -362,7 +362,7 @@ ifdef HAVE_CLOCK_MONOTONIC
|
||||
EXTRA_DSO_LDOPTS += $(REALTIME_LIBS)
|
||||
endif
|
||||
|
||||
ifeq (,$(filter-out cocoa android,$(MOZ_WIDGET_TOOLKIT)))
|
||||
ifeq (,$(filter-out cocoa android windows,$(MOZ_WIDGET_TOOLKIT)))
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_SKIA_LIBS)
|
||||
endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user