зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1231881 - Remove NativeSurfaceType::CAIRO_SURFACE. r=bas.
We have both NativeSurfaceType::CAIRO_CONTEXT and NativeSurfaceType::CAIRO_SURFACE. They both refer to DrawTargets with Cairo backends. The only reason for having both is so you can call GetNativeSurface() and get either the |cairo_t*| or the underlying |cairo_surface_t*|. I argue that this convenience confuses things more than it helps. This patch removes CAIRO_SURFACE, and adds explicit cairo_get_target() calls where necessary. --HG-- extra : rebase_source : 6f1701a8131d854c7f623272182029847876754e
This commit is contained in:
Родитель
8d672d003f
Коммит
4b651d870f
|
@ -1715,7 +1715,7 @@ DrawTargetCairo::OptimizeSourceSurface(SourceSurface *aSurface) const
|
|||
already_AddRefed<SourceSurface>
|
||||
DrawTargetCairo::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
|
||||
{
|
||||
if (aSurface.mType == NativeSurfaceType::CAIRO_SURFACE) {
|
||||
if (aSurface.mType == NativeSurfaceType::CAIRO_CONTEXT) {
|
||||
if (aSurface.mSize.width <= 0 ||
|
||||
aSurface.mSize.height <= 0) {
|
||||
gfxWarning() << "Can't create a SourceSurface without a valid size";
|
||||
|
@ -1864,9 +1864,6 @@ DrawTargetCairo::Init(unsigned char* aData, const IntSize &aSize, int32_t aStrid
|
|||
void *
|
||||
DrawTargetCairo::GetNativeSurface(NativeSurfaceType aType)
|
||||
{
|
||||
if (aType == NativeSurfaceType::CAIRO_SURFACE) {
|
||||
return cairo_get_group_target(mContext);
|
||||
}
|
||||
if (aType == NativeSurfaceType::CAIRO_CONTEXT) {
|
||||
return mContext;
|
||||
}
|
||||
|
|
|
@ -763,7 +763,7 @@ DrawTargetSkia::OptimizeSourceSurface(SourceSurface *aSurface) const
|
|||
already_AddRefed<SourceSurface>
|
||||
DrawTargetSkia::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
|
||||
{
|
||||
if (aSurface.mType == NativeSurfaceType::CAIRO_SURFACE) {
|
||||
if (aSurface.mType == NativeSurfaceType::CAIRO_CONTEXT) {
|
||||
if (aSurface.mSize.width <= 0 ||
|
||||
aSurface.mSize.height <= 0) {
|
||||
gfxWarning() << "Can't create a SourceSurface without a valid size";
|
||||
|
|
|
@ -143,7 +143,6 @@ enum class FontType : int8_t {
|
|||
|
||||
enum class NativeSurfaceType : int8_t {
|
||||
D3D10_TEXTURE,
|
||||
CAIRO_SURFACE,
|
||||
CAIRO_CONTEXT,
|
||||
CGCONTEXT,
|
||||
CGCONTEXT_ACCELERATED,
|
||||
|
|
|
@ -37,7 +37,7 @@ X11TextureSourceBasic::GetSurface(DrawTarget* aTarget)
|
|||
if (!mSourceSurface) {
|
||||
NativeSurface surf;
|
||||
surf.mFormat = GetFormat();
|
||||
surf.mType = NativeSurfaceType::CAIRO_SURFACE;
|
||||
surf.mType = NativeSurfaceType::CAIRO_CONTEXT;
|
||||
surf.mSurface = mSurface->CairoSurface();
|
||||
surf.mSize = GetSize();
|
||||
mSourceSurface = aTarget->CreateSourceSurfaceFromNativeSurface(surf);
|
||||
|
|
|
@ -112,16 +112,19 @@ already_AddRefed<gfxASurface>
|
|||
gfxContext::CurrentSurface(gfxFloat *dx, gfxFloat *dy)
|
||||
{
|
||||
if (mDT->GetBackendType() == BackendType::CAIRO) {
|
||||
cairo_surface_t *s =
|
||||
(cairo_surface_t*)mDT->GetNativeSurface(NativeSurfaceType::CAIRO_SURFACE);
|
||||
if (s) {
|
||||
if (dx && dy) {
|
||||
double sdx, sdy;
|
||||
cairo_surface_get_device_offset(s, &sdx, &sdy);
|
||||
*dx = -CurrentState().deviceOffset.x + sdx;
|
||||
*dy = -CurrentState().deviceOffset.y + sdy;
|
||||
cairo_t* ctx = static_cast<cairo_t*>
|
||||
(mDT->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT));
|
||||
if (ctx) {
|
||||
cairo_surface_t* s = cairo_get_group_target(ctx);
|
||||
if (s) {
|
||||
if (dx && dy) {
|
||||
double sdx, sdy;
|
||||
cairo_surface_get_device_offset(s, &sdx, &sdy);
|
||||
*dx = -CurrentState().deviceOffset.x + sdx;
|
||||
*dy = -CurrentState().deviceOffset.y + sdy;
|
||||
}
|
||||
return gfxASurface::Wrap(s);
|
||||
}
|
||||
return gfxASurface::Wrap(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -900,7 +900,7 @@ gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurfa
|
|||
// slowdown).
|
||||
NativeSurface surf;
|
||||
surf.mFormat = format;
|
||||
surf.mType = NativeSurfaceType::CAIRO_SURFACE;
|
||||
surf.mType = NativeSurfaceType::CAIRO_CONTEXT;
|
||||
surf.mSurface = aSurface->CairoSurface();
|
||||
surf.mSize = aSurface->GetSize();
|
||||
// We return here regardless of whether CreateSourceSurfaceFromNativeSurface
|
||||
|
@ -958,7 +958,7 @@ gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurfa
|
|||
// very slow.
|
||||
NativeSurface surf;
|
||||
surf.mFormat = format;
|
||||
surf.mType = NativeSurfaceType::CAIRO_SURFACE;
|
||||
surf.mType = NativeSurfaceType::CAIRO_CONTEXT;
|
||||
surf.mSurface = aSurface->CairoSurface();
|
||||
surf.mSize = aSurface->GetSize();
|
||||
RefPtr<DrawTarget> drawTarget =
|
||||
|
|
|
@ -87,19 +87,20 @@ DCFromDrawTarget::DCFromDrawTarget(DrawTarget& aDrawTarget)
|
|||
{
|
||||
mDC = nullptr;
|
||||
if (aDrawTarget.GetBackendType() == BackendType::CAIRO) {
|
||||
cairo_surface_t *surf = (cairo_surface_t*)
|
||||
aDrawTarget.GetNativeSurface(NativeSurfaceType::CAIRO_SURFACE);
|
||||
if (surf) {
|
||||
cairo_surface_type_t surfaceType = cairo_surface_get_type(surf);
|
||||
if (surfaceType == CAIRO_SURFACE_TYPE_WIN32 ||
|
||||
surfaceType == CAIRO_SURFACE_TYPE_WIN32_PRINTING) {
|
||||
mDC = cairo_win32_surface_get_dc(surf);
|
||||
mNeedsRelease = false;
|
||||
SaveDC(mDC);
|
||||
cairo_t* ctx = (cairo_t*)
|
||||
aDrawTarget.GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT);
|
||||
cairo_scaled_font_t* scaled = cairo_get_scaled_font(ctx);
|
||||
cairo_win32_scaled_font_select_font(scaled, mDC);
|
||||
cairo_t* ctx = static_cast<cairo_t*>
|
||||
(aDrawTarget.GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT));
|
||||
if (ctx) {
|
||||
cairo_surface_t* surf = cairo_get_group_target(ctx);
|
||||
if (surf) {
|
||||
cairo_surface_type_t surfaceType = cairo_surface_get_type(surf);
|
||||
if (surfaceType == CAIRO_SURFACE_TYPE_WIN32 ||
|
||||
surfaceType == CAIRO_SURFACE_TYPE_WIN32_PRINTING) {
|
||||
mDC = cairo_win32_surface_get_dc(surf);
|
||||
mNeedsRelease = false;
|
||||
SaveDC(mDC);
|
||||
cairo_scaled_font_t* scaled = cairo_get_scaled_font(ctx);
|
||||
cairo_win32_scaled_font_select_font(scaled, mDC);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -530,9 +530,12 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size,
|
|||
DrawingMethod method;
|
||||
Matrix dtTransform = drawTarget->GetTransform();
|
||||
gfxPoint deviceTranslation = gfxPoint(dtTransform._31, dtTransform._32);
|
||||
cairo_surface_t* cairoTarget = static_cast<cairo_surface_t*>
|
||||
(drawTarget->GetNativeSurface(NativeSurfaceType::CAIRO_SURFACE));
|
||||
cairo_t* cairo = static_cast<cairo_t*>
|
||||
(drawTarget->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT));
|
||||
if (!cairo)
|
||||
return;
|
||||
|
||||
cairo_surface_t* cairoTarget = cairo_get_group_target(cairo);
|
||||
cairo_surface_t* tempXlibSurface =
|
||||
CreateTempXlibSurface(cairoTarget, drawTarget, size,
|
||||
canDrawOverBackground, flags, screen, visual,
|
||||
|
@ -573,7 +576,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size,
|
|||
if (drawTarget) {
|
||||
NativeSurface native;
|
||||
native.mFormat = moz2DFormat;
|
||||
native.mType = NativeSurfaceType::CAIRO_SURFACE;
|
||||
native.mType = NativeSurfaceType::CAIRO_CONTEXT;
|
||||
native.mSurface = tempXlibSurface;
|
||||
native.mSize = size;
|
||||
RefPtr<SourceSurface> sourceSurface =
|
||||
|
@ -615,7 +618,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size,
|
|||
if (drawTarget) {
|
||||
NativeSurface native;
|
||||
native.mFormat = moz2DFormat;
|
||||
native.mType = NativeSurfaceType::CAIRO_SURFACE;
|
||||
native.mType = NativeSurfaceType::CAIRO_CONTEXT;
|
||||
native.mSurface = paintSurface->CairoSurface();
|
||||
native.mSize = size;
|
||||
RefPtr<SourceSurface> sourceSurface =
|
||||
|
|
Загрузка…
Ссылка в новой задаче