2010-05-25 06:35:35 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
2010-05-25 06:35:35 +00:00
|
|
|
|
|
|
|
#ifndef GFX_LAYERMANAGEROGLPROGRAM_H
|
|
|
|
#define GFX_LAYERMANAGEROGLPROGRAM_H
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "prenv.h"
|
|
|
|
|
|
|
|
#include "nsString.h"
|
2013-03-17 07:55:16 +00:00
|
|
|
#include "nsTArray.h"
|
2012-11-26 22:23:27 +00:00
|
|
|
#include "GLContextTypes.h"
|
2013-07-04 17:25:50 +00:00
|
|
|
#include "GLDefs.h"
|
2012-07-18 16:31:40 +00:00
|
|
|
#include "gfx3DMatrix.h"
|
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
|
|
|
#include "mozilla/layers/LayersTypes.h"
|
2013-07-04 21:48:33 +00:00
|
|
|
#include "mozilla/layers/CompositorTypes.h"
|
2012-11-26 22:23:27 +00:00
|
|
|
#include "gfxColor.h"
|
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
|
|
|
#include "mozilla/gfx/Matrix.h"
|
|
|
|
#include "mozilla/RefPtr.h"
|
2013-07-04 17:25:50 +00:00
|
|
|
#include "gfxASurface.h"
|
2010-05-25 06:35:35 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2012-11-26 22:23:27 +00:00
|
|
|
namespace gl {
|
|
|
|
class GLContext;
|
|
|
|
}
|
2010-05-25 06:35:35 +00:00
|
|
|
namespace layers {
|
|
|
|
|
2012-07-18 16:31:40 +00:00
|
|
|
class Layer;
|
|
|
|
|
2013-07-04 17:25:50 +00:00
|
|
|
enum ShaderProgramType {
|
|
|
|
RGBALayerProgramType,
|
|
|
|
RGBALayerExternalProgramType,
|
|
|
|
BGRALayerProgramType,
|
|
|
|
RGBXLayerProgramType,
|
|
|
|
BGRXLayerProgramType,
|
|
|
|
RGBARectLayerProgramType,
|
2013-07-18 03:24:15 +00:00
|
|
|
RGBXRectLayerProgramType,
|
2013-07-09 04:21:05 +00:00
|
|
|
BGRARectLayerProgramType,
|
2013-07-04 17:25:50 +00:00
|
|
|
RGBAExternalLayerProgramType,
|
|
|
|
ColorLayerProgramType,
|
|
|
|
YCbCrLayerProgramType,
|
|
|
|
ComponentAlphaPass1ProgramType,
|
2013-07-09 14:13:33 +00:00
|
|
|
ComponentAlphaPass1RGBProgramType,
|
2013-07-04 17:25:50 +00:00
|
|
|
ComponentAlphaPass2ProgramType,
|
2013-07-09 14:13:33 +00:00
|
|
|
ComponentAlphaPass2RGBProgramType,
|
2013-07-04 17:25:50 +00:00
|
|
|
Copy2DProgramType,
|
|
|
|
Copy2DRectProgramType,
|
|
|
|
NumProgramTypes
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline ShaderProgramType
|
|
|
|
ShaderProgramFromSurfaceFormat(gfx::SurfaceFormat aFormat)
|
|
|
|
{
|
|
|
|
switch (aFormat) {
|
|
|
|
case gfx::FORMAT_B8G8R8A8:
|
|
|
|
return BGRALayerProgramType;
|
|
|
|
case gfx::FORMAT_B8G8R8X8:
|
|
|
|
return BGRXLayerProgramType;
|
|
|
|
case gfx::FORMAT_R8G8B8A8:
|
|
|
|
return RGBALayerProgramType;
|
|
|
|
case gfx::FORMAT_R8G8B8X8:
|
|
|
|
case gfx::FORMAT_R5G6B5:
|
|
|
|
return RGBXLayerProgramType;
|
|
|
|
case gfx::FORMAT_A8:
|
|
|
|
// We don't have a specific luminance shader
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_ASSERTION(false, "Unhandled surface format!");
|
|
|
|
}
|
|
|
|
return ShaderProgramType(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline ShaderProgramType
|
|
|
|
ShaderProgramFromTargetAndFormat(GLenum aTarget,
|
|
|
|
gfx::SurfaceFormat aFormat)
|
|
|
|
{
|
|
|
|
switch(aTarget) {
|
|
|
|
case LOCAL_GL_TEXTURE_EXTERNAL:
|
2013-07-08 14:26:02 +00:00
|
|
|
MOZ_ASSERT(aFormat == gfx::FORMAT_R8G8B8A8);
|
2013-07-04 17:25:50 +00:00
|
|
|
return RGBALayerExternalProgramType;
|
|
|
|
case LOCAL_GL_TEXTURE_RECTANGLE_ARB:
|
2013-07-18 03:24:15 +00:00
|
|
|
MOZ_ASSERT(aFormat == gfx::FORMAT_R8G8B8A8 ||
|
|
|
|
aFormat == gfx::FORMAT_R8G8B8X8);
|
|
|
|
if (aFormat == gfx::FORMAT_R8G8B8A8)
|
|
|
|
return RGBARectLayerProgramType;
|
|
|
|
else
|
|
|
|
return RGBXRectLayerProgramType;
|
2013-07-04 17:25:50 +00:00
|
|
|
default:
|
|
|
|
return ShaderProgramFromSurfaceFormat(aFormat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline ShaderProgramType
|
|
|
|
ShaderProgramFromContentType(gfxASurface::gfxContentType aContentType)
|
|
|
|
{
|
|
|
|
if (aContentType == gfxASurface::CONTENT_COLOR_ALPHA)
|
|
|
|
return RGBALayerProgramType;
|
|
|
|
return RGBXLayerProgramType;
|
|
|
|
}
|
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
/**
|
|
|
|
* This struct represents the shaders that make up a program and the uniform
|
|
|
|
* and attribute parmeters that those shaders take.
|
|
|
|
* It is used by ShaderProgramOGL.
|
|
|
|
* Use the factory method GetProfileFor to create instances.
|
|
|
|
*/
|
|
|
|
struct ProgramProfileOGL
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Factory method; creates an instance of this class for the given
|
|
|
|
* ShaderProgramType
|
|
|
|
*/
|
2013-07-04 17:25:50 +00:00
|
|
|
static ProgramProfileOGL GetProfileFor(ShaderProgramType aType,
|
2012-03-18 20:07:25 +00:00
|
|
|
MaskType aMask);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns true if such a shader program exists
|
|
|
|
*/
|
2013-07-04 17:25:50 +00:00
|
|
|
static bool ProgramExists(ShaderProgramType aType, MaskType aMask)
|
2012-05-18 15:42:04 +00:00
|
|
|
{
|
|
|
|
if (aType < 0 ||
|
2013-07-04 17:25:50 +00:00
|
|
|
aType >= NumProgramTypes)
|
2012-05-18 15:42:04 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (aMask < MaskNone ||
|
|
|
|
aMask >= NumMaskTypes)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (aMask == Mask2d &&
|
2013-07-04 17:25:50 +00:00
|
|
|
(aType == Copy2DProgramType ||
|
|
|
|
aType == Copy2DRectProgramType))
|
2012-05-18 15:42:04 +00:00
|
|
|
return false;
|
|
|
|
|
2013-07-09 04:21:05 +00:00
|
|
|
if (aMask != MaskNone &&
|
|
|
|
aType == BGRARectLayerProgramType)
|
|
|
|
return false;
|
|
|
|
|
2012-05-18 15:42:04 +00:00
|
|
|
return aMask != Mask3d ||
|
2013-07-04 17:25:50 +00:00
|
|
|
aType == RGBARectLayerProgramType ||
|
2013-07-18 03:24:15 +00:00
|
|
|
aType == RGBXRectLayerProgramType ||
|
2013-07-04 17:25:50 +00:00
|
|
|
aType == RGBALayerProgramType;
|
2012-05-18 15:42:04 +00:00
|
|
|
}
|
2012-03-18 20:07:25 +00:00
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* These two methods lookup the location of a uniform and attribute,
|
|
|
|
* respectively. Returns -1 if the named uniform/attribute does not
|
|
|
|
* have a location for the shaders represented by this profile.
|
|
|
|
*/
|
|
|
|
GLint LookupUniformLocation(const char* aName)
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < mUniforms.Length(); ++i) {
|
2012-03-18 20:07:25 +00:00
|
|
|
if (strcmp(mUniforms[i].mName, aName) == 0) {
|
|
|
|
return mUniforms[i].mLocation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLint LookupAttributeLocation(const char* aName)
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < mAttributes.Length(); ++i) {
|
2012-03-18 20:07:25 +00:00
|
|
|
if (strcmp(mAttributes[i].mName, aName) == 0) {
|
|
|
|
return mAttributes[i].mLocation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// represents the name and location of a uniform or attribute
|
|
|
|
struct Argument
|
|
|
|
{
|
|
|
|
Argument(const char* aName) :
|
|
|
|
mName(aName) {}
|
|
|
|
const char* mName;
|
|
|
|
GLint mLocation;
|
|
|
|
};
|
|
|
|
|
|
|
|
// the source code for the program's shaders
|
|
|
|
const char *mVertexShaderString;
|
|
|
|
const char *mFragmentShaderString;
|
|
|
|
|
|
|
|
nsTArray<Argument> mUniforms;
|
|
|
|
nsTArray<Argument> mAttributes;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mTextureCount;
|
2012-03-18 20:07:25 +00:00
|
|
|
bool mHasMatrixProj;
|
2012-03-18 20:07:25 +00:00
|
|
|
private:
|
2012-03-18 20:07:25 +00:00
|
|
|
ProgramProfileOGL() :
|
|
|
|
mTextureCount(0),
|
2013-07-19 03:05:06 +00:00
|
|
|
mHasMatrixProj(false) {}
|
2012-03-18 20:07:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-05-23 16:54:47 +00:00
|
|
|
#if defined(DEBUG)
|
2011-01-07 20:32:42 +00:00
|
|
|
#define CHECK_CURRENT_PROGRAM 1
|
2010-05-25 06:35:35 +00:00
|
|
|
#define ASSERT_THIS_PROGRAM \
|
|
|
|
do { \
|
|
|
|
NS_ASSERTION(mGL->GetUserData(&sCurrentProgramKey) == this, \
|
|
|
|
"SetUniform with wrong program active!"); \
|
|
|
|
} while (0)
|
2011-01-07 20:32:42 +00:00
|
|
|
#else
|
|
|
|
#define ASSERT_THIS_PROGRAM
|
|
|
|
#endif
|
2010-05-25 06:35:35 +00:00
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
/**
|
|
|
|
* Represents an OGL shader program. The details of a program are represented
|
|
|
|
* by a ProgramProfileOGL
|
|
|
|
*/
|
|
|
|
class ShaderProgramOGL
|
|
|
|
{
|
2010-05-25 06:35:35 +00:00
|
|
|
public:
|
|
|
|
typedef mozilla::gl::GLContext GLContext;
|
|
|
|
|
2012-11-26 22:23:27 +00:00
|
|
|
ShaderProgramOGL(GLContext* aGL, const ProgramProfileOGL& aProfile);
|
2010-05-25 06:35:35 +00:00
|
|
|
|
2012-11-26 22:23:27 +00:00
|
|
|
~ShaderProgramOGL();
|
2010-05-25 06:35:35 +00:00
|
|
|
|
2012-05-02 02:54:40 +00:00
|
|
|
bool HasInitialized() {
|
|
|
|
NS_ASSERTION(mProgramState != STATE_OK || mProgram > 0, "Inconsistent program state");
|
|
|
|
return mProgramState == STATE_OK;
|
|
|
|
}
|
|
|
|
|
2012-11-26 22:23:27 +00:00
|
|
|
void Activate();
|
2010-05-25 06:35:35 +00:00
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
bool Initialize();
|
2010-05-25 06:35:35 +00:00
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
GLint CreateShader(GLenum aShaderType, const char *aShaderSource);
|
2010-05-25 06:35:35 +00:00
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
/**
|
|
|
|
* Creates a program and stores its id.
|
|
|
|
*/
|
2010-05-25 06:35:35 +00:00
|
|
|
bool CreateProgram(const char *aVertexShaderString,
|
2012-03-18 20:07:25 +00:00
|
|
|
const char *aFragmentShaderString);
|
2010-05-25 06:35:35 +00:00
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
/**
|
|
|
|
* Lookup the location of an attribute
|
|
|
|
*/
|
|
|
|
GLint AttribLocation(const char* aName) {
|
|
|
|
return mProfile.LookupAttributeLocation(aName);
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
GLint GetTexCoordMultiplierUniformLocation() {
|
|
|
|
return mTexCoordMultiplierUniformLocation;
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
2012-03-18 20:08:49 +00:00
|
|
|
/**
|
|
|
|
* aLayer is the mask layer to use for rendering, or null, if there is no
|
|
|
|
* mask layer.
|
|
|
|
* If aLayer is non-null, then the result of rendering aLayer is stored as
|
|
|
|
* as a texture to be used by the shader. It is stored in the next available
|
|
|
|
* texture unit, as determined by the texture unit requirements for the
|
|
|
|
* shader.
|
|
|
|
* Any other features of the mask layer required by the shader are also
|
|
|
|
* loaded to graphics memory. In particular the transform used to move from
|
|
|
|
* the layer's coordinates to the mask's coordinates is loaded; this must be
|
|
|
|
* a 2D transform.
|
|
|
|
*/
|
|
|
|
bool LoadMask(Layer* aLayer);
|
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
/**
|
|
|
|
* The following set of methods set a uniform argument to the shader program.
|
|
|
|
* Not all uniforms may be set for all programs, and such uses will throw
|
|
|
|
* an assertion.
|
|
|
|
*/
|
2010-05-25 06:35:35 +00:00
|
|
|
void SetLayerTransform(const gfx3DMatrix& aMatrix) {
|
2012-03-18 20:07:25 +00:00
|
|
|
SetMatrixUniform(mProfile.LookupUniformLocation("uLayerTransform"), aMatrix);
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
void SetLayerTransform(const gfx::Matrix4x4& aMatrix) {
|
|
|
|
SetMatrixUniform(mProfile.LookupUniformLocation("uLayerTransform"), aMatrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetMaskLayerTransform(const gfx::Matrix4x4& aMatrix) {
|
|
|
|
SetMatrixUniform(mProfile.LookupUniformLocation("uMaskQuadTransform"), aMatrix);
|
|
|
|
}
|
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
void SetLayerQuadRect(const nsIntRect& aRect) {
|
|
|
|
gfx3DMatrix m;
|
|
|
|
m._11 = float(aRect.width);
|
|
|
|
m._22 = float(aRect.height);
|
|
|
|
m._41 = float(aRect.x);
|
|
|
|
m._42 = float(aRect.y);
|
2012-03-18 20:07:25 +00:00
|
|
|
SetMatrixUniform(mProfile.LookupUniformLocation("uLayerQuadTransform"), m);
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
void SetLayerQuadRect(const gfx::Rect& aRect) {
|
|
|
|
gfx3DMatrix m;
|
|
|
|
m._11 = aRect.width;
|
|
|
|
m._22 = aRect.height;
|
|
|
|
m._41 = aRect.x;
|
|
|
|
m._42 = aRect.y;
|
|
|
|
SetMatrixUniform(mProfile.LookupUniformLocation("uLayerQuadTransform"), m);
|
|
|
|
}
|
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
// activates this program and sets its projection matrix, if the program uses one
|
2012-05-02 02:54:40 +00:00
|
|
|
void CheckAndSetProjectionMatrix(const gfx3DMatrix& aMatrix)
|
|
|
|
{
|
|
|
|
if (mProfile.mHasMatrixProj) {
|
|
|
|
mIsProjectionMatrixStale = true;
|
|
|
|
mProjectionMatrix = aMatrix;
|
|
|
|
}
|
|
|
|
}
|
2012-03-18 20:07:25 +00:00
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
void SetProjectionMatrix(const gfx3DMatrix& aMatrix) {
|
2012-03-18 20:07:25 +00:00
|
|
|
SetMatrixUniform(mProfile.LookupUniformLocation("uMatrixProj"), aMatrix);
|
2012-05-02 02:54:40 +00:00
|
|
|
mIsProjectionMatrixStale = false;
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
2012-07-20 19:20:51 +00:00
|
|
|
// sets this program's texture transform, if it uses one
|
|
|
|
void SetTextureTransform(const gfx3DMatrix& aMatrix) {
|
2013-07-19 03:05:06 +00:00
|
|
|
SetMatrixUniform(mProfile.LookupUniformLocation("uTextureTransform"), aMatrix);
|
2012-07-20 19:20:51 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
void SetTextureTransform(const gfx::Matrix4x4& aMatrix) {
|
2013-07-19 03:05:06 +00:00
|
|
|
SetMatrixUniform(mProfile.LookupUniformLocation("uTextureTransform"), aMatrix);
|
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
|
|
|
}
|
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
void SetRenderOffset(const nsIntPoint& aOffset) {
|
|
|
|
float vals[4] = { float(aOffset.x), float(aOffset.y), 0.0f, 0.0f };
|
2012-03-18 20:07:25 +00:00
|
|
|
SetUniform(mProfile.LookupUniformLocation("uRenderTargetOffset"), 4, vals);
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetRenderOffset(float aX, float aY) {
|
|
|
|
float vals[4] = { aX, aY, 0.0f, 0.0f };
|
2012-03-18 20:07:25 +00:00
|
|
|
SetUniform(mProfile.LookupUniformLocation("uRenderTargetOffset"), 4, vals);
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetLayerOpacity(float aOpacity) {
|
2012-03-18 20:07:25 +00:00
|
|
|
SetUniform(mProfile.LookupUniformLocation("uLayerOpacity"), aOpacity);
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetTextureUnit(GLint aUnit) {
|
2012-03-18 20:07:25 +00:00
|
|
|
SetUniform(mProfile.LookupUniformLocation("uTexture"), aUnit);
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
void SetYTextureUnit(GLint aUnit) {
|
2012-03-18 20:07:25 +00:00
|
|
|
SetUniform(mProfile.LookupUniformLocation("uYTexture"), aUnit);
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetCbTextureUnit(GLint aUnit) {
|
2012-03-18 20:07:25 +00:00
|
|
|
SetUniform(mProfile.LookupUniformLocation("uCbTexture"), aUnit);
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetCrTextureUnit(GLint aUnit) {
|
2012-03-18 20:07:25 +00:00
|
|
|
SetUniform(mProfile.LookupUniformLocation("uCrTexture"), aUnit);
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetYCbCrTextureUnits(GLint aYUnit, GLint aCbUnit, GLint aCrUnit) {
|
2012-03-18 20:07:25 +00:00
|
|
|
SetUniform(mProfile.LookupUniformLocation("uYTexture"), aYUnit);
|
|
|
|
SetUniform(mProfile.LookupUniformLocation("uCbTexture"), aCbUnit);
|
|
|
|
SetUniform(mProfile.LookupUniformLocation("uCrTexture"), aCrUnit);
|
2011-01-18 07:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetBlackTextureUnit(GLint aUnit) {
|
2012-03-18 20:07:25 +00:00
|
|
|
SetUniform(mProfile.LookupUniformLocation("uBlackTexture"), aUnit);
|
2011-01-18 07:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetWhiteTextureUnit(GLint aUnit) {
|
2012-03-18 20:07:25 +00:00
|
|
|
SetUniform(mProfile.LookupUniformLocation("uWhiteTexture"), aUnit);
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
void SetMaskTextureUnit(GLint aUnit) {
|
|
|
|
SetUniform(mProfile.LookupUniformLocation("uMaskTexture"), aUnit);
|
|
|
|
}
|
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
void SetRenderColor(const gfxRGBA& aColor) {
|
2012-03-18 20:07:25 +00:00
|
|
|
SetUniform(mProfile.LookupUniformLocation("uRenderColor"), aColor);
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
void SetRenderColor(const gfx::Color& aColor) {
|
|
|
|
SetUniform(mProfile.LookupUniformLocation("uRenderColor"), aColor);
|
|
|
|
}
|
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
void SetTexCoordMultiplier(float aWidth, float aHeight) {
|
|
|
|
float f[] = {aWidth, aHeight};
|
|
|
|
SetUniform(mTexCoordMultiplierUniformLocation, 2, f);
|
|
|
|
}
|
2010-05-25 06:35:35 +00:00
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
// the names of attributes
|
|
|
|
static const char* const VertexCoordAttrib;
|
|
|
|
static const char* const TexCoordAttrib;
|
2010-05-25 06:35:35 +00:00
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
protected:
|
2012-05-02 02:54:40 +00:00
|
|
|
gfx3DMatrix mProjectionMatrix;
|
|
|
|
// true if the projection matrix needs setting
|
|
|
|
bool mIsProjectionMatrixStale;
|
|
|
|
|
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
|
|
|
RefPtr<GLContext> mGL;
|
|
|
|
// the OpenGL id of the program
|
2012-03-18 20:07:25 +00:00
|
|
|
GLuint mProgram;
|
|
|
|
ProgramProfileOGL mProfile;
|
2012-05-02 02:54:40 +00:00
|
|
|
enum {
|
|
|
|
STATE_NEW,
|
|
|
|
STATE_OK,
|
|
|
|
STATE_ERROR
|
|
|
|
} mProgramState;
|
2010-05-25 06:35:35 +00:00
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
GLint mTexCoordMultiplierUniformLocation;
|
|
|
|
#ifdef CHECK_CURRENT_PROGRAM
|
|
|
|
static int sCurrentProgramKey;
|
|
|
|
#endif
|
2010-05-25 06:35:35 +00:00
|
|
|
|
2012-11-26 22:23:27 +00:00
|
|
|
void SetUniform(GLint aLocation, float aFloatValue);
|
|
|
|
void SetUniform(GLint aLocation, const gfxRGBA& aColor);
|
|
|
|
void SetUniform(GLint aLocation, int aLength, float *aFloatValues);
|
|
|
|
void SetUniform(GLint aLocation, GLint aIntValue);
|
|
|
|
void SetMatrixUniform(GLint aLocation, const gfx3DMatrix& aMatrix);
|
|
|
|
void SetMatrixUniform(GLint aLocation, const float *aFloatValues);
|
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
|
|
|
|
|
|
|
void SetUniform(GLint aLocation, const gfx::Color& aColor);
|
|
|
|
void SetMatrixUniform(GLint aLocation, const gfx::Matrix4x4& aMatrix) {
|
|
|
|
SetMatrixUniform(aLocation, &aMatrix._11);
|
|
|
|
}
|
2010-05-25 06:35:35 +00:00
|
|
|
};
|
|
|
|
|
2012-03-18 20:07:25 +00:00
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
} /* layers */
|
|
|
|
} /* mozilla */
|
|
|
|
|
|
|
|
#endif /* GFX_LAYERMANAGEROGLPROGRAM_H */
|