mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1003707 - Pass surfaces sizes in to CreateSourceSurfaceFromNativeSurface instead of trying to extract it from cairo. r=Bas
This commit is contained in:
parent
a203d88ce4
commit
b4ecb7164e
@ -60,6 +60,7 @@ class FilterNode;
|
|||||||
struct NativeSurface {
|
struct NativeSurface {
|
||||||
NativeSurfaceType mType;
|
NativeSurfaceType mType;
|
||||||
SurfaceFormat mFormat;
|
SurfaceFormat mFormat;
|
||||||
|
gfx::IntSize mSize;
|
||||||
void *mSurface;
|
void *mSurface;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1034,10 +1035,6 @@ public:
|
|||||||
|
|
||||||
static TemporaryRef<DrawTarget> CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat = nullptr);
|
static TemporaryRef<DrawTarget> CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat = nullptr);
|
||||||
|
|
||||||
static TemporaryRef<SourceSurface>
|
|
||||||
CreateSourceSurfaceForCairoSurface(cairo_surface_t* aSurface,
|
|
||||||
SurfaceFormat aFormat);
|
|
||||||
|
|
||||||
static TemporaryRef<DrawTarget>
|
static TemporaryRef<DrawTarget>
|
||||||
CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat);
|
CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat);
|
||||||
|
|
||||||
|
@ -81,70 +81,6 @@ private:
|
|||||||
|
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
static bool
|
|
||||||
GetCairoSurfaceSize(cairo_surface_t* surface, IntSize& size)
|
|
||||||
{
|
|
||||||
switch (cairo_surface_get_type(surface))
|
|
||||||
{
|
|
||||||
case CAIRO_SURFACE_TYPE_IMAGE:
|
|
||||||
{
|
|
||||||
size.width = cairo_image_surface_get_width(surface);
|
|
||||||
size.height = cairo_image_surface_get_height(surface);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CAIRO_HAS_XLIB_SURFACE
|
|
||||||
case CAIRO_SURFACE_TYPE_XLIB:
|
|
||||||
{
|
|
||||||
size.width = cairo_xlib_surface_get_width(surface);
|
|
||||||
size.height = cairo_xlib_surface_get_height(surface);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CAIRO_HAS_QUARTZ_SURFACE
|
|
||||||
case CAIRO_SURFACE_TYPE_QUARTZ:
|
|
||||||
{
|
|
||||||
CGContextRef cgc = cairo_quartz_surface_get_cg_context(surface);
|
|
||||||
|
|
||||||
// It's valid to call these CGBitmapContext functions on non-bitmap
|
|
||||||
// contexts; they'll just return 0 in that case.
|
|
||||||
size.width = CGBitmapContextGetWidth(cgc);
|
|
||||||
size.height = CGBitmapContextGetHeight(cgc);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef CAIRO_HAS_WIN32_SURFACE
|
|
||||||
#ifdef MOZ2D_HAS_MOZ_CAIRO
|
|
||||||
case CAIRO_SURFACE_TYPE_WIN32:
|
|
||||||
case CAIRO_SURFACE_TYPE_WIN32_PRINTING:
|
|
||||||
{
|
|
||||||
size.width = cairo_win32_surface_get_width(surface);
|
|
||||||
size.height = cairo_win32_surface_get_height(surface);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
case CAIRO_SURFACE_TYPE_WIN32:
|
|
||||||
{
|
|
||||||
cairo_surface_t *img = cairo_win32_surface_get_image(surface);
|
|
||||||
|
|
||||||
if (!img) {
|
|
||||||
// XXX - fix me
|
|
||||||
MOZ_ASSERT(false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
size.width = cairo_image_surface_get_width(img);
|
|
||||||
size.height = cairo_image_surface_get_height(img);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
SupportsSelfCopy(cairo_surface_t* surface)
|
SupportsSelfCopy(cairo_surface_t* surface)
|
||||||
{
|
{
|
||||||
@ -1131,26 +1067,14 @@ TemporaryRef<SourceSurface>
|
|||||||
DrawTargetCairo::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
|
DrawTargetCairo::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
|
||||||
{
|
{
|
||||||
if (aSurface.mType == NativeSurfaceType::CAIRO_SURFACE) {
|
if (aSurface.mType == NativeSurfaceType::CAIRO_SURFACE) {
|
||||||
IntSize size;
|
if (aSurface.mSize.width <= 0 ||
|
||||||
cairo_surface_t* surf = static_cast<cairo_surface_t*>(aSurface.mSurface);
|
aSurface.mSize.height <= 0) {
|
||||||
if (GetCairoSurfaceSize(surf, size)) {
|
gfxWarning() << "Can't create a SourceSurface without a valid size";
|
||||||
RefPtr<SourceSurfaceCairo> source =
|
return nullptr;
|
||||||
new SourceSurfaceCairo(surf, size, aSurface.mFormat);
|
|
||||||
return source;
|
|
||||||
}
|
}
|
||||||
}
|
cairo_surface_t* surf = static_cast<cairo_surface_t*>(aSurface.mSurface);
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
TemporaryRef<SourceSurface>
|
|
||||||
DrawTargetCairo::CreateSourceSurfaceForCairoSurface(cairo_surface_t *aSurface,
|
|
||||||
SurfaceFormat aFormat)
|
|
||||||
{
|
|
||||||
IntSize size;
|
|
||||||
if (GetCairoSurfaceSize(aSurface, size)) {
|
|
||||||
RefPtr<SourceSurfaceCairo> source =
|
RefPtr<SourceSurfaceCairo> source =
|
||||||
new SourceSurfaceCairo(aSurface, size, aFormat);
|
new SourceSurfaceCairo(surf, aSurface.mSize, aSurface.mFormat);
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,10 +169,6 @@ public:
|
|||||||
|
|
||||||
static cairo_surface_t *GetDummySurface();
|
static cairo_surface_t *GetDummySurface();
|
||||||
|
|
||||||
static TemporaryRef<SourceSurface>
|
|
||||||
CreateSourceSurfaceForCairoSurface(cairo_surface_t* aSurface,
|
|
||||||
SurfaceFormat aFormat);
|
|
||||||
|
|
||||||
private: // methods
|
private: // methods
|
||||||
// Init cairo surface without doing a cairo_surface_reference() call.
|
// Init cairo surface without doing a cairo_surface_reference() call.
|
||||||
bool InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat = nullptr);
|
bool InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat = nullptr);
|
||||||
|
@ -637,18 +637,6 @@ Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSiz
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
TemporaryRef<SourceSurface>
|
|
||||||
Factory::CreateSourceSurfaceForCairoSurface(cairo_surface_t* aSurface,
|
|
||||||
SurfaceFormat aFormat)
|
|
||||||
{
|
|
||||||
RefPtr<SourceSurface> retVal;
|
|
||||||
|
|
||||||
#ifdef USE_CAIRO
|
|
||||||
retVal = DrawTargetCairo::CreateSourceSurfaceForCairoSurface(aSurface, aFormat);
|
|
||||||
#endif
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
TemporaryRef<DrawTarget>
|
TemporaryRef<DrawTarget>
|
||||||
Factory::CreateDrawTargetForCairoCGContext(CGContextRef cg, const IntSize& aSize)
|
Factory::CreateDrawTargetForCairoCGContext(CGContextRef cg, const IntSize& aSize)
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
|
|
||||||
virtual TextureSourceBasic* AsSourceBasic() MOZ_OVERRIDE { return this; }
|
virtual TextureSourceBasic* AsSourceBasic() MOZ_OVERRIDE { return this; }
|
||||||
|
|
||||||
virtual gfx::SourceSurface* GetSurface() MOZ_OVERRIDE { return mSurface; }
|
virtual gfx::SourceSurface* GetSurface(DrawTarget* aTarget) MOZ_OVERRIDE { return mSurface; }
|
||||||
|
|
||||||
SurfaceFormat GetFormat() const MOZ_OVERRIDE
|
SurfaceFormat GetFormat() const MOZ_OVERRIDE
|
||||||
{
|
{
|
||||||
@ -293,7 +293,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
|
|||||||
Matrix maskTransform;
|
Matrix maskTransform;
|
||||||
if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) {
|
if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) {
|
||||||
EffectMask *effectMask = static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EffectTypes::MASK].get());
|
EffectMask *effectMask = static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EffectTypes::MASK].get());
|
||||||
sourceMask = effectMask->mMaskTexture->AsSourceBasic()->GetSurface();
|
sourceMask = effectMask->mMaskTexture->AsSourceBasic()->GetSurface(dest);
|
||||||
MOZ_ASSERT(effectMask->mMaskTransform.Is2D(), "How did we end up with a 3D transform here?!");
|
MOZ_ASSERT(effectMask->mMaskTransform.Is2D(), "How did we end up with a 3D transform here?!");
|
||||||
MOZ_ASSERT(!effectMask->mIs3D);
|
MOZ_ASSERT(!effectMask->mIs3D);
|
||||||
maskTransform = effectMask->mMaskTransform.As2D();
|
maskTransform = effectMask->mMaskTransform.As2D();
|
||||||
@ -315,7 +315,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
|
|||||||
TextureSourceBasic* source = texturedEffect->mTexture->AsSourceBasic();
|
TextureSourceBasic* source = texturedEffect->mTexture->AsSourceBasic();
|
||||||
|
|
||||||
DrawSurfaceWithTextureCoords(dest, aRect,
|
DrawSurfaceWithTextureCoords(dest, aRect,
|
||||||
source->GetSurface(),
|
source->GetSurface(dest),
|
||||||
texturedEffect->mTextureCoords,
|
texturedEffect->mTextureCoords,
|
||||||
texturedEffect->mFilter,
|
texturedEffect->mFilter,
|
||||||
aOpacity, sourceMask, &maskTransform);
|
aOpacity, sourceMask, &maskTransform);
|
||||||
|
@ -46,7 +46,7 @@ MacIOSurfaceTextureHostBasic::MacIOSurfaceTextureHostBasic(
|
|||||||
}
|
}
|
||||||
|
|
||||||
gfx::SourceSurface*
|
gfx::SourceSurface*
|
||||||
MacIOSurfaceTextureSourceBasic::GetSurface()
|
MacIOSurfaceTextureSourceBasic::GetSurface(gfx::DrawTarget* aTarget)
|
||||||
{
|
{
|
||||||
if (!mSourceSurface) {
|
if (!mSourceSurface) {
|
||||||
mSourceSurface = mSurface->GetAsSurface();
|
mSourceSurface = mSurface->GetAsSurface();
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
|
|
||||||
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
|
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
|
||||||
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
|
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
|
||||||
virtual gfx::SourceSurface* GetSurface() MOZ_OVERRIDE;
|
virtual gfx::SourceSurface* GetSurface(gfx::DrawTarget* aTarget) MOZ_OVERRIDE;
|
||||||
|
|
||||||
virtual void DeallocateDeviceData() MOZ_OVERRIDE { }
|
virtual void DeallocateDeviceData() MOZ_OVERRIDE { }
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class TextureSourceBasic
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~TextureSourceBasic() {}
|
virtual ~TextureSourceBasic() {}
|
||||||
virtual gfx::SourceSurface* GetSurface() = 0;
|
virtual gfx::SourceSurface* GetSurface(gfx::DrawTarget* aTarget) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace layers
|
} // namespace layers
|
||||||
|
@ -32,11 +32,15 @@ X11TextureSourceBasic::GetFormat() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
SourceSurface*
|
SourceSurface*
|
||||||
X11TextureSourceBasic::GetSurface()
|
X11TextureSourceBasic::GetSurface(DrawTarget* aTarget)
|
||||||
{
|
{
|
||||||
if (!mSourceSurface) {
|
if (!mSourceSurface) {
|
||||||
mSourceSurface =
|
NativeSurface surf;
|
||||||
Factory::CreateSourceSurfaceForCairoSurface(mSurface->CairoSurface(), GetFormat());
|
surf.mFormat = GetFormat();
|
||||||
|
surf.mType = NativeSurfaceType::CAIRO_SURFACE;
|
||||||
|
surf.mSurface = mSurface->CairoSurface();
|
||||||
|
surf.mSize = GetSize();
|
||||||
|
mSourceSurface = aTarget->CreateSourceSurfaceFromNativeSurface(surf);
|
||||||
}
|
}
|
||||||
return mSourceSurface;
|
return mSourceSurface;
|
||||||
}
|
}
|
||||||
@ -62,4 +66,4 @@ X11TextureSourceBasic::ContentTypeToSurfaceFormat(gfxContentType aType)
|
|||||||
default:
|
default:
|
||||||
return SurfaceFormat::UNKNOWN;
|
return SurfaceFormat::UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public:
|
|||||||
|
|
||||||
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
|
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
|
||||||
|
|
||||||
virtual gfx::SourceSurface* GetSurface() MOZ_OVERRIDE;
|
virtual gfx::SourceSurface* GetSurface(gfx::DrawTarget* aTarget) MOZ_OVERRIDE;
|
||||||
|
|
||||||
virtual void DeallocateDeviceData() MOZ_OVERRIDE { }
|
virtual void DeallocateDeviceData() MOZ_OVERRIDE { }
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "mozilla/MemoryReporting.h"
|
#include "mozilla/MemoryReporting.h"
|
||||||
#include "nsISupportsImpl.h"
|
#include "nsISupportsImpl.h"
|
||||||
#include "mozilla/gfx/2D.h"
|
#include "mozilla/gfx/2D.h"
|
||||||
|
#include "gfx2DGlue.h"
|
||||||
|
|
||||||
#include "gfxASurface.h"
|
#include "gfxASurface.h"
|
||||||
#include "gfxContext.h"
|
#include "gfxContext.h"
|
||||||
|
@ -739,6 +739,7 @@ gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurfa
|
|||||||
surf.mFormat = format;
|
surf.mFormat = format;
|
||||||
surf.mType = NativeSurfaceType::D3D10_TEXTURE;
|
surf.mType = NativeSurfaceType::D3D10_TEXTURE;
|
||||||
surf.mSurface = static_cast<gfxD2DSurface*>(aSurface)->GetTexture();
|
surf.mSurface = static_cast<gfxD2DSurface*>(aSurface)->GetTexture();
|
||||||
|
surf.mSize = ToIntSize(aSurface->GetSize());
|
||||||
mozilla::gfx::DrawTarget *dt = static_cast<mozilla::gfx::DrawTarget*>(aSurface->GetData(&kDrawTarget));
|
mozilla::gfx::DrawTarget *dt = static_cast<mozilla::gfx::DrawTarget*>(aSurface->GetData(&kDrawTarget));
|
||||||
if (dt) {
|
if (dt) {
|
||||||
dt->Flush();
|
dt->Flush();
|
||||||
@ -753,6 +754,7 @@ gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurfa
|
|||||||
surf.mFormat = format;
|
surf.mFormat = format;
|
||||||
surf.mType = NativeSurfaceType::CAIRO_SURFACE;
|
surf.mType = NativeSurfaceType::CAIRO_SURFACE;
|
||||||
surf.mSurface = aSurface->CairoSurface();
|
surf.mSurface = aSurface->CairoSurface();
|
||||||
|
surf.mSize = ToIntSize(aSurface->GetSize());
|
||||||
srcBuffer = aTarget->CreateSourceSurfaceFromNativeSurface(surf);
|
srcBuffer = aTarget->CreateSourceSurfaceFromNativeSurface(surf);
|
||||||
|
|
||||||
if (srcBuffer) {
|
if (srcBuffer) {
|
||||||
|
@ -575,18 +575,19 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, nsIntSize size,
|
|||||||
cairo_surface_destroy(tempXlibSurface);
|
cairo_surface_destroy(tempXlibSurface);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SurfaceFormat moz2DFormat =
|
SurfaceFormat moz2DFormat =
|
||||||
cairo_surface_get_content(tempXlibSurface) == CAIRO_CONTENT_COLOR ?
|
cairo_surface_get_content(tempXlibSurface) == CAIRO_CONTENT_COLOR ?
|
||||||
SurfaceFormat::B8G8R8A8 : SurfaceFormat::B8G8R8X8;
|
SurfaceFormat::B8G8R8A8 : SurfaceFormat::B8G8R8X8;
|
||||||
if (method != eAlphaExtraction) {
|
if (method != eAlphaExtraction) {
|
||||||
if (drawTarget) {
|
if (drawTarget) {
|
||||||
// It doesn't matter if moz2DFormat doesn't exactly match the format
|
NativeSurface native;
|
||||||
// of tempXlibSurface, since this DrawTarget just wraps the cairo
|
native.mFormat = moz2DFormat;
|
||||||
// drawing.
|
native.mType = NativeSurfaceType::CAIRO_SURFACE;
|
||||||
|
native.mSurface = tempXlibSurface;
|
||||||
|
native.mSize = ToIntSize(size);
|
||||||
RefPtr<SourceSurface> sourceSurface =
|
RefPtr<SourceSurface> sourceSurface =
|
||||||
Factory::CreateSourceSurfaceForCairoSurface(tempXlibSurface,
|
drawTarget->CreateSourceSurfaceFromNativeSurface(native);
|
||||||
moz2DFormat);
|
|
||||||
if (sourceSurface) {
|
if (sourceSurface) {
|
||||||
drawTarget->DrawSurface(sourceSurface,
|
drawTarget->DrawSurface(sourceSurface,
|
||||||
Rect(offset.x, offset.y, size.width, size.height),
|
Rect(offset.x, offset.y, size.width, size.height),
|
||||||
@ -622,9 +623,13 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, nsIntSize size,
|
|||||||
|
|
||||||
gfxASurface* paintSurface = blackImage;
|
gfxASurface* paintSurface = blackImage;
|
||||||
if (drawTarget) {
|
if (drawTarget) {
|
||||||
|
NativeSurface native;
|
||||||
|
native.mFormat = moz2DFormat;
|
||||||
|
native.mType = NativeSurfaceType::CAIRO_SURFACE;
|
||||||
|
native.mSurface = tempXlibSurface;
|
||||||
|
native.mSize = ToIntSize(size);
|
||||||
RefPtr<SourceSurface> sourceSurface =
|
RefPtr<SourceSurface> sourceSurface =
|
||||||
Factory::CreateSourceSurfaceForCairoSurface(paintSurface->CairoSurface(),
|
drawTarget->CreateSourceSurfaceFromNativeSurface(native);
|
||||||
moz2DFormat);
|
|
||||||
if (sourceSurface) {
|
if (sourceSurface) {
|
||||||
drawTarget->DrawSurface(sourceSurface,
|
drawTarget->DrawSurface(sourceSurface,
|
||||||
Rect(offset.x, offset.y, size.width, size.height),
|
Rect(offset.x, offset.y, size.width, size.height),
|
||||||
|
Loading…
Reference in New Issue
Block a user