Bug 867460: remove notion of ShaderProgramTypes from gfx/gl. Carry r=bas. r=bgirard for the changes.

This commit is contained in:
Andreas Gal ext:(%2C%20Milan%20Sreckovic%20%3Cmilan%40mozilla.com%3E) 2013-07-04 13:25:50 -04:00
Родитель d4cc20985d
Коммит 4c463d2865
27 изменённых файлов: 254 добавлений и 220 удалений

Просмотреть файл

@ -1481,7 +1481,7 @@ static already_AddRefed<gfxImageSurface> YInvertImageSurface(gfxImageSurface* aS
}
already_AddRefed<gfxImageSurface>
GLContext::GetTexImage(GLuint aTexture, bool aYInvert, ShaderProgramType aShader)
GLContext::GetTexImage(GLuint aTexture, bool aYInvert, SurfaceFormat aFormat)
{
MakeCurrent();
GuaranteeResolve();
@ -1507,7 +1507,7 @@ GLContext::GetTexImage(GLuint aTexture, bool aYInvert, ShaderProgramType aShader
fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, currentPackAlignment);
}
if (aShader == RGBALayerProgramType || aShader == RGBXLayerProgramType) {
if (aFormat == FORMAT_R8G8B8A8 || aFormat == FORMAT_R8G8B8X8) {
SwapRAndBComponents(surf);
}
@ -1768,7 +1768,7 @@ GLContext::ReadPixelsIntoImageSurface(gfxImageSurface* dest)
if (DebugMode()) {
NS_WARNING("Needing intermediary surface for ReadPixels. This will be slow!");
}
gfxASurface::gfxImageFormat readFormatGFX;
ImageFormat readFormatGFX;
switch (readFormat) {
case LOCAL_GL_RGBA:
@ -2033,7 +2033,7 @@ DataOffset(gfxImageSurface *aSurf, const nsIntPoint &aPoint)
return data;
}
ShaderProgramType
GLContext::SurfaceFormat
GLContext::UploadSurfaceToTexture(gfxASurface *aSurface,
const nsIntRegion& aDstRegion,
GLuint& aTexture,
@ -2110,37 +2110,36 @@ GLContext::UploadSurfaceToTexture(gfxASurface *aSurface,
GLenum format;
GLenum type;
int32_t pixelSize = gfxASurface::BytePerPixelFromFormat(imageSurface->Format());
ShaderProgramType shader;
SurfaceFormat surfaceFormat;
switch (imageSurface->Format()) {
case gfxASurface::ImageFormatARGB32:
format = LOCAL_GL_RGBA;
type = LOCAL_GL_UNSIGNED_BYTE;
shader = BGRALayerProgramType;
surfaceFormat = FORMAT_B8G8R8A8;
break;
case gfxASurface::ImageFormatRGB24:
// Treat RGB24 surfaces as RGBA32 except for the shader
// program used.
format = LOCAL_GL_RGBA;
type = LOCAL_GL_UNSIGNED_BYTE;
shader = BGRXLayerProgramType;
surfaceFormat = FORMAT_B8G8R8X8;
break;
case gfxASurface::ImageFormatRGB16_565:
format = LOCAL_GL_RGB;
type = LOCAL_GL_UNSIGNED_SHORT_5_6_5;
shader = RGBALayerProgramType;
surfaceFormat = FORMAT_R5G6B5;
break;
case gfxASurface::ImageFormatA8:
format = LOCAL_GL_LUMINANCE;
type = LOCAL_GL_UNSIGNED_BYTE;
// We don't have a specific luminance shader
shader = ShaderProgramType(0);
surfaceFormat = FORMAT_A8;
break;
default:
NS_ASSERTION(false, "Unhandled image surface format!");
format = 0;
type = 0;
shader = ShaderProgramType(0);
surfaceFormat = FORMAT_UNKNOWN;
}
int32_t stride = imageSurface->Stride();
@ -2189,7 +2188,7 @@ GLContext::UploadSurfaceToTexture(gfxASurface *aSurface,
}
return shader;
return surfaceFormat;
}
static GLint GetAddressAlignment(ptrdiff_t aAddress)

Просмотреть файл

@ -89,6 +89,8 @@ class GLContext
protected:
typedef class gfx::SharedSurface SharedSurface;
typedef gfx::SharedSurfaceType SharedSurfaceType;
typedef gfxASurface::gfxImageFormat ImageFormat;
typedef gfx::SurfaceFormat SurfaceFormat;
public:
typedef struct gfx::SurfaceCaps SurfaceCaps;
@ -489,7 +491,7 @@ public:
typedef struct {
GLenum mTarget;
ShaderProgramType mProgramType;
SurfaceFormat mTextureFormat;
gfx3DMatrix mTextureTransform;
} SharedHandleDetails;
@ -805,7 +807,7 @@ public:
GLenum aTextureFormat,
bool aYInvert = false);
already_AddRefed<gfxImageSurface> GetTexImage(GLuint aTexture, bool aYInvert, ShaderProgramType aShader);
already_AddRefed<gfxImageSurface> GetTexImage(GLuint aTexture, bool aYInvert, SurfaceFormat aFormat);
/**
* Call ReadPixels into an existing gfxImageSurface.
@ -877,15 +879,15 @@ public:
* surface. This testure may be overridden, clients should not rely on
* the contents of this texture after this call or even on this
* texture unit being active.
* \return Shader program needed to render this texture.
* \return Surface format of this texture.
*/
ShaderProgramType UploadSurfaceToTexture(gfxASurface *aSurface,
const nsIntRegion& aDstRegion,
GLuint& aTexture,
bool aOverwrite = false,
const nsIntPoint& aSrcPoint = nsIntPoint(0, 0),
bool aPixelBuffer = false,
GLenum aTextureUnit = LOCAL_GL_TEXTURE0);
SurfaceFormat UploadSurfaceToTexture(gfxASurface *aSurface,
const nsIntRegion& aDstRegion,
GLuint& aTexture,
bool aOverwrite = false,
const nsIntPoint& aSrcPoint = nsIntPoint(0, 0),
bool aPixelBuffer = false,
GLenum aTextureUnit = LOCAL_GL_TEXTURE0);
void TexImage2D(GLenum target, GLint level, GLint internalformat,

Просмотреть файл

@ -201,7 +201,7 @@ public:
SharedHandleDetails& details)
{
details.mTarget = LOCAL_GL_TEXTURE_RECTANGLE_ARB;
details.mProgramType = RGBARectLayerProgramType;
details.mTextureFormat = FORMAT_R8G8B8A8;
return true;
}

Просмотреть файл

@ -120,6 +120,7 @@ public:
#include "gfxCrashReporterUtils.h"
using namespace mozilla::gfx;
#if defined(MOZ_PLATFORM_MAEMO) || defined(MOZ_WIDGET_GONK)
static bool gUseBackingSurface = true;
@ -981,7 +982,7 @@ bool GLContextEGL::GetSharedHandleDetails(SharedTextureShareType shareType,
SurfaceTextureWrapper* surfaceWrapper = reinterpret_cast<SurfaceTextureWrapper*>(wrapper);
details.mTarget = LOCAL_GL_TEXTURE_EXTERNAL;
details.mProgramType = RGBALayerExternalProgramType;
details.mTextureFormat = FORMAT_R8G8B8A8;
surfaceWrapper->SurfaceTexture()->GetTransformMatrix(details.mTextureTransform);
break;
}
@ -989,7 +990,7 @@ bool GLContextEGL::GetSharedHandleDetails(SharedTextureShareType shareType,
case SharedHandleType::Image:
details.mTarget = LOCAL_GL_TEXTURE_2D;
details.mProgramType = RGBALayerProgramType;
details.mTextureFormat = FORMAT_R8G8B8A8;
break;
default:
@ -1117,21 +1118,21 @@ public:
if (gUseBackingSurface) {
if (mUpdateFormat != gfxASurface::ImageFormatARGB32) {
mShaderType = RGBXLayerProgramType;
mTextureFormat = FORMAT_R8G8B8X8;
} else {
mShaderType = RGBALayerProgramType;
mTextureFormat = FORMAT_R8G8B8A8;
}
Resize(aSize);
} else {
if (mUpdateFormat == gfxASurface::ImageFormatRGB16_565) {
mShaderType = RGBXLayerProgramType;
mTextureFormat = FORMAT_R8G8B8X8;
} else if (mUpdateFormat == gfxASurface::ImageFormatRGB24) {
// RGB24 means really RGBX for Thebes, which means we have to
// use the right shader and ignore the uninitialized alpha
// value.
mShaderType = BGRXLayerProgramType;
mTextureFormat = FORMAT_B8G8R8X8;
} else {
mShaderType = BGRALayerProgramType;
mTextureFormat = FORMAT_B8G8R8A8;
}
}
}
@ -1296,7 +1297,7 @@ public:
region = aRegion;
}
mShaderType =
mTextureFormat =
mGLContext->UploadSurfaceToTexture(aSurf,
region,
mTexture,

Просмотреть файл

@ -1062,9 +1062,9 @@ private:
, sGLXLib(sGLXLibrary[aLibType])
{
if (aSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA) {
mShaderType = gl::RGBALayerProgramType;
mTextureFormat = FORMAT_R8G8B8A8;
} else {
mShaderType = gl::RGBXLayerProgramType;
mTextureFormat = FORMAT_R8G8B8X8;
}
}

Просмотреть файл

@ -15,23 +15,6 @@ typedef int GLsizei;
namespace mozilla {
namespace gl {
enum ShaderProgramType {
RGBALayerProgramType,
RGBALayerExternalProgramType,
BGRALayerProgramType,
RGBXLayerProgramType,
BGRXLayerProgramType,
RGBARectLayerProgramType,
RGBAExternalLayerProgramType,
ColorLayerProgramType,
YCbCrLayerProgramType,
ComponentAlphaPass1ProgramType,
ComponentAlphaPass2ProgramType,
Copy2DProgramType,
Copy2DRectProgramType,
NumProgramTypes
};
struct GLFormats
{
// Constructs a zeroed object:

Просмотреть файл

@ -98,7 +98,7 @@ BasicTextureImage::EndUpdate()
bool relative = FinishedSurfaceUpdate();
mShaderType =
mTextureFormat =
mGLContext->UploadSurfaceToTexture(mUpdateSurface,
mUpdateRegion,
mTexture,
@ -156,7 +156,7 @@ BasicTextureImage::DirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion,
region = aRegion;
}
mShaderType =
mTextureFormat =
mGLContext->UploadSurfaceToTexture(aSurf,
region,
mTexture,
@ -268,7 +268,7 @@ TiledTextureImage::DirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion,
} while (NextTile() || (mTextureState != Valid));
mCurrentImage = oldCurrentImage;
mShaderType = mImages[0]->GetShaderProgramType();
mTextureFormat = mImages[0]->GetTextureFormat();
mTextureState = Valid;
return result;
}
@ -380,7 +380,7 @@ TiledTextureImage::EndUpdate()
mImages[mCurrentImage]->EndUpdate();
mInUpdate = false;
mTextureState = Valid;
mShaderType = mImages[mCurrentImage]->GetShaderProgramType();
mTextureFormat = mImages[mCurrentImage]->GetTextureFormat();
return;
}
@ -407,7 +407,7 @@ TiledTextureImage::EndUpdate()
mUpdateSurface = nullptr;
mInUpdate = false;
mShaderType = mImages[0]->GetShaderProgramType();
mTextureFormat = mImages[0]->GetTextureFormat();
mTextureState = Valid;
}

Просмотреть файл

@ -36,6 +36,8 @@ class GLContext;
class TextureImage
{
NS_INLINE_DECL_REFCOUNTING(TextureImage)
protected:
typedef gfxASurface::gfxImageFormat ImageFormat;
public:
enum TextureState
{
@ -201,13 +203,11 @@ public:
};
/**
* Returns the shader program type that should be used to render
* this texture. Only valid after a matching BeginUpdate/EndUpdate
* pair have been called.
* Returns the image format of the texture. Only valid after a matching
* BeginUpdate/EndUpdate pair have been called.
*/
virtual ShaderProgramType GetShaderProgramType()
{
return mShaderType;
virtual gfx::SurfaceFormat GetTextureFormat() {
return mTextureFormat;
}
/** Can be called safely at any time. */
@ -258,7 +258,7 @@ protected:
nsIntSize mSize;
GLenum mWrapMode;
ContentType mContentType;
ShaderProgramType mShaderType;
gfx::SurfaceFormat mTextureFormat;
gfxPattern::GraphicsFilter mFilter;
Flags mFlags;
};
@ -276,7 +276,6 @@ class BasicTextureImage
: public TextureImage
{
public:
typedef gfxASurface::gfxImageFormat ImageFormat;
virtual ~BasicTextureImage();
BasicTextureImage(GLuint aTexture,

Просмотреть файл

@ -131,11 +131,7 @@ CanvasLayerOGL::Initialize(const Data& aData)
gfxXlibSurface *xsurf = static_cast<gfxXlibSurface*>(aData.mSurface);
mPixmap = xsurf->GetGLXPixmap();
if (mPixmap) {
if (aData.mSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA) {
mLayerProgram = gl::RGBALayerProgramType;
} else {
mLayerProgram = gl::RGBXLayerProgramType;
}
mLayerProgram = ShaderProgramFromContentType(aData.mSurface->GetContentType());
MakeTextureIfNeeded(gl(), mUploadTexture);
}
}
@ -236,7 +232,7 @@ CanvasLayerOGL::UpdateSurface()
gfx::NATIVE_SURFACE_CGCONTEXT_ACCELERATED),
gl());
mTextureTarget = LOCAL_GL_TEXTURE_RECTANGLE_ARB;
mLayerProgram = gl::RGBARectLayerProgramType;
mLayerProgram = RGBARectLayerProgramType;
}
mDrawTarget->Flush();
return;
@ -249,11 +245,13 @@ CanvasLayerOGL::UpdateSurface()
if (updatedSurface) {
mOGLManager->MakeCurrent();
mLayerProgram = gl()->UploadSurfaceToTexture(updatedSurface,
mBounds,
mUploadTexture,
true,//false,
nsIntPoint(0, 0));
gfx::SurfaceFormat format =
gl()->UploadSurfaceToTexture(updatedSurface,
mBounds,
mUploadTexture,
true,//false,
nsIntPoint(0, 0));
mLayerProgram = ShaderProgramFromSurfaceFormat(format);
mTexture = mUploadTexture;
if (temporarySurface)
@ -294,12 +292,13 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
drawRect.IntersectRect(drawRect, GetEffectiveVisibleRegion().GetBounds());
mLayerProgram =
gfx::SurfaceFormat format =
gl()->UploadSurfaceToTexture(mCanvasSurface,
nsIntRect(0, 0, drawRect.width, drawRect.height),
mUploadTexture,
true,
drawRect.TopLeft());
mLayerProgram = ShaderProgramFromSurfaceFormat(format);
mTexture = mUploadTexture;
}
@ -316,7 +315,7 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
gl()->ApplyFilterToBoundTexture(mFilter);
program->Activate();
if (mLayerProgram == gl::RGBARectLayerProgramType) {
if (mLayerProgram == RGBARectLayerProgramType) {
// This is used by IOSurface that use 0,0...w,h coordinate rather then 0,0..1,1.
program->SetTexCoordMultiplier(mDrawTarget->GetSize().width, mDrawTarget->GetSize().height);
}

Просмотреть файл

@ -28,7 +28,7 @@ public:
CanvasLayerOGL(LayerManagerOGL *aManager)
: CanvasLayer(aManager, NULL)
, LayerOGL(aManager)
, mLayerProgram(gl::RGBALayerProgramType)
, mLayerProgram(RGBALayerProgramType)
, mTexture(0)
, mTextureTarget(LOCAL_GL_TEXTURE_2D)
, mDelayedUpdates(false)
@ -61,7 +61,7 @@ protected:
nsRefPtr<gfxASurface> mCanvasSurface;
nsRefPtr<GLContext> mGLContext;
gl::ShaderProgramType mLayerProgram;
ShaderProgramType mLayerProgram;
RefPtr<gfx::DrawTarget> mDrawTarget;
GLuint mTexture;

Просмотреть файл

@ -34,7 +34,7 @@ RenderColorLayer(ColorLayer* aLayer, LayerManagerOGL *aManager,
color.b *= opacity;
color.a = opacity;
ShaderProgramOGL *program = aManager->GetProgram(gl::ColorLayerProgramType,
ShaderProgramOGL *program = aManager->GetProgram(ColorLayerProgramType,
aLayer->GetMaskLayer());
program->Activate();
program->SetLayerQuadRect(visibleRect);

Просмотреть файл

@ -160,7 +160,7 @@ public:
{
MOZ_ASSERT(mInitParams.mStatus == InitParams::INITIALIZED);
CompositorOGL* compositorOGL = static_cast<CompositorOGL*>(aCompositor);
return mGL->GetTexImage(mTextureHandle, true, compositorOGL->GetFBOLayerProgramType());
return mGL->GetTexImage(mTextureHandle, true, compositorOGL->GetFBOFormat());
}
#endif

Просмотреть файл

@ -384,7 +384,7 @@ CompositorOGL::Initialize()
}
// initialise a common shader to check that we can actually compile a shader
if (!mPrograms[gl::RGBALayerProgramType].mVariations[MaskNone]->Initialize()) {
if (!mPrograms[RGBALayerProgramType].mVariations[MaskNone]->Initialize()) {
return false;
}
@ -952,12 +952,12 @@ CompositorOGL::CreateFBOWithTexture(const IntRect& aRect, SurfaceInitMode aInit,
*aTexture = tex;
}
gl::ShaderProgramType
ShaderProgramType
CompositorOGL::GetProgramTypeForEffect(Effect *aEffect) const
{
switch(aEffect->mType) {
case EFFECT_SOLID_COLOR:
return gl::ColorLayerProgramType;
return ColorLayerProgramType;
case EFFECT_RGBA:
case EFFECT_RGBX:
case EFFECT_BGRA:
@ -966,14 +966,16 @@ CompositorOGL::GetProgramTypeForEffect(Effect *aEffect) const
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffect);
TextureSourceOGL* source = texturedEffect->mTexture->AsSourceOGL();
return source->GetShaderProgram();
return ShaderProgramFromTargetAndFormat(source->GetTextureTarget(),
source->GetTextureFormat());
}
case EFFECT_YCBCR:
return gl::YCbCrLayerProgramType;
return YCbCrLayerProgramType;
case EFFECT_RENDER_TARGET:
return GetFBOLayerProgramType();
default:
return gl::RGBALayerProgramType;
return RGBALayerProgramType;
}
}
@ -1046,10 +1048,10 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
maskType = MaskNone;
}
gl::ShaderProgramType programType = GetProgramTypeForEffect(aEffectChain.mPrimaryEffect);
ShaderProgramType programType = GetProgramTypeForEffect(aEffectChain.mPrimaryEffect);
ShaderProgramOGL *program = GetProgram(programType, maskType);
program->Activate();
if (programType == gl::RGBARectLayerProgramType) {
if (programType == RGBARectLayerProgramType) {
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
TextureSourceOGL* source = texturedEffect->mTexture->AsSourceOGL();
@ -1105,7 +1107,7 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
}
AutoBindTexture bindSource(source->AsSourceOGL(), LOCAL_GL_TEXTURE0);
if (programType == gl::RGBALayerExternalProgramType) {
if (programType == RGBALayerExternalProgramType) {
program->SetTextureTransform(source->AsSourceOGL()->GetTextureTransform());
}
@ -1213,11 +1215,11 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
for (int32_t pass = 1; pass <=2; ++pass) {
ShaderProgramOGL* program;
if (pass == 1) {
program = GetProgram(gl::ComponentAlphaPass1ProgramType, maskType);
program = GetProgram(ComponentAlphaPass1ProgramType, maskType);
gl()->fBlendFuncSeparate(LOCAL_GL_ZERO, LOCAL_GL_ONE_MINUS_SRC_COLOR,
LOCAL_GL_ONE, LOCAL_GL_ONE);
} else {
program = GetProgram(gl::ComponentAlphaPass2ProgramType, maskType);
program = GetProgram(ComponentAlphaPass2ProgramType, maskType);
gl()->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE,
LOCAL_GL_ONE, LOCAL_GL_ONE);
}

Просмотреть файл

@ -24,7 +24,7 @@ class GLManagerCompositor;
class CompositorOGL : public Compositor
{
typedef mozilla::gl::GLContext GLContext;
typedef mozilla::gl::ShaderProgramType ProgramType;
typedef ShaderProgramType ProgramType;
friend class GLManagerCompositor;
@ -130,9 +130,12 @@ public:
}
GLContext* gl() const { return mGLContext; }
gl::ShaderProgramType GetFBOLayerProgramType() const {
ShaderProgramType GetFBOLayerProgramType() const {
return mFBOTextureTarget == LOCAL_GL_TEXTURE_RECTANGLE_ARB ?
gl::RGBARectLayerProgramType : gl::RGBALayerProgramType;
RGBARectLayerProgramType : RGBALayerProgramType;
}
gfx::SurfaceFormat GetFBOFormat() const {
return gfx::FORMAT_R8G8B8A8;
}
/**
@ -216,7 +219,7 @@ private:
gfx::Rect *aClipRectOut = nullptr,
gfx::Rect *aRenderBoundsOut = nullptr) MOZ_OVERRIDE;
gl::ShaderProgramType GetProgramTypeForEffect(Effect* aEffect) const;
ShaderProgramType GetProgramTypeForEffect(Effect* aEffect) const;
/**
* Updates all layer programs with a new projection matrix.
@ -227,9 +230,9 @@ private:
* Helper method for Initialize, creates all valid variations of a program
* and adds them to mPrograms
*/
void AddPrograms(gl::ShaderProgramType aType);
void AddPrograms(ShaderProgramType aType);
ShaderProgramOGL* GetProgram(gl::ShaderProgramType aType,
ShaderProgramOGL* GetProgram(ShaderProgramType aType,
MaskType aMask = MaskNone) {
MOZ_ASSERT(ProgramProfileOGL::ProgramExists(aType, aMask),
"Invalid program type.");

Просмотреть файл

@ -287,7 +287,7 @@ ContainerRender(Container* aContainer,
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPainting) {
nsRefPtr<gfxImageSurface> surf =
aContainer->gl()->GetTexImage(containerSurface, true, aManager->GetFBOLayerProgramType());
aContainer->gl()->GetTexImage(containerSurface, true, aManager->GetFBOTextureFormat());
WriteSnapshotToDumpFile(aContainer, surf);
}

Просмотреть файл

@ -47,7 +47,7 @@ public:
return mImpl->gl();
}
virtual ShaderProgramOGL* GetProgram(gl::ShaderProgramType aType) MOZ_OVERRIDE
virtual ShaderProgramOGL* GetProgram(ShaderProgramType aType) MOZ_OVERRIDE
{
return mImpl->GetProgram(aType);
}

Просмотреть файл

@ -27,9 +27,12 @@ public:
virtual ~GLManager() {}
virtual gl::GLContext* gl() const = 0;
virtual ShaderProgramOGL* GetProgram(gl::ShaderProgramType aType) = 0;
virtual ShaderProgramOGL* GetProgram(ShaderProgramType aType) = 0;
virtual void BindAndDrawQuad(ShaderProgramOGL *aProg) = 0;
ShaderProgramOGL* GetProgram(gfx::SurfaceFormat aFormat) {
return GetProgram(ShaderProgramFromSurfaceFormat(aFormat));
}
};
}

Просмотреть файл

@ -230,7 +230,7 @@ ImageLayerOGL::RenderLayer(int,
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, data->mTextures[0].GetTextureID());
gl()->ApplyFilterToBoundTexture(mFilter);
ShaderProgramOGL *program = mOGLManager->GetProgram(YCbCrLayerProgramType,
GetMaskLayer());
@ -288,8 +288,7 @@ ImageLayerOGL::RenderLayer(int,
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, data->mTexture.GetTextureID());
ShaderProgramOGL *program =
mOGLManager->GetProgram(data->mLayerProgram, GetMaskLayer());
ShaderProgramOGL *program = mOGLManager->GetProgram(data->mLayerProgram, GetMaskLayer());
gl()->ApplyFilterToBoundTexture(mFilter);
@ -314,10 +313,13 @@ ImageLayerOGL::RenderLayer(int,
return;
}
ShaderProgramOGL* program = mOGLManager->GetProgram(handleDetails.mProgramType, GetMaskLayer());
ShaderProgramType programType =
ShaderProgramFromTargetAndFormat(handleDetails.mTarget,
handleDetails.mTextureFormat);
ShaderProgramOGL* program = mOGLManager->GetProgram(programType, GetMaskLayer());
program->Activate();
if (handleDetails.mProgramType == gl::RGBARectLayerProgramType) {
if (programType == RGBARectLayerProgramType) {
// 2DRect case, get the multiplier right for a sampler2DRect
program->SetTexCoordMultiplier(data->mSize.width, data->mSize.height);
}
@ -459,12 +461,7 @@ ImageLayerOGL::AllocateTexturesCairo(CairoImage *aImage)
static_cast<gfxXlibSurface*>(aImage->mSurface.get());
GLXPixmap pixmap = xsurf->GetGLXPixmap();
if (pixmap) {
if (aImage->mSurface->GetContentType()
== gfxASurface::CONTENT_COLOR_ALPHA) {
backendData->mLayerProgram = gl::RGBALayerProgramType;
} else {
backendData->mLayerProgram = gl::RGBXLayerProgramType;
}
backendData->mLayerProgram = ShaderProgramFromContentType(aImage->mSurface->GetContentType());
aImage->SetBackendData(LAYERS_OPENGL, backendData.forget());
@ -474,10 +471,11 @@ ImageLayerOGL::AllocateTexturesCairo(CairoImage *aImage)
}
}
#endif
backendData->mLayerProgram =
gfx::SurfaceFormat format =
gl->UploadSurfaceToTexture(aImage->mSurface,
nsIntRect(0,0, aImage->mSize.width, aImage->mSize.height),
tex, true);
backendData->mLayerProgram = ShaderProgramFromSurfaceFormat(format);
aImage->SetBackendData(LAYERS_OPENGL, backendData.forget());
}
@ -547,13 +545,14 @@ ImageLayerOGL::LoadAsTexture(GLuint aTextureUnit, gfxIntSize* aSize)
GLuint texID = texture.GetTextureID();
data->mLayerProgram =
gfx::SurfaceFormat format =
texGL->UploadSurfaceToTexture(cairoImage->mSurface,
nsIntRect(0,0,
data->mTextureSize.width,
data->mTextureSize.height),
texID, true, nsIntPoint(0,0), false,
aTextureUnit);
data->mLayerProgram = ShaderProgramFromSurfaceFormat(format);
cairoImage->SetBackendData(LAYERS_OPENGL, data);

Просмотреть файл

@ -147,9 +147,9 @@ struct PlanarYCbCrOGLBackendData : public ImageBackendData
struct CairoOGLBackendData : public ImageBackendData
{
CairoOGLBackendData() : mLayerProgram(gl::RGBALayerProgramType) {}
CairoOGLBackendData() : mLayerProgram(RGBALayerProgramType) {}
GLTexture mTexture;
gl::ShaderProgramType mLayerProgram;
ShaderProgramType mLayerProgram;
gfxIntSize mTextureSize;
};

Просмотреть файл

@ -292,7 +292,7 @@ LayerManagerOGL::Initialize(bool force)
}
// initialise a common shader to check that we can actually compile a shader
if (!mPrograms[gl::RGBALayerProgramType].mVariations[MaskNone]->Initialize()) {
if (!mPrograms[RGBALayerProgramType].mVariations[MaskNone]->Initialize()) {
#ifdef MOZ_WIDGET_ANDROID
NS_RUNTIMEABORT("Shader initialization failed");
#endif

Просмотреть файл

@ -46,7 +46,6 @@ struct FPSState;
class LayerManagerOGL : public LayerManager
{
typedef mozilla::gl::GLContext GLContext;
typedef mozilla::gl::ShaderProgramType ProgramType;
public:
LayerManagerOGL(nsIWidget *aWidget, int aSurfaceWidth = -1, int aSurfaceHeight = -1,
@ -125,29 +124,29 @@ public:
ShaderProgramOGL* GetBasicLayerProgram(bool aOpaque, bool aIsRGB,
MaskType aMask = MaskNone)
{
gl::ShaderProgramType format = gl::BGRALayerProgramType;
ShaderProgramType format = BGRALayerProgramType;
if (aIsRGB) {
if (aOpaque) {
format = gl::RGBXLayerProgramType;
format = RGBXLayerProgramType;
} else {
format = gl::RGBALayerProgramType;
format = RGBALayerProgramType;
}
} else {
if (aOpaque) {
format = gl::BGRXLayerProgramType;
format = BGRXLayerProgramType;
}
}
return GetProgram(format, aMask);
}
ShaderProgramOGL* GetProgram(gl::ShaderProgramType aType,
ShaderProgramOGL* GetProgram(ShaderProgramType aType,
Layer* aMaskLayer) {
if (aMaskLayer)
return GetProgram(aType, Mask2d);
return GetProgram(aType, MaskNone);
}
ShaderProgramOGL* GetProgram(gl::ShaderProgramType aType,
ShaderProgramOGL* GetProgram(ShaderProgramType aType,
MaskType aMask = MaskNone) {
NS_ASSERTION(ProgramProfileOGL::ProgramExists(aType, aMask),
"Invalid program type.");
@ -158,10 +157,14 @@ public:
return GetProgram(GetFBOLayerProgramType(), aMask);
}
gl::ShaderProgramType GetFBOLayerProgramType() {
ShaderProgramType GetFBOLayerProgramType() {
if (mFBOTextureTarget == LOCAL_GL_TEXTURE_RECTANGLE_ARB)
return gl::RGBARectLayerProgramType;
return gl::RGBALayerProgramType;
return RGBARectLayerProgramType;
return RGBALayerProgramType;
}
gfx::SurfaceFormat GetFBOTextureFormat() {
return gfx::FORMAT_R8G8B8A8;
}
GLContext* gl() const { return mGLContext; }
@ -395,7 +398,7 @@ private:
* Helper method for Initialize, creates all valid variations of a program
* and adds them to mPrograms
*/
void AddPrograms(gl::ShaderProgramType aType);
void AddPrograms(ShaderProgramType aType);
/**
* Recursive helper method for use by ComputeRenderIntegrity. Subtracts

Просмотреть файл

@ -36,14 +36,14 @@ AddCommonTextureArgs(ProgramProfileOGL& aProfile)
}
/* static */ ProgramProfileOGL
ProgramProfileOGL::GetProfileFor(gl::ShaderProgramType aType,
ProgramProfileOGL::GetProfileFor(ShaderProgramType aType,
MaskType aMask)
{
NS_ASSERTION(ProgramExists(aType, aMask), "Invalid program type.");
ProgramProfileOGL result;
switch (aType) {
case gl::RGBALayerProgramType:
case RGBALayerProgramType:
if (aMask == Mask3d) {
result.mVertexShaderString = sLayerMask3DVS;
result.mFragmentShaderString = sRGBATextureLayerMask3DFS;
@ -58,7 +58,7 @@ ProgramProfileOGL::GetProfileFor(gl::ShaderProgramType aType,
AddCommonTextureArgs(result);
result.mTextureCount = 1;
break;
case gl::RGBALayerExternalProgramType:
case RGBALayerExternalProgramType:
if (aMask == Mask3d) {
result.mVertexShaderString = sLayerMask3DVS;
result.mFragmentShaderString = sRGBATextureLayerExternalMask3DFS;
@ -75,7 +75,7 @@ ProgramProfileOGL::GetProfileFor(gl::ShaderProgramType aType,
result.mHasTextureTransform = true;
result.mTextureCount = 1;
break;
case gl::BGRALayerProgramType:
case BGRALayerProgramType:
if (aMask == Mask2d) {
result.mVertexShaderString = sLayerMaskVS;
result.mFragmentShaderString = sBGRATextureLayerMaskFS;
@ -87,7 +87,7 @@ ProgramProfileOGL::GetProfileFor(gl::ShaderProgramType aType,
AddCommonTextureArgs(result);
result.mTextureCount = 1;
break;
case gl::RGBXLayerProgramType:
case RGBXLayerProgramType:
if (aMask == Mask2d) {
result.mVertexShaderString = sLayerMaskVS;
result.mFragmentShaderString = sRGBXTextureLayerMaskFS;
@ -99,7 +99,7 @@ ProgramProfileOGL::GetProfileFor(gl::ShaderProgramType aType,
AddCommonTextureArgs(result);
result.mTextureCount = 1;
break;
case gl::BGRXLayerProgramType:
case BGRXLayerProgramType:
if (aMask == Mask2d) {
result.mVertexShaderString = sLayerMaskVS;
result.mFragmentShaderString = sBGRXTextureLayerMaskFS;
@ -111,7 +111,7 @@ ProgramProfileOGL::GetProfileFor(gl::ShaderProgramType aType,
AddCommonTextureArgs(result);
result.mTextureCount = 1;
break;
case gl::RGBARectLayerProgramType:
case RGBARectLayerProgramType:
if (aMask == Mask3d) {
result.mVertexShaderString = sLayerMask3DVS;
result.mFragmentShaderString = sRGBARectTextureLayerMask3DFS;
@ -126,7 +126,7 @@ ProgramProfileOGL::GetProfileFor(gl::ShaderProgramType aType,
AddCommonTextureArgs(result);
result.mTextureCount = 1;
break;
case gl::RGBAExternalLayerProgramType:
case RGBAExternalLayerProgramType:
if (aMask == Mask3d) {
result.mVertexShaderString = sLayerMask3DVS;
result.mFragmentShaderString = sRGBAExternalTextureLayerMask3DFS;
@ -141,7 +141,7 @@ ProgramProfileOGL::GetProfileFor(gl::ShaderProgramType aType,
AddCommonTextureArgs(result);
result.mTextureCount = 1;
break;
case gl::ColorLayerProgramType:
case ColorLayerProgramType:
if (aMask == Mask2d) {
result.mVertexShaderString = sLayerMaskVS;
result.mFragmentShaderString = sSolidColorLayerMaskFS;
@ -152,7 +152,7 @@ ProgramProfileOGL::GetProfileFor(gl::ShaderProgramType aType,
AddCommonArgs(result);
result.mUniforms.AppendElement(Argument("uRenderColor"));
break;
case gl::YCbCrLayerProgramType:
case YCbCrLayerProgramType:
if (aMask == Mask2d) {
result.mVertexShaderString = sLayerMaskVS;
result.mFragmentShaderString = sYCbCrTextureLayerMaskFS;
@ -168,7 +168,7 @@ ProgramProfileOGL::GetProfileFor(gl::ShaderProgramType aType,
result.mAttributes.AppendElement(Argument("aTexCoord"));
result.mTextureCount = 3;
break;
case gl::ComponentAlphaPass1ProgramType:
case ComponentAlphaPass1ProgramType:
if (aMask == Mask2d) {
result.mVertexShaderString = sLayerMaskVS;
result.mFragmentShaderString = sComponentPassMask1FS;
@ -183,7 +183,7 @@ ProgramProfileOGL::GetProfileFor(gl::ShaderProgramType aType,
result.mAttributes.AppendElement(Argument("aTexCoord"));
result.mTextureCount = 2;
break;
case gl::ComponentAlphaPass2ProgramType:
case ComponentAlphaPass2ProgramType:
if (aMask == Mask2d) {
result.mVertexShaderString = sLayerMaskVS;
result.mFragmentShaderString = sComponentPassMask2FS;
@ -198,7 +198,7 @@ ProgramProfileOGL::GetProfileFor(gl::ShaderProgramType aType,
result.mAttributes.AppendElement(Argument("aTexCoord"));
result.mTextureCount = 2;
break;
case gl::Copy2DProgramType:
case Copy2DProgramType:
NS_ASSERTION(!aMask, "Program does not have masked variant.");
result.mVertexShaderString = sCopyVS;
result.mFragmentShaderString = sCopy2DFS;
@ -207,7 +207,7 @@ ProgramProfileOGL::GetProfileFor(gl::ShaderProgramType aType,
result.mAttributes.AppendElement(Argument("aTexCoord"));
result.mTextureCount = 1;
break;
case gl::Copy2DRectProgramType:
case Copy2DRectProgramType:
NS_ASSERTION(!aMask, "Program does not have masked variant.");
result.mVertexShaderString = sCopyVS;
result.mFragmentShaderString = sCopy2DRectFS;

Просмотреть файл

@ -13,11 +13,13 @@
#include "nsString.h"
#include "nsTArray.h"
#include "GLContextTypes.h"
#include "GLDefs.h"
#include "gfx3DMatrix.h"
#include "mozilla/layers/LayersTypes.h"
#include "gfxColor.h"
#include "mozilla/gfx/Matrix.h"
#include "mozilla/RefPtr.h"
#include "gfxASurface.h"
namespace mozilla {
namespace gl {
@ -27,6 +29,67 @@ namespace layers {
class Layer;
enum ShaderProgramType {
RGBALayerProgramType,
RGBALayerExternalProgramType,
BGRALayerProgramType,
RGBXLayerProgramType,
BGRXLayerProgramType,
RGBARectLayerProgramType,
RGBAExternalLayerProgramType,
ColorLayerProgramType,
YCbCrLayerProgramType,
ComponentAlphaPass1ProgramType,
ComponentAlphaPass2ProgramType,
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:
return RGBALayerExternalProgramType;
case LOCAL_GL_TEXTURE_RECTANGLE_ARB:
return RGBARectLayerProgramType;
default:
return ShaderProgramFromSurfaceFormat(aFormat);
}
}
static inline ShaderProgramType
ShaderProgramFromContentType(gfxASurface::gfxContentType aContentType)
{
if (aContentType == gfxASurface::CONTENT_COLOR_ALPHA)
return RGBALayerProgramType;
return RGBXLayerProgramType;
}
/**
* This struct represents the shaders that make up a program and the uniform
* and attribute parmeters that those shaders take.
@ -39,16 +102,16 @@ struct ProgramProfileOGL
* Factory method; creates an instance of this class for the given
* ShaderProgramType
*/
static ProgramProfileOGL GetProfileFor(gl::ShaderProgramType aType,
static ProgramProfileOGL GetProfileFor(ShaderProgramType aType,
MaskType aMask);
/**
* returns true if such a shader program exists
*/
static bool ProgramExists(gl::ShaderProgramType aType, MaskType aMask)
static bool ProgramExists(ShaderProgramType aType, MaskType aMask)
{
if (aType < 0 ||
aType >= gl::NumProgramTypes)
aType >= NumProgramTypes)
return false;
if (aMask < MaskNone ||
@ -56,13 +119,13 @@ struct ProgramProfileOGL
return false;
if (aMask == Mask2d &&
(aType == gl::Copy2DProgramType ||
aType == gl::Copy2DRectProgramType))
(aType == Copy2DProgramType ||
aType == Copy2DRectProgramType))
return false;
return aMask != Mask3d ||
aType == gl::RGBARectLayerProgramType ||
aType == gl::RGBALayerProgramType;
aType == RGBARectLayerProgramType ||
aType == RGBALayerProgramType;
}

Просмотреть файл

@ -99,26 +99,6 @@ WrapMode(gl::GLContext *aGl, bool aAllowRepeat)
return LOCAL_GL_CLAMP_TO_EDGE;
}
gfx::SurfaceFormat
FormatFromShaderType(ShaderProgramType aShaderType)
{
switch (aShaderType) {
case RGBALayerProgramType:
case RGBALayerExternalProgramType:
case RGBARectLayerProgramType:
case RGBAExternalLayerProgramType:
return FORMAT_R8G8B8A8;
case RGBXLayerProgramType:
return FORMAT_R8G8B8X8;
case BGRALayerProgramType:
return FORMAT_B8G8R8A8;
case BGRXLayerProgramType:
return FORMAT_B8G8R8X8;
default:
MOZ_CRASH("Unsupported texture shader type");
}
}
TextureImageTextureHostOGL::~TextureImageTextureHostOGL()
{
MOZ_COUNT_DTOR(TextureImageTextureHostOGL);
@ -221,7 +201,7 @@ TextureImageTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
offset = *aOffset;
}
mTexture->DirectUpdate(surf.Get(), updateRegion, offset);
mFormat = FormatFromShaderType(mTexture->GetShaderProgramType());
mFormat = mTexture->GetTextureFormat();
if (mTexture->InUpdate()) {
mTexture->EndUpdate();
@ -239,7 +219,7 @@ TextureImageTextureHostOGL::Lock()
NS_ASSERTION(mTexture->GetContentType() != gfxASurface::CONTENT_ALPHA,
"Image layer has alpha image");
mFormat = FormatFromShaderType(mTexture->GetShaderProgramType());
mFormat = mTexture->GetTextureFormat();
return true;
}
@ -303,8 +283,7 @@ SharedTextureHostOGL::SwapTexturesImpl(const SurfaceDescriptor& aImage,
GLContext::SharedHandleDetails handleDetails;
if (mSharedHandle && mGL->GetSharedHandleDetails(mShareType, mSharedHandle, handleDetails)) {
mTextureTarget = handleDetails.mTarget;
mShaderProgram = handleDetails.mProgramType;
mFormat = FormatFromShaderType(mShaderProgram);
mFormat = handleDetails.mTextureFormat;
}
}
@ -410,8 +389,8 @@ SurfaceStreamHostOGL::Lock()
glTexSurf->SetConsumerGL(mGL);
mTextureHandle = glTexSurf->Texture();
MOZ_ASSERT(mTextureHandle);
mShaderProgram = sharedSurf->HasAlpha() ? RGBALayerProgramType
: RGBXLayerProgramType;
mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
: FORMAT_R8G8B8X8;
break;
}
case SharedSurfaceType::EGLImageShare: {
@ -423,8 +402,8 @@ SurfaceStreamHostOGL::Lock()
toUpload = eglImageSurf->GetPixels();
MOZ_ASSERT(toUpload);
} else {
mShaderProgram = sharedSurf->HasAlpha() ? RGBALayerProgramType
: RGBXLayerProgramType;
mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
: FORMAT_R8G8B8X8;
}
break;
}
@ -442,15 +421,13 @@ SurfaceStreamHostOGL::Lock()
nsIntSize size(toUpload->GetSize());
nsIntRect rect(nsIntPoint(0,0), size);
nsIntRegion bounds(rect);
mShaderProgram = mGL->UploadSurfaceToTexture(toUpload,
bounds,
mUploadTexture,
true);
mFormat = mGL->UploadSurfaceToTexture(toUpload,
bounds,
mUploadTexture,
true);
mTextureHandle = mUploadTexture;
}
mFormat = FormatFromShaderType(mShaderProgram);
MOZ_ASSERT(mTextureHandle);
mGL->fBindTexture(LOCAL_GL_TEXTURE_2D, mTextureHandle);
mGL->fTexParameteri(LOCAL_GL_TEXTURE_2D,
@ -891,7 +868,7 @@ TextureImageTextureHostOGL::GetAsSurface() {
nsRefPtr<gfxImageSurface> surf = IsValid() ?
mGL->GetTexImage(mTexture->GetTextureID(),
false,
mTexture->GetShaderProgramType())
mTexture->GetTextureFormat())
: nullptr;
return surf.forget();
}
@ -901,7 +878,7 @@ YCbCrTextureHostOGL::GetAsSurface() {
nsRefPtr<gfxImageSurface> surf = IsValid() ?
mGL->GetTexImage(mYTexture->mTexImage->GetTextureID(),
false,
mYTexture->mTexImage->GetShaderProgramType())
mYTexture->mTexImage->GetTextureFormat())
: nullptr;
return surf.forget();
}
@ -911,7 +888,7 @@ SharedTextureHostOGL::GetAsSurface() {
nsRefPtr<gfxImageSurface> surf = IsValid() ?
mGL->GetTexImage(GetTextureHandle(),
false,
GetShaderProgram())
GetTextureFormat())
: nullptr;
return surf.forget();
}
@ -921,7 +898,7 @@ SurfaceStreamHostOGL::GetAsSurface() {
nsRefPtr<gfxImageSurface> surf = IsValid() ?
mGL->GetTexImage(mTextureHandle,
false,
GetShaderProgram())
GetTextureFormat())
: nullptr;
return surf.forget();
}
@ -931,7 +908,7 @@ TiledTextureHostOGL::GetAsSurface() {
nsRefPtr<gfxImageSurface> surf = IsValid() ?
mGL->GetTexImage(mTextureHandle,
false,
GetShaderProgram())
GetTextureFormat())
: nullptr;
return surf.forget();
}
@ -952,7 +929,7 @@ GrallocTextureHostOGL::GetAsSurface() {
nsRefPtr<gfxImageSurface> surf = IsValid() ?
gl()->GetTexImage(tex,
false,
GetShaderProgram())
GetTextureFormat())
: nullptr;
return surf.forget();
}

Просмотреть файл

@ -1,7 +1,7 @@
/* -*- 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/. */
* 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_TEXTUREOGL_H
#define MOZILLA_GFX_TEXTUREOGL_H
@ -49,8 +49,8 @@ public:
virtual void BindTexture(GLenum aTextureUnit) = 0;
virtual void ReleaseTexture() = 0;
virtual gfx::IntSize GetSize() const = 0;
virtual gl::ShaderProgramType GetShaderProgram() const {
MOZ_CRASH("unhandled shader type");
virtual gfx::SurfaceFormat GetTextureFormat() const {
MOZ_CRASH("unhandled texture format");
}
// TODO: Noone's implementing this anymore, should see if we need this.
virtual GLenum GetTextureTarget() const { return LOCAL_GL_TEXTURE_2D; }
@ -60,18 +60,18 @@ public:
virtual TextureImageTextureHostOGL* AsTextureImageTextureHost() { return nullptr; }
};
inline gl::ShaderProgramType
inline ShaderProgramType
GetProgramTypeForTexture(const TextureHost *aTextureHost)
{
switch (aTextureHost->GetFormat()) {
case gfx::FORMAT_B8G8R8A8:
return gl::BGRALayerProgramType;;
return BGRALayerProgramType;;
case gfx::FORMAT_B8G8R8X8:
return gl::BGRXLayerProgramType;;
return BGRXLayerProgramType;;
case gfx::FORMAT_R8G8B8X8:
return gl::RGBXLayerProgramType;;
return RGBXLayerProgramType;;
case gfx::FORMAT_R8G8B8A8:
return gl::RGBALayerProgramType;;
return RGBALayerProgramType;;
default:
MOZ_CRASH("unhandled program type");
}
@ -148,9 +148,9 @@ public:
gfx::IntSize GetSize() const MOZ_OVERRIDE;
gl::ShaderProgramType GetShaderProgram() const MOZ_OVERRIDE
gfx::SurfaceFormat GetTextureFormat() const MOZ_OVERRIDE
{
return GetProgramTypeForTexture(this);
return GetFormat();
}
GLenum GetWrapMode() const MOZ_OVERRIDE
@ -368,9 +368,14 @@ public:
virtual GLenum GetWrapMode() const MOZ_OVERRIDE { return mWrapMode; }
virtual void SetWrapMode(GLenum aMode) { mWrapMode = aMode; }
gl::ShaderProgramType GetShaderProgram() const MOZ_OVERRIDE
gfx::SurfaceFormat GetTextureFormat() const MOZ_OVERRIDE
{
return mShaderProgram;
return mFormat;
}
virtual GLenum GetTextureTarget() const MOZ_OVERRIDE
{
return mTextureTarget;
}
gfx::IntSize GetSize() const MOZ_OVERRIDE {
@ -409,7 +414,6 @@ protected:
GLenum mWrapMode;
GLenum mTextureTarget;
gl::SharedTextureHandle mSharedHandle;
gl::ShaderProgramType mShaderProgram;
gl::GLContext::SharedTextureShareType mShareType;
};
@ -451,9 +455,9 @@ public:
mWrapMode = aMode;
}
gl::ShaderProgramType GetShaderProgram() const MOZ_OVERRIDE
gfx::SurfaceFormat GetTextureFormat() const MOZ_OVERRIDE
{
return mShaderProgram;
return mFormat;
}
gfx::IntSize GetSize() const MOZ_OVERRIDE {
@ -500,7 +504,6 @@ protected:
GLuint mTextureHandle;
GLuint mUploadTexture;
GLenum mWrapMode;
gl::ShaderProgramType mShaderProgram;
};
class TiledTextureHostOGL : public TextureHost
@ -534,9 +537,9 @@ public:
return mSize;
}
gl::ShaderProgramType GetShaderProgram() const MOZ_OVERRIDE
gfx::SurfaceFormat GetTextureFormat() const MOZ_OVERRIDE
{
return GetProgramTypeForTexture(this);
return GetFormat();
}
virtual void SwapTexturesImpl(const SurfaceDescriptor& aImage,
@ -599,15 +602,13 @@ public:
return mGraphicBuffer.get() ? gfx::IntSize(mGraphicBuffer->getWidth(), mGraphicBuffer->getHeight()) : gfx::IntSize(0, 0);
}
gl::ShaderProgramType GetShaderProgram() const MOZ_OVERRIDE
gfx::SurfaceFormat GetTextureFormat() const MOZ_OVERRIDE
{
if (mTextureTarget == LOCAL_GL_TEXTURE_EXTERNAL) {
return gl::RGBAExternalLayerProgramType;
return gfx::FORMAT_R8G8B8A8;
}
MOZ_ASSERT(mTextureTarget == LOCAL_GL_TEXTURE_2D);
return mFormat == gfx::FORMAT_B8G8R8A8 || mFormat == gfx::FORMAT_B8G8R8X8
? gl::BGRALayerProgramType
: gl::RGBALayerProgramType;
return mFormat;
}
GLenum GetWrapMode() const MOZ_OVERRIDE

Просмотреть файл

@ -134,7 +134,7 @@ ThebesLayerBufferOGL::RenderTo(const nsIntPoint& aOffset,
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPainting) {
nsRefPtr<gfxImageSurface> surf =
gl()->GetTexImage(mTexImage->GetTextureID(), false, mTexImage->GetShaderProgramType());
gl()->GetTexImage(mTexImage->GetTextureID(), false, mTexImage->GetTextureFormat());
WriteSnapshotToDumpFile(mLayer, surf);
}
@ -147,12 +147,12 @@ ThebesLayerBufferOGL::RenderTo(const nsIntPoint& aOffset,
if (passes == 2) {
ShaderProgramOGL* alphaProgram;
if (pass == 1) {
alphaProgram = aManager->GetProgram(gl::ComponentAlphaPass1ProgramType,
alphaProgram = aManager->GetProgram(ComponentAlphaPass1ProgramType,
mLayer->GetMaskLayer());
gl()->fBlendFuncSeparate(LOCAL_GL_ZERO, LOCAL_GL_ONE_MINUS_SRC_COLOR,
LOCAL_GL_ONE, LOCAL_GL_ONE);
} else {
alphaProgram = aManager->GetProgram(gl::ComponentAlphaPass2ProgramType,
alphaProgram = aManager->GetProgram(ComponentAlphaPass2ProgramType,
mLayer->GetMaskLayer());
gl()->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE,
LOCAL_GL_ONE, LOCAL_GL_ONE);
@ -166,7 +166,7 @@ ThebesLayerBufferOGL::RenderTo(const nsIntPoint& aOffset,
// Note BGR: Cairo's image surfaces are always in what
// OpenGL and our shaders consider BGR format.
ShaderProgramOGL* basicProgram =
aManager->GetProgram(mTexImage->GetShaderProgramType(),
aManager->GetProgram(ShaderProgramFromSurfaceFormat(mTexImage->GetTextureFormat()),
mLayer->GetMaskLayer());
basicProgram->Activate();

Просмотреть файл

@ -2015,7 +2015,7 @@ nsChildView::MaybeDrawResizeIndicator(GLManager* aManager, const nsIntRect& aRec
TextureImage::ScopedBindTexture texBind(mResizerImage, LOCAL_GL_TEXTURE0);
ShaderProgramOGL *program =
aManager->GetProgram(mResizerImage->GetShaderProgramType());
aManager->GetProgram(mResizerImage->GetTextureFormat());
program->Activate();
program->SetLayerQuadRect(nsIntRect(bottomX - resizeIndicatorWidth,
bottomY - resizeIndicatorHeight,
@ -2217,7 +2217,7 @@ nsChildView::MaybeDrawTitlebar(GLManager* aManager, const nsIntRect& aRect)
TextureImage::ScopedBindTexture texBind(mTitlebarImage, LOCAL_GL_TEXTURE0);
ShaderProgramOGL *program =
aManager->GetProgram(mTitlebarImage->GetShaderProgramType());
aManager->GetProgram(mTitlebarImage->GetTextureFormat());
program->Activate();
program->SetLayerQuadRect(nsIntRect(nsIntPoint(0, 0),
mTitlebarImage->GetSize()));
@ -2285,7 +2285,7 @@ nsChildView::MaybeDrawRoundedCorners(GLManager* aManager, const nsIntRect& aRect
TextureImage::ScopedBindTexture texBind(mCornerMaskImage, LOCAL_GL_TEXTURE0);
ShaderProgramOGL *program = aManager->GetProgram(mCornerMaskImage->GetShaderProgramType());
ShaderProgramOGL *program = aManager->GetProgram(mCornerMaskImage->GetTextureFormat());
program->Activate();
program->SetLayerQuadRect(nsIntRect(nsIntPoint(0, 0),
mCornerMaskImage->GetSize()));