mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 922942 - Update BufferTextureClients using Azure. r=nical
This commit is contained in:
parent
3eddbec497
commit
8a32a82431
@ -1191,6 +1191,11 @@ DrawTargetCG::CopySurface(SourceSurface *aSurface,
|
||||
CGRect flippedRect = CGRectMake(aDestination.x, -(aDestination.y + aSourceRect.height),
|
||||
aSourceRect.width, aSourceRect.height);
|
||||
|
||||
// Quartz seems to copy A8 surfaces incorrectly if we don't initialize them
|
||||
// to transparent first.
|
||||
if (mFormat == FORMAT_A8) {
|
||||
CGContextClearRect(mCg, flippedRect);
|
||||
}
|
||||
CGContextDrawImage(mCg, flippedRect, image);
|
||||
|
||||
CGContextRestoreGState(mCg);
|
||||
|
@ -16,6 +16,8 @@
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
using namespace gfx;
|
||||
|
||||
// The Data is layed out as follows:
|
||||
//
|
||||
// +-------------------+ -++ --+ <-- ImageDataSerializerBase::mData pointer
|
||||
@ -36,11 +38,11 @@ struct SurfaceBufferInfo
|
||||
{
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
gfx::SurfaceFormat format;
|
||||
SurfaceFormat format;
|
||||
|
||||
static uint32_t GetOffset()
|
||||
{
|
||||
return gfx::GetAlignedStride<16>(sizeof(SurfaceBufferInfo));
|
||||
return GetAlignedStride<16>(sizeof(SurfaceBufferInfo));
|
||||
}
|
||||
};
|
||||
} // anonymous namespace
|
||||
@ -53,8 +55,8 @@ GetBufferInfo(uint8_t* aBuffer)
|
||||
|
||||
|
||||
void
|
||||
ImageDataSerializer::InitializeBufferInfo(gfx::IntSize aSize,
|
||||
gfx::SurfaceFormat aFormat)
|
||||
ImageDataSerializer::InitializeBufferInfo(IntSize aSize,
|
||||
SurfaceFormat aFormat)
|
||||
{
|
||||
SurfaceBufferInfo* info = GetBufferInfo(mData);
|
||||
info->width = aSize.width;
|
||||
@ -63,18 +65,18 @@ ImageDataSerializer::InitializeBufferInfo(gfx::IntSize aSize,
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
ComputeStride(gfx::SurfaceFormat aFormat, uint32_t aWidth)
|
||||
ComputeStride(SurfaceFormat aFormat, uint32_t aWidth)
|
||||
{
|
||||
return gfx::GetAlignedStride<4>(gfx::BytesPerPixel(aFormat) * aWidth);
|
||||
return GetAlignedStride<4>(BytesPerPixel(aFormat) * aWidth);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
ImageDataSerializer::ComputeMinBufferSize(gfx::IntSize aSize,
|
||||
gfx::SurfaceFormat aFormat)
|
||||
ImageDataSerializer::ComputeMinBufferSize(IntSize aSize,
|
||||
SurfaceFormat aFormat)
|
||||
{
|
||||
uint32_t bufsize = aSize.height * ComputeStride(aFormat, aSize.width);
|
||||
return SurfaceBufferInfo::GetOffset()
|
||||
+ gfx::GetAlignedStride<16>(bufsize);
|
||||
+ GetAlignedStride<16>(bufsize);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -91,15 +93,23 @@ ImageDataSerializerBase::GetData()
|
||||
return mData + SurfaceBufferInfo::GetOffset();
|
||||
}
|
||||
|
||||
gfx::IntSize
|
||||
uint32_t
|
||||
ImageDataSerializerBase::GetStride() const
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
SurfaceBufferInfo* info = GetBufferInfo(mData);
|
||||
return ComputeStride(GetFormat(), info->width);
|
||||
}
|
||||
|
||||
IntSize
|
||||
ImageDataSerializerBase::GetSize() const
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
SurfaceBufferInfo* info = GetBufferInfo(mData);
|
||||
return gfx::IntSize(info->width, info->height);
|
||||
return IntSize(info->width, info->height);
|
||||
}
|
||||
|
||||
gfx::SurfaceFormat
|
||||
SurfaceFormat
|
||||
ImageDataSerializerBase::GetFormat() const
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
@ -110,25 +120,31 @@ TemporaryRef<gfxImageSurface>
|
||||
ImageDataSerializerBase::GetAsThebesSurface()
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
SurfaceBufferInfo* info = GetBufferInfo(mData);
|
||||
uint32_t stride = ComputeStride(GetFormat(), info->width);
|
||||
gfxIntSize size(info->width, info->height);
|
||||
RefPtr<gfxImageSurface> surf =
|
||||
new gfxImageSurface(GetData(), size, stride,
|
||||
gfx::SurfaceFormatToImageFormat(GetFormat()));
|
||||
return surf.forget();
|
||||
IntSize size = GetSize();
|
||||
return new gfxImageSurface(GetData(),
|
||||
gfxIntSize(size.width, size.height),
|
||||
GetStride(),
|
||||
SurfaceFormatToImageFormat(GetFormat()));
|
||||
}
|
||||
|
||||
TemporaryRef<gfx::DataSourceSurface>
|
||||
TemporaryRef<DrawTarget>
|
||||
ImageDataSerializerBase::GetAsDrawTarget()
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
return gfxPlatform::GetPlatform()->CreateDrawTargetForData(GetData(),
|
||||
GetSize(),
|
||||
GetStride(),
|
||||
GetFormat());
|
||||
}
|
||||
|
||||
TemporaryRef<DataSourceSurface>
|
||||
ImageDataSerializerBase::GetAsSurface()
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
SurfaceBufferInfo* info = GetBufferInfo(mData);
|
||||
gfx::IntSize size(info->width, info->height);
|
||||
uint32_t stride = ComputeStride(GetFormat(), info->width);
|
||||
RefPtr<gfx::DataSourceSurface> surf =
|
||||
gfx::Factory::CreateWrappingDataSourceSurface(GetData(), stride, size, GetFormat());
|
||||
return surf.forget();
|
||||
return Factory::CreateWrappingDataSourceSurface(GetData(),
|
||||
GetStride(),
|
||||
GetSize(),
|
||||
GetFormat());
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
|
@ -19,6 +19,7 @@ class gfxImageSurface;
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
class DataSourceSurface;
|
||||
class DrawTarget;
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
||||
@ -35,8 +36,11 @@ public:
|
||||
gfx::SurfaceFormat GetFormat() const;
|
||||
TemporaryRef<gfx::DataSourceSurface> GetAsSurface();
|
||||
TemporaryRef<gfxImageSurface> GetAsThebesSurface();
|
||||
TemporaryRef<gfx::DrawTarget> GetAsDrawTarget();
|
||||
|
||||
protected:
|
||||
uint32_t GetStride() const;
|
||||
|
||||
ImageDataSerializerBase(uint8_t* aData)
|
||||
: mData(aData) {}
|
||||
uint8_t* mData;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING, etc
|
||||
#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc
|
||||
#include "ImageContainer.h" // for PlanarYCbCrImage, etc
|
||||
#include "mozilla/gfx/2D.h"
|
||||
|
||||
#ifdef MOZ_ANDROID_OMTC
|
||||
# include "gfxReusableImageSurfaceWrapper.h"
|
||||
@ -32,6 +33,7 @@
|
||||
#endif
|
||||
|
||||
using namespace mozilla::gl;
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
@ -259,15 +261,23 @@ BufferTextureClient::UpdateSurface(gfxASurface* aSurface)
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<gfxImageSurface> surf = serializer.GetAsThebesSurface();
|
||||
if (!surf) {
|
||||
return false;
|
||||
if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
|
||||
RefPtr<DrawTarget> dt = serializer.GetAsDrawTarget();
|
||||
RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface);
|
||||
|
||||
dt->CopySurface(source, IntRect(IntPoint(), serializer.GetSize()), IntPoint());
|
||||
} else {
|
||||
RefPtr<gfxImageSurface> surf = serializer.GetAsThebesSurface();
|
||||
if (!surf) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxContext> tmpCtx = new gfxContext(surf.get());
|
||||
tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
tmpCtx->DrawSurface(aSurface, gfxSize(serializer.GetSize().width,
|
||||
serializer.GetSize().height));
|
||||
}
|
||||
|
||||
nsRefPtr<gfxContext> tmpCtx = new gfxContext(surf.get());
|
||||
tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
tmpCtx->DrawSurface(aSurface, gfxSize(serializer.GetSize().width,
|
||||
serializer.GetSize().height));
|
||||
|
||||
if (TextureRequiresLocking(mFlags) && !ImplementsLocking()) {
|
||||
// We don't have support for proper locking yet, so we'll
|
||||
|
Loading…
Reference in New Issue
Block a user