Bug 1066280 - Fixes. - r=kamidphish,mattwoodrow
From 4e9f52ab105333e8b1120342e9583b2d833a4465 Mon Sep 17 00:00:00 2001 --- dom/canvas/WebGLContext.cpp | 10 +++++-- gfx/gl/GLContext.cpp | 20 -------------- gfx/gl/GLContext.h | 3 -- gfx/gl/GLReadTexImageHelper.cpp | 5 +++- gfx/gl/GLScreenBuffer.cpp | 13 +++++++-- gfx/gl/GLUploadHelpers.cpp | 27 ++++++++++++++++++ gfx/gl/SharedSurfaceGralloc.cpp | 14 ++++------ gfx/gl/SharedSurfaceGralloc.h | 10 +++++-- gfx/gl/SurfaceTypes.cpp | 2 ++ gfx/gl/SurfaceTypes.h | 1 + gfx/layers/client/CanvasClient.cpp | 44 ++++++++++++++++++------------ gfx/layers/client/CanvasClient.h | 8 +++--- gfx/layers/client/ClientCanvasLayer.cpp | 6 ++++ gfx/layers/client/ClientCanvasLayer.h | 2 +- gfx/layers/client/TextureClient.cpp | 11 ++++---- gfx/layers/client/TextureClient.h | 6 ++-- gfx/layers/composite/TextureHost.cpp | 15 +++++----- gfx/layers/composite/TextureHost.h | 10 +++---- gfx/layers/d3d10/CanvasLayerD3D10.cpp | 9 ++++-- gfx/layers/d3d9/CanvasLayerD3D9.cpp | 8 ++++-- gfx/layers/ipc/LayersSurfaces.ipdlh | 4 +-- gfx/layers/moz.build | 4 ++- gfx/layers/opengl/GrallocTextureClient.cpp | 26 +++++++++++++++++- gfx/layers/opengl/GrallocTextureClient.h | 3 ++ 24 files changed, 171 insertions(+), 90 deletions(-)
This commit is contained in:
@@ -661,6 +661,7 @@ CreateOffscreen(GLContext* gl,
|
|||||||
baseCaps.alpha = options.alpha;
|
baseCaps.alpha = options.alpha;
|
||||||
baseCaps.antialias = options.antialias;
|
baseCaps.antialias = options.antialias;
|
||||||
baseCaps.depth = options.depth;
|
baseCaps.depth = options.depth;
|
||||||
|
baseCaps.premultAlpha = options.premultipliedAlpha;
|
||||||
baseCaps.preserve = options.preserveDrawingBuffer;
|
baseCaps.preserve = options.preserveDrawingBuffer;
|
||||||
baseCaps.stencil = options.stencil;
|
baseCaps.stencil = options.stencil;
|
||||||
|
|
||||||
@@ -1421,10 +1422,15 @@ WebGLContext::PresentScreenBuffer()
|
|||||||
if (!mShouldPresent) {
|
if (!mShouldPresent) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
MOZ_ASSERT(!mBackbufferNeedsClear);
|
||||||
|
|
||||||
gl->MakeCurrent();
|
gl->MakeCurrent();
|
||||||
MOZ_ASSERT(!mBackbufferNeedsClear);
|
|
||||||
if (!gl->PublishFrame()) {
|
auto screen = gl->Screen();
|
||||||
|
MOZ_ASSERT(screen);
|
||||||
|
|
||||||
|
auto size = screen->Size();
|
||||||
|
if (!screen->PublishFrame(size)) {
|
||||||
ForceLoseContext();
|
ForceLoseContext();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1992,26 +1992,6 @@ GLContext::AssembleOffscreenFBs(const GLuint colorMSRB,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
GLContext::PublishFrame()
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(mScreen);
|
|
||||||
|
|
||||||
return mScreen->PublishFrame(OffscreenSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
SharedSurface*
|
|
||||||
GLContext::RequestFrame()
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(mScreen);
|
|
||||||
MOZ_CRASH("Not anymore!");
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GLContext::ClearSafely()
|
GLContext::ClearSafely()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3529,9 +3529,6 @@ public:
|
|||||||
return mScreen.get();
|
return mScreen.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PublishFrame();
|
|
||||||
SharedSurface* RequestFrame();
|
|
||||||
|
|
||||||
/* Clear to transparent black, with 0 depth and stencil,
|
/* Clear to transparent black, with 0 depth and stencil,
|
||||||
* while preserving current ClearColor etc. values.
|
* while preserving current ClearColor etc. values.
|
||||||
* Useful for resizing offscreen buffers.
|
* Useful for resizing offscreen buffers.
|
||||||
|
|||||||
@@ -192,8 +192,11 @@ GetActualReadFormats(GLContext* gl,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LOCAL_GL_BGRA: {
|
case LOCAL_GL_BGRA: {
|
||||||
if (destType == LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV)
|
if (destType == LOCAL_GL_UNSIGNED_BYTE ||
|
||||||
|
destType == LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV)
|
||||||
|
{
|
||||||
fallback = false;
|
fallback = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "GLScreenBuffer.h"
|
#include "GLScreenBuffer.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include "CompositorTypes.h"
|
||||||
#include "GLContext.h"
|
#include "GLContext.h"
|
||||||
#include "GLBlitHelper.h"
|
#include "GLBlitHelper.h"
|
||||||
#include "GLReadTexImageHelper.h"
|
#include "GLReadTexImageHelper.h"
|
||||||
@@ -43,11 +44,19 @@ GLScreenBuffer::Create(GLContext* gl,
|
|||||||
|
|
||||||
#ifdef MOZ_WIDGET_GONK
|
#ifdef MOZ_WIDGET_GONK
|
||||||
/* On B2G, we want a Gralloc factory, and we want one right at the start */
|
/* On B2G, we want a Gralloc factory, and we want one right at the start */
|
||||||
|
auto allocator = caps.surfaceAllocator;
|
||||||
if (!factory &&
|
if (!factory &&
|
||||||
caps.surfaceAllocator &&
|
allocator &&
|
||||||
XRE_GetProcessType() != GeckoProcessType_Default)
|
XRE_GetProcessType() != GeckoProcessType_Default)
|
||||||
{
|
{
|
||||||
factory = MakeUnique<SurfaceFactory_Gralloc>(gl, caps);
|
layers::TextureFlags flags = TextureFlags::DEALLOCATE_CLIENT |
|
||||||
|
TextureFlags::NEEDS_Y_FLIP;
|
||||||
|
if (!caps.premultAlpha) {
|
||||||
|
flags |= TextureFlags::NON_PREMULTIPLIED;
|
||||||
|
}
|
||||||
|
|
||||||
|
factory = MakeUnique<SurfaceFactory_Gralloc>(gl, caps, flags,
|
||||||
|
allocator);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
|
|||||||
@@ -430,6 +430,7 @@ UploadImageDataToTexture(GLContext* gl,
|
|||||||
|
|
||||||
MOZ_ASSERT(gl->GetPreferredARGB32Format() == LOCAL_GL_BGRA ||
|
MOZ_ASSERT(gl->GetPreferredARGB32Format() == LOCAL_GL_BGRA ||
|
||||||
gl->GetPreferredARGB32Format() == LOCAL_GL_RGBA);
|
gl->GetPreferredARGB32Format() == LOCAL_GL_RGBA);
|
||||||
|
|
||||||
switch (aFormat) {
|
switch (aFormat) {
|
||||||
case SurfaceFormat::B8G8R8A8:
|
case SurfaceFormat::B8G8R8A8:
|
||||||
if (gl->GetPreferredARGB32Format() == LOCAL_GL_BGRA) {
|
if (gl->GetPreferredARGB32Format() == LOCAL_GL_BGRA) {
|
||||||
@@ -457,6 +458,32 @@ UploadImageDataToTexture(GLContext* gl,
|
|||||||
}
|
}
|
||||||
internalFormat = LOCAL_GL_RGBA;
|
internalFormat = LOCAL_GL_RGBA;
|
||||||
break;
|
break;
|
||||||
|
case SurfaceFormat::R8G8B8A8:
|
||||||
|
if (gl->GetPreferredARGB32Format() == LOCAL_GL_BGRA) {
|
||||||
|
format = LOCAL_GL_BGRA;
|
||||||
|
type = LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||||
|
surfaceFormat = SurfaceFormat::B8G8R8A8;
|
||||||
|
} else {
|
||||||
|
format = LOCAL_GL_RGBA;
|
||||||
|
type = LOCAL_GL_UNSIGNED_BYTE;
|
||||||
|
surfaceFormat = SurfaceFormat::R8G8B8A8;
|
||||||
|
}
|
||||||
|
internalFormat = LOCAL_GL_RGBA;
|
||||||
|
break;
|
||||||
|
case SurfaceFormat::R8G8B8X8:
|
||||||
|
// Treat RGBX surfaces as RGBA except for the surface
|
||||||
|
// format used.
|
||||||
|
if (gl->GetPreferredARGB32Format() == LOCAL_GL_BGRA) {
|
||||||
|
format = LOCAL_GL_BGRA;
|
||||||
|
type = LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||||
|
surfaceFormat = SurfaceFormat::B8G8R8X8;
|
||||||
|
} else {
|
||||||
|
format = LOCAL_GL_RGBA;
|
||||||
|
type = LOCAL_GL_UNSIGNED_BYTE;
|
||||||
|
surfaceFormat = SurfaceFormat::R8G8B8X8;
|
||||||
|
}
|
||||||
|
internalFormat = LOCAL_GL_RGBA;
|
||||||
|
break;
|
||||||
case SurfaceFormat::R5G6B5:
|
case SurfaceFormat::R5G6B5:
|
||||||
internalFormat = format = LOCAL_GL_RGB;
|
internalFormat = format = LOCAL_GL_RGB;
|
||||||
type = LOCAL_GL_UNSIGNED_SHORT_5_6_5;
|
type = LOCAL_GL_UNSIGNED_SHORT_5_6_5;
|
||||||
|
|||||||
@@ -37,16 +37,13 @@ using namespace android;
|
|||||||
|
|
||||||
SurfaceFactory_Gralloc::SurfaceFactory_Gralloc(GLContext* prodGL,
|
SurfaceFactory_Gralloc::SurfaceFactory_Gralloc(GLContext* prodGL,
|
||||||
const SurfaceCaps& caps,
|
const SurfaceCaps& caps,
|
||||||
|
layers::TextureFlags flags,
|
||||||
layers::ISurfaceAllocator* allocator)
|
layers::ISurfaceAllocator* allocator)
|
||||||
: SurfaceFactory(prodGL, SharedSurfaceType::Gralloc, caps)
|
: SurfaceFactory(prodGL, SharedSurfaceType::Gralloc, caps)
|
||||||
|
, mFlags(flags)
|
||||||
|
, mAllocator(allocator)
|
||||||
{
|
{
|
||||||
if (caps.surfaceAllocator) {
|
MOZ_ASSERT(mAllocator);
|
||||||
allocator = caps.surfaceAllocator;
|
|
||||||
}
|
|
||||||
|
|
||||||
MOZ_ASSERT(allocator);
|
|
||||||
|
|
||||||
mAllocator = allocator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ UniquePtr<SharedSurface_Gralloc>
|
/*static*/ UniquePtr<SharedSurface_Gralloc>
|
||||||
@@ -54,6 +51,7 @@ SharedSurface_Gralloc::Create(GLContext* prodGL,
|
|||||||
const GLFormats& formats,
|
const GLFormats& formats,
|
||||||
const gfx::IntSize& size,
|
const gfx::IntSize& size,
|
||||||
bool hasAlpha,
|
bool hasAlpha,
|
||||||
|
layers::TextureFlags flags,
|
||||||
ISurfaceAllocator* allocator)
|
ISurfaceAllocator* allocator)
|
||||||
{
|
{
|
||||||
GLLibraryEGL* egl = &sEGLLibrary;
|
GLLibraryEGL* egl = &sEGLLibrary;
|
||||||
@@ -77,7 +75,7 @@ SharedSurface_Gralloc::Create(GLContext* prodGL,
|
|||||||
allocator,
|
allocator,
|
||||||
gfx::ImageFormatToSurfaceFormat(format),
|
gfx::ImageFormatToSurfaceFormat(format),
|
||||||
gfx::BackendType::NONE, // we don't need to use it with a DrawTarget
|
gfx::BackendType::NONE, // we don't need to use it with a DrawTarget
|
||||||
layers::TextureFlags::DEFAULT);
|
flags);
|
||||||
|
|
||||||
if (!grallocTC->AllocateForGLRendering(size)) {
|
if (!grallocTC->AllocateForGLRendering(size)) {
|
||||||
return Move(ret);
|
return Move(ret);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#ifndef SHARED_SURFACE_GRALLOC_H_
|
#ifndef SHARED_SURFACE_GRALLOC_H_
|
||||||
#define SHARED_SURFACE_GRALLOC_H_
|
#define SHARED_SURFACE_GRALLOC_H_
|
||||||
|
|
||||||
|
#include "mozilla/layers/CompositorTypes.h"
|
||||||
#include "mozilla/layers/LayersSurfaces.h"
|
#include "mozilla/layers/LayersSurfaces.h"
|
||||||
#include "SharedSurface.h"
|
#include "SharedSurface.h"
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ public:
|
|||||||
const GLFormats& formats,
|
const GLFormats& formats,
|
||||||
const gfx::IntSize& size,
|
const gfx::IntSize& size,
|
||||||
bool hasAlpha,
|
bool hasAlpha,
|
||||||
|
layers::TextureFlags flags,
|
||||||
layers::ISurfaceAllocator* allocator);
|
layers::ISurfaceAllocator* allocator);
|
||||||
|
|
||||||
static SharedSurface_Gralloc* Cast(SharedSurface* surf) {
|
static SharedSurface_Gralloc* Cast(SharedSurface* surf) {
|
||||||
@@ -77,20 +79,22 @@ class SurfaceFactory_Gralloc
|
|||||||
: public SurfaceFactory
|
: public SurfaceFactory
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
const layers::TextureFlags mFlags;
|
||||||
RefPtr<layers::ISurfaceAllocator> mAllocator;
|
RefPtr<layers::ISurfaceAllocator> mAllocator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SurfaceFactory_Gralloc(GLContext* prodGL,
|
SurfaceFactory_Gralloc(GLContext* prodGL,
|
||||||
const SurfaceCaps& caps,
|
const SurfaceCaps& caps,
|
||||||
layers::ISurfaceAllocator* allocator = nullptr);
|
layers::TextureFlags flags,
|
||||||
|
layers::ISurfaceAllocator* allocator);
|
||||||
|
|
||||||
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
|
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
|
||||||
bool hasAlpha = mReadCaps.alpha;
|
bool hasAlpha = mReadCaps.alpha;
|
||||||
|
|
||||||
UniquePtr<SharedSurface> ret;
|
UniquePtr<SharedSurface> ret;
|
||||||
if (mAllocator) {
|
if (mAllocator) {
|
||||||
ret = SharedSurface_Gralloc::Create(mGL, mFormats, size,
|
ret = SharedSurface_Gralloc::Create(mGL, mFormats, size, hasAlpha,
|
||||||
hasAlpha, mAllocator);
|
mFlags, mAllocator);
|
||||||
}
|
}
|
||||||
return Move(ret);
|
return Move(ret);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ SurfaceCaps::operator=(const SurfaceCaps& other)
|
|||||||
depth = other.depth;
|
depth = other.depth;
|
||||||
stencil = other.stencil;
|
stencil = other.stencil;
|
||||||
antialias = other.antialias;
|
antialias = other.antialias;
|
||||||
|
premultAlpha = other.premultAlpha;
|
||||||
preserve = other.preserve;
|
preserve = other.preserve;
|
||||||
surfaceAllocator = other.surfaceAllocator;
|
surfaceAllocator = other.surfaceAllocator;
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ SurfaceCaps::Clear()
|
|||||||
depth = false;
|
depth = false;
|
||||||
stencil = false;
|
stencil = false;
|
||||||
antialias = false;
|
antialias = false;
|
||||||
|
premultAlpha = false;
|
||||||
preserve = false;
|
preserve = false;
|
||||||
surfaceAllocator = nullptr;
|
surfaceAllocator = nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ struct SurfaceCaps MOZ_FINAL
|
|||||||
bool bpp16;
|
bool bpp16;
|
||||||
bool depth, stencil;
|
bool depth, stencil;
|
||||||
bool antialias;
|
bool antialias;
|
||||||
|
bool premultAlpha;
|
||||||
bool preserve;
|
bool preserve;
|
||||||
|
|
||||||
// The surface allocator that we want to create this
|
// The surface allocator that we want to create this
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ CanvasClient::CreateCanvasClient(CanvasClientType aType,
|
|||||||
|
|
||||||
switch (aType) {
|
switch (aType) {
|
||||||
case CanvasClientTypeShSurf:
|
case CanvasClientTypeShSurf:
|
||||||
return new CanvasClientShSurf(aForwarder, aFlags);
|
return new CanvasClientSharedSurface(aForwarder, aFlags);
|
||||||
|
|
||||||
case CanvasClientGLContext:
|
case CanvasClientGLContext:
|
||||||
aFlags |= TextureFlags::DEALLOCATE_CLIENT;
|
aFlags |= TextureFlags::DEALLOCATE_CLIENT;
|
||||||
@@ -240,7 +240,7 @@ CanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CanvasClientShSurf::CanvasClientShSurf(CompositableForwarder* aLayerForwarder,
|
CanvasClientSharedSurface::CanvasClientSharedSurface(CompositableForwarder* aLayerForwarder,
|
||||||
TextureFlags aFlags)
|
TextureFlags aFlags)
|
||||||
: CanvasClient(aLayerForwarder, aFlags)
|
: CanvasClient(aLayerForwarder, aFlags)
|
||||||
{
|
{
|
||||||
@@ -250,10 +250,8 @@ CanvasClientShSurf::CanvasClientShSurf(CompositableForwarder* aLayerForwarder,
|
|||||||
// Accelerated backends
|
// Accelerated backends
|
||||||
|
|
||||||
static TemporaryRef<TextureClient>
|
static TemporaryRef<TextureClient>
|
||||||
TexClientFromShSurf(SharedSurface* surf, TextureFlags baseFlags)
|
TexClientFromShSurf(SharedSurface* surf, TextureFlags flags)
|
||||||
{
|
{
|
||||||
TextureFlags flags = baseFlags | TextureFlags::DEALLOCATE_CLIENT;
|
|
||||||
|
|
||||||
switch (surf->mType) {
|
switch (surf->mType) {
|
||||||
case SharedSurfaceType::Basic:
|
case SharedSurfaceType::Basic:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -264,7 +262,7 @@ TexClientFromShSurf(SharedSurface* surf, TextureFlags baseFlags)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return new ShSurfTexClient(flags, surf);
|
return new SharedSurfaceTextureClient(flags, surf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,16 +282,18 @@ class TexClientFactory
|
|||||||
const gfx::IntSize mSize;
|
const gfx::IntSize mSize;
|
||||||
const gfx::BackendType mBackendType;
|
const gfx::BackendType mBackendType;
|
||||||
const TextureFlags mBaseTexFlags;
|
const TextureFlags mBaseTexFlags;
|
||||||
|
const LayersBackend mLayersBackend;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TexClientFactory(ISurfaceAllocator* allocator, bool hasAlpha,
|
TexClientFactory(ISurfaceAllocator* allocator, bool hasAlpha,
|
||||||
const gfx::IntSize& size, gfx::BackendType backendType,
|
const gfx::IntSize& size, gfx::BackendType backendType,
|
||||||
TextureFlags baseTexFlags)
|
TextureFlags baseTexFlags, LayersBackend layersBackend)
|
||||||
: mAllocator(allocator)
|
: mAllocator(allocator)
|
||||||
, mHasAlpha(hasAlpha)
|
, mHasAlpha(hasAlpha)
|
||||||
, mSize(size)
|
, mSize(size)
|
||||||
, mBackendType(backendType)
|
, mBackendType(backendType)
|
||||||
, mBaseTexFlags(baseTexFlags)
|
, mBaseTexFlags(baseTexFlags)
|
||||||
|
, mLayersBackend(layersBackend)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,12 +312,21 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
TemporaryRef<BufferTextureClient> CreateR8G8B8AX8() {
|
TemporaryRef<BufferTextureClient> CreateR8G8B8AX8() {
|
||||||
// For now, assume that all RGBA formats are broken.
|
RefPtr<BufferTextureClient> ret;
|
||||||
RefPtr<BufferTextureClient> ret = CreateB8G8R8AX8();
|
|
||||||
|
|
||||||
|
bool areRGBAFormatsBroken = mLayersBackend == LayersBackend::LAYERS_BASIC;
|
||||||
|
if (!areRGBAFormatsBroken) {
|
||||||
|
gfx::SurfaceFormat format = mHasAlpha ? gfx::SurfaceFormat::R8G8B8A8
|
||||||
|
: gfx::SurfaceFormat::R8G8B8X8;
|
||||||
|
ret = Create(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
ret = CreateB8G8R8AX8();
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ret->AddFlags(TextureFlags::RB_SWAPPED);
|
ret->AddFlags(TextureFlags::RB_SWAPPED);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret.forget();
|
return ret.forget();
|
||||||
}
|
}
|
||||||
@@ -329,7 +338,7 @@ TexClientFromReadback(SharedSurface* src, ISurfaceAllocator* allocator,
|
|||||||
{
|
{
|
||||||
auto backendType = gfx::BackendType::CAIRO;
|
auto backendType = gfx::BackendType::CAIRO;
|
||||||
TexClientFactory factory(allocator, src->mHasAlpha, src->mSize, backendType,
|
TexClientFactory factory(allocator, src->mHasAlpha, src->mSize, backendType,
|
||||||
baseFlags);
|
baseFlags, layersBackend);
|
||||||
|
|
||||||
RefPtr<BufferTextureClient> texClient;
|
RefPtr<BufferTextureClient> texClient;
|
||||||
|
|
||||||
@@ -389,8 +398,10 @@ TexClientFromReadback(SharedSurface* src, ISurfaceAllocator* allocator,
|
|||||||
|
|
||||||
// RB_SWAPPED doesn't work with D3D11. (bug 1051010)
|
// RB_SWAPPED doesn't work with D3D11. (bug 1051010)
|
||||||
// RB_SWAPPED doesn't work with Basic. (bug ???????)
|
// RB_SWAPPED doesn't work with Basic. (bug ???????)
|
||||||
bool layersNeedsManualSwap = layersBackend == LayersBackend::LAYERS_D3D11 ||
|
// RB_SWAPPED doesn't work with D3D9. (bug ???????)
|
||||||
layersBackend == LayersBackend::LAYERS_BASIC;
|
bool layersNeedsManualSwap = layersBackend == LayersBackend::LAYERS_BASIC ||
|
||||||
|
layersBackend == LayersBackend::LAYERS_D3D9 ||
|
||||||
|
layersBackend == LayersBackend::LAYERS_D3D11;
|
||||||
if (texClient->HasFlags(TextureFlags::RB_SWAPPED) &&
|
if (texClient->HasFlags(TextureFlags::RB_SWAPPED) &&
|
||||||
layersNeedsManualSwap)
|
layersNeedsManualSwap)
|
||||||
{
|
{
|
||||||
@@ -413,7 +424,7 @@ TexClientFromReadback(SharedSurface* src, ISurfaceAllocator* allocator,
|
|||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
|
|
||||||
void
|
void
|
||||||
CanvasClientShSurf::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
CanvasClientSharedSurface::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
||||||
{
|
{
|
||||||
aLayer->mGLContext->MakeCurrent();
|
aLayer->mGLContext->MakeCurrent();
|
||||||
GLScreenBuffer* screen = aLayer->mGLContext->Screen();
|
GLScreenBuffer* screen = aLayer->mGLContext->Screen();
|
||||||
@@ -424,7 +435,6 @@ CanvasClientShSurf::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mFront = screen->Front();
|
mFront = screen->Front();
|
||||||
|
|
||||||
if (!mFront)
|
if (!mFront)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ private:
|
|||||||
|
|
||||||
// Used for GL canvases where we don't need to do any readback, i.e., with a
|
// Used for GL canvases where we don't need to do any readback, i.e., with a
|
||||||
// GL backend.
|
// GL backend.
|
||||||
class CanvasClientShSurf : public CanvasClient
|
class CanvasClientSharedSurface : public CanvasClient
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
RefPtr<gl::ShSurfHandle> mFront;
|
RefPtr<gl::ShSurfHandle> mFront;
|
||||||
@@ -151,7 +151,7 @@ private:
|
|||||||
RefPtr<TextureClient> mFrontTex;
|
RefPtr<TextureClient> mFrontTex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CanvasClientShSurf(CompositableForwarder* aLayerForwarder,
|
CanvasClientSharedSurface(CompositableForwarder* aLayerForwarder,
|
||||||
TextureFlags aFlags);
|
TextureFlags aFlags);
|
||||||
|
|
||||||
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE {
|
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE {
|
||||||
@@ -168,7 +168,7 @@ public:
|
|||||||
ClientCanvasLayer* aLayer) MOZ_OVERRIDE;
|
ClientCanvasLayer* aLayer) MOZ_OVERRIDE;
|
||||||
|
|
||||||
virtual void OnDetach() MOZ_OVERRIDE {
|
virtual void OnDetach() MOZ_OVERRIDE {
|
||||||
CanvasClientShSurf::Clear();
|
CanvasClientSharedSurface::Clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -77,8 +77,14 @@ ClientCanvasLayer::Initialize(const Data& aData)
|
|||||||
case mozilla::layers::LayersBackend::LAYERS_OPENGL: {
|
case mozilla::layers::LayersBackend::LAYERS_OPENGL: {
|
||||||
if (mGLContext->GetContextType() == GLContextType::EGL) {
|
if (mGLContext->GetContextType() == GLContextType::EGL) {
|
||||||
#ifdef MOZ_WIDGET_GONK
|
#ifdef MOZ_WIDGET_GONK
|
||||||
|
TextureFlags flags = TextureFlags::DEALLOCATE_CLIENT |
|
||||||
|
TextureFlags::NEEDS_Y_FLIP;
|
||||||
|
if (!aData.mIsGLAlphaPremult) {
|
||||||
|
flags |= TextureFlags::NON_PREMULTIPLIED;
|
||||||
|
}
|
||||||
factory = MakeUnique<SurfaceFactory_Gralloc>(mGLContext,
|
factory = MakeUnique<SurfaceFactory_Gralloc>(mGLContext,
|
||||||
caps,
|
caps,
|
||||||
|
flags,
|
||||||
ClientManager()->AsShadowForwarder());
|
ClientManager()->AsShadowForwarder());
|
||||||
#else
|
#else
|
||||||
bool isCrossProcess = !(XRE_GetProcessType() == GeckoProcessType_Default);
|
bool isCrossProcess = !(XRE_GetProcessType() == GeckoProcessType_Default);
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ protected:
|
|||||||
friend class CanvasClient2D;
|
friend class CanvasClient2D;
|
||||||
friend class DeprecatedCanvasClientSurfaceStream;
|
friend class DeprecatedCanvasClientSurfaceStream;
|
||||||
friend class CanvasClientSurfaceStream;
|
friend class CanvasClientSurfaceStream;
|
||||||
friend class CanvasClientShSurf;
|
friend class CanvasClientSharedSurface;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -861,9 +861,10 @@ StreamTextureClient::IsAllocated() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// ShSurfTexClient
|
// SharedSurfaceTextureClient
|
||||||
|
|
||||||
ShSurfTexClient::ShSurfTexClient(TextureFlags aFlags, gl::SharedSurface* surf)
|
SharedSurfaceTextureClient::SharedSurfaceTextureClient(TextureFlags aFlags,
|
||||||
|
gl::SharedSurface* surf)
|
||||||
: TextureClient(aFlags)
|
: TextureClient(aFlags)
|
||||||
, mIsLocked(false)
|
, mIsLocked(false)
|
||||||
, mSurf(surf)
|
, mSurf(surf)
|
||||||
@@ -872,15 +873,15 @@ ShSurfTexClient::ShSurfTexClient(TextureFlags aFlags, gl::SharedSurface* surf)
|
|||||||
mSurf->Fence();
|
mSurf->Fence();
|
||||||
}
|
}
|
||||||
|
|
||||||
ShSurfTexClient::~ShSurfTexClient()
|
SharedSurfaceTextureClient::~SharedSurfaceTextureClient()
|
||||||
{
|
{
|
||||||
// the data is owned externally.
|
// the data is owned externally.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ShSurfTexClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
SharedSurfaceTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
||||||
{
|
{
|
||||||
aOutDescriptor = ShSurfDescriptor((uintptr_t)mSurf);
|
aOutDescriptor = SharedSurfaceDescriptor((uintptr_t)mSurf);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -682,13 +682,13 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* A TextureClient implementation to share SharedSurfaces.
|
* A TextureClient implementation to share SharedSurfaces.
|
||||||
*/
|
*/
|
||||||
class ShSurfTexClient : public TextureClient
|
class SharedSurfaceTextureClient : public TextureClient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ShSurfTexClient(TextureFlags aFlags, gl::SharedSurface* surf);
|
SharedSurfaceTextureClient(TextureFlags aFlags, gl::SharedSurface* surf);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~ShSurfTexClient();
|
~SharedSurfaceTextureClient();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Boilerplate start
|
// Boilerplate start
|
||||||
|
|||||||
@@ -203,8 +203,8 @@ TextureHost::Create(const SurfaceDescriptor& aDesc,
|
|||||||
case SurfaceDescriptor::TSurfaceStreamDescriptor:
|
case SurfaceDescriptor::TSurfaceStreamDescriptor:
|
||||||
return new StreamTextureHost(aFlags, aDesc.get_SurfaceStreamDescriptor());
|
return new StreamTextureHost(aFlags, aDesc.get_SurfaceStreamDescriptor());
|
||||||
|
|
||||||
case SurfaceDescriptor::TShSurfDescriptor:
|
case SurfaceDescriptor::TSharedSurfaceDescriptor:
|
||||||
return new ShSurfTexHost(aFlags, aDesc.get_ShSurfDescriptor());
|
return new SharedSurfaceTextureHost(aFlags, aDesc.get_SharedSurfaceDescriptor());
|
||||||
|
|
||||||
case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface:
|
case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface:
|
||||||
if (Compositor::GetBackend() == LayersBackend::LAYERS_OPENGL) {
|
if (Compositor::GetBackend() == LayersBackend::LAYERS_OPENGL) {
|
||||||
@@ -1089,9 +1089,10 @@ ShSurfToTexSource(gl::SharedSurface* abstractSurf, Compositor* compositor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// ShSurfTexHost
|
// SharedSurfaceTextureHost
|
||||||
|
|
||||||
ShSurfTexHost::ShSurfTexHost(TextureFlags aFlags, const ShSurfDescriptor& aDesc)
|
SharedSurfaceTextureHost::SharedSurfaceTextureHost(TextureFlags aFlags,
|
||||||
|
const SharedSurfaceDescriptor& aDesc)
|
||||||
: TextureHost(aFlags)
|
: TextureHost(aFlags)
|
||||||
, mIsLocked(false)
|
, mIsLocked(false)
|
||||||
, mSurf((gl::SharedSurface*)aDesc.surf())
|
, mSurf((gl::SharedSurface*)aDesc.surf())
|
||||||
@@ -1101,21 +1102,21 @@ ShSurfTexHost::ShSurfTexHost(TextureFlags aFlags, const ShSurfDescriptor& aDesc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gfx::SurfaceFormat
|
gfx::SurfaceFormat
|
||||||
ShSurfTexHost::GetFormat() const
|
SharedSurfaceTextureHost::GetFormat() const
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mTexSource);
|
MOZ_ASSERT(mTexSource);
|
||||||
return mTexSource->GetFormat();
|
return mTexSource->GetFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::IntSize
|
gfx::IntSize
|
||||||
ShSurfTexHost::GetSize() const
|
SharedSurfaceTextureHost::GetSize() const
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mTexSource);
|
MOZ_ASSERT(mTexSource);
|
||||||
return mTexSource->GetSize();
|
return mTexSource->GetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShSurfTexHost::EnsureTexSource()
|
SharedSurfaceTextureHost::EnsureTexSource()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mIsLocked);
|
MOZ_ASSERT(mIsLocked);
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class CompositableBackendSpecificData;
|
|||||||
class CompositableParentManager;
|
class CompositableParentManager;
|
||||||
class SurfaceDescriptor;
|
class SurfaceDescriptor;
|
||||||
class SurfaceStreamDescriptor;
|
class SurfaceStreamDescriptor;
|
||||||
class ShSurfDescriptor;
|
class SharedSurfaceDescriptor;
|
||||||
class ISurfaceAllocator;
|
class ISurfaceAllocator;
|
||||||
class TextureHostOGL;
|
class TextureHostOGL;
|
||||||
class TextureSourceOGL;
|
class TextureSourceOGL;
|
||||||
@@ -620,12 +620,12 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* A TextureHost for SharedSurfaces
|
* A TextureHost for SharedSurfaces
|
||||||
*/
|
*/
|
||||||
class ShSurfTexHost : public TextureHost
|
class SharedSurfaceTextureHost : public TextureHost
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ShSurfTexHost(TextureFlags aFlags, const ShSurfDescriptor& aDesc);
|
SharedSurfaceTextureHost(TextureFlags aFlags, const ShSurfDescriptor& aDesc);
|
||||||
|
|
||||||
virtual ~ShSurfTexHost() {};
|
virtual ~SharedSurfaceTextureHost() {};
|
||||||
|
|
||||||
virtual void DeallocateDeviceData() MOZ_OVERRIDE {};
|
virtual void DeallocateDeviceData() MOZ_OVERRIDE {};
|
||||||
|
|
||||||
@@ -667,7 +667,7 @@ public:
|
|||||||
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
|
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
|
||||||
|
|
||||||
#ifdef MOZ_LAYERS_HAVE_LOG
|
#ifdef MOZ_LAYERS_HAVE_LOG
|
||||||
virtual const char* Name() { return "ShSurfTexHost"; }
|
virtual const char* Name() { return "SharedSurfaceTextureHost"; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -118,10 +118,13 @@ CanvasLayerD3D10::UpdateSurface()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mGLContext) {
|
if (mGLContext) {
|
||||||
SharedSurface* surf = mGLContext->RequestFrame();
|
auto screen = mGLContext->Screen();
|
||||||
if (!surf) {
|
MOZ_ASSERT(screen);
|
||||||
|
|
||||||
|
SharedSurface* surf = screen->Front()->Surf();
|
||||||
|
if (!surf)
|
||||||
return;
|
return;
|
||||||
}
|
surf->WaitSync();
|
||||||
|
|
||||||
switch (surf->mType) {
|
switch (surf->mType) {
|
||||||
case SharedSurfaceType::EGLSurfaceANGLE: {
|
case SharedSurfaceType::EGLSurfaceANGLE: {
|
||||||
|
|||||||
@@ -80,9 +80,13 @@ CanvasLayerD3D9::UpdateSurface()
|
|||||||
RefPtr<SourceSurface> surface;
|
RefPtr<SourceSurface> surface;
|
||||||
|
|
||||||
if (mGLContext) {
|
if (mGLContext) {
|
||||||
SharedSurface* surf = mGLContext->RequestFrame();
|
auto screen = mGLContext->Screen();
|
||||||
|
MOZ_ASSERT(screen);
|
||||||
|
|
||||||
|
SharedSurface* surf = screen->Front()->Surf();
|
||||||
if (!surf)
|
if (!surf)
|
||||||
return;
|
return;
|
||||||
|
surf->WaitSync();
|
||||||
|
|
||||||
SharedSurface_Basic* shareSurf = SharedSurface_Basic::Cast(surf);
|
SharedSurface_Basic* shareSurf = SharedSurface_Basic::Cast(surf);
|
||||||
surface = shareSurf->GetData();
|
surface = shareSurf->GetData();
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ struct SurfaceStreamDescriptor {
|
|||||||
bool yflip;
|
bool yflip;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ShSurfDescriptor {
|
struct SharedSurfaceDescriptor {
|
||||||
uintptr_t surf;
|
uintptr_t surf;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ union SurfaceDescriptor {
|
|||||||
SurfaceStreamDescriptor;
|
SurfaceStreamDescriptor;
|
||||||
SurfaceDescriptorMacIOSurface;
|
SurfaceDescriptorMacIOSurface;
|
||||||
NewSurfaceDescriptorGralloc;
|
NewSurfaceDescriptorGralloc;
|
||||||
ShSurfDescriptor;
|
SharedSurfaceDescriptor;
|
||||||
null_t;
|
null_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ EXPORTS += [
|
|||||||
'client/ClientTiledPaintedLayer.h',
|
'client/ClientTiledPaintedLayer.h',
|
||||||
'composite/CompositableHost.h',
|
'composite/CompositableHost.h',
|
||||||
'composite/ImageHost.h',
|
'composite/ImageHost.h',
|
||||||
|
'CompositorTypes.h',
|
||||||
'CopyableCanvasLayer.h',
|
'CopyableCanvasLayer.h',
|
||||||
'D3D9SurfaceImage.h',
|
'D3D9SurfaceImage.h',
|
||||||
'FrameMetrics.h',
|
'FrameMetrics.h',
|
||||||
@@ -33,6 +34,7 @@ EXPORTS += [
|
|||||||
'LayerScope.h',
|
'LayerScope.h',
|
||||||
'LayersLogging.h',
|
'LayersLogging.h',
|
||||||
'LayerSorter.h',
|
'LayerSorter.h',
|
||||||
|
'LayersTypes.h',
|
||||||
'LayerTreeInvalidation.h',
|
'LayerTreeInvalidation.h',
|
||||||
'opengl/Composer2D.h',
|
'opengl/Composer2D.h',
|
||||||
'opengl/OGLShaderProgram.h',
|
'opengl/OGLShaderProgram.h',
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "mozilla/layers/ISurfaceAllocator.h"
|
#include "mozilla/layers/ISurfaceAllocator.h"
|
||||||
#include "mozilla/layers/ShadowLayerUtilsGralloc.h"
|
#include "mozilla/layers/ShadowLayerUtilsGralloc.h"
|
||||||
#include "gfx2DGlue.h"
|
#include "gfx2DGlue.h"
|
||||||
|
#include "SharedSurfaceGralloc.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace layers {
|
namespace layers {
|
||||||
@@ -346,6 +347,29 @@ GrallocTextureClientOGL::GetBufferSize() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*static*/ TemporaryRef<TextureClient>
|
||||||
|
GrallocTextureClientOGL::FromShSurf(gl::SharedSurface* abstractSurf,
|
||||||
|
TextureFlags flags)
|
||||||
|
{
|
||||||
|
auto surf = gl::SharedSurface_Gralloc::Cast(abstractSurf);
|
||||||
|
|
||||||
|
RefPtr<TextureClient> ret = surf->GetTextureClient();
|
||||||
|
|
||||||
|
TextureFlags mask = TextureFlags::NEEDS_Y_FLIP |
|
||||||
|
TextureFlags::RB_SWAPPED |
|
||||||
|
TextureFlags::NON_PREMULTIPLIED;
|
||||||
|
TextureFlags required = flags & mask;
|
||||||
|
TextureFlags present = ret->GetFlags() & mask;
|
||||||
|
|
||||||
|
if (present != required) {
|
||||||
|
printf_stderr("Present flags: 0x%x. Required: 0x%x.\n",
|
||||||
|
(uint32_t)present,
|
||||||
|
(uint32_t)required);
|
||||||
|
MOZ_CRASH("Flag requirement mismatch.");
|
||||||
|
}
|
||||||
|
return ret.forget();
|
||||||
|
}
|
||||||
|
|
||||||
} // namesapace layers
|
} // namesapace layers
|
||||||
} // namesapace mozilla
|
} // namesapace mozilla
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,9 @@ public:
|
|||||||
CreateSimilar(TextureFlags aFlags = TextureFlags::DEFAULT,
|
CreateSimilar(TextureFlags aFlags = TextureFlags::DEFAULT,
|
||||||
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const MOZ_OVERRIDE;
|
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const MOZ_OVERRIDE;
|
||||||
|
|
||||||
|
static TemporaryRef<TextureClient> FromShSurf(gl::SharedSurface* surf,
|
||||||
|
TextureFlags flags);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Unfortunately, until bug 879681 is fixed we need to use a GrallocBufferActor.
|
* Unfortunately, until bug 879681 is fixed we need to use a GrallocBufferActor.
|
||||||
|
|||||||
Reference in New Issue
Block a user