Bug 907011 - Expose cairo objects from gfxContext when using Azure/cairo. r=Bas

This commit is contained in:
Matt Woodrow 2013-08-23 16:53:53 +12:00
Родитель 6cd20c1e43
Коммит 1bfd3d4370
4 изменённых файлов: 39 добавлений и 2 удалений

Просмотреть файл

@ -1026,6 +1026,9 @@ DrawTargetCairo::GetNativeSurface(NativeSurfaceType aType)
if (aType == NATIVE_SURFACE_CAIRO_SURFACE) {
return cairo_get_target(mContext);
}
if (aType == NATIVE_SURFACE_CAIRO_CONTEXT) {
return mContext;
}
return nullptr;
}

Просмотреть файл

@ -69,6 +69,7 @@ enum NativeSurfaceType
{
NATIVE_SURFACE_D3D10_TEXTURE,
NATIVE_SURFACE_CAIRO_SURFACE,
NATIVE_SURFACE_CAIRO_CONTEXT,
NATIVE_SURFACE_CGCONTEXT,
NATIVE_SURFACE_CGCONTEXT_ACCELERATED
};

Просмотреть файл

@ -138,7 +138,19 @@ gfxContext::~gfxContext()
gfxASurface *
gfxContext::OriginalSurface()
{
return mSurface;
if (mCairo || mSurface) {
return mSurface;
}
if (mOriginalDT && mOriginalDT->GetType() == BACKEND_CAIRO) {
cairo_surface_t *s =
(cairo_surface_t*)mOriginalDT->GetNativeSurface(NATIVE_SURFACE_CAIRO_SURFACE);
if (s) {
mSurface = gfxASurface::Wrap(s);
return mSurface;
}
}
return nullptr;
}
already_AddRefed<gfxASurface>
@ -157,6 +169,16 @@ gfxContext::CurrentSurface(gfxFloat *dx, gfxFloat *dy)
cairo_surface_get_device_offset(s, dx, dy);
return gfxASurface::Wrap(s);
} else {
if (mDT->GetType() == BACKEND_CAIRO) {
cairo_surface_t *s =
(cairo_surface_t*)mDT->GetNativeSurface(NATIVE_SURFACE_CAIRO_SURFACE);
if (s) {
if (dx && dy)
cairo_surface_get_device_offset(s, dx, dy);
return gfxASurface::Wrap(s);
}
}
if (dx && dy) {
*dx = *dy = 0;
}
@ -172,6 +194,14 @@ gfxContext::GetCairo()
return mCairo;
}
if (mDT->GetType() == BACKEND_CAIRO) {
cairo_t *ctx =
(cairo_t*)mOriginalDT->GetNativeSurface(NATIVE_SURFACE_CAIRO_CONTEXT);
if (ctx) {
return ctx;
}
}
if (mRefCairo) {
// Set transform!
return mRefCairo;

Просмотреть файл

@ -11,6 +11,7 @@
#include "gfxWindowsSurface.h"
#include "gfxAlphaRecovery.h"
#include "gfxPattern.h"
#include "mozilla/gfx/2D.h"
enum {
RENDER_STATE_INIT,
@ -182,7 +183,9 @@ gfxWindowsNativeDrawing::BeginNativeDrawing()
bool
gfxWindowsNativeDrawing::IsDoublePass()
{
if (!mContext->IsCairo()) {
if (!mContext->IsCairo() &&
(mContext->GetDrawTarget()->GetType() != mozilla::gfx::BACKEND_CAIRO ||
mContext->GetDrawTarget()->IsDualDrawTarget())) {
return true;
}