Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* 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 MOZILLA_GFX_COMPOSITOROGL_H
|
|
|
|
#define MOZILLA_GFX_COMPOSITOROGL_H
|
|
|
|
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "./../mozilla-config.h" // for MOZ_DUMP_PAINTING
|
|
|
|
#include "GLContext.h" // for GLContext
|
|
|
|
#include "GLContextTypes.h" // for GLuint, GLenum, GLint
|
|
|
|
#include "GLDefs.h" // for GLintptr, GLvoid, etc
|
|
|
|
#include "LayerManagerOGLProgram.h" // for ShaderProgramOGL, etc
|
|
|
|
#include "Units.h" // for ScreenPoint
|
|
|
|
#include "gfxContext.h" // for gfxContext
|
|
|
|
#include "gfxPoint.h" // for gfxIntSize
|
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
|
|
|
#include "mozilla/Attributes.h" // for MOZ_OVERRIDE, MOZ_FINAL
|
|
|
|
#include "mozilla/RefPtr.h" // for TemporaryRef, RefPtr
|
|
|
|
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize, Point
|
|
|
|
#include "mozilla/gfx/Rect.h" // for Rect, IntRect
|
|
|
|
#include "mozilla/gfx/Types.h" // for Float, SurfaceFormat, etc
|
|
|
|
#include "mozilla/layers/Compositor.h" // for SurfaceInitMode, Compositor, etc
|
|
|
|
#include "mozilla/layers/CompositorTypes.h" // for MaskType::NumMaskTypes, etc
|
|
|
|
#include "mozilla/layers/LayersTypes.h"
|
|
|
|
#include "nsAutoPtr.h" // for nsRefPtr, nsAutoPtr
|
|
|
|
#include "nsCOMPtr.h" // for already_AddRefed
|
|
|
|
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING
|
|
|
|
#include "nsISupportsImpl.h" // for gfxContext::AddRef, etc
|
|
|
|
#include "nsSize.h" // for nsIntSize
|
|
|
|
#include "nsTArray.h" // for nsAutoTArray, nsTArray, etc
|
|
|
|
#include "nsThreadUtils.h" // for nsRunnable
|
|
|
|
#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc
|
|
|
|
#include "nsXULAppAPI.h" // for XRE_GetProcessType
|
|
|
|
#include "nscore.h" // for NS_IMETHOD
|
2013-08-22 19:04:55 +00:00
|
|
|
#include "VBOArena.h" // for gl::VBOArena
|
|
|
|
|
2013-08-11 23:17:23 +00:00
|
|
|
class gfx3DMatrix;
|
|
|
|
class nsIWidget;
|
|
|
|
struct gfxMatrix;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-08-24 06:12:51 +00:00
|
|
|
class TimeStamp;
|
|
|
|
|
2013-08-11 23:17:23 +00:00
|
|
|
namespace gfx {
|
|
|
|
class Matrix4x4;
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
namespace layers {
|
|
|
|
|
2013-08-11 23:17:23 +00:00
|
|
|
class CompositingRenderTarget;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
class CompositingRenderTargetOGL;
|
2013-08-11 23:17:23 +00:00
|
|
|
class DataTextureSource;
|
2013-04-16 21:35:57 +00:00
|
|
|
class GLManagerCompositor;
|
2013-08-11 23:17:23 +00:00
|
|
|
class TextureSource;
|
|
|
|
struct Effect;
|
|
|
|
struct EffectChain;
|
|
|
|
struct FPSState;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
|
|
|
|
class CompositorOGL : public Compositor
|
|
|
|
{
|
|
|
|
typedef mozilla::gl::GLContext GLContext;
|
2013-07-04 17:25:50 +00:00
|
|
|
typedef ShaderProgramType ProgramType;
|
2013-04-16 21:35:57 +00:00
|
|
|
|
|
|
|
friend class GLManagerCompositor;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
CompositorOGL(nsIWidget *aWidget, int aSurfaceWidth = -1, int aSurfaceHeight = -1,
|
2013-04-30 03:16:04 +00:00
|
|
|
bool aUseExternalSurfaceSize = false);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
|
|
|
|
virtual ~CompositorOGL();
|
|
|
|
|
2013-07-30 09:59:51 +00:00
|
|
|
virtual TemporaryRef<DataTextureSource>
|
|
|
|
CreateDataTextureSource(TextureFlags aFlags = 0) MOZ_OVERRIDE;
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
virtual bool Initialize() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual void Destroy() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() MOZ_OVERRIDE
|
|
|
|
{
|
2013-05-16 03:45:43 +00:00
|
|
|
return TextureFactoryIdentifier(LAYERS_OPENGL,
|
2013-08-04 07:46:17 +00:00
|
|
|
XRE_GetProcessType(),
|
2013-05-16 03:45:43 +00:00
|
|
|
GetMaxTextureSize(),
|
|
|
|
mFBOTextureTarget == LOCAL_GL_TEXTURE_2D,
|
|
|
|
SupportsPartialTextureUpdate());
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual TemporaryRef<CompositingRenderTarget>
|
|
|
|
CreateRenderTarget(const gfx::IntRect &aRect, SurfaceInitMode aInit) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual TemporaryRef<CompositingRenderTarget>
|
|
|
|
CreateRenderTargetFromSource(const gfx::IntRect &aRect,
|
|
|
|
const CompositingRenderTarget *aSource) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual void SetRenderTarget(CompositingRenderTarget *aSurface) MOZ_OVERRIDE;
|
|
|
|
virtual CompositingRenderTarget* GetCurrentRenderTarget() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual void DrawQuad(const gfx::Rect& aRect, const gfx::Rect& aClipRect,
|
|
|
|
const EffectChain &aEffectChain,
|
|
|
|
gfx::Float aOpacity, const gfx::Matrix4x4 &aTransform,
|
|
|
|
const gfx::Point& aOffset) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual void EndFrame() MOZ_OVERRIDE;
|
|
|
|
virtual void EndFrameForExternalComposition(const gfxMatrix& aTransform) MOZ_OVERRIDE;
|
|
|
|
virtual void AbortFrame() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool SupportsPartialTextureUpdate() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return mGLContext->CanUploadSubTextures();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
if (!mGLContext)
|
|
|
|
return false;
|
|
|
|
int32_t maxSize = GetMaxTextureSize();
|
|
|
|
return aSize <= gfxIntSize(maxSize, maxSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mGLContext);
|
|
|
|
GLint texSize = 0;
|
|
|
|
mGLContext->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE,
|
|
|
|
&texSize);
|
|
|
|
MOZ_ASSERT(texSize != 0);
|
|
|
|
return texSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the size of the EGL surface we're rendering to, if we're rendering to
|
|
|
|
* an EGL surface.
|
|
|
|
*/
|
|
|
|
virtual void SetDestinationSurfaceSize(const gfx::IntSize& aSize) MOZ_OVERRIDE;
|
|
|
|
|
2013-06-03 14:00:02 +00:00
|
|
|
virtual void SetScreenRenderOffset(const ScreenPoint& aOffset) MOZ_OVERRIDE {
|
2013-04-25 17:47:08 +00:00
|
|
|
mRenderOffset = aOffset;
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) MOZ_OVERRIDE {
|
|
|
|
if (mDestroyed) {
|
|
|
|
NS_WARNING("Call on destroyed layer manager");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mGLContext->MakeCurrent(aFlags & ForceMakeCurrent);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetTargetContext(gfxContext* aTarget) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
mTarget = aTarget;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void PrepareViewport(const gfx::IntSize& aSize,
|
|
|
|
const gfxMatrix& aWorldTransform) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
virtual const char* Name() const MOZ_OVERRIDE { return "OGL"; }
|
|
|
|
#endif // MOZ_DUMP_PAINTING
|
|
|
|
|
|
|
|
virtual void NotifyLayersTransaction() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual void Pause() MOZ_OVERRIDE;
|
|
|
|
virtual bool Resume() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual nsIWidget* GetWidget() const MOZ_OVERRIDE { return mWidget; }
|
|
|
|
virtual const nsIntSize& GetWidgetSize() MOZ_OVERRIDE {
|
|
|
|
return mWidgetSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLContext* gl() const { return mGLContext; }
|
2013-07-04 17:25:50 +00:00
|
|
|
ShaderProgramType GetFBOLayerProgramType() const {
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
return mFBOTextureTarget == LOCAL_GL_TEXTURE_RECTANGLE_ARB ?
|
2013-07-04 17:25:50 +00:00
|
|
|
RGBARectLayerProgramType : RGBALayerProgramType;
|
|
|
|
}
|
|
|
|
gfx::SurfaceFormat GetFBOFormat() const {
|
|
|
|
return gfx::FORMAT_R8G8B8A8;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
}
|
|
|
|
|
2013-06-04 18:44:37 +00:00
|
|
|
/**
|
|
|
|
* The compositor provides with temporary textures for use with direct
|
|
|
|
* textruing like gralloc texture.
|
|
|
|
* Doing so lets us use gralloc the way it has been designed to be used
|
|
|
|
* (see https://wiki.mozilla.org/Platform/GFX/Gralloc)
|
|
|
|
*/
|
|
|
|
GLuint GetTemporaryTexture(GLenum aUnit);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Context target, nullptr when drawing directly to our swap chain.
|
|
|
|
*/
|
|
|
|
nsRefPtr<gfxContext> mTarget;
|
|
|
|
|
|
|
|
/** Widget associated with this compositor */
|
|
|
|
nsIWidget *mWidget;
|
|
|
|
nsIntSize mWidgetSize;
|
|
|
|
nsRefPtr<GLContext> mGLContext;
|
|
|
|
|
|
|
|
/** The size of the surface we are rendering to */
|
|
|
|
nsIntSize mSurfaceSize;
|
|
|
|
|
2013-06-03 14:00:02 +00:00
|
|
|
ScreenPoint mRenderOffset;
|
2013-04-25 17:47:08 +00:00
|
|
|
|
2013-04-17 22:34:26 +00:00
|
|
|
/** Helper-class used by Initialize **/
|
|
|
|
class ReadDrawFPSPref MOZ_FINAL : public nsRunnable {
|
|
|
|
public:
|
|
|
|
NS_IMETHOD Run() MOZ_OVERRIDE;
|
|
|
|
};
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
already_AddRefed<mozilla::gl::GLContext> CreateContext();
|
|
|
|
|
|
|
|
/** Shader Programs */
|
|
|
|
struct ShaderProgramVariations {
|
|
|
|
nsAutoTArray<nsAutoPtr<ShaderProgramOGL>, NumMaskTypes> mVariations;
|
|
|
|
ShaderProgramVariations() {
|
|
|
|
MOZ_COUNT_CTOR(ShaderProgramVariations);
|
|
|
|
mVariations.SetLength(NumMaskTypes);
|
|
|
|
}
|
|
|
|
~ShaderProgramVariations() {
|
|
|
|
MOZ_COUNT_DTOR(ShaderProgramVariations);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
nsTArray<ShaderProgramVariations> mPrograms;
|
|
|
|
|
|
|
|
/** Texture target to use for FBOs */
|
|
|
|
GLenum mFBOTextureTarget;
|
|
|
|
|
|
|
|
/** Currently bound render target */
|
|
|
|
RefPtr<CompositingRenderTargetOGL> mCurrentRenderTarget;
|
|
|
|
#ifdef DEBUG
|
|
|
|
CompositingRenderTargetOGL* mWindowRenderTarget;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** VBO that has some basics in it for a textured quad,
|
|
|
|
* including vertex coords and texcoords for both
|
|
|
|
* flipped and unflipped textures */
|
|
|
|
GLuint mQuadVBO;
|
|
|
|
|
2013-08-22 19:04:55 +00:00
|
|
|
/**
|
|
|
|
* When we can't use mQuadVBO, we allocate VBOs from this arena instead.
|
|
|
|
*/
|
|
|
|
gl::VBOArena mVBOs;
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
bool mHasBGRA;
|
|
|
|
|
|
|
|
/**
|
2013-04-30 03:16:04 +00:00
|
|
|
* When rendering to some EGL surfaces (e.g. on Android), we rely on being told
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
* about size changes (via SetSurfaceSize) rather than pulling this information
|
|
|
|
* from the widget.
|
|
|
|
*/
|
2013-04-30 03:16:04 +00:00
|
|
|
bool mUseExternalSurfaceSize;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Have we had DrawQuad calls since the last frame was rendered?
|
|
|
|
*/
|
|
|
|
bool mFrameInProgress;
|
|
|
|
|
|
|
|
/* Start a new frame. If aClipRectIn is null and aClipRectOut is non-null,
|
|
|
|
* sets *aClipRectOut to the screen dimensions.
|
|
|
|
*/
|
|
|
|
virtual void BeginFrame(const gfx::Rect *aClipRectIn,
|
|
|
|
const gfxMatrix& aTransform,
|
|
|
|
const gfx::Rect& aRenderBounds,
|
|
|
|
gfx::Rect *aClipRectOut = nullptr,
|
|
|
|
gfx::Rect *aRenderBoundsOut = nullptr) MOZ_OVERRIDE;
|
|
|
|
|
2013-07-04 17:25:50 +00:00
|
|
|
ShaderProgramType GetProgramTypeForEffect(Effect* aEffect) const;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates all layer programs with a new projection matrix.
|
|
|
|
*/
|
|
|
|
void SetLayerProgramProjectionMatrix(const gfx3DMatrix& aMatrix);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper method for Initialize, creates all valid variations of a program
|
|
|
|
* and adds them to mPrograms
|
|
|
|
*/
|
2013-07-04 17:25:50 +00:00
|
|
|
void AddPrograms(ShaderProgramType aType);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
|
2013-07-04 17:25:50 +00:00
|
|
|
ShaderProgramOGL* GetProgram(ShaderProgramType aType,
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
MaskType aMask = MaskNone) {
|
|
|
|
MOZ_ASSERT(ProgramProfileOGL::ProgramExists(aType, aMask),
|
|
|
|
"Invalid program type.");
|
|
|
|
return mPrograms[aType].mVariations[aMask];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a FBO backed by a texture.
|
|
|
|
* Note that the texture target type will be
|
|
|
|
* of the type returned by FBOTextureTarget; different
|
|
|
|
* shaders are required to sample from the different
|
|
|
|
* texture types.
|
|
|
|
*/
|
|
|
|
void CreateFBOWithTexture(const gfx::IntRect& aRect, SurfaceInitMode aInit,
|
|
|
|
GLuint aSourceFrameBuffer,
|
|
|
|
GLuint *aFBO, GLuint *aTexture);
|
|
|
|
|
|
|
|
GLintptr QuadVBOVertexOffset() { return 0; }
|
|
|
|
GLintptr QuadVBOTexCoordOffset() { return sizeof(float)*4*2; }
|
|
|
|
GLintptr QuadVBOFlippedTexCoordOffset() { return sizeof(float)*8*2; }
|
|
|
|
|
|
|
|
void BindQuadVBO() {
|
|
|
|
mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mQuadVBO);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QuadVBOVerticesAttrib(GLuint aAttribIndex) {
|
|
|
|
mGLContext->fVertexAttribPointer(aAttribIndex, 2,
|
|
|
|
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
|
|
|
|
(GLvoid*) QuadVBOVertexOffset());
|
|
|
|
}
|
|
|
|
|
|
|
|
void QuadVBOTexCoordsAttrib(GLuint aAttribIndex) {
|
|
|
|
mGLContext->fVertexAttribPointer(aAttribIndex, 2,
|
|
|
|
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
|
|
|
|
(GLvoid*) QuadVBOTexCoordOffset());
|
|
|
|
}
|
|
|
|
|
|
|
|
void QuadVBOFlippedTexCoordsAttrib(GLuint aAttribIndex) {
|
|
|
|
mGLContext->fVertexAttribPointer(aAttribIndex, 2,
|
|
|
|
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
|
|
|
|
(GLvoid*) QuadVBOFlippedTexCoordOffset());
|
|
|
|
}
|
|
|
|
|
|
|
|
void BindAndDrawQuad(GLuint aVertAttribIndex,
|
|
|
|
GLuint aTexCoordAttribIndex,
|
|
|
|
bool aFlipped = false)
|
|
|
|
{
|
|
|
|
BindQuadVBO();
|
|
|
|
QuadVBOVerticesAttrib(aVertAttribIndex);
|
|
|
|
|
|
|
|
if (aTexCoordAttribIndex != GLuint(-1)) {
|
|
|
|
if (aFlipped)
|
|
|
|
QuadVBOFlippedTexCoordsAttrib(aTexCoordAttribIndex);
|
|
|
|
else
|
|
|
|
QuadVBOTexCoordsAttrib(aTexCoordAttribIndex);
|
|
|
|
|
|
|
|
mGLContext->fEnableVertexAttribArray(aTexCoordAttribIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
mGLContext->fEnableVertexAttribArray(aVertAttribIndex);
|
|
|
|
mGLContext->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
mGLContext->fDisableVertexAttribArray(aVertAttribIndex);
|
|
|
|
|
|
|
|
if (aTexCoordAttribIndex != GLuint(-1)) {
|
|
|
|
mGLContext->fDisableVertexAttribArray(aTexCoordAttribIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BindAndDrawQuad(ShaderProgramOGL *aProg,
|
|
|
|
bool aFlipped = false)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aProg->HasInitialized(), "Shader program not correctly initialized");
|
|
|
|
BindAndDrawQuad(aProg->AttribLocation(ShaderProgramOGL::VertexCoordAttrib),
|
|
|
|
aProg->AttribLocation(ShaderProgramOGL::TexCoordAttrib),
|
|
|
|
aFlipped);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg,
|
|
|
|
const gfx::Rect& aTexCoordRect,
|
|
|
|
TextureSource *aTexture);
|
|
|
|
|
|
|
|
void CleanupResources();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copies the content of our backbuffer to the set transaction target.
|
|
|
|
* Does not restore the target FBO, so only call from EndFrame.
|
|
|
|
*/
|
|
|
|
void CopyToTarget(gfxContext *aTarget, const gfxMatrix& aWorldMatrix);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Records the passed frame timestamp and returns the current estimated FPS.
|
|
|
|
*/
|
|
|
|
double AddFrameAndGetFps(const TimeStamp& timestamp);
|
|
|
|
|
|
|
|
bool mDestroyed;
|
|
|
|
|
|
|
|
nsAutoPtr<FPSState> mFPS;
|
2013-06-04 18:44:37 +00:00
|
|
|
// Textures used for direct texturing of buffers like gralloc.
|
|
|
|
// The index of the texture in this array must correspond to the texture unit.
|
2013-06-12 09:05:06 +00:00
|
|
|
nsTArray<GLuint> mTextures;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
static bool sDrawFPS;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_COMPOSITOROGL_H */
|