зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1528394 - Reduce includes of GLContext.h. r=lsalzman
Splitting part of OGLShaderProgram.h out into OGLShaderConfig.h makes it easier to keep GLContext.h included in OGLShaderProgram.h for inlining purposes. Differential Revision: https://phabricator.services.mozilla.com/D20017 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e83ec79232
Коммит
d6410e953a
|
@ -40,6 +40,7 @@ EXPORTS += [
|
|||
'LayersTypes.h',
|
||||
'LayerTreeInvalidation.h',
|
||||
'LayerUserData.h',
|
||||
'opengl/OGLShaderConfig.h',
|
||||
'opengl/OGLShaderProgram.h',
|
||||
'protobuf/LayerScopePacket.pb.h',
|
||||
'ReadbackLayer.h',
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "nsRect.h" // for mozilla::gfx::IntRect
|
||||
#include "nsServiceManagerUtils.h" // for do_GetService
|
||||
#include "nsString.h" // for nsString, nsAutoCString, etc
|
||||
#include "OGLShaderProgram.h" // for ShaderProgramOGL, etc
|
||||
#include "ScopedGLHelpers.h"
|
||||
#include "GLReadTexImageHelper.h"
|
||||
#include "GLBlitTextureImageHelper.h"
|
||||
|
@ -152,6 +153,12 @@ bool AsyncReadbackBufferOGL::MapAndCopyInto(DataSourceSurface* aSurface,
|
|||
return true;
|
||||
}
|
||||
|
||||
PerUnitTexturePoolOGL::PerUnitTexturePoolOGL(gl::GLContext* aGL)
|
||||
: mTextureTarget(0), // zero is never a valid texture target
|
||||
mGL(aGL) {}
|
||||
|
||||
PerUnitTexturePoolOGL::~PerUnitTexturePoolOGL() { DestroyTextures(); }
|
||||
|
||||
static void BindMaskForProgram(ShaderProgramOGL* aProgram,
|
||||
TextureSourceOGL* aSourceMask, GLenum aTexUnit,
|
||||
const gfx::Matrix4x4& aTransform) {
|
||||
|
|
|
@ -7,12 +7,13 @@
|
|||
#ifndef MOZILLA_GFX_COMPOSITOROGL_H
|
||||
#define MOZILLA_GFX_COMPOSITOROGL_H
|
||||
|
||||
#include <map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "gfx2DGlue.h"
|
||||
#include "GLContextTypes.h" // for GLContext, etc
|
||||
#include "GLDefs.h" // for GLuint, LOCAL_GL_TEXTURE_2D, etc
|
||||
#include "OGLShaderProgram.h" // for ShaderProgramOGL, etc
|
||||
#include "OGLShaderConfig.h" // for ShaderConfigOGL
|
||||
#include "Units.h" // for ScreenPoint
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
||||
#include "mozilla/Attributes.h" // for override, final
|
||||
|
@ -45,6 +46,7 @@ class CompositingRenderTarget;
|
|||
class CompositingRenderTargetOGL;
|
||||
class DataTextureSource;
|
||||
class GLManagerCompositor;
|
||||
class ShaderProgramOGL;
|
||||
class TextureSource;
|
||||
class TextureSourceOGL;
|
||||
class BufferTextureHost;
|
||||
|
@ -81,12 +83,8 @@ class CompositorTexturePoolOGL {
|
|||
*/
|
||||
class PerUnitTexturePoolOGL : public CompositorTexturePoolOGL {
|
||||
public:
|
||||
explicit PerUnitTexturePoolOGL(gl::GLContext* aGL)
|
||||
: mTextureTarget(0) // zero is never a valid texture target
|
||||
,
|
||||
mGL(aGL) {}
|
||||
|
||||
virtual ~PerUnitTexturePoolOGL() { DestroyTextures(); }
|
||||
explicit PerUnitTexturePoolOGL(gl::GLContext* aGL);
|
||||
virtual ~PerUnitTexturePoolOGL();
|
||||
|
||||
virtual void Clear() override { DestroyTextures(); }
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "GLManager.h"
|
||||
#include "CompositorOGL.h" // for CompositorOGL
|
||||
#include "GLContext.h" // for GLContext
|
||||
#include "CompositorOGL.h" // for CompositorOGL
|
||||
#include "GLContext.h" // for GLContext
|
||||
#include "OGLShaderProgram.h"
|
||||
#include "mozilla/Attributes.h" // for override
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#define MOZILLA_GFX_GLMANAGER_H
|
||||
|
||||
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
||||
#include "OGLShaderProgram.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
@ -18,6 +17,7 @@ class GLContext;
|
|||
namespace layers {
|
||||
|
||||
class LayerManagerComposite;
|
||||
class ShaderProgramOGL;
|
||||
|
||||
/**
|
||||
* Minimal interface to allow widgets to draw using OpenGL. Abstracts
|
||||
|
|
|
@ -0,0 +1,266 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 GFX_OGLSHADERCONFIG_H
|
||||
#define GFX_OGLSHADERCONFIG_H
|
||||
|
||||
#include "gfxTypes.h"
|
||||
#include "ImageTypes.h"
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
||||
#include "mozilla/Pair.h" // for Pair
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
||||
#include "mozilla/gfx/Rect.h" // for Rect
|
||||
#include "mozilla/gfx/Types.h"
|
||||
#include "nsDebug.h" // for NS_ASSERTION
|
||||
#include "nsPoint.h" // for nsIntPoint
|
||||
#include "nsTArray.h" // for nsTArray
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
enum ShaderFeatures {
|
||||
ENABLE_RENDER_COLOR = 0x01,
|
||||
ENABLE_TEXTURE_RECT = 0x02,
|
||||
ENABLE_TEXTURE_EXTERNAL = 0x04,
|
||||
ENABLE_TEXTURE_YCBCR = 0x08,
|
||||
ENABLE_TEXTURE_NV12 = 0x10,
|
||||
ENABLE_TEXTURE_COMPONENT_ALPHA = 0x20,
|
||||
ENABLE_TEXTURE_NO_ALPHA = 0x40,
|
||||
ENABLE_TEXTURE_RB_SWAP = 0x80,
|
||||
ENABLE_OPACITY = 0x100,
|
||||
ENABLE_BLUR = 0x200,
|
||||
ENABLE_COLOR_MATRIX = 0x400,
|
||||
ENABLE_MASK = 0x800,
|
||||
ENABLE_NO_PREMUL_ALPHA = 0x1000,
|
||||
ENABLE_DEAA = 0x2000,
|
||||
ENABLE_DYNAMIC_GEOMETRY = 0x4000,
|
||||
ENABLE_MASK_TEXTURE_RECT = 0x8000,
|
||||
};
|
||||
|
||||
class KnownUniform {
|
||||
public:
|
||||
// this needs to be kept in sync with strings in 'AddUniforms'
|
||||
enum KnownUniformName {
|
||||
NotAKnownUniform = -1,
|
||||
|
||||
LayerTransform = 0,
|
||||
LayerTransformInverse,
|
||||
MaskTransform,
|
||||
BackdropTransform,
|
||||
LayerRects,
|
||||
MatrixProj,
|
||||
TextureTransform,
|
||||
TextureRects,
|
||||
RenderTargetOffset,
|
||||
LayerOpacity,
|
||||
Texture,
|
||||
YTexture,
|
||||
CbTexture,
|
||||
CrTexture,
|
||||
BlackTexture,
|
||||
WhiteTexture,
|
||||
MaskTexture,
|
||||
BackdropTexture,
|
||||
RenderColor,
|
||||
TexCoordMultiplier,
|
||||
CbCrTexCoordMultiplier,
|
||||
MaskCoordMultiplier,
|
||||
TexturePass2,
|
||||
ColorMatrix,
|
||||
ColorMatrixVector,
|
||||
BlurRadius,
|
||||
BlurOffset,
|
||||
BlurAlpha,
|
||||
BlurGaussianKernel,
|
||||
SSEdges,
|
||||
ViewportSize,
|
||||
VisibleCenter,
|
||||
YuvColorMatrix,
|
||||
|
||||
KnownUniformCount
|
||||
};
|
||||
|
||||
KnownUniform() {
|
||||
mName = NotAKnownUniform;
|
||||
mNameString = nullptr;
|
||||
mLocation = -1;
|
||||
memset(&mValue, 0, sizeof(mValue));
|
||||
}
|
||||
|
||||
bool UpdateUniform(int32_t i1) {
|
||||
if (mLocation == -1) return false;
|
||||
if (mValue.i1 != i1) {
|
||||
mValue.i1 = i1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UpdateUniform(float f1) {
|
||||
if (mLocation == -1) return false;
|
||||
if (mValue.f1 != f1) {
|
||||
mValue.f1 = f1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UpdateUniform(float f1, float f2) {
|
||||
if (mLocation == -1) return false;
|
||||
if (mValue.f16v[0] != f1 || mValue.f16v[1] != f2) {
|
||||
mValue.f16v[0] = f1;
|
||||
mValue.f16v[1] = f2;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UpdateUniform(float f1, float f2, float f3, float f4) {
|
||||
if (mLocation == -1) return false;
|
||||
if (mValue.f16v[0] != f1 || mValue.f16v[1] != f2 || mValue.f16v[2] != f3 ||
|
||||
mValue.f16v[3] != f4) {
|
||||
mValue.f16v[0] = f1;
|
||||
mValue.f16v[1] = f2;
|
||||
mValue.f16v[2] = f3;
|
||||
mValue.f16v[3] = f4;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UpdateUniform(int cnt, const float* fp) {
|
||||
if (mLocation == -1) return false;
|
||||
switch (cnt) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 9:
|
||||
case 16:
|
||||
if (memcmp(mValue.f16v, fp, sizeof(float) * cnt) != 0) {
|
||||
memcpy(mValue.f16v, fp, sizeof(float) * cnt);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_ASSERT_UNREACHABLE("cnt must be 1 2 3 4 9 or 16");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UpdateArrayUniform(int cnt, const float* fp) {
|
||||
if (mLocation == -1) return false;
|
||||
if (cnt > 16) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (memcmp(mValue.f16v, fp, sizeof(float) * cnt) != 0) {
|
||||
memcpy(mValue.f16v, fp, sizeof(float) * cnt);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UpdateArrayUniform(int cnt, const gfx::Point3D* points) {
|
||||
if (mLocation == -1) return false;
|
||||
if (cnt > 4) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float fp[12];
|
||||
float* d = fp;
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
// Note: Do not want to make assumptions about .x, .y, .z member packing.
|
||||
// If gfx::Point3D is updated to make this guarantee, SIMD optimizations
|
||||
// may be possible
|
||||
*d++ = points[i].x;
|
||||
*d++ = points[i].y;
|
||||
*d++ = points[i].z;
|
||||
}
|
||||
|
||||
if (memcmp(mValue.f16v, fp, sizeof(float) * cnt * 3) != 0) {
|
||||
memcpy(mValue.f16v, fp, sizeof(float) * cnt * 3);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
KnownUniformName mName;
|
||||
const char* mNameString;
|
||||
int32_t mLocation;
|
||||
|
||||
union {
|
||||
int i1;
|
||||
float f1;
|
||||
float f16v[16];
|
||||
} mValue;
|
||||
};
|
||||
|
||||
class ShaderConfigOGL {
|
||||
public:
|
||||
ShaderConfigOGL()
|
||||
: mFeatures(0),
|
||||
mMultiplier(1),
|
||||
mCompositionOp(gfx::CompositionOp::OP_OVER) {}
|
||||
|
||||
void SetRenderColor(bool aEnabled);
|
||||
void SetTextureTarget(GLenum aTarget);
|
||||
void SetMaskTextureTarget(GLenum aTarget);
|
||||
void SetRBSwap(bool aEnabled);
|
||||
void SetNoAlpha(bool aEnabled);
|
||||
void SetOpacity(bool aEnabled);
|
||||
void SetYCbCr(bool aEnabled);
|
||||
void SetNV12(bool aEnabled);
|
||||
void SetComponentAlpha(bool aEnabled);
|
||||
void SetColorMatrix(bool aEnabled);
|
||||
void SetBlur(bool aEnabled);
|
||||
void SetMask(bool aEnabled);
|
||||
void SetDEAA(bool aEnabled);
|
||||
void SetCompositionOp(gfx::CompositionOp aOp);
|
||||
void SetNoPremultipliedAlpha();
|
||||
void SetDynamicGeometry(bool aEnabled);
|
||||
void SetColorMultiplier(uint32_t aMultiplier);
|
||||
|
||||
bool operator<(const ShaderConfigOGL& other) const {
|
||||
return mFeatures < other.mFeatures ||
|
||||
(mFeatures == other.mFeatures &&
|
||||
(int)mCompositionOp < (int)other.mCompositionOp) ||
|
||||
(mFeatures == other.mFeatures &&
|
||||
(int)mCompositionOp == (int)other.mCompositionOp &&
|
||||
mMultiplier < other.mMultiplier);
|
||||
}
|
||||
|
||||
public:
|
||||
void SetFeature(int aBitmask, bool aState) {
|
||||
if (aState)
|
||||
mFeatures |= aBitmask;
|
||||
else
|
||||
mFeatures &= (~aBitmask);
|
||||
}
|
||||
|
||||
int mFeatures;
|
||||
uint32_t mMultiplier;
|
||||
gfx::CompositionOp mCompositionOp;
|
||||
};
|
||||
|
||||
static inline ShaderConfigOGL ShaderConfigFromTargetAndFormat(
|
||||
GLenum aTarget, gfx::SurfaceFormat aFormat) {
|
||||
ShaderConfigOGL config;
|
||||
config.SetTextureTarget(aTarget);
|
||||
config.SetRBSwap(aFormat == gfx::SurfaceFormat::B8G8R8A8 ||
|
||||
aFormat == gfx::SurfaceFormat::B8G8R8X8);
|
||||
config.SetNoAlpha(aFormat == gfx::SurfaceFormat::B8G8R8X8 ||
|
||||
aFormat == gfx::SurfaceFormat::R8G8B8X8 ||
|
||||
aFormat == gfx::SurfaceFormat::R5G6B5_UINT16);
|
||||
return config;
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // GFX_OGLSHADERCONFIG_H
|
|
@ -5,6 +5,7 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "OGLShaderProgram.h"
|
||||
|
||||
#include <stdint.h> // for uint32_t
|
||||
#include <sstream> // for ostringstream
|
||||
#include "gfxEnv.h"
|
||||
|
|
|
@ -8,262 +8,27 @@
|
|||
#define GFX_OGLSHADERPROGRAM_H
|
||||
|
||||
#include "GLContext.h" // for fast inlines of glUniform*
|
||||
#include "gfxTypes.h"
|
||||
#include "ImageTypes.h"
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
||||
#include "mozilla/Pair.h" // for Pair
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
||||
#include "mozilla/gfx/Rect.h" // for Rect
|
||||
#include "mozilla/gfx/Types.h"
|
||||
#include "nsDebug.h" // for NS_ASSERTION
|
||||
#include "nsPoint.h" // for nsIntPoint
|
||||
#include "nsTArray.h" // for nsTArray
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
#include "OGLShaderConfig.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class Layer;
|
||||
|
||||
enum ShaderFeatures {
|
||||
ENABLE_RENDER_COLOR = 0x01,
|
||||
ENABLE_TEXTURE_RECT = 0x02,
|
||||
ENABLE_TEXTURE_EXTERNAL = 0x04,
|
||||
ENABLE_TEXTURE_YCBCR = 0x08,
|
||||
ENABLE_TEXTURE_NV12 = 0x10,
|
||||
ENABLE_TEXTURE_COMPONENT_ALPHA = 0x20,
|
||||
ENABLE_TEXTURE_NO_ALPHA = 0x40,
|
||||
ENABLE_TEXTURE_RB_SWAP = 0x80,
|
||||
ENABLE_OPACITY = 0x100,
|
||||
ENABLE_BLUR = 0x200,
|
||||
ENABLE_COLOR_MATRIX = 0x400,
|
||||
ENABLE_MASK = 0x800,
|
||||
ENABLE_NO_PREMUL_ALPHA = 0x1000,
|
||||
ENABLE_DEAA = 0x2000,
|
||||
ENABLE_DYNAMIC_GEOMETRY = 0x4000,
|
||||
ENABLE_MASK_TEXTURE_RECT = 0x8000,
|
||||
};
|
||||
|
||||
class KnownUniform {
|
||||
public:
|
||||
// this needs to be kept in sync with strings in 'AddUniforms'
|
||||
enum KnownUniformName {
|
||||
NotAKnownUniform = -1,
|
||||
|
||||
LayerTransform = 0,
|
||||
LayerTransformInverse,
|
||||
MaskTransform,
|
||||
BackdropTransform,
|
||||
LayerRects,
|
||||
MatrixProj,
|
||||
TextureTransform,
|
||||
TextureRects,
|
||||
RenderTargetOffset,
|
||||
LayerOpacity,
|
||||
Texture,
|
||||
YTexture,
|
||||
CbTexture,
|
||||
CrTexture,
|
||||
BlackTexture,
|
||||
WhiteTexture,
|
||||
MaskTexture,
|
||||
BackdropTexture,
|
||||
RenderColor,
|
||||
TexCoordMultiplier,
|
||||
CbCrTexCoordMultiplier,
|
||||
MaskCoordMultiplier,
|
||||
TexturePass2,
|
||||
ColorMatrix,
|
||||
ColorMatrixVector,
|
||||
BlurRadius,
|
||||
BlurOffset,
|
||||
BlurAlpha,
|
||||
BlurGaussianKernel,
|
||||
SSEdges,
|
||||
ViewportSize,
|
||||
VisibleCenter,
|
||||
YuvColorMatrix,
|
||||
|
||||
KnownUniformCount
|
||||
};
|
||||
|
||||
KnownUniform() {
|
||||
mName = NotAKnownUniform;
|
||||
mNameString = nullptr;
|
||||
mLocation = -1;
|
||||
memset(&mValue, 0, sizeof(mValue));
|
||||
}
|
||||
|
||||
bool UpdateUniform(int32_t i1) {
|
||||
if (mLocation == -1) return false;
|
||||
if (mValue.i1 != i1) {
|
||||
mValue.i1 = i1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UpdateUniform(float f1) {
|
||||
if (mLocation == -1) return false;
|
||||
if (mValue.f1 != f1) {
|
||||
mValue.f1 = f1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UpdateUniform(float f1, float f2) {
|
||||
if (mLocation == -1) return false;
|
||||
if (mValue.f16v[0] != f1 || mValue.f16v[1] != f2) {
|
||||
mValue.f16v[0] = f1;
|
||||
mValue.f16v[1] = f2;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UpdateUniform(float f1, float f2, float f3, float f4) {
|
||||
if (mLocation == -1) return false;
|
||||
if (mValue.f16v[0] != f1 || mValue.f16v[1] != f2 || mValue.f16v[2] != f3 ||
|
||||
mValue.f16v[3] != f4) {
|
||||
mValue.f16v[0] = f1;
|
||||
mValue.f16v[1] = f2;
|
||||
mValue.f16v[2] = f3;
|
||||
mValue.f16v[3] = f4;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UpdateUniform(int cnt, const float* fp) {
|
||||
if (mLocation == -1) return false;
|
||||
switch (cnt) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 9:
|
||||
case 16:
|
||||
if (memcmp(mValue.f16v, fp, sizeof(float) * cnt) != 0) {
|
||||
memcpy(mValue.f16v, fp, sizeof(float) * cnt);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_ASSERT_UNREACHABLE("cnt must be 1 2 3 4 9 or 16");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UpdateArrayUniform(int cnt, const float* fp) {
|
||||
if (mLocation == -1) return false;
|
||||
if (cnt > 16) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (memcmp(mValue.f16v, fp, sizeof(float) * cnt) != 0) {
|
||||
memcpy(mValue.f16v, fp, sizeof(float) * cnt);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UpdateArrayUniform(int cnt, const gfx::Point3D* points) {
|
||||
if (mLocation == -1) return false;
|
||||
if (cnt > 4) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float fp[12];
|
||||
float* d = fp;
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
// Note: Do not want to make assumptions about .x, .y, .z member packing.
|
||||
// If gfx::Point3D is updated to make this guarantee, SIMD optimizations
|
||||
// may be possible
|
||||
*d++ = points[i].x;
|
||||
*d++ = points[i].y;
|
||||
*d++ = points[i].z;
|
||||
}
|
||||
|
||||
if (memcmp(mValue.f16v, fp, sizeof(float) * cnt * 3) != 0) {
|
||||
memcpy(mValue.f16v, fp, sizeof(float) * cnt * 3);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
KnownUniformName mName;
|
||||
const char* mNameString;
|
||||
int32_t mLocation;
|
||||
|
||||
union {
|
||||
int i1;
|
||||
float f1;
|
||||
float f16v[16];
|
||||
} mValue;
|
||||
};
|
||||
|
||||
class ShaderConfigOGL {
|
||||
public:
|
||||
ShaderConfigOGL()
|
||||
: mFeatures(0),
|
||||
mMultiplier(1),
|
||||
mCompositionOp(gfx::CompositionOp::OP_OVER) {}
|
||||
|
||||
void SetRenderColor(bool aEnabled);
|
||||
void SetTextureTarget(GLenum aTarget);
|
||||
void SetMaskTextureTarget(GLenum aTarget);
|
||||
void SetRBSwap(bool aEnabled);
|
||||
void SetNoAlpha(bool aEnabled);
|
||||
void SetOpacity(bool aEnabled);
|
||||
void SetYCbCr(bool aEnabled);
|
||||
void SetNV12(bool aEnabled);
|
||||
void SetComponentAlpha(bool aEnabled);
|
||||
void SetColorMatrix(bool aEnabled);
|
||||
void SetBlur(bool aEnabled);
|
||||
void SetMask(bool aEnabled);
|
||||
void SetDEAA(bool aEnabled);
|
||||
void SetCompositionOp(gfx::CompositionOp aOp);
|
||||
void SetNoPremultipliedAlpha();
|
||||
void SetDynamicGeometry(bool aEnabled);
|
||||
void SetColorMultiplier(uint32_t aMultiplier);
|
||||
|
||||
bool operator<(const ShaderConfigOGL& other) const {
|
||||
return mFeatures < other.mFeatures ||
|
||||
(mFeatures == other.mFeatures &&
|
||||
(int)mCompositionOp < (int)other.mCompositionOp) ||
|
||||
(mFeatures == other.mFeatures &&
|
||||
(int)mCompositionOp == (int)other.mCompositionOp &&
|
||||
mMultiplier < other.mMultiplier);
|
||||
}
|
||||
|
||||
public:
|
||||
void SetFeature(int aBitmask, bool aState) {
|
||||
if (aState)
|
||||
mFeatures |= aBitmask;
|
||||
else
|
||||
mFeatures &= (~aBitmask);
|
||||
}
|
||||
|
||||
int mFeatures;
|
||||
uint32_t mMultiplier;
|
||||
gfx::CompositionOp mCompositionOp;
|
||||
};
|
||||
|
||||
static inline ShaderConfigOGL ShaderConfigFromTargetAndFormat(
|
||||
GLenum aTarget, gfx::SurfaceFormat aFormat) {
|
||||
ShaderConfigOGL config;
|
||||
config.SetTextureTarget(aTarget);
|
||||
config.SetRBSwap(aFormat == gfx::SurfaceFormat::B8G8R8A8 ||
|
||||
aFormat == gfx::SurfaceFormat::B8G8R8X8);
|
||||
config.SetNoAlpha(aFormat == gfx::SurfaceFormat::B8G8R8X8 ||
|
||||
aFormat == gfx::SurfaceFormat::R8G8B8X8 ||
|
||||
aFormat == gfx::SurfaceFormat::R5G6B5_UINT16);
|
||||
return config;
|
||||
}
|
||||
#if defined(DEBUG)
|
||||
# define CHECK_CURRENT_PROGRAM 1
|
||||
# define ASSERT_THIS_PROGRAM \
|
||||
do { \
|
||||
GLuint currentProgram; \
|
||||
mGL->GetUIntegerv(LOCAL_GL_CURRENT_PROGRAM, ¤tProgram); \
|
||||
MOZ_ASSERT(currentProgram == mProgram, \
|
||||
"SetUniform with wrong program active!"); \
|
||||
} while (0)
|
||||
#else
|
||||
# define ASSERT_THIS_PROGRAM \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This struct represents the shaders that make up a program and the uniform
|
||||
|
@ -296,21 +61,6 @@ struct ProgramProfileOGL {
|
|||
std::ostringstream& fs);
|
||||
};
|
||||
|
||||
#if defined(DEBUG)
|
||||
# define CHECK_CURRENT_PROGRAM 1
|
||||
# define ASSERT_THIS_PROGRAM \
|
||||
do { \
|
||||
GLuint currentProgram; \
|
||||
mGL->GetUIntegerv(LOCAL_GL_CURRENT_PROGRAM, ¤tProgram); \
|
||||
MOZ_ASSERT(currentProgram == mProgram, \
|
||||
"SetUniform with wrong program active!"); \
|
||||
} while (0)
|
||||
#else
|
||||
# define ASSERT_THIS_PROGRAM \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Represents an OGL shader program. The details of a program are represented
|
||||
* by a ProgramProfileOGL
|
||||
|
@ -645,4 +395,4 @@ class ShaderProgramOGL {
|
|||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* GFX_OGLSHADERPROGRAM_H */
|
||||
#endif // GFX_OGLSHADERPROGRAM_H
|
||||
|
|
|
@ -39,6 +39,17 @@ namespace layers {
|
|||
|
||||
class Compositor;
|
||||
|
||||
void ApplySamplingFilterToBoundTexture(gl::GLContext* aGL,
|
||||
gfx::SamplingFilter aSamplingFilter,
|
||||
GLuint aTarget) {
|
||||
GLenum filter =
|
||||
(aSamplingFilter == gfx::SamplingFilter::POINT ? LOCAL_GL_NEAREST
|
||||
: LOCAL_GL_LINEAR);
|
||||
|
||||
aGL->fTexParameteri(aTarget, LOCAL_GL_TEXTURE_MIN_FILTER, filter);
|
||||
aGL->fTexParameteri(aTarget, LOCAL_GL_TEXTURE_MAG_FILTER, filter);
|
||||
}
|
||||
|
||||
already_AddRefed<TextureHost> CreateTextureHostOGL(
|
||||
const SurfaceDescriptor& aDesc, ISurfaceAllocator* aDeallocator,
|
||||
LayersBackend aBackend, TextureFlags aFlags) {
|
||||
|
|
|
@ -27,11 +27,10 @@
|
|||
#include "mozilla/layers/TextureHost.h" // for TextureHost, etc
|
||||
#include "mozilla/mozalloc.h" // for operator delete, etc
|
||||
#include "mozilla/webrender/RenderThread.h"
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "nsDebug.h" // for NS_WARNING
|
||||
#include "nsISupportsImpl.h" // for TextureImage::Release, etc
|
||||
#include "nsRegionFwd.h" // for nsIntRegion
|
||||
#include "OGLShaderProgram.h" // for ShaderProgramType, etc
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "nsDebug.h" // for NS_WARNING
|
||||
#include "nsISupportsImpl.h" // for TextureImage::Release, etc
|
||||
#include "nsRegionFwd.h" // for nsIntRegion
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
# include "GeneratedJNIWrappers.h"
|
||||
|
@ -50,16 +49,9 @@ class CompositorOGL;
|
|||
class TextureImageTextureSourceOGL;
|
||||
class GLTextureSource;
|
||||
|
||||
inline void ApplySamplingFilterToBoundTexture(
|
||||
gl::GLContext* aGL, gfx::SamplingFilter aSamplingFilter,
|
||||
GLuint aTarget = LOCAL_GL_TEXTURE_2D) {
|
||||
GLenum filter =
|
||||
(aSamplingFilter == gfx::SamplingFilter::POINT ? LOCAL_GL_NEAREST
|
||||
: LOCAL_GL_LINEAR);
|
||||
|
||||
aGL->fTexParameteri(aTarget, LOCAL_GL_TEXTURE_MIN_FILTER, filter);
|
||||
aGL->fTexParameteri(aTarget, LOCAL_GL_TEXTURE_MAG_FILTER, filter);
|
||||
}
|
||||
void ApplySamplingFilterToBoundTexture(gl::GLContext* aGL,
|
||||
gfx::SamplingFilter aSamplingFilter,
|
||||
GLuint aTarget = LOCAL_GL_TEXTURE_2D);
|
||||
|
||||
/*
|
||||
* TextureHost implementations for the OpenGL backend.
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "X11TextureSourceOGL.h"
|
||||
#include "gfxXlibSurface.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "RenderAndroidSurfaceTextureHostOGL.h"
|
||||
|
||||
#include "mozilla/gfx/Logging.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace wr {
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/webrender/WebRenderTypes.h"
|
||||
#include "mozilla/layers/SynchronousTask.h"
|
||||
#include "GLContext.h"
|
||||
#include "mozilla/VsyncDispatcher.h"
|
||||
|
||||
#include <list>
|
||||
|
@ -28,6 +27,9 @@
|
|||
#include <unordered_map>
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
class GLContext;
|
||||
} // namespace gl
|
||||
namespace wr {
|
||||
|
||||
typedef MozPromise<MemoryReport, bool, true> MemoryReportPromise;
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
#include "GLTextureImage.h"
|
||||
#include "GLContextProvider.h"
|
||||
#include "GLContextCGL.h"
|
||||
#include "OGLShaderProgram.h"
|
||||
#include "ScopedGLHelpers.h"
|
||||
#include "HeapCopyOfStackArray.h"
|
||||
#include "mozilla/layers/IAPZCTreeManager.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче