зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1037151 - Merge SharedSurface_GL into SharedSurface. - r=mattwoodrow
This commit is contained in:
Родитель
bdf28b83b7
Коммит
f032a2a672
|
@ -944,7 +944,8 @@ CanvasRenderingContext2D::EnsureTarget()
|
|||
if (glue && glue->GetGrContext() && glue->GetGLContext()) {
|
||||
mTarget = Factory::CreateDrawTargetSkiaWithGrContext(glue->GetGrContext(), size, format);
|
||||
if (mTarget) {
|
||||
mStream = gfx::SurfaceStream::CreateForType(SurfaceStreamType::TripleBuffer, glue->GetGLContext());
|
||||
mStream = gl::SurfaceStream::CreateForType(gl::SurfaceStreamType::TripleBuffer,
|
||||
glue->GetGLContext());
|
||||
AddDemotableContext(this);
|
||||
} else {
|
||||
printf_stderr("Failed to create a SkiaGL DrawTarget, falling back to software\n");
|
||||
|
|
|
@ -30,7 +30,7 @@ class nsGlobalWindow;
|
|||
class nsXULElement;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
namespace gl {
|
||||
class SourceSurface;
|
||||
class SurfaceStream;
|
||||
}
|
||||
|
@ -711,7 +711,7 @@ protected:
|
|||
// sErrorTarget.
|
||||
mozilla::RefPtr<mozilla::gfx::DrawTarget> mTarget;
|
||||
|
||||
RefPtr<gfx::SurfaceStream> mStream;
|
||||
RefPtr<gl::SurfaceStream> mStream;
|
||||
|
||||
/**
|
||||
* Flag to avoid duplicate calls to InvalidateFrame. Set to true whenever
|
||||
|
|
|
@ -55,6 +55,7 @@ using namespace mozilla;
|
|||
#include "GLContext.h"
|
||||
#include "TexturePoolOGL.h"
|
||||
#include "GLSharedHandleHelpers.h"
|
||||
#include "SurfaceTypes.h"
|
||||
|
||||
using namespace mozilla::gl;
|
||||
|
||||
|
@ -89,7 +90,7 @@ static bool EnsureGLContext()
|
|||
if (!sPluginContext) {
|
||||
gfxIntSize dummySize(16, 16);
|
||||
sPluginContext = GLContextProvider::CreateOffscreen(dummySize,
|
||||
GLContext::SurfaceCaps::Any());
|
||||
SurfaceCaps::Any());
|
||||
}
|
||||
|
||||
return sPluginContext != nullptr;
|
||||
|
|
|
@ -1669,22 +1669,15 @@ GLContext::PublishFrame()
|
|||
{
|
||||
MOZ_ASSERT(mScreen);
|
||||
|
||||
if (!mScreen->PublishFrame(OffscreenSize()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return mScreen->PublishFrame(OffscreenSize());
|
||||
}
|
||||
|
||||
SharedSurface_GL*
|
||||
SharedSurface*
|
||||
GLContext::RequestFrame()
|
||||
{
|
||||
MOZ_ASSERT(mScreen);
|
||||
|
||||
SharedSurface* ret = mScreen->Stream()->SwapConsumer();
|
||||
if (!ret)
|
||||
return nullptr;
|
||||
|
||||
return SharedSurface_GL::Cast(ret);
|
||||
return mScreen->Stream()->SwapConsumer();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -54,9 +54,8 @@ namespace android {
|
|||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
class SourceSurface;
|
||||
class DataSourceSurface;
|
||||
struct SurfaceCaps;
|
||||
class SourceSurface;
|
||||
}
|
||||
|
||||
namespace gl {
|
||||
|
@ -67,7 +66,7 @@ namespace mozilla {
|
|||
class GLBlitHelper;
|
||||
class GLBlitTextureImageHelper;
|
||||
class GLReadTexImageHelper;
|
||||
class SharedSurface_GL;
|
||||
struct SurfaceCaps;
|
||||
}
|
||||
|
||||
namespace layers {
|
||||
|
@ -2504,11 +2503,6 @@ public:
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constructor
|
||||
public:
|
||||
|
||||
typedef struct gfx::SurfaceCaps SurfaceCaps;
|
||||
|
||||
|
||||
protected:
|
||||
GLContext(const SurfaceCaps& caps,
|
||||
GLContext* sharedContext = nullptr,
|
||||
|
@ -2524,8 +2518,6 @@ public:
|
|||
// -----------------------------------------------------------------------------
|
||||
// Everything that isn't standard GL APIs
|
||||
protected:
|
||||
typedef class gfx::SharedSurface SharedSurface;
|
||||
typedef gfx::SharedSurfaceType SharedSurfaceType;
|
||||
typedef gfx::SurfaceFormat SurfaceFormat;
|
||||
|
||||
virtual bool MakeCurrentImpl(bool aForce) = 0;
|
||||
|
@ -2709,7 +2701,7 @@ public:
|
|||
GLint GetMaxTextureImageSize() { return mMaxTextureImageSize; }
|
||||
|
||||
public:
|
||||
std::map<GLuint, SharedSurface_GL*> mFBOMapping;
|
||||
std::map<GLuint, SharedSurface*> mFBOMapping;
|
||||
|
||||
enum {
|
||||
DebugEnabled = 1 << 0,
|
||||
|
@ -2778,7 +2770,7 @@ public:
|
|||
fScissor(0, 0, size.width, size.height);
|
||||
fViewport(0, 0, size.width, size.height);
|
||||
|
||||
mCaps = mScreen->Caps();
|
||||
mCaps = mScreen->mCaps;
|
||||
if (mCaps.any)
|
||||
DetermineCaps();
|
||||
|
||||
|
@ -2869,20 +2861,20 @@ protected:
|
|||
|
||||
void DestroyScreenBuffer();
|
||||
|
||||
SharedSurface_GL* mLockedSurface;
|
||||
SharedSurface* mLockedSurface;
|
||||
|
||||
public:
|
||||
void LockSurface(SharedSurface_GL* surf) {
|
||||
void LockSurface(SharedSurface* surf) {
|
||||
MOZ_ASSERT(!mLockedSurface);
|
||||
mLockedSurface = surf;
|
||||
}
|
||||
|
||||
void UnlockSurface(SharedSurface_GL* surf) {
|
||||
void UnlockSurface(SharedSurface* surf) {
|
||||
MOZ_ASSERT(mLockedSurface == surf);
|
||||
mLockedSurface = nullptr;
|
||||
}
|
||||
|
||||
SharedSurface_GL* GetLockedSurface() const {
|
||||
SharedSurface* GetLockedSurface() const {
|
||||
return mLockedSurface;
|
||||
}
|
||||
|
||||
|
@ -2895,7 +2887,7 @@ public:
|
|||
}
|
||||
|
||||
bool PublishFrame();
|
||||
SharedSurface_GL* RequestFrame();
|
||||
SharedSurface* RequestFrame();
|
||||
|
||||
/* Clear to transparent black, with 0 depth and stencil,
|
||||
* while preserving current ClearColor etc. values.
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
class GL_CONTEXT_PROVIDER_NAME
|
||||
{
|
||||
public:
|
||||
typedef gfx::SurfaceCaps SurfaceCaps;
|
||||
/**
|
||||
* Create a context that renders to the surface of the widget that is
|
||||
* passed in. The context is always created with an RGB pixel format,
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
using gfx::SurfaceFormat;
|
||||
|
||||
GLScreenBuffer*
|
||||
GLScreenBuffer::Create(GLContext* gl,
|
||||
const gfx::IntSize& size,
|
||||
const SurfaceCaps& caps)
|
||||
const gfx::IntSize& size,
|
||||
const SurfaceCaps& caps)
|
||||
{
|
||||
if (caps.antialias &&
|
||||
!gl->IsSupported(GLFeature::framebuffer_multisample))
|
||||
|
@ -37,7 +37,7 @@ GLScreenBuffer::Create(GLContext* gl,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
SurfaceFactory_GL* factory = nullptr;
|
||||
SurfaceFactory* factory = nullptr;
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
/* On B2G, we want a Gralloc factory, and we want one right at the start */
|
||||
|
@ -50,8 +50,7 @@ GLScreenBuffer::Create(GLContext* gl,
|
|||
#endif
|
||||
#ifdef XP_MACOSX
|
||||
/* On OSX, we want an IOSurface factory, and we want one right at the start */
|
||||
if (!factory)
|
||||
{
|
||||
if (!factory) {
|
||||
factory = new SurfaceFactory_IOSurface(gl, caps);
|
||||
}
|
||||
#endif
|
||||
|
@ -300,15 +299,17 @@ GLScreenBuffer::BeforeReadCall()
|
|||
}
|
||||
|
||||
bool
|
||||
GLScreenBuffer::ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type, GLvoid *pixels)
|
||||
GLScreenBuffer::ReadPixels(GLint x, GLint y,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
GLvoid* pixels)
|
||||
{
|
||||
// If the currently bound framebuffer is backed by a SharedSurface_GL
|
||||
// If the currently bound framebuffer is backed by a SharedSurface
|
||||
// then it might want to override how we read pixel data from it.
|
||||
// This is normally only the default framebuffer, but we can also
|
||||
// have SharedSurfaces bound to other framebuffers when doing
|
||||
// readback for BasicLayers.
|
||||
SharedSurface_GL* surf;
|
||||
SharedSurface* surf;
|
||||
if (GetReadFB() == 0) {
|
||||
surf = SharedSurf();
|
||||
} else {
|
||||
|
@ -340,7 +341,7 @@ GLScreenBuffer::AssureBlitted()
|
|||
MOZ_ASSERT(drawFB != 0);
|
||||
MOZ_ASSERT(drawFB != readFB);
|
||||
MOZ_ASSERT(mGL->IsSupported(GLFeature::framebuffer_blit));
|
||||
MOZ_ASSERT(mDraw->Size() == mRead->Size());
|
||||
MOZ_ASSERT(mDraw->mSize == mRead->Size());
|
||||
|
||||
ScopedBindFramebuffer boundFB(mGL);
|
||||
ScopedGLState scissor(mGL, LOCAL_GL_SCISSOR_TEST, false);
|
||||
|
@ -348,7 +349,7 @@ GLScreenBuffer::AssureBlitted()
|
|||
BindReadFB_Internal(drawFB);
|
||||
BindDrawFB_Internal(readFB);
|
||||
|
||||
const gfx::IntSize& srcSize = mDraw->Size();
|
||||
const gfx::IntSize& srcSize = mDraw->mSize;
|
||||
const gfx::IntSize& destSize = mRead->Size();
|
||||
|
||||
mGL->raw_fBlitFramebuffer(0, 0, srcSize.width, srcSize.height,
|
||||
|
@ -362,7 +363,7 @@ GLScreenBuffer::AssureBlitted()
|
|||
}
|
||||
|
||||
void
|
||||
GLScreenBuffer::Morph(SurfaceFactory_GL* newFactory, SurfaceStreamType streamType)
|
||||
GLScreenBuffer::Morph(SurfaceFactory* newFactory, SurfaceStreamType streamType)
|
||||
{
|
||||
MOZ_ASSERT(mStream);
|
||||
|
||||
|
@ -381,18 +382,17 @@ GLScreenBuffer::Morph(SurfaceFactory_GL* newFactory, SurfaceStreamType streamTyp
|
|||
}
|
||||
|
||||
bool
|
||||
GLScreenBuffer::Attach(SharedSurface* surface, const gfx::IntSize& size)
|
||||
GLScreenBuffer::Attach(SharedSurface* surf, const gfx::IntSize& size)
|
||||
{
|
||||
ScopedBindFramebuffer autoFB(mGL);
|
||||
|
||||
SharedSurface_GL* surf = SharedSurface_GL::Cast(surface);
|
||||
if (mRead && SharedSurf())
|
||||
SharedSurf()->UnlockProd();
|
||||
|
||||
surf->LockProd();
|
||||
|
||||
if (mRead &&
|
||||
surf->AttachType() == SharedSurf()->AttachType() &&
|
||||
surf->mAttachType == SharedSurf()->mAttachType &&
|
||||
size == Size())
|
||||
{
|
||||
// Same size, same type, ready for reuse!
|
||||
|
@ -436,7 +436,7 @@ GLScreenBuffer::Swap(const gfx::IntSize& size)
|
|||
{
|
||||
SharedSurface* nextSurf = mStream->SwapProducer(mFactory, size);
|
||||
if (!nextSurf) {
|
||||
SurfaceFactory_Basic basicFactory(mGL, mFactory->Caps());
|
||||
SurfaceFactory_Basic basicFactory(mGL, mFactory->mCaps);
|
||||
nextSurf = mStream->SwapProducer(&basicFactory, size);
|
||||
if (!nextSurf)
|
||||
return false;
|
||||
|
@ -470,30 +470,30 @@ GLScreenBuffer::Resize(const gfx::IntSize& size)
|
|||
bool
|
||||
GLScreenBuffer::CreateDraw(const gfx::IntSize& size, DrawBuffer** out_buffer)
|
||||
{
|
||||
GLContext* gl = mFactory->GL();
|
||||
const GLFormats& formats = mFactory->Formats();
|
||||
GLContext* gl = mFactory->mGL;
|
||||
const GLFormats& formats = mFactory->mFormats;
|
||||
const SurfaceCaps& caps = mFactory->DrawCaps();
|
||||
|
||||
return DrawBuffer::Create(gl, caps, formats, size, out_buffer);
|
||||
}
|
||||
|
||||
ReadBuffer*
|
||||
GLScreenBuffer::CreateRead(SharedSurface_GL* surf)
|
||||
GLScreenBuffer::CreateRead(SharedSurface* surf)
|
||||
{
|
||||
GLContext* gl = mFactory->GL();
|
||||
const GLFormats& formats = mFactory->Formats();
|
||||
GLContext* gl = mFactory->mGL;
|
||||
const GLFormats& formats = mFactory->mFormats;
|
||||
const SurfaceCaps& caps = mFactory->ReadCaps();
|
||||
|
||||
return ReadBuffer::Create(gl, caps, formats, surf);
|
||||
}
|
||||
|
||||
void
|
||||
GLScreenBuffer::Readback(SharedSurface_GL* src, DataSourceSurface* dest)
|
||||
GLScreenBuffer::Readback(SharedSurface* src, gfx::DataSourceSurface* dest)
|
||||
{
|
||||
MOZ_ASSERT(src && dest);
|
||||
MOZ_ASSERT(dest->GetSize() == src->Size());
|
||||
MOZ_ASSERT(dest->GetFormat() == (src->HasAlpha() ? SurfaceFormat::B8G8R8A8
|
||||
: SurfaceFormat::B8G8R8X8));
|
||||
MOZ_ASSERT(dest->GetSize() == src->mSize);
|
||||
MOZ_ASSERT(dest->GetFormat() == (src->mHasAlpha ? SurfaceFormat::B8G8R8A8
|
||||
: SurfaceFormat::B8G8R8X8));
|
||||
|
||||
mGL->MakeCurrent();
|
||||
|
||||
|
@ -506,7 +506,7 @@ GLScreenBuffer::Readback(SharedSurface_GL* src, DataSourceSurface* dest)
|
|||
ReadBuffer* buffer = CreateRead(src);
|
||||
MOZ_ASSERT(buffer);
|
||||
|
||||
ScopedBindFramebuffer autoFB(mGL, buffer->FB());
|
||||
ScopedBindFramebuffer autoFB(mGL, buffer->mFB);
|
||||
ReadPixelsIntoDataSurface(mGL, dest);
|
||||
|
||||
delete buffer;
|
||||
|
@ -517,6 +517,9 @@ GLScreenBuffer::Readback(SharedSurface_GL* src, DataSourceSurface* dest)
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// DrawBuffer
|
||||
|
||||
bool
|
||||
DrawBuffer::Create(GLContext* const gl,
|
||||
const SurfaceCaps& caps,
|
||||
|
@ -591,20 +594,18 @@ DrawBuffer::~DrawBuffer()
|
|||
mGL->fDeleteRenderbuffers(3, rbs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// ReadBuffer
|
||||
|
||||
ReadBuffer*
|
||||
ReadBuffer::Create(GLContext* gl,
|
||||
const SurfaceCaps& caps,
|
||||
const GLFormats& formats,
|
||||
SharedSurface_GL* surf)
|
||||
SharedSurface* surf)
|
||||
{
|
||||
MOZ_ASSERT(surf);
|
||||
|
||||
if (surf->AttachType() == AttachmentType::Screen) {
|
||||
if (surf->mAttachType == AttachmentType::Screen) {
|
||||
// Don't need anything. Our read buffer will be the 'screen'.
|
||||
|
||||
return new ReadBuffer(gl,
|
||||
|
@ -618,14 +619,14 @@ ReadBuffer::Create(GLContext* gl,
|
|||
GLuint* pDepthRB = caps.depth ? &depthRB : nullptr;
|
||||
GLuint* pStencilRB = caps.stencil ? &stencilRB : nullptr;
|
||||
|
||||
CreateRenderbuffersForOffscreen(gl, formats, surf->Size(), caps.antialias,
|
||||
CreateRenderbuffersForOffscreen(gl, formats, surf->mSize, caps.antialias,
|
||||
nullptr, pDepthRB, pStencilRB);
|
||||
|
||||
GLuint colorTex = 0;
|
||||
GLuint colorRB = 0;
|
||||
GLenum target = 0;
|
||||
|
||||
switch (surf->AttachType()) {
|
||||
switch (surf->mAttachType) {
|
||||
case AttachmentType::GLTexture:
|
||||
colorTex = surf->ProdTexture();
|
||||
target = surf->ProdTextureTarget();
|
||||
|
@ -670,19 +671,19 @@ ReadBuffer::~ReadBuffer()
|
|||
}
|
||||
|
||||
void
|
||||
ReadBuffer::Attach(SharedSurface_GL* surf)
|
||||
ReadBuffer::Attach(SharedSurface* surf)
|
||||
{
|
||||
MOZ_ASSERT(surf && mSurf);
|
||||
MOZ_ASSERT(surf->AttachType() == mSurf->AttachType());
|
||||
MOZ_ASSERT(surf->Size() == mSurf->Size());
|
||||
MOZ_ASSERT(surf->mAttachType == mSurf->mAttachType);
|
||||
MOZ_ASSERT(surf->mSize == mSurf->mSize);
|
||||
|
||||
// Nothing else is needed for AttachType Screen.
|
||||
if (surf->AttachType() != AttachmentType::Screen) {
|
||||
if (surf->mAttachType != AttachmentType::Screen) {
|
||||
GLuint colorTex = 0;
|
||||
GLuint colorRB = 0;
|
||||
GLenum target = 0;
|
||||
|
||||
switch (surf->AttachType()) {
|
||||
switch (surf->mAttachType) {
|
||||
case AttachmentType::GLTexture:
|
||||
colorTex = surf->ProdTexture();
|
||||
target = surf->ProdTextureTarget();
|
||||
|
@ -705,7 +706,7 @@ ReadBuffer::Attach(SharedSurface_GL* surf)
|
|||
const gfx::IntSize&
|
||||
ReadBuffer::Size() const
|
||||
{
|
||||
return mSurf->Size();
|
||||
return mSurf->mSize;
|
||||
}
|
||||
|
||||
} /* namespace gl */
|
||||
|
|
|
@ -22,26 +22,15 @@
|
|||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/Point.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
class SurfaceStream;
|
||||
class SharedSurface;
|
||||
}
|
||||
namespace gl {
|
||||
class GLContext;
|
||||
class SharedSurface_GL;
|
||||
class SurfaceFactory_GL;
|
||||
}
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
class GLContext;
|
||||
class SharedSurface;
|
||||
class SurfaceStream;
|
||||
|
||||
class DrawBuffer
|
||||
{
|
||||
protected:
|
||||
typedef struct gfx::SurfaceCaps SurfaceCaps;
|
||||
|
||||
public:
|
||||
// Fallible!
|
||||
// But it may return true with *out_buffer==nullptr if unneeded.
|
||||
|
@ -53,8 +42,10 @@ public:
|
|||
|
||||
protected:
|
||||
GLContext* const mGL;
|
||||
public:
|
||||
const gfx::IntSize mSize;
|
||||
const GLuint mFB;
|
||||
protected:
|
||||
const GLuint mColorMSRB;
|
||||
const GLuint mDepthRB;
|
||||
const GLuint mStencilRB;
|
||||
|
@ -75,43 +66,33 @@ protected:
|
|||
|
||||
public:
|
||||
virtual ~DrawBuffer();
|
||||
|
||||
const gfx::IntSize& Size() const {
|
||||
return mSize;
|
||||
}
|
||||
|
||||
GLuint FB() const {
|
||||
return mFB;
|
||||
}
|
||||
};
|
||||
|
||||
class ReadBuffer
|
||||
{
|
||||
protected:
|
||||
typedef struct gfx::SurfaceCaps SurfaceCaps;
|
||||
|
||||
public:
|
||||
// Infallible, always non-null.
|
||||
static ReadBuffer* Create(GLContext* gl,
|
||||
const SurfaceCaps& caps,
|
||||
const GLFormats& formats,
|
||||
SharedSurface_GL* surf);
|
||||
SharedSurface* surf);
|
||||
|
||||
protected:
|
||||
GLContext* const mGL;
|
||||
|
||||
public:
|
||||
const GLuint mFB;
|
||||
protected:
|
||||
// mFB has the following attachments:
|
||||
const GLuint mDepthRB;
|
||||
const GLuint mStencilRB;
|
||||
// note no mColorRB here: this is provided by mSurf.
|
||||
SharedSurface_GL* mSurf; // Owned by GLScreenBuffer's SurfaceStream.
|
||||
SharedSurface* mSurf; // Owned by GLScreenBuffer's SurfaceStream.
|
||||
|
||||
ReadBuffer(GLContext* gl,
|
||||
GLuint fb,
|
||||
GLuint depthRB,
|
||||
GLuint stencilRB,
|
||||
SharedSurface_GL* surf)
|
||||
SharedSurface* surf)
|
||||
: mGL(gl)
|
||||
, mFB(fb)
|
||||
, mDepthRB(depthRB)
|
||||
|
@ -123,15 +104,11 @@ public:
|
|||
virtual ~ReadBuffer();
|
||||
|
||||
// Cannot attach a surf of a different AttachType or Size than before.
|
||||
void Attach(SharedSurface_GL* surf);
|
||||
void Attach(SharedSurface* surf);
|
||||
|
||||
const gfx::IntSize& Size() const;
|
||||
|
||||
GLuint FB() const {
|
||||
return mFB;
|
||||
}
|
||||
|
||||
SharedSurface_GL* SharedSurf() const {
|
||||
SharedSurface* SharedSurf() const {
|
||||
return mSurf;
|
||||
}
|
||||
};
|
||||
|
@ -139,13 +116,6 @@ public:
|
|||
|
||||
class GLScreenBuffer
|
||||
{
|
||||
protected:
|
||||
typedef class gfx::SurfaceStream SurfaceStream;
|
||||
typedef class gfx::SharedSurface SharedSurface;
|
||||
typedef gfx::SurfaceStreamType SurfaceStreamType;
|
||||
typedef gfx::SharedSurfaceType SharedSurfaceType;
|
||||
typedef struct gfx::SurfaceCaps SurfaceCaps;
|
||||
|
||||
public:
|
||||
// Infallible.
|
||||
static GLScreenBuffer* Create(GLContext* gl,
|
||||
|
@ -154,8 +124,10 @@ public:
|
|||
|
||||
protected:
|
||||
GLContext* const mGL; // Owns us.
|
||||
SurfaceCaps mCaps;
|
||||
SurfaceFactory_GL* mFactory; // Owned by us.
|
||||
public:
|
||||
const SurfaceCaps mCaps;
|
||||
protected:
|
||||
SurfaceFactory* mFactory; // Owned by us.
|
||||
RefPtr<SurfaceStream> mStream;
|
||||
|
||||
DrawBuffer* mDraw; // Owned by us.
|
||||
|
@ -176,7 +148,7 @@ protected:
|
|||
|
||||
GLScreenBuffer(GLContext* gl,
|
||||
const SurfaceCaps& caps,
|
||||
SurfaceFactory_GL* factory,
|
||||
SurfaceFactory* factory,
|
||||
SurfaceStream* stream)
|
||||
: mGL(gl)
|
||||
, mCaps(caps)
|
||||
|
@ -202,11 +174,11 @@ public:
|
|||
return mStream;
|
||||
}
|
||||
|
||||
SurfaceFactory_GL* Factory() const {
|
||||
SurfaceFactory* Factory() const {
|
||||
return mFactory;
|
||||
}
|
||||
|
||||
SharedSurface_GL* SharedSurf() const {
|
||||
SharedSurface* SharedSurf() const {
|
||||
MOZ_ASSERT(mRead);
|
||||
return mRead->SharedSurf();
|
||||
}
|
||||
|
@ -215,26 +187,22 @@ public:
|
|||
return mCaps.preserve;
|
||||
}
|
||||
|
||||
const SurfaceCaps& Caps() const {
|
||||
return mCaps;
|
||||
}
|
||||
|
||||
GLuint DrawFB() const {
|
||||
if (!mDraw)
|
||||
return ReadFB();
|
||||
|
||||
return mDraw->FB();
|
||||
return mDraw->mFB;
|
||||
}
|
||||
|
||||
GLuint ReadFB() const {
|
||||
return mRead->FB();
|
||||
return mRead->mFB;
|
||||
}
|
||||
|
||||
void DeletingFB(GLuint fb);
|
||||
|
||||
const gfx::IntSize& Size() const {
|
||||
MOZ_ASSERT(mRead);
|
||||
MOZ_ASSERT(!mDraw || mDraw->Size() == mRead->Size());
|
||||
MOZ_ASSERT(!mDraw || mDraw->mSize == mRead->Size());
|
||||
return mRead->Size();
|
||||
}
|
||||
|
||||
|
@ -247,7 +215,7 @@ public:
|
|||
|
||||
/**
|
||||
* Attempts to read pixels from the current bound framebuffer, if
|
||||
* it is backed by a SharedSurface_GL.
|
||||
* it is backed by a SharedSurface.
|
||||
*
|
||||
* Returns true if the pixel data has been read back, false
|
||||
* otherwise.
|
||||
|
@ -267,7 +235,7 @@ public:
|
|||
* Once you pass newFactory into Morph, newFactory will be owned by
|
||||
* GLScreenBuffer, so `forget` any references to it that still exist.
|
||||
*/
|
||||
void Morph(SurfaceFactory_GL* newFactory, SurfaceStreamType streamType);
|
||||
void Morph(SurfaceFactory* newFactory, SurfaceStreamType streamType);
|
||||
|
||||
protected:
|
||||
// Returns false on error or inability to resize.
|
||||
|
@ -278,13 +246,13 @@ public:
|
|||
|
||||
bool Resize(const gfx::IntSize& size);
|
||||
|
||||
void Readback(SharedSurface_GL* src, gfx::DataSourceSurface* dest);
|
||||
void Readback(SharedSurface* src, gfx::DataSourceSurface* dest);
|
||||
|
||||
protected:
|
||||
bool Attach(SharedSurface* surface, const gfx::IntSize& size);
|
||||
|
||||
bool CreateDraw(const gfx::IntSize& size, DrawBuffer** out_buffer);
|
||||
ReadBuffer* CreateRead(SharedSurface_GL* surf);
|
||||
ReadBuffer* CreateRead(SharedSurface* surf);
|
||||
|
||||
public:
|
||||
/* `fb` in these functions is the framebuffer the GLContext is hoping to
|
||||
|
|
|
@ -4,25 +4,297 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SharedSurface.h"
|
||||
|
||||
#include "GLContext.h"
|
||||
#include "GLBlitHelper.h"
|
||||
#include "ScopedGLHelpers.h"
|
||||
#include "SharedSurfaceGL.h"
|
||||
|
||||
using namespace mozilla::gl;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
namespace gl {
|
||||
|
||||
// |src| must begin and end locked, though it
|
||||
// can be temporarily unlocked if needed.
|
||||
void
|
||||
SharedSurface::Copy(SharedSurface* src, SharedSurface* dest, SurfaceFactory* factory)
|
||||
/*static*/ void
|
||||
SharedSurface::ProdCopy(SharedSurface* src, SharedSurface* dest,
|
||||
SurfaceFactory* factory)
|
||||
{
|
||||
MOZ_ASSERT( src->APIType() == APITypeT::OpenGL);
|
||||
MOZ_ASSERT(dest->APIType() == APITypeT::OpenGL);
|
||||
GLContext* gl = src->mGL;
|
||||
|
||||
SharedSurface_GL* srcGL = (SharedSurface_GL*)src;
|
||||
SharedSurface_GL* destGL = (SharedSurface_GL*)dest;
|
||||
// If `src` begins locked, it must end locked, though we may
|
||||
// temporarily unlock it if we need to.
|
||||
MOZ_ASSERT((src == gl->GetLockedSurface()) == src->IsLocked());
|
||||
|
||||
SharedSurface_GL::ProdCopy(srcGL, destGL, (SurfaceFactory_GL*)factory);
|
||||
gl->MakeCurrent();
|
||||
|
||||
if (src->mAttachType == AttachmentType::Screen &&
|
||||
dest->mAttachType == AttachmentType::Screen)
|
||||
{
|
||||
// Here, we actually need to blit through a temp surface, so let's make one.
|
||||
nsAutoPtr<SharedSurface_GLTexture> tempSurf;
|
||||
tempSurf = SharedSurface_GLTexture::Create(gl,
|
||||
gl,
|
||||
factory->mFormats,
|
||||
src->mSize,
|
||||
factory->mCaps.alpha);
|
||||
|
||||
ProdCopy(src, tempSurf, factory);
|
||||
ProdCopy(tempSurf, dest, factory);
|
||||
return;
|
||||
}
|
||||
|
||||
if (src->mAttachType == AttachmentType::Screen) {
|
||||
SharedSurface* origLocked = gl->GetLockedSurface();
|
||||
bool srcNeedsUnlock = false;
|
||||
bool origNeedsRelock = false;
|
||||
if (origLocked != src) {
|
||||
if (origLocked) {
|
||||
origLocked->UnlockProd();
|
||||
origNeedsRelock = true;
|
||||
}
|
||||
|
||||
src->LockProd();
|
||||
srcNeedsUnlock = true;
|
||||
}
|
||||
|
||||
if (dest->mAttachType == AttachmentType::GLTexture) {
|
||||
GLuint destTex = dest->ProdTexture();
|
||||
GLenum destTarget = dest->ProdTextureTarget();
|
||||
|
||||
gl->BlitHelper()->BlitFramebufferToTexture(0, destTex, src->mSize, dest->mSize, destTarget);
|
||||
} else if (dest->mAttachType == AttachmentType::GLRenderbuffer) {
|
||||
GLuint destRB = dest->ProdRenderbuffer();
|
||||
ScopedFramebufferForRenderbuffer destWrapper(gl, destRB);
|
||||
|
||||
gl->BlitHelper()->BlitFramebufferToFramebuffer(0, destWrapper.FB(),
|
||||
src->mSize, dest->mSize);
|
||||
} else {
|
||||
MOZ_CRASH("Unhandled dest->mAttachType.");
|
||||
}
|
||||
|
||||
if (srcNeedsUnlock)
|
||||
src->UnlockProd();
|
||||
|
||||
if (origNeedsRelock)
|
||||
origLocked->LockProd();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (dest->mAttachType == AttachmentType::Screen) {
|
||||
SharedSurface* origLocked = gl->GetLockedSurface();
|
||||
bool destNeedsUnlock = false;
|
||||
bool origNeedsRelock = false;
|
||||
if (origLocked != dest) {
|
||||
if (origLocked) {
|
||||
origLocked->UnlockProd();
|
||||
origNeedsRelock = true;
|
||||
}
|
||||
|
||||
dest->LockProd();
|
||||
destNeedsUnlock = true;
|
||||
}
|
||||
|
||||
if (src->mAttachType == AttachmentType::GLTexture) {
|
||||
GLuint srcTex = src->ProdTexture();
|
||||
GLenum srcTarget = src->ProdTextureTarget();
|
||||
|
||||
gl->BlitHelper()->BlitTextureToFramebuffer(srcTex, 0, src->mSize, dest->mSize, srcTarget);
|
||||
} else if (src->mAttachType == AttachmentType::GLRenderbuffer) {
|
||||
GLuint srcRB = src->ProdRenderbuffer();
|
||||
ScopedFramebufferForRenderbuffer srcWrapper(gl, srcRB);
|
||||
|
||||
gl->BlitHelper()->BlitFramebufferToFramebuffer(srcWrapper.FB(), 0,
|
||||
src->mSize, dest->mSize);
|
||||
} else {
|
||||
MOZ_CRASH("Unhandled src->mAttachType.");
|
||||
}
|
||||
|
||||
if (destNeedsUnlock)
|
||||
dest->UnlockProd();
|
||||
|
||||
if (origNeedsRelock)
|
||||
origLocked->LockProd();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Alright, done with cases involving Screen types.
|
||||
// Only {src,dest}x{texture,renderbuffer} left.
|
||||
|
||||
if (src->mAttachType == AttachmentType::GLTexture) {
|
||||
GLuint srcTex = src->ProdTexture();
|
||||
GLenum srcTarget = src->ProdTextureTarget();
|
||||
|
||||
if (dest->mAttachType == AttachmentType::GLTexture) {
|
||||
GLuint destTex = dest->ProdTexture();
|
||||
GLenum destTarget = dest->ProdTextureTarget();
|
||||
|
||||
gl->BlitHelper()->BlitTextureToTexture(srcTex, destTex,
|
||||
src->mSize, dest->mSize,
|
||||
srcTarget, destTarget);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (dest->mAttachType == AttachmentType::GLRenderbuffer) {
|
||||
GLuint destRB = dest->ProdRenderbuffer();
|
||||
ScopedFramebufferForRenderbuffer destWrapper(gl, destRB);
|
||||
|
||||
gl->BlitHelper()->BlitTextureToFramebuffer(srcTex, destWrapper.FB(),
|
||||
src->mSize, dest->mSize, srcTarget);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_CRASH("Unhandled dest->mAttachType.");
|
||||
}
|
||||
|
||||
if (src->mAttachType == AttachmentType::GLRenderbuffer) {
|
||||
GLuint srcRB = src->ProdRenderbuffer();
|
||||
ScopedFramebufferForRenderbuffer srcWrapper(gl, srcRB);
|
||||
|
||||
if (dest->mAttachType == AttachmentType::GLTexture) {
|
||||
GLuint destTex = dest->ProdTexture();
|
||||
GLenum destTarget = dest->ProdTextureTarget();
|
||||
|
||||
gl->BlitHelper()->BlitFramebufferToTexture(srcWrapper.FB(), destTex,
|
||||
src->mSize, dest->mSize, destTarget);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (dest->mAttachType == AttachmentType::GLRenderbuffer) {
|
||||
GLuint destRB = dest->ProdRenderbuffer();
|
||||
ScopedFramebufferForRenderbuffer destWrapper(gl, destRB);
|
||||
|
||||
gl->BlitHelper()->BlitFramebufferToFramebuffer(srcWrapper.FB(), destWrapper.FB(),
|
||||
src->mSize, dest->mSize);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_CRASH("Unhandled dest->mAttachType.");
|
||||
}
|
||||
|
||||
MOZ_CRASH("Unhandled src->mAttachType.");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// SharedSurface
|
||||
|
||||
void
|
||||
SharedSurface::LockProd()
|
||||
{
|
||||
MOZ_ASSERT(!mIsLocked);
|
||||
|
||||
LockProdImpl();
|
||||
|
||||
mGL->LockSurface(this);
|
||||
mIsLocked = true;
|
||||
}
|
||||
|
||||
void
|
||||
SharedSurface::UnlockProd()
|
||||
{
|
||||
if (!mIsLocked)
|
||||
return;
|
||||
|
||||
UnlockProdImpl();
|
||||
|
||||
mGL->UnlockSurface(this);
|
||||
mIsLocked = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// SurfaceFactory
|
||||
|
||||
static void
|
||||
ChooseBufferBits(const SurfaceCaps& caps,
|
||||
SurfaceCaps* const out_drawCaps,
|
||||
SurfaceCaps* const out_readCaps)
|
||||
{
|
||||
MOZ_ASSERT(out_drawCaps);
|
||||
MOZ_ASSERT(out_readCaps);
|
||||
|
||||
SurfaceCaps screenCaps;
|
||||
|
||||
screenCaps.color = caps.color;
|
||||
screenCaps.alpha = caps.alpha;
|
||||
screenCaps.bpp16 = caps.bpp16;
|
||||
|
||||
screenCaps.depth = caps.depth;
|
||||
screenCaps.stencil = caps.stencil;
|
||||
|
||||
screenCaps.antialias = caps.antialias;
|
||||
screenCaps.preserve = caps.preserve;
|
||||
|
||||
if (caps.antialias) {
|
||||
*out_drawCaps = screenCaps;
|
||||
out_readCaps->Clear();
|
||||
|
||||
// Color caps need to be duplicated in readCaps.
|
||||
out_readCaps->color = caps.color;
|
||||
out_readCaps->alpha = caps.alpha;
|
||||
out_readCaps->bpp16 = caps.bpp16;
|
||||
} else {
|
||||
out_drawCaps->Clear();
|
||||
*out_readCaps = screenCaps;
|
||||
}
|
||||
}
|
||||
|
||||
SurfaceFactory::SurfaceFactory(GLContext* gl,
|
||||
SharedSurfaceType type,
|
||||
const SurfaceCaps& caps)
|
||||
: mGL(gl)
|
||||
, mCaps(caps)
|
||||
, mType(type)
|
||||
, mFormats(gl->ChooseGLFormats(caps))
|
||||
{
|
||||
ChooseBufferBits(mCaps, &mDrawCaps, &mReadCaps);
|
||||
}
|
||||
|
||||
SurfaceFactory::~SurfaceFactory()
|
||||
{
|
||||
while (!mScraps.empty()) {
|
||||
SharedSurface* cur = mScraps.front();
|
||||
mScraps.pop();
|
||||
|
||||
delete cur;
|
||||
}
|
||||
}
|
||||
|
||||
SharedSurface*
|
||||
SurfaceFactory::NewSharedSurface(const gfx::IntSize& size)
|
||||
{
|
||||
// Attempt to reuse an old surface.
|
||||
while (!mScraps.empty()) {
|
||||
SharedSurface* cur = mScraps.front();
|
||||
mScraps.pop();
|
||||
if (cur->mSize == size)
|
||||
return cur;
|
||||
|
||||
// Destroy old surfaces of the wrong size.
|
||||
delete cur;
|
||||
}
|
||||
|
||||
SharedSurface* ret = CreateShared(size);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Auto-deletes surfs of the wrong type.
|
||||
void
|
||||
SurfaceFactory::Recycle(SharedSurface*& surf)
|
||||
{
|
||||
if (!surf)
|
||||
return;
|
||||
|
||||
if (surf->mType == mType) {
|
||||
mScraps.push(surf);
|
||||
} else {
|
||||
delete surf;
|
||||
}
|
||||
|
||||
surf = nullptr;
|
||||
}
|
||||
|
||||
} /* namespace gfx */
|
||||
|
|
|
@ -15,35 +15,43 @@
|
|||
#ifndef SHARED_SURFACE_H_
|
||||
#define SHARED_SURFACE_H_
|
||||
|
||||
#include <queue>
|
||||
#include <stdint.h>
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
#include "GLContextTypes.h"
|
||||
#include "GLDefs.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/gfx/Point.h"
|
||||
#include "SurfaceTypes.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
namespace gl {
|
||||
|
||||
class GLContext;
|
||||
class SurfaceFactory;
|
||||
|
||||
class SharedSurface
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
static void ProdCopy(SharedSurface* src, SharedSurface* dest,
|
||||
SurfaceFactory* factory);
|
||||
|
||||
const SharedSurfaceType mType;
|
||||
const APITypeT mAPI;
|
||||
const AttachmentType mAttachType;
|
||||
GLContext* const mGL;
|
||||
const gfx::IntSize mSize;
|
||||
const bool mHasAlpha;
|
||||
protected:
|
||||
bool mIsLocked;
|
||||
|
||||
SharedSurface(SharedSurfaceType type,
|
||||
APITypeT api,
|
||||
AttachmentType attachType,
|
||||
GLContext* gl,
|
||||
const gfx::IntSize& size,
|
||||
bool hasAlpha)
|
||||
: mType(type)
|
||||
, mAPI(api)
|
||||
, mAttachType(attachType)
|
||||
, mGL(gl)
|
||||
, mSize(size)
|
||||
, mHasAlpha(hasAlpha)
|
||||
, mIsLocked(false)
|
||||
|
@ -54,29 +62,22 @@ public:
|
|||
virtual ~SharedSurface() {
|
||||
}
|
||||
|
||||
static void Copy(SharedSurface* src, SharedSurface* dest,
|
||||
SurfaceFactory* factory);
|
||||
bool IsLocked() const {
|
||||
return mIsLocked;
|
||||
}
|
||||
|
||||
// This locks the SharedSurface as the production buffer for the context.
|
||||
// This is needed by backends which use PBuffers and/or EGLSurfaces.
|
||||
virtual void LockProd() {
|
||||
MOZ_ASSERT(!mIsLocked);
|
||||
LockProdImpl();
|
||||
mIsLocked = true;
|
||||
}
|
||||
void LockProd();
|
||||
|
||||
// Unlocking is harmless if we're already unlocked.
|
||||
virtual void UnlockProd() {
|
||||
if (!mIsLocked)
|
||||
return;
|
||||
|
||||
UnlockProdImpl();
|
||||
mIsLocked = false;
|
||||
}
|
||||
void UnlockProd();
|
||||
|
||||
protected:
|
||||
virtual void LockProdImpl() = 0;
|
||||
virtual void UnlockProdImpl() = 0;
|
||||
|
||||
public:
|
||||
virtual void Fence() = 0;
|
||||
virtual bool WaitSync() = 0;
|
||||
|
||||
|
@ -85,28 +86,71 @@ public:
|
|||
// even when its buffer is still being used.
|
||||
virtual void WaitForBufferOwnership() {}
|
||||
|
||||
SharedSurfaceType Type() const {
|
||||
return mType;
|
||||
// For use when AttachType is correct.
|
||||
virtual GLenum ProdTextureTarget() const {
|
||||
MOZ_ASSERT(mAttachType == AttachmentType::GLTexture);
|
||||
return LOCAL_GL_TEXTURE_2D;
|
||||
}
|
||||
|
||||
APITypeT APIType() const {
|
||||
return mAPI;
|
||||
virtual GLuint ProdTexture() {
|
||||
MOZ_ASSERT(mAttachType == AttachmentType::GLTexture);
|
||||
MOZ_CRASH("Did you forget to override this function?");
|
||||
}
|
||||
|
||||
AttachmentType AttachType() const {
|
||||
return mAttachType;
|
||||
virtual GLuint ProdRenderbuffer() {
|
||||
MOZ_ASSERT(mAttachType == AttachmentType::GLRenderbuffer);
|
||||
MOZ_CRASH("Did you forget to override this function?");
|
||||
}
|
||||
|
||||
const gfx::IntSize& Size() const {
|
||||
return mSize;
|
||||
}
|
||||
|
||||
bool HasAlpha() const {
|
||||
return mHasAlpha;
|
||||
virtual bool ReadPixels(GLint x, GLint y,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
GLvoid* pixels)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace gfx */
|
||||
} /* namespace mozilla */
|
||||
class SurfaceFactory
|
||||
{
|
||||
public:
|
||||
GLContext* const mGL;
|
||||
const SurfaceCaps mCaps;
|
||||
const SharedSurfaceType mType;
|
||||
const GLFormats mFormats;
|
||||
|
||||
#endif /* SHARED_SURFACE_H_ */
|
||||
protected:
|
||||
SurfaceCaps mDrawCaps;
|
||||
SurfaceCaps mReadCaps;
|
||||
|
||||
SurfaceFactory(GLContext* gl,
|
||||
SharedSurfaceType type,
|
||||
const SurfaceCaps& caps);
|
||||
|
||||
public:
|
||||
virtual ~SurfaceFactory();
|
||||
|
||||
const SurfaceCaps& DrawCaps() const {
|
||||
return mDrawCaps;
|
||||
}
|
||||
|
||||
const SurfaceCaps& ReadCaps() const {
|
||||
return mReadCaps;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual SharedSurface* CreateShared(const gfx::IntSize& size) = 0;
|
||||
|
||||
std::queue<SharedSurface*> mScraps;
|
||||
|
||||
public:
|
||||
SharedSurface* NewSharedSurface(const gfx::IntSize& size);
|
||||
|
||||
// Auto-deletes surfs of the wrong type.
|
||||
void Recycle(SharedSurface*& surf);
|
||||
};
|
||||
|
||||
} // namespace gl
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // SHARED_SURFACE_H_
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
#include "SharedSurfaceANGLE.h"
|
||||
|
||||
#include "GLContextEGL.h"
|
||||
#include "GLLibraryEGL.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
SurfaceFactory_ANGLEShareHandle*
|
||||
SurfaceFactory_ANGLEShareHandle::Create(GLContext* gl,
|
||||
const SurfaceCaps& caps)
|
||||
|
@ -227,7 +226,7 @@ SharedSurface_ANGLEShareHandle::Create(GLContext* gl,
|
|||
SurfaceFactory_ANGLEShareHandle::SurfaceFactory_ANGLEShareHandle(GLContext* gl,
|
||||
GLLibraryEGL* egl,
|
||||
const SurfaceCaps& caps)
|
||||
: SurfaceFactory_GL(gl, SharedSurfaceType::EGLSurfaceANGLE, caps)
|
||||
: SurfaceFactory(gl, SharedSurfaceType::EGLSurfaceANGLE, caps)
|
||||
, mProdGL(gl)
|
||||
, mEGL(egl)
|
||||
{
|
||||
|
|
|
@ -6,20 +6,18 @@
|
|||
#ifndef SHARED_SURFACE_ANGLE_H_
|
||||
#define SHARED_SURFACE_ANGLE_H_
|
||||
|
||||
#include "SharedSurfaceGL.h"
|
||||
#include "SurfaceFactory.h"
|
||||
#include "GLLibraryEGL.h"
|
||||
#include "SurfaceTypes.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "SharedSurface.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
class GLContext;
|
||||
class GLLibraryEGL;
|
||||
|
||||
class SharedSurface_ANGLEShareHandle
|
||||
: public SharedSurface_GL
|
||||
: public SharedSurface
|
||||
{
|
||||
public:
|
||||
static SharedSurface_ANGLEShareHandle* Create(GLContext* gl,
|
||||
|
@ -28,7 +26,7 @@ public:
|
|||
bool hasAlpha);
|
||||
|
||||
static SharedSurface_ANGLEShareHandle* Cast(SharedSurface* surf) {
|
||||
MOZ_ASSERT(surf->Type() == SharedSurfaceType::EGLSurfaceANGLE);
|
||||
MOZ_ASSERT(surf->mType == SharedSurfaceType::EGLSurfaceANGLE);
|
||||
|
||||
return (SharedSurface_ANGLEShareHandle*)surf;
|
||||
}
|
||||
|
@ -46,11 +44,11 @@ protected:
|
|||
EGLContext context,
|
||||
EGLSurface pbuffer,
|
||||
HANDLE shareHandle)
|
||||
: SharedSurface_GL(SharedSurfaceType::EGLSurfaceANGLE,
|
||||
AttachmentType::Screen,
|
||||
gl,
|
||||
size,
|
||||
hasAlpha)
|
||||
: SharedSurface(SharedSurfaceType::EGLSurfaceANGLE,
|
||||
AttachmentType::Screen,
|
||||
gl,
|
||||
size,
|
||||
hasAlpha)
|
||||
, mEGL(egl)
|
||||
, mContext(context)
|
||||
, mPBuffer(pbuffer)
|
||||
|
@ -77,7 +75,7 @@ public:
|
|||
|
||||
|
||||
class SurfaceFactory_ANGLEShareHandle
|
||||
: public SurfaceFactory_GL
|
||||
: public SurfaceFactory
|
||||
{
|
||||
protected:
|
||||
GLContext* const mProdGL;
|
||||
|
|
|
@ -4,16 +4,14 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SharedSurfaceEGL.h"
|
||||
#include "GLContextEGL.h"
|
||||
#include "GLBlitHelper.h"
|
||||
#include "ScopedGLHelpers.h"
|
||||
#include "SharedSurfaceGL.h"
|
||||
#include "SurfaceFactory.h"
|
||||
#include "GLLibraryEGL.h"
|
||||
#include "TextureGarbageBin.h"
|
||||
#include "GLReadTexImageHelper.h"
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
#include "GLBlitHelper.h"
|
||||
#include "GLContextEGL.h"
|
||||
#include "GLLibraryEGL.h"
|
||||
#include "GLReadTexImageHelper.h"
|
||||
#include "ScopedGLHelpers.h"
|
||||
#include "SharedSurface.h"
|
||||
#include "TextureGarbageBin.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
@ -69,11 +67,11 @@ SharedSurface_EGLImage::SharedSurface_EGLImage(GLContext* gl,
|
|||
const GLFormats& formats,
|
||||
GLuint prodTex,
|
||||
EGLImage image)
|
||||
: SharedSurface_GL(SharedSurfaceType::EGLImageShare,
|
||||
AttachmentType::GLTexture,
|
||||
gl,
|
||||
size,
|
||||
hasAlpha)
|
||||
: SharedSurface(SharedSurfaceType::EGLImageShare,
|
||||
AttachmentType::GLTexture,
|
||||
gl,
|
||||
size,
|
||||
hasAlpha)
|
||||
, mMutex("SharedSurface_EGLImage mutex")
|
||||
, mEGL(egl)
|
||||
, mFormats(formats)
|
||||
|
|
|
@ -6,21 +6,20 @@
|
|||
#ifndef SHARED_SURFACE_EGL_H_
|
||||
#define SHARED_SURFACE_EGL_H_
|
||||
|
||||
#include "SharedSurfaceGL.h"
|
||||
#include "SurfaceFactory.h"
|
||||
#include "GLLibraryEGL.h"
|
||||
#include "SurfaceTypes.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "SharedSurface.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
class GLContext;
|
||||
class GLLibraryEGL;
|
||||
class TextureGarbageBin;
|
||||
|
||||
class SharedSurface_EGLImage
|
||||
: public SharedSurface_GL
|
||||
: public SharedSurface
|
||||
{
|
||||
public:
|
||||
static SharedSurface_EGLImage* Create(GLContext* prodGL,
|
||||
|
@ -30,7 +29,7 @@ public:
|
|||
EGLContext context);
|
||||
|
||||
static SharedSurface_EGLImage* Cast(SharedSurface* surf) {
|
||||
MOZ_ASSERT(surf->Type() == SharedSurfaceType::EGLImageShare);
|
||||
MOZ_ASSERT(surf->mType == SharedSurfaceType::EGLImageShare);
|
||||
|
||||
return (SharedSurface_EGLImage*)surf;
|
||||
}
|
||||
|
@ -81,7 +80,7 @@ public:
|
|||
|
||||
|
||||
class SurfaceFactory_EGLImage
|
||||
: public SurfaceFactory_GL
|
||||
: public SurfaceFactory
|
||||
{
|
||||
public:
|
||||
// Fallible:
|
||||
|
@ -94,7 +93,7 @@ protected:
|
|||
SurfaceFactory_EGLImage(GLContext* prodGL,
|
||||
EGLContext context,
|
||||
const SurfaceCaps& caps)
|
||||
: SurfaceFactory_GL(prodGL, SharedSurfaceType::EGLImageShare, caps)
|
||||
: SurfaceFactory(prodGL, SharedSurfaceType::EGLImageShare, caps)
|
||||
, mContext(context)
|
||||
{}
|
||||
|
||||
|
|
|
@ -4,244 +4,18 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SharedSurfaceGL.h"
|
||||
|
||||
#include "GLContext.h"
|
||||
#include "GLBlitHelper.h"
|
||||
#include "ScopedGLHelpers.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "GLReadTexImageHelper.h"
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
// |src| must begin and end locked, though we may
|
||||
// temporarily unlock it if we need to.
|
||||
void
|
||||
SharedSurface_GL::ProdCopy(SharedSurface_GL* src, SharedSurface_GL* dest,
|
||||
SurfaceFactory_GL* factory)
|
||||
{
|
||||
GLContext* gl = src->GL();
|
||||
|
||||
gl->MakeCurrent();
|
||||
|
||||
if (src->AttachType() == AttachmentType::Screen &&
|
||||
dest->AttachType() == AttachmentType::Screen)
|
||||
{
|
||||
// Here, we actually need to blit through a temp surface, so let's make one.
|
||||
nsAutoPtr<SharedSurface_GLTexture> tempSurf(
|
||||
SharedSurface_GLTexture::Create(gl, gl,
|
||||
factory->Formats(),
|
||||
src->Size(),
|
||||
factory->Caps().alpha));
|
||||
|
||||
ProdCopy(src, tempSurf, factory);
|
||||
ProdCopy(tempSurf, dest, factory);
|
||||
return;
|
||||
}
|
||||
|
||||
if (src->AttachType() == AttachmentType::Screen) {
|
||||
SharedSurface_GL* origLocked = gl->GetLockedSurface();
|
||||
bool srcNeedsUnlock = false;
|
||||
bool origNeedsRelock = false;
|
||||
if (origLocked != src) {
|
||||
if (origLocked) {
|
||||
origLocked->UnlockProd();
|
||||
origNeedsRelock = true;
|
||||
}
|
||||
|
||||
src->LockProd();
|
||||
srcNeedsUnlock = true;
|
||||
}
|
||||
|
||||
if (dest->AttachType() == AttachmentType::GLTexture) {
|
||||
GLuint destTex = dest->ProdTexture();
|
||||
GLenum destTarget = dest->ProdTextureTarget();
|
||||
|
||||
gl->BlitHelper()->BlitFramebufferToTexture(0, destTex, src->Size(), dest->Size(), destTarget);
|
||||
} else if (dest->AttachType() == AttachmentType::GLRenderbuffer) {
|
||||
GLuint destRB = dest->ProdRenderbuffer();
|
||||
ScopedFramebufferForRenderbuffer destWrapper(gl, destRB);
|
||||
|
||||
gl->BlitHelper()->BlitFramebufferToFramebuffer(0, destWrapper.FB(),
|
||||
src->Size(), dest->Size());
|
||||
} else {
|
||||
MOZ_CRASH("Unhandled dest->AttachType().");
|
||||
}
|
||||
|
||||
if (srcNeedsUnlock)
|
||||
src->UnlockProd();
|
||||
|
||||
if (origNeedsRelock)
|
||||
origLocked->LockProd();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (dest->AttachType() == AttachmentType::Screen) {
|
||||
SharedSurface_GL* origLocked = gl->GetLockedSurface();
|
||||
bool destNeedsUnlock = false;
|
||||
bool origNeedsRelock = false;
|
||||
if (origLocked != dest) {
|
||||
if (origLocked) {
|
||||
origLocked->UnlockProd();
|
||||
origNeedsRelock = true;
|
||||
}
|
||||
|
||||
dest->LockProd();
|
||||
destNeedsUnlock = true;
|
||||
}
|
||||
|
||||
if (src->AttachType() == AttachmentType::GLTexture) {
|
||||
GLuint srcTex = src->ProdTexture();
|
||||
GLenum srcTarget = src->ProdTextureTarget();
|
||||
|
||||
gl->BlitHelper()->BlitTextureToFramebuffer(srcTex, 0, src->Size(), dest->Size(), srcTarget);
|
||||
} else if (src->AttachType() == AttachmentType::GLRenderbuffer) {
|
||||
GLuint srcRB = src->ProdRenderbuffer();
|
||||
ScopedFramebufferForRenderbuffer srcWrapper(gl, srcRB);
|
||||
|
||||
gl->BlitHelper()->BlitFramebufferToFramebuffer(srcWrapper.FB(), 0,
|
||||
src->Size(), dest->Size());
|
||||
} else {
|
||||
MOZ_CRASH("Unhandled src->AttachType().");
|
||||
}
|
||||
|
||||
if (destNeedsUnlock)
|
||||
dest->UnlockProd();
|
||||
|
||||
if (origNeedsRelock)
|
||||
origLocked->LockProd();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Alright, done with cases involving Screen types.
|
||||
// Only {src,dest}x{texture,renderbuffer} left.
|
||||
|
||||
if (src->AttachType() == AttachmentType::GLTexture) {
|
||||
GLuint srcTex = src->ProdTexture();
|
||||
GLenum srcTarget = src->ProdTextureTarget();
|
||||
|
||||
if (dest->AttachType() == AttachmentType::GLTexture) {
|
||||
GLuint destTex = dest->ProdTexture();
|
||||
GLenum destTarget = dest->ProdTextureTarget();
|
||||
|
||||
gl->BlitHelper()->BlitTextureToTexture(srcTex, destTex,
|
||||
src->Size(), dest->Size(),
|
||||
srcTarget, destTarget);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (dest->AttachType() == AttachmentType::GLRenderbuffer) {
|
||||
GLuint destRB = dest->ProdRenderbuffer();
|
||||
ScopedFramebufferForRenderbuffer destWrapper(gl, destRB);
|
||||
|
||||
gl->BlitHelper()->BlitTextureToFramebuffer(srcTex, destWrapper.FB(),
|
||||
src->Size(), dest->Size(), srcTarget);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_CRASH("Unhandled dest->AttachType().");
|
||||
}
|
||||
|
||||
if (src->AttachType() == AttachmentType::GLRenderbuffer) {
|
||||
GLuint srcRB = src->ProdRenderbuffer();
|
||||
ScopedFramebufferForRenderbuffer srcWrapper(gl, srcRB);
|
||||
|
||||
if (dest->AttachType() == AttachmentType::GLTexture) {
|
||||
GLuint destTex = dest->ProdTexture();
|
||||
GLenum destTarget = dest->ProdTextureTarget();
|
||||
|
||||
gl->BlitHelper()->BlitFramebufferToTexture(srcWrapper.FB(), destTex,
|
||||
src->Size(), dest->Size(), destTarget);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (dest->AttachType() == AttachmentType::GLRenderbuffer) {
|
||||
GLuint destRB = dest->ProdRenderbuffer();
|
||||
ScopedFramebufferForRenderbuffer destWrapper(gl, destRB);
|
||||
|
||||
gl->BlitHelper()->BlitFramebufferToFramebuffer(srcWrapper.FB(), destWrapper.FB(),
|
||||
src->Size(), dest->Size());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_CRASH("Unhandled dest->AttachType().");
|
||||
}
|
||||
|
||||
MOZ_CRASH("Unhandled src->AttachType().");
|
||||
}
|
||||
|
||||
void
|
||||
SharedSurface_GL::LockProd()
|
||||
{
|
||||
MOZ_ASSERT(!mIsLocked);
|
||||
|
||||
LockProdImpl();
|
||||
|
||||
mGL->LockSurface(this);
|
||||
mIsLocked = true;
|
||||
}
|
||||
|
||||
void
|
||||
SharedSurface_GL::UnlockProd()
|
||||
{
|
||||
if (!mIsLocked)
|
||||
return;
|
||||
|
||||
UnlockProdImpl();
|
||||
|
||||
mGL->UnlockSurface(this);
|
||||
mIsLocked = false;
|
||||
}
|
||||
|
||||
|
||||
SurfaceFactory_GL::SurfaceFactory_GL(GLContext* gl,
|
||||
SharedSurfaceType type,
|
||||
const SurfaceCaps& caps)
|
||||
: SurfaceFactory(type, caps)
|
||||
, mGL(gl)
|
||||
, mFormats(gl->ChooseGLFormats(caps))
|
||||
{
|
||||
ChooseBufferBits(caps, mDrawCaps, mReadCaps);
|
||||
}
|
||||
|
||||
void
|
||||
SurfaceFactory_GL::ChooseBufferBits(const SurfaceCaps& caps,
|
||||
SurfaceCaps& drawCaps,
|
||||
SurfaceCaps& readCaps) const
|
||||
{
|
||||
SurfaceCaps screenCaps;
|
||||
|
||||
screenCaps.color = caps.color;
|
||||
screenCaps.alpha = caps.alpha;
|
||||
screenCaps.bpp16 = caps.bpp16;
|
||||
|
||||
screenCaps.depth = caps.depth;
|
||||
screenCaps.stencil = caps.stencil;
|
||||
|
||||
screenCaps.antialias = caps.antialias;
|
||||
screenCaps.preserve = caps.preserve;
|
||||
|
||||
if (caps.antialias) {
|
||||
drawCaps = screenCaps;
|
||||
readCaps.Clear();
|
||||
|
||||
// Color caps need to be duplicated in readCaps.
|
||||
readCaps.color = caps.color;
|
||||
readCaps.alpha = caps.alpha;
|
||||
readCaps.bpp16 = caps.bpp16;
|
||||
} else {
|
||||
drawCaps.Clear();
|
||||
readCaps = screenCaps;
|
||||
}
|
||||
}
|
||||
|
||||
using gfx::IntSize;
|
||||
using gfx::SurfaceFormat;
|
||||
|
||||
SharedSurface_Basic*
|
||||
SharedSurface_Basic::Create(GLContext* gl,
|
||||
|
@ -279,12 +53,13 @@ SharedSurface_Basic::SharedSurface_Basic(GLContext* gl,
|
|||
bool hasAlpha,
|
||||
SurfaceFormat format,
|
||||
GLuint tex)
|
||||
: SharedSurface_GL(SharedSurfaceType::Basic,
|
||||
AttachmentType::GLTexture,
|
||||
gl,
|
||||
size,
|
||||
hasAlpha)
|
||||
, mTex(tex), mFB(0)
|
||||
: SharedSurface(SharedSurfaceType::Basic,
|
||||
AttachmentType::GLTexture,
|
||||
gl,
|
||||
size,
|
||||
hasAlpha)
|
||||
, mTex(tex)
|
||||
, mFB(0)
|
||||
{
|
||||
mGL->MakeCurrent();
|
||||
mGL->fGenFramebuffers(1, &mFB);
|
||||
|
@ -302,8 +77,8 @@ SharedSurface_Basic::SharedSurface_Basic(GLContext* gl,
|
|||
mFB = 0;
|
||||
}
|
||||
|
||||
mData = Factory::CreateDataSourceSurfaceWithStride(size, format,
|
||||
GetAlignedStride<4>(size.width * BytesPerPixel(format)));
|
||||
int32_t stride = gfx::GetAlignedStride<4>(size.width * BytesPerPixel(format));
|
||||
mData = gfx::Factory::CreateDataSourceSurfaceWithStride(size, format, stride);
|
||||
}
|
||||
|
||||
SharedSurface_Basic::~SharedSurface_Basic()
|
||||
|
@ -331,7 +106,7 @@ SharedSurface_GLTexture*
|
|||
SharedSurface_GLTexture::Create(GLContext* prodGL,
|
||||
GLContext* consGL,
|
||||
const GLFormats& formats,
|
||||
const gfx::IntSize& size,
|
||||
const IntSize& size,
|
||||
bool hasAlpha,
|
||||
GLuint texture)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include "ScopedGLHelpers.h"
|
||||
#include "SharedSurface.h"
|
||||
#include "SurfaceFactory.h"
|
||||
#include "SurfaceTypes.h"
|
||||
#include "GLContextTypes.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
@ -30,111 +29,9 @@ namespace mozilla {
|
|||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
class SurfaceFactory_GL;
|
||||
|
||||
class SharedSurface_GL
|
||||
: public gfx::SharedSurface
|
||||
{
|
||||
protected:
|
||||
typedef class gfx::SharedSurface SharedSurface;
|
||||
typedef gfx::SharedSurfaceType SharedSurfaceType;
|
||||
typedef gfx::APITypeT APITypeT;
|
||||
typedef gfx::AttachmentType AttachmentType;
|
||||
|
||||
GLContext* const mGL;
|
||||
|
||||
SharedSurface_GL(SharedSurfaceType type,
|
||||
AttachmentType attachType,
|
||||
GLContext* gl,
|
||||
const gfx::IntSize& size,
|
||||
bool hasAlpha)
|
||||
: SharedSurface(type, APITypeT::OpenGL, attachType, size, hasAlpha)
|
||||
, mGL(gl)
|
||||
{}
|
||||
|
||||
public:
|
||||
static void ProdCopy(SharedSurface_GL* src, SharedSurface_GL* dest,
|
||||
SurfaceFactory_GL* factory);
|
||||
|
||||
static SharedSurface_GL* Cast(SharedSurface* surf) {
|
||||
MOZ_ASSERT(surf->APIType() == APITypeT::OpenGL);
|
||||
|
||||
return (SharedSurface_GL*)surf;
|
||||
}
|
||||
|
||||
// For use when AttachType is correct.
|
||||
virtual GLuint ProdTexture() {
|
||||
MOZ_ASSERT(AttachType() == AttachmentType::GLTexture);
|
||||
MOZ_CRASH("Did you forget to override this function?");
|
||||
}
|
||||
|
||||
virtual GLenum ProdTextureTarget() const {
|
||||
return LOCAL_GL_TEXTURE_2D;
|
||||
}
|
||||
|
||||
virtual GLuint ProdRenderbuffer() {
|
||||
MOZ_ASSERT(AttachType() == AttachmentType::GLRenderbuffer);
|
||||
MOZ_CRASH("Did you forget to override this function?");
|
||||
}
|
||||
|
||||
virtual bool ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type, GLvoid *pixels) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void LockProd() MOZ_OVERRIDE;
|
||||
virtual void UnlockProd() MOZ_OVERRIDE;
|
||||
|
||||
GLContext* GL() const {
|
||||
return mGL;
|
||||
}
|
||||
};
|
||||
|
||||
class SurfaceFactory_GL
|
||||
: public gfx::SurfaceFactory
|
||||
{
|
||||
protected:
|
||||
typedef struct gfx::SurfaceCaps SurfaceCaps;
|
||||
typedef class gfx::SurfaceFactory SurfaceFactory;
|
||||
typedef class gfx::SharedSurface SharedSurface;
|
||||
typedef gfx::SharedSurfaceType SharedSurfaceType;
|
||||
|
||||
GLContext* const mGL;
|
||||
const GLFormats mFormats;
|
||||
|
||||
SurfaceCaps mDrawCaps;
|
||||
SurfaceCaps mReadCaps;
|
||||
|
||||
// This uses ChooseBufferBits to pick drawBits/readBits.
|
||||
SurfaceFactory_GL(GLContext* gl,
|
||||
SharedSurfaceType type,
|
||||
const SurfaceCaps& caps);
|
||||
|
||||
virtual void ChooseBufferBits(const SurfaceCaps& caps,
|
||||
SurfaceCaps& drawCaps,
|
||||
SurfaceCaps& readCaps) const;
|
||||
|
||||
public:
|
||||
GLContext* GL() const {
|
||||
return mGL;
|
||||
}
|
||||
|
||||
const GLFormats& Formats() const {
|
||||
return mFormats;
|
||||
}
|
||||
|
||||
const SurfaceCaps& DrawCaps() const {
|
||||
return mDrawCaps;
|
||||
}
|
||||
|
||||
const SurfaceCaps& ReadCaps() const {
|
||||
return mReadCaps;
|
||||
}
|
||||
};
|
||||
|
||||
// For readback and bootstrapping:
|
||||
class SharedSurface_Basic
|
||||
: public SharedSurface_GL
|
||||
: public SharedSurface
|
||||
{
|
||||
public:
|
||||
static SharedSurface_Basic* Create(GLContext* gl,
|
||||
|
@ -143,7 +40,7 @@ public:
|
|||
bool hasAlpha);
|
||||
|
||||
static SharedSurface_Basic* Cast(SharedSurface* surf) {
|
||||
MOZ_ASSERT(surf->Type() == SharedSurfaceType::Basic);
|
||||
MOZ_ASSERT(surf->mType == SharedSurfaceType::Basic);
|
||||
|
||||
return (SharedSurface_Basic*)surf;
|
||||
}
|
||||
|
@ -185,11 +82,11 @@ public:
|
|||
};
|
||||
|
||||
class SurfaceFactory_Basic
|
||||
: public SurfaceFactory_GL
|
||||
: public SurfaceFactory
|
||||
{
|
||||
public:
|
||||
SurfaceFactory_Basic(GLContext* gl, const SurfaceCaps& caps)
|
||||
: SurfaceFactory_GL(gl, SharedSurfaceType::Basic, caps)
|
||||
: SurfaceFactory(gl, SharedSurfaceType::Basic, caps)
|
||||
{}
|
||||
|
||||
virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
|
||||
|
@ -201,7 +98,7 @@ public:
|
|||
|
||||
// Using shared GL textures:
|
||||
class SharedSurface_GLTexture
|
||||
: public SharedSurface_GL
|
||||
: public SharedSurface
|
||||
{
|
||||
public:
|
||||
static SharedSurface_GLTexture* Create(GLContext* prodGL,
|
||||
|
@ -212,7 +109,7 @@ public:
|
|||
GLuint texture = 0);
|
||||
|
||||
static SharedSurface_GLTexture* Cast(SharedSurface* surf) {
|
||||
MOZ_ASSERT(surf->Type() == SharedSurfaceType::GLTextureShare);
|
||||
MOZ_ASSERT(surf->mType == SharedSurfaceType::GLTextureShare);
|
||||
|
||||
return (SharedSurface_GLTexture*)surf;
|
||||
}
|
||||
|
@ -230,11 +127,11 @@ protected:
|
|||
bool hasAlpha,
|
||||
GLuint tex,
|
||||
bool ownsTex)
|
||||
: SharedSurface_GL(SharedSurfaceType::GLTextureShare,
|
||||
AttachmentType::GLTexture,
|
||||
prodGL,
|
||||
size,
|
||||
hasAlpha)
|
||||
: SharedSurface(SharedSurfaceType::GLTextureShare,
|
||||
AttachmentType::GLTexture,
|
||||
prodGL,
|
||||
size,
|
||||
hasAlpha)
|
||||
, mConsGL(consGL)
|
||||
, mTex(tex)
|
||||
, mOwnsTex(ownsTex)
|
||||
|
@ -268,7 +165,7 @@ public:
|
|||
};
|
||||
|
||||
class SurfaceFactory_GLTexture
|
||||
: public SurfaceFactory_GL
|
||||
: public SurfaceFactory
|
||||
{
|
||||
protected:
|
||||
GLContext* const mConsGL;
|
||||
|
@ -280,7 +177,7 @@ public:
|
|||
SurfaceFactory_GLTexture(GLContext* prodGL,
|
||||
GLContext* consGL,
|
||||
const SurfaceCaps& caps)
|
||||
: SurfaceFactory_GL(prodGL, SharedSurfaceType::GLTextureShare, caps)
|
||||
: SurfaceFactory(prodGL, SharedSurfaceType::GLTextureShare, caps)
|
||||
, mConsGL(consGL)
|
||||
{
|
||||
MOZ_ASSERT(consGL != prodGL);
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
#include "SharedSurfaceGralloc.h"
|
||||
|
||||
#include "GLContext.h"
|
||||
#include "SharedSurfaceGL.h"
|
||||
#include "SurfaceFactory.h"
|
||||
#include "SharedSurface.h"
|
||||
#include "GLLibraryEGL.h"
|
||||
#include "mozilla/layers/GrallocTextureClient.h"
|
||||
#include "mozilla/layers/ShadowLayers.h"
|
||||
|
@ -32,14 +31,13 @@
|
|||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::layers;
|
||||
using namespace android;
|
||||
|
||||
SurfaceFactory_Gralloc::SurfaceFactory_Gralloc(GLContext* prodGL,
|
||||
const SurfaceCaps& caps,
|
||||
layers::ISurfaceAllocator* allocator)
|
||||
: SurfaceFactory_GL(prodGL, SharedSurfaceType::Gralloc, caps)
|
||||
: SurfaceFactory(prodGL, SharedSurfaceType::Gralloc, caps)
|
||||
{
|
||||
if (caps.surfaceAllocator) {
|
||||
allocator = caps.surfaceAllocator;
|
||||
|
@ -126,11 +124,11 @@ SharedSurface_Gralloc::SharedSurface_Gralloc(GLContext* prodGL,
|
|||
layers::ISurfaceAllocator* allocator,
|
||||
layers::GrallocTextureClientOGL* textureClient,
|
||||
GLuint prodTex)
|
||||
: SharedSurface_GL(SharedSurfaceType::Gralloc,
|
||||
AttachmentType::GLTexture,
|
||||
prodGL,
|
||||
size,
|
||||
hasAlpha)
|
||||
: SharedSurface(SharedSurfaceType::Gralloc,
|
||||
AttachmentType::GLTexture,
|
||||
prodGL,
|
||||
size,
|
||||
hasAlpha)
|
||||
, mEGL(egl)
|
||||
, mSync(0)
|
||||
, mAllocator(allocator)
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#ifndef SHARED_SURFACE_GRALLOC_H_
|
||||
#define SHARED_SURFACE_GRALLOC_H_
|
||||
|
||||
#include "SharedSurfaceGL.h"
|
||||
#include "mozilla/layers/LayersSurfaces.h"
|
||||
#include "SharedSurface.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -20,7 +20,7 @@ class GLContext;
|
|||
class GLLibraryEGL;
|
||||
|
||||
class SharedSurface_Gralloc
|
||||
: public SharedSurface_GL
|
||||
: public SharedSurface
|
||||
{
|
||||
public:
|
||||
static SharedSurface_Gralloc* Create(GLContext* prodGL,
|
||||
|
@ -30,7 +30,7 @@ public:
|
|||
layers::ISurfaceAllocator* allocator);
|
||||
|
||||
static SharedSurface_Gralloc* Cast(SharedSurface* surf) {
|
||||
MOZ_ASSERT(surf->Type() == SharedSurfaceType::Gralloc);
|
||||
MOZ_ASSERT(surf->mType == SharedSurfaceType::Gralloc);
|
||||
|
||||
return (SharedSurface_Gralloc*)surf;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public:
|
|||
};
|
||||
|
||||
class SurfaceFactory_Gralloc
|
||||
: public SurfaceFactory_GL
|
||||
: public SurfaceFactory
|
||||
{
|
||||
protected:
|
||||
RefPtr<layers::ISurfaceAllocator> mAllocator;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SharedSurfaceIO.h"
|
||||
|
||||
#include "GLContextCGL.h"
|
||||
#include "mozilla/gfx/MacIOSurface.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
|
@ -12,10 +13,8 @@
|
|||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
using namespace gfx;
|
||||
|
||||
/* static */ SharedSurface_IOSurface*
|
||||
SharedSurface_IOSurface::Create(MacIOSurface* surface, GLContext *gl, bool hasAlpha)
|
||||
SharedSurface_IOSurface::Create(MacIOSurface* surface, GLContext* gl, bool hasAlpha)
|
||||
{
|
||||
MOZ_ASSERT(surface);
|
||||
MOZ_ASSERT(gl);
|
||||
|
@ -33,7 +32,7 @@ SharedSurface_IOSurface::Fence()
|
|||
|
||||
bool
|
||||
SharedSurface_IOSurface::ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type, GLvoid *pixels)
|
||||
GLenum format, GLenum type, GLvoid* pixels)
|
||||
{
|
||||
// Calling glReadPixels when an IOSurface is bound to the current framebuffer
|
||||
// can cause corruption in following glReadPixel calls (even if they aren't
|
||||
|
@ -50,7 +49,7 @@ SharedSurface_IOSurface::ReadPixels(GLint x, GLint y, GLsizei width, GLsizei hei
|
|||
ScopedBindFramebuffer bindFB(mGL, srcFB.FB());
|
||||
ScopedBindTexture bindTex(mGL, destTex.Texture());
|
||||
mGL->fCopyTexImage2D(LOCAL_GL_TEXTURE_2D, 0,
|
||||
HasAlpha() ? LOCAL_GL_RGBA : LOCAL_GL_RGB,
|
||||
mHasAlpha ? LOCAL_GL_RGBA : LOCAL_GL_RGB,
|
||||
x, y,
|
||||
width, height, 0);
|
||||
}
|
||||
|
@ -92,7 +91,11 @@ SharedSurface_IOSurface::SharedSurface_IOSurface(MacIOSurface* surface,
|
|||
GLContext* gl,
|
||||
const gfx::IntSize& size,
|
||||
bool hasAlpha)
|
||||
: SharedSurface_GL(SharedSurfaceType::IOSurface, AttachmentType::GLTexture, gl, size, hasAlpha)
|
||||
: SharedSurface(SharedSurfaceType::IOSurface,
|
||||
AttachmentType::GLTexture,
|
||||
gl,
|
||||
size,
|
||||
hasAlpha)
|
||||
, mSurface(surface)
|
||||
, mCurConsGL(nullptr)
|
||||
, mConsTex(0)
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
#ifndef SHARED_SURFACEIO_H_
|
||||
#define SHARED_SURFACEIO_H_
|
||||
|
||||
#include "SharedSurfaceGL.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "SharedSurface.h"
|
||||
|
||||
class MacIOSurface;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
class SharedSurface_IOSurface : public SharedSurface_GL
|
||||
class SharedSurface_IOSurface : public SharedSurface
|
||||
{
|
||||
public:
|
||||
static SharedSurface_IOSurface* Create(MacIOSurface* surface, GLContext *gl, bool hasAlpha);
|
||||
static SharedSurface_IOSurface* Create(MacIOSurface* surface, GLContext* gl, bool hasAlpha);
|
||||
|
||||
~SharedSurface_IOSurface();
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
|||
}
|
||||
|
||||
static SharedSurface_IOSurface* Cast(SharedSurface *surf) {
|
||||
MOZ_ASSERT(surf->Type() == SharedSurfaceType::IOSurface);
|
||||
MOZ_ASSERT(surf->mType == SharedSurfaceType::IOSurface);
|
||||
return static_cast<SharedSurface_IOSurface*>(surf);
|
||||
}
|
||||
|
||||
|
@ -62,12 +62,12 @@ private:
|
|||
GLuint mConsTex;
|
||||
};
|
||||
|
||||
class SurfaceFactory_IOSurface : public SurfaceFactory_GL
|
||||
class SurfaceFactory_IOSurface : public SurfaceFactory
|
||||
{
|
||||
public:
|
||||
SurfaceFactory_IOSurface(GLContext* gl,
|
||||
const SurfaceCaps& caps)
|
||||
: SurfaceFactory_GL(gl, SharedSurfaceType::IOSurface, caps)
|
||||
: SurfaceFactory(gl, SharedSurfaceType::IOSurface, caps)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SurfaceFactory.h"
|
||||
|
||||
#include "SharedSurface.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
SurfaceFactory::~SurfaceFactory()
|
||||
{
|
||||
while (!mScraps.empty()) {
|
||||
SharedSurface* cur = mScraps.front();
|
||||
mScraps.pop();
|
||||
|
||||
delete cur;
|
||||
}
|
||||
}
|
||||
|
||||
SharedSurface*
|
||||
SurfaceFactory::NewSharedSurface(const gfx::IntSize& size)
|
||||
{
|
||||
// Attempt to reuse an old surface.
|
||||
while (!mScraps.empty()) {
|
||||
SharedSurface* cur = mScraps.front();
|
||||
mScraps.pop();
|
||||
if (cur->Size() == size)
|
||||
return cur;
|
||||
|
||||
// Destroy old surfaces of the wrong size.
|
||||
delete cur;
|
||||
}
|
||||
|
||||
SharedSurface* ret = CreateShared(size);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Auto-deletes surfs of the wrong type.
|
||||
void
|
||||
SurfaceFactory::Recycle(SharedSurface*& surf)
|
||||
{
|
||||
if (!surf)
|
||||
return;
|
||||
|
||||
if (surf->Type() == mType) {
|
||||
mScraps.push(surf);
|
||||
} else {
|
||||
delete surf;
|
||||
}
|
||||
|
||||
surf = nullptr;
|
||||
}
|
||||
|
||||
} /* namespace gfx */
|
||||
} /* namespace mozilla */
|
|
@ -1,55 +0,0 @@
|
|||
/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef SURFACE_FACTORY_H_
|
||||
#define SURFACE_FACTORY_H_
|
||||
|
||||
#include <queue>
|
||||
#include "SurfaceTypes.h"
|
||||
#include "gfxPoint.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
// Forward:
|
||||
class SharedSurface;
|
||||
|
||||
class SurfaceFactory
|
||||
{
|
||||
protected:
|
||||
SurfaceCaps mCaps;
|
||||
SharedSurfaceType mType;
|
||||
|
||||
SurfaceFactory(SharedSurfaceType type, const SurfaceCaps& caps)
|
||||
: mCaps(caps)
|
||||
, mType(type)
|
||||
{}
|
||||
|
||||
public:
|
||||
virtual ~SurfaceFactory();
|
||||
|
||||
protected:
|
||||
virtual SharedSurface* CreateShared(const gfx::IntSize& size) = 0;
|
||||
|
||||
std::queue<SharedSurface*> mScraps;
|
||||
|
||||
public:
|
||||
SharedSurface* NewSharedSurface(const gfx::IntSize& size);
|
||||
|
||||
// Auto-deletes surfs of the wrong type.
|
||||
void Recycle(SharedSurface*& surf);
|
||||
|
||||
const SurfaceCaps& Caps() const {
|
||||
return mCaps;
|
||||
}
|
||||
|
||||
SharedSurfaceType Type() const {
|
||||
return mType;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // SURFACE_FACTORY_H_
|
|
@ -8,11 +8,10 @@
|
|||
#include "gfxPoint.h"
|
||||
#include "SharedSurface.h"
|
||||
#include "SharedSurfaceGL.h"
|
||||
#include "SurfaceFactory.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
namespace gl {
|
||||
|
||||
SurfaceStreamType
|
||||
SurfaceStream::ChooseGLStreamType(SurfaceStream::OMTC omtc,
|
||||
|
@ -61,15 +60,15 @@ bool
|
|||
SurfaceStream_TripleBuffer::CopySurfaceToProducer(SharedSurface* src, SurfaceFactory* factory)
|
||||
{
|
||||
if (!mProducer) {
|
||||
New(factory, src->Size(), mProducer);
|
||||
New(factory, src->mSize, mProducer);
|
||||
if (!mProducer) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_ASSERT(src->Size() == mProducer->Size(), "Size mismatch");
|
||||
MOZ_ASSERT(src->mSize == mProducer->mSize, "Size mismatch");
|
||||
|
||||
SharedSurface::Copy(src, mProducer, factory);
|
||||
SharedSurface::ProdCopy(src, mProducer, factory);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -254,12 +253,12 @@ SurfaceStream_SingleBuffer::SwapProducer(SurfaceFactory* factory,
|
|||
|
||||
// Size mismatch means we need to squirrel the current Prod
|
||||
// into Cons, and leave Prod empty, so it gets a new surface below.
|
||||
bool needsNewBuffer = mProducer->Size() != size;
|
||||
bool needsNewBuffer = mProducer->mSize != size;
|
||||
|
||||
// Even if we're the right size, if the type has changed, and we don't
|
||||
// need to preserve, we should switch out for (presumedly) better perf.
|
||||
if (mProducer->Type() != factory->Type() &&
|
||||
!factory->Caps().preserve)
|
||||
if (mProducer->mType != factory->mType &&
|
||||
!factory->mCaps.preserve)
|
||||
{
|
||||
needsNewBuffer = true;
|
||||
}
|
||||
|
@ -350,9 +349,9 @@ SurfaceStream_TripleBuffer_Copy::SwapProducer(SurfaceFactory* factory,
|
|||
mStaging->Fence();
|
||||
|
||||
New(factory, size, mProducer);
|
||||
|
||||
if (mProducer && mStaging->Size() == mProducer->Size())
|
||||
SharedSurface::Copy(mStaging, mProducer, factory);
|
||||
|
||||
if (mProducer && mStaging->mSize == mProducer->mSize)
|
||||
SharedSurface::ProdCopy(mStaging, mProducer, factory);
|
||||
} else {
|
||||
New(factory, size, mProducer);
|
||||
}
|
||||
|
|
|
@ -18,9 +18,6 @@ namespace mozilla {
|
|||
|
||||
namespace gl {
|
||||
class GLContext;
|
||||
}
|
||||
|
||||
namespace gfx {
|
||||
class SharedSurface;
|
||||
class SurfaceFactory;
|
||||
|
||||
|
@ -41,14 +38,6 @@ public:
|
|||
mozilla::gl::GLContext* glContext,
|
||||
SurfaceStream* prevStream = nullptr);
|
||||
|
||||
SurfaceStreamHandle GetShareHandle() {
|
||||
return reinterpret_cast<SurfaceStreamHandle>(this);
|
||||
}
|
||||
|
||||
static SurfaceStream* FromHandle(SurfaceStreamHandle handle) {
|
||||
return (SurfaceStream*)handle;
|
||||
}
|
||||
|
||||
const SurfaceStreamType mType;
|
||||
|
||||
mozilla::gl::GLContext* GLContext() const { return mGLContext; }
|
||||
|
@ -229,7 +218,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
} /* namespace gfx */
|
||||
} /* namespace mozilla */
|
||||
} // namespace gl
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* SURFACESTREAM_H_ */
|
||||
#endif // SURFACESTREAM_H_
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SurfaceTypes.h"
|
||||
|
||||
#include "mozilla/layers/ISurfaceAllocator.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
namespace gl {
|
||||
|
||||
SurfaceCaps::SurfaceCaps()
|
||||
{
|
||||
|
@ -53,5 +54,5 @@ SurfaceCaps::~SurfaceCaps()
|
|||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace gl
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -16,9 +16,7 @@ namespace layers {
|
|||
class ISurfaceAllocator;
|
||||
}
|
||||
|
||||
namespace gfx {
|
||||
|
||||
typedef uintptr_t SurfaceStreamHandle;
|
||||
namespace gl {
|
||||
|
||||
struct SurfaceCaps MOZ_FINAL
|
||||
{
|
||||
|
@ -93,15 +91,6 @@ MOZ_BEGIN_ENUM_CLASS(SurfaceStreamType, uint8_t)
|
|||
MOZ_END_ENUM_CLASS(SurfaceStreamType)
|
||||
|
||||
|
||||
MOZ_BEGIN_ENUM_CLASS(APITypeT, uint8_t)
|
||||
Generic = 0,
|
||||
|
||||
OpenGL,
|
||||
|
||||
Max
|
||||
MOZ_END_ENUM_CLASS(APITypeT)
|
||||
|
||||
|
||||
MOZ_BEGIN_ENUM_CLASS(AttachmentType, uint8_t)
|
||||
Screen = 0,
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ EXPORTS += [
|
|||
'SharedSurface.h',
|
||||
'SharedSurfaceEGL.h',
|
||||
'SharedSurfaceGL.h',
|
||||
'SurfaceFactory.h',
|
||||
'SurfaceStream.h',
|
||||
'SurfaceTypes.h',
|
||||
'TextureGarbageBin.h',
|
||||
|
@ -135,7 +134,6 @@ UNIFIED_SOURCES += [
|
|||
'SharedSurface.cpp',
|
||||
'SharedSurfaceEGL.cpp',
|
||||
'SharedSurfaceGL.cpp',
|
||||
'SurfaceFactory.cpp',
|
||||
'SurfaceStream.cpp',
|
||||
'SurfaceTypes.cpp',
|
||||
'TextureGarbageBin.cpp',
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include "GLContext.h" // for GLContext
|
||||
#include "GLScreenBuffer.h" // for GLScreenBuffer
|
||||
#include "SharedSurface.h" // for SharedSurface
|
||||
#include "SharedSurfaceGL.h" // for SharedSurface_GL, etc
|
||||
#include "SurfaceTypes.h" // for APITypeT, APITypeT::OpenGL, etc
|
||||
#include "SharedSurfaceGL.h" // for SharedSurface
|
||||
#include "SurfaceStream.h" // for SurfaceStream
|
||||
#include "gfxMatrix.h" // for gfxMatrix
|
||||
#include "gfxPattern.h" // for gfxPattern, etc
|
||||
#include "gfxPlatform.h" // for gfxPlatform, gfxImageFormat
|
||||
|
@ -98,9 +98,9 @@ CopyableCanvasLayer::UpdateTarget(DrawTarget* aDestTarget)
|
|||
}
|
||||
|
||||
if (mGLContext) {
|
||||
SharedSurface_GL* sharedSurf = nullptr;
|
||||
SharedSurface* sharedSurf = nullptr;
|
||||
if (mStream) {
|
||||
sharedSurf = SharedSurface_GL::Cast(mStream->SwapConsumer());
|
||||
sharedSurf = mStream->SwapConsumer();
|
||||
} else {
|
||||
sharedSurf = mGLContext->RequestFrame();
|
||||
}
|
||||
|
@ -110,11 +110,11 @@ CopyableCanvasLayer::UpdateTarget(DrawTarget* aDestTarget)
|
|||
return;
|
||||
}
|
||||
|
||||
IntSize readSize(sharedSurf->Size());
|
||||
IntSize readSize(sharedSurf->mSize);
|
||||
SurfaceFormat format = (GetContentFlags() & CONTENT_OPAQUE)
|
||||
? SurfaceFormat::B8G8R8X8
|
||||
: SurfaceFormat::B8G8R8A8;
|
||||
bool needsPremult = sharedSurf->HasAlpha() && !mIsAlphaPremultiplied;
|
||||
bool needsPremult = sharedSurf->mHasAlpha && !mIsAlphaPremultiplied;
|
||||
|
||||
// Try to read back directly into aDestTarget's output buffer
|
||||
if (aDestTarget) {
|
||||
|
@ -138,7 +138,7 @@ CopyableCanvasLayer::UpdateTarget(DrawTarget* aDestTarget)
|
|||
}
|
||||
|
||||
RefPtr<SourceSurface> resultSurf;
|
||||
if (sharedSurf->Type() == SharedSurfaceType::Basic && !needsPremult) {
|
||||
if (sharedSurf->mType == SharedSurfaceType::Basic && !needsPremult) {
|
||||
SharedSurface_Basic* sharedSurf_Basic = SharedSurface_Basic::Cast(sharedSurf);
|
||||
resultSurf = sharedSurf_Basic->GetData();
|
||||
} else {
|
||||
|
|
|
@ -21,11 +21,8 @@
|
|||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace gfx {
|
||||
namespace gl{
|
||||
class SurfaceStream;
|
||||
class SharedSurface;
|
||||
class SurfaceFactory;
|
||||
}
|
||||
|
||||
namespace layers {
|
||||
|
@ -52,10 +49,10 @@ protected:
|
|||
void UpdateTarget(gfx::DrawTarget* aDestTarget = nullptr);
|
||||
|
||||
RefPtr<gfx::SourceSurface> mSurface;
|
||||
nsRefPtr<mozilla::gl::GLContext> mGLContext;
|
||||
nsRefPtr<gl::GLContext> mGLContext;
|
||||
mozilla::RefPtr<mozilla::gfx::DrawTarget> mDrawTarget;
|
||||
|
||||
RefPtr<gfx::SurfaceStream> mStream;
|
||||
RefPtr<gl::SurfaceStream> mStream;
|
||||
|
||||
uint32_t mCanvasFramebuffer;
|
||||
|
||||
|
|
|
@ -59,11 +59,11 @@ class WebGLContext;
|
|||
|
||||
namespace gl {
|
||||
class GLContext;
|
||||
class SurfaceStream;
|
||||
}
|
||||
|
||||
namespace gfx {
|
||||
class DrawTarget;
|
||||
class SurfaceStream;
|
||||
}
|
||||
|
||||
namespace css {
|
||||
|
@ -1930,7 +1930,7 @@ public:
|
|||
mozilla::gl::GLContext* mGLContext; // or this, for GL.
|
||||
|
||||
// Canvas/SkiaGL uses this
|
||||
mozilla::gfx::SurfaceStream* mStream;
|
||||
mozilla::gl::SurfaceStream* mStream;
|
||||
|
||||
// ID of the texture backing the canvas layer (defaults to 0)
|
||||
uint32_t mTexID;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/layers/CanvasClient.h"
|
||||
#include "CanvasClient.h"
|
||||
|
||||
#include "ClientCanvasLayer.h" // for ClientCanvasLayer
|
||||
#include "CompositorChild.h" // for CompositorChild
|
||||
#include "GLContext.h" // for GLContext
|
||||
|
@ -169,7 +170,7 @@ CanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
|||
return;
|
||||
}
|
||||
|
||||
if (surf->Type() != SharedSurfaceType::Gralloc) {
|
||||
if (surf->mType != SharedSurfaceType::Gralloc) {
|
||||
printf_stderr("Unexpected non-Gralloc SharedSurface in IPC path!");
|
||||
MOZ_ASSERT(false);
|
||||
return;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
namespace gl {
|
||||
class SharedSurface;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,14 +66,14 @@ ClientCanvasLayer::Initialize(const Data& aData)
|
|||
// The screen caps are irrelevant if we're using a separate stream
|
||||
caps = aData.mHasAlpha ? SurfaceCaps::ForRGBA() : SurfaceCaps::ForRGB();
|
||||
} else {
|
||||
caps = screen->Caps();
|
||||
caps = screen->mCaps;
|
||||
}
|
||||
MOZ_ASSERT(caps.alpha == aData.mHasAlpha);
|
||||
|
||||
SurfaceStreamType streamType =
|
||||
SurfaceStream::ChooseGLStreamType(SurfaceStream::OffMainThread,
|
||||
screen->PreserveBuffer());
|
||||
SurfaceFactory_GL* factory = nullptr;
|
||||
SurfaceFactory* factory = nullptr;
|
||||
if (!gfxPrefs::WebGLForceLayersReadback()) {
|
||||
switch (ClientManager()->AsShadowForwarder()->GetCompositorBackendType()) {
|
||||
case mozilla::layers::LayersBackend::LAYERS_OPENGL: {
|
||||
|
|
|
@ -20,6 +20,12 @@
|
|||
#include "nsRegion.h" // for nsIntRegion
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
class SurfaceStream;
|
||||
class SharedSurface;
|
||||
class SurfaceFactory;
|
||||
}
|
||||
|
||||
namespace layers {
|
||||
|
||||
class CompositableClient;
|
||||
|
@ -92,8 +98,8 @@ protected:
|
|||
|
||||
RefPtr<CanvasClient> mCanvasClient;
|
||||
|
||||
gfx::SharedSurface* mTextureSurface;
|
||||
gfx::SurfaceFactory* mFactory;
|
||||
gl::SharedSurface* mTextureSurface;
|
||||
gl::SurfaceFactory* mFactory;
|
||||
|
||||
friend class DeprecatedCanvasClient2D;
|
||||
friend class CanvasClient2D;
|
||||
|
|
|
@ -787,13 +787,12 @@ StreamTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
|||
return false;
|
||||
}
|
||||
|
||||
gfx::SurfaceStreamHandle handle = mStream->GetShareHandle();
|
||||
aOutDescriptor = SurfaceStreamDescriptor(handle, false);
|
||||
aOutDescriptor = SurfaceStreamDescriptor((uintptr_t)mStream.get(), false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
StreamTextureClient::InitWith(gfx::SurfaceStream* aStream)
|
||||
StreamTextureClient::InitWith(gl::SurfaceStream* aStream)
|
||||
{
|
||||
MOZ_ASSERT(!IsAllocated());
|
||||
mStream = aStream;
|
||||
|
|
|
@ -31,12 +31,9 @@ class gfxReusableSurfaceWrapper;
|
|||
class gfxImageSurface;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
class SurfaceStream;
|
||||
}
|
||||
|
||||
namespace gl {
|
||||
class GLContext;
|
||||
class SurfaceStream;
|
||||
}
|
||||
|
||||
namespace layers {
|
||||
|
@ -576,7 +573,7 @@ public:
|
|||
|
||||
virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return false; }
|
||||
|
||||
void InitWith(gfx::SurfaceStream* aStream);
|
||||
void InitWith(gl::SurfaceStream* aStream);
|
||||
|
||||
virtual gfx::IntSize GetSize() const { return gfx::IntSize(); }
|
||||
|
||||
|
@ -593,7 +590,7 @@ public:
|
|||
|
||||
protected:
|
||||
bool mIsLocked;
|
||||
RefPtr<gfx::SurfaceStream> mStream;
|
||||
RefPtr<gl::SurfaceStream> mStream;
|
||||
RefPtr<gl::GLContext> mGL; // Just for reference holding.
|
||||
};
|
||||
|
||||
|
|
|
@ -814,7 +814,7 @@ StreamTextureHost::StreamTextureHost(TextureFlags aFlags,
|
|||
const SurfaceStreamDescriptor& aDesc)
|
||||
: TextureHost(aFlags)
|
||||
{
|
||||
mStream = gfx::SurfaceStream::FromHandle(aDesc.handle());
|
||||
mStream = (gl::SurfaceStream*)aDesc.surfStream();
|
||||
MOZ_ASSERT(mStream);
|
||||
}
|
||||
|
||||
|
@ -831,7 +831,7 @@ StreamTextureHost::Lock()
|
|||
return false;
|
||||
}
|
||||
|
||||
gfx::SharedSurface* abstractSurf = mStream->SwapConsumer();
|
||||
gl::SharedSurface* abstractSurf = mStream->SwapConsumer();
|
||||
if (!abstractSurf) {
|
||||
return false;
|
||||
}
|
||||
|
@ -841,8 +841,8 @@ StreamTextureHost::Lock()
|
|||
case LayersBackend::LAYERS_BASIC:
|
||||
case LayersBackend::LAYERS_D3D9:
|
||||
case LayersBackend::LAYERS_D3D10:
|
||||
switch (abstractSurf->Type()) {
|
||||
case gfx::SharedSurfaceType::Basic:
|
||||
switch (abstractSurf->mType) {
|
||||
case gl::SharedSurfaceType::Basic:
|
||||
compositorSupportsShSurfType = true;
|
||||
break;
|
||||
default:
|
||||
|
@ -850,12 +850,12 @@ StreamTextureHost::Lock()
|
|||
}
|
||||
break;
|
||||
case LayersBackend::LAYERS_OPENGL:
|
||||
switch (abstractSurf->Type()) {
|
||||
case gfx::SharedSurfaceType::Basic:
|
||||
case gfx::SharedSurfaceType::GLTextureShare:
|
||||
case gfx::SharedSurfaceType::EGLImageShare:
|
||||
case gfx::SharedSurfaceType::Gralloc:
|
||||
case gfx::SharedSurfaceType::IOSurface:
|
||||
switch (abstractSurf->mType) {
|
||||
case gl::SharedSurfaceType::Basic:
|
||||
case gl::SharedSurfaceType::GLTextureShare:
|
||||
case gl::SharedSurfaceType::EGLImageShare:
|
||||
case gl::SharedSurfaceType::Gralloc:
|
||||
case gl::SharedSurfaceType::IOSurface:
|
||||
compositorSupportsShSurfType = true;
|
||||
break;
|
||||
default:
|
||||
|
@ -863,9 +863,9 @@ StreamTextureHost::Lock()
|
|||
}
|
||||
break;
|
||||
case LayersBackend::LAYERS_D3D11:
|
||||
switch (abstractSurf->Type()) {
|
||||
case gfx::SharedSurfaceType::Basic:
|
||||
case gfx::SharedSurfaceType::EGLSurfaceANGLE:
|
||||
switch (abstractSurf->mType) {
|
||||
case gl::SharedSurfaceType::Basic:
|
||||
case gl::SharedSurfaceType::EGLSurfaceANGLE:
|
||||
compositorSupportsShSurfType = true;
|
||||
break;
|
||||
default:
|
||||
|
@ -878,11 +878,11 @@ StreamTextureHost::Lock()
|
|||
|
||||
RefPtr<NewTextureSource> newTexSource;
|
||||
if (compositorSupportsShSurfType) {
|
||||
gfx::SurfaceFormat format = abstractSurf->HasAlpha() ? gfx::SurfaceFormat::R8G8B8A8
|
||||
: gfx::SurfaceFormat::R8G8B8X8;
|
||||
gfx::SurfaceFormat format = abstractSurf->mHasAlpha ? gfx::SurfaceFormat::R8G8B8A8
|
||||
: gfx::SurfaceFormat::R8G8B8X8;
|
||||
|
||||
switch (abstractSurf->Type()) {
|
||||
case gfx::SharedSurfaceType::Basic: {
|
||||
switch (abstractSurf->mType) {
|
||||
case gl::SharedSurfaceType::Basic: {
|
||||
gl::SharedSurface_Basic* surf = gl::SharedSurface_Basic::Cast(abstractSurf);
|
||||
|
||||
if (!this->mDataTextureSource) {
|
||||
|
@ -894,7 +894,7 @@ StreamTextureHost::Lock()
|
|||
newTexSource = mDataTextureSource;
|
||||
break;
|
||||
}
|
||||
case gfx::SharedSurfaceType::GLTextureShare: {
|
||||
case gl::SharedSurfaceType::GLTextureShare: {
|
||||
gl::SharedSurface_GLTexture* surf = gl::SharedSurface_GLTexture::Cast(abstractSurf);
|
||||
|
||||
MOZ_ASSERT(mCompositor->GetBackendType() == LayersBackend::LAYERS_OPENGL);
|
||||
|
@ -907,11 +907,11 @@ StreamTextureHost::Lock()
|
|||
tex,
|
||||
format,
|
||||
target,
|
||||
surf->Size());
|
||||
surf->mSize);
|
||||
break;
|
||||
}
|
||||
#ifdef MOZ_ENABLE_D3D10_LAYER
|
||||
case gfx::SharedSurfaceType::EGLSurfaceANGLE: {
|
||||
case gl::SharedSurfaceType::EGLSurfaceANGLE: {
|
||||
gl::SharedSurface_ANGLEShareHandle* surf = gl::SharedSurface_ANGLEShareHandle::Cast(abstractSurf);
|
||||
HANDLE shareHandle = surf->GetShareHandle();
|
||||
|
||||
|
@ -931,7 +931,7 @@ StreamTextureHost::Lock()
|
|||
break;
|
||||
}
|
||||
#endif
|
||||
case gfx::SharedSurfaceType::EGLImageShare: {
|
||||
case gl::SharedSurfaceType::EGLImageShare: {
|
||||
gl::SharedSurface_EGLImage* surf = gl::SharedSurface_EGLImage::Cast(abstractSurf);
|
||||
|
||||
MOZ_ASSERT(mCompositor->GetBackendType() == LayersBackend::LAYERS_OPENGL);
|
||||
|
@ -947,15 +947,15 @@ StreamTextureHost::Lock()
|
|||
tex,
|
||||
format,
|
||||
target,
|
||||
surf->Size());
|
||||
surf->mSize);
|
||||
break;
|
||||
}
|
||||
case gfx::SharedSurfaceType::Gralloc: {
|
||||
case gl::SharedSurfaceType::Gralloc: {
|
||||
MOZ_ASSERT(false, "WebGL in the Host process? Gralloc without E10S? Not yet supported.");
|
||||
break;
|
||||
}
|
||||
#ifdef XP_MACOSX
|
||||
case gfx::SharedSurfaceType::IOSurface: {
|
||||
case gl::SharedSurfaceType::IOSurface: {
|
||||
gl::SharedSurface_IOSurface* surf = gl::SharedSurface_IOSurface::Cast(abstractSurf);
|
||||
MacIOSurface* ioSurf = surf->GetIOSurface();
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ struct nsIntSize;
|
|||
struct nsIntRect;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
namespace gl {
|
||||
class SurfaceStream;
|
||||
}
|
||||
namespace ipc {
|
||||
|
@ -635,7 +635,7 @@ public:
|
|||
|
||||
protected:
|
||||
Compositor* mCompositor;
|
||||
gfx::SurfaceStream* mStream;
|
||||
gl::SurfaceStream* mStream;
|
||||
RefPtr<NewTextureSource> mTextureSource;
|
||||
RefPtr<DataTextureSource> mDataTextureSource;
|
||||
};
|
||||
|
|
|
@ -51,11 +51,11 @@ CanvasLayerD3D10::Initialize(const Data& aData)
|
|||
SurfaceStream::ChooseGLStreamType(SurfaceStream::MainThread,
|
||||
screen->PreserveBuffer());
|
||||
|
||||
SurfaceFactory_GL* factory = nullptr;
|
||||
SurfaceFactory* factory = nullptr;
|
||||
if (!gfxPrefs::WebGLForceLayersReadback()) {
|
||||
if (mGLContext->IsANGLE()) {
|
||||
factory = SurfaceFactory_ANGLEShareHandle::Create(mGLContext,
|
||||
screen->Caps());
|
||||
screen->mCaps);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,12 +121,12 @@ CanvasLayerD3D10::UpdateSurface()
|
|||
}
|
||||
|
||||
if (mGLContext) {
|
||||
SharedSurface_GL* surf = mGLContext->RequestFrame();
|
||||
SharedSurface* surf = mGLContext->RequestFrame();
|
||||
if (!surf) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (surf->Type()) {
|
||||
switch (surf->mType) {
|
||||
case SharedSurfaceType::EGLSurfaceANGLE: {
|
||||
SharedSurface_ANGLEShareHandle* shareSurf = SharedSurface_ANGLEShareHandle::Cast(surf);
|
||||
HANDLE shareHandle = shareSurf->GetShareHandle();
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "gfxWindowsSurface.h"
|
||||
#include "gfxWindowsPlatform.h"
|
||||
#include "SurfaceStream.h"
|
||||
#include "SharedSurface.h"
|
||||
#include "SharedSurfaceGL.h"
|
||||
#include "GLContext.h"
|
||||
#include "CanvasLayerD3D9.h"
|
||||
|
@ -79,7 +80,7 @@ CanvasLayerD3D9::UpdateSurface()
|
|||
RefPtr<SourceSurface> surface;
|
||||
|
||||
if (mGLContext) {
|
||||
SharedSurface_GL* surf = mGLContext->RequestFrame();
|
||||
SharedSurface* surf = mGLContext->RequestFrame();
|
||||
if (!surf)
|
||||
return;
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
|
|||
using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h";
|
||||
using mozilla::gl::SharedTextureHandle from "GLContextTypes.h";
|
||||
using mozilla::gl::SharedTextureShareType from "GLContextTypes.h";
|
||||
using mozilla::gfx::SurfaceStreamHandle from "SurfaceTypes.h";
|
||||
using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
|
||||
using mozilla::gfx::IntSize from "mozilla/gfx/Point.h";
|
||||
using gfxImageFormat from "gfxTypes.h";
|
||||
|
@ -67,7 +66,7 @@ struct NewSurfaceDescriptorGralloc {
|
|||
};
|
||||
|
||||
struct SurfaceStreamDescriptor {
|
||||
SurfaceStreamHandle handle;
|
||||
uintptr_t surfStream;
|
||||
bool yflip;
|
||||
};
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
namespace gl {
|
||||
class SurfaceStream;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ struct nsIntSize;
|
|||
namespace mozilla {
|
||||
namespace gfx {
|
||||
class DataSourceSurface;
|
||||
}
|
||||
|
||||
namespace gl {
|
||||
class SurfaceStream;
|
||||
}
|
||||
|
||||
|
|
|
@ -886,7 +886,7 @@ gfxPlatform::GetSkiaGLGlue()
|
|||
* FIXME: This should be stored in TLS or something, since there needs to be one for each thread using it. As it
|
||||
* stands, this only works on the main thread.
|
||||
*/
|
||||
mozilla::gfx::SurfaceCaps caps = mozilla::gfx::SurfaceCaps::ForRGBA();
|
||||
mozilla::gl::SurfaceCaps caps = mozilla::gl::SurfaceCaps::ForRGBA();
|
||||
nsRefPtr<mozilla::gl::GLContext> glContext = mozilla::gl::GLContextProvider::CreateOffscreen(gfxIntSize(16, 16), caps);
|
||||
if (!glContext) {
|
||||
printf_stderr("Failed to create GLContext for SkiaGL!\n");
|
||||
|
|
|
@ -71,9 +71,9 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
nsRefPtr<gl::GLContext> gl = gl::GLContextProvider::CreateOffscreen(
|
||||
gfxIntSize(16, 16),
|
||||
gfx::SurfaceCaps::ForRGB());
|
||||
nsRefPtr<gl::GLContext> gl;
|
||||
gl = gl::GLContextProvider::CreateOffscreen(gfxIntSize(16, 16),
|
||||
gl::SurfaceCaps::ForRGB());
|
||||
|
||||
if (!gl) {
|
||||
// Setting mReady to true here means that we won't retry. Everything will
|
||||
|
|
Загрузка…
Ссылка в новой задаче