mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 9d673e562fa6 (bug 945023) for OSX bustage.
This commit is contained in:
parent
a47d920ed3
commit
fee893bac3
@ -12,115 +12,6 @@
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
static void
|
||||
RenderbufferStorageBySamples(GLContext* aGL, GLsizei aSamples,
|
||||
GLenum aInternalFormat, const gfxIntSize& aSize)
|
||||
{
|
||||
if (aSamples) {
|
||||
aGL->fRenderbufferStorageMultisample(LOCAL_GL_RENDERBUFFER,
|
||||
aSamples,
|
||||
aInternalFormat,
|
||||
aSize.width, aSize.height);
|
||||
} else {
|
||||
aGL->fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
|
||||
aInternalFormat,
|
||||
aSize.width, aSize.height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GLuint
|
||||
CreateTexture(GLContext* aGL, GLenum aInternalFormat, GLenum aFormat,
|
||||
GLenum aType, const gfxIntSize& aSize)
|
||||
{
|
||||
GLuint tex = 0;
|
||||
aGL->fGenTextures(1, &tex);
|
||||
ScopedBindTexture autoTex(aGL, tex);
|
||||
|
||||
aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
|
||||
aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
|
||||
aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
|
||||
aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
|
||||
|
||||
aGL->fTexImage2D(LOCAL_GL_TEXTURE_2D,
|
||||
0,
|
||||
aInternalFormat,
|
||||
aSize.width, aSize.height,
|
||||
0,
|
||||
aFormat,
|
||||
aType,
|
||||
nullptr);
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
||||
GLuint
|
||||
CreateTextureForOffscreen(GLContext* aGL, const GLFormats& aFormats,
|
||||
const gfxIntSize& aSize)
|
||||
{
|
||||
MOZ_ASSERT(aFormats.color_texInternalFormat);
|
||||
MOZ_ASSERT(aFormats.color_texFormat);
|
||||
MOZ_ASSERT(aFormats.color_texType);
|
||||
|
||||
return CreateTexture(aGL,
|
||||
aFormats.color_texInternalFormat,
|
||||
aFormats.color_texFormat,
|
||||
aFormats.color_texType,
|
||||
aSize);
|
||||
}
|
||||
|
||||
|
||||
GLuint
|
||||
CreateRenderbuffer(GLContext* aGL, GLenum aFormat, GLsizei aSamples,
|
||||
const gfxIntSize& aSize)
|
||||
{
|
||||
GLuint rb = 0;
|
||||
aGL->fGenRenderbuffers(1, &rb);
|
||||
ScopedBindRenderbuffer autoRB(aGL, rb);
|
||||
|
||||
RenderbufferStorageBySamples(aGL, aSamples, aFormat, aSize);
|
||||
|
||||
return rb;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CreateRenderbuffersForOffscreen(GLContext* aGL, const GLFormats& aFormats,
|
||||
const gfxIntSize& aSize, bool aMultisample,
|
||||
GLuint* aColorMSRB, GLuint* aDepthRB,
|
||||
GLuint* aStencilRB)
|
||||
{
|
||||
GLsizei samples = aMultisample ? aFormats.samples : 0;
|
||||
if (aColorMSRB) {
|
||||
MOZ_ASSERT(aFormats.samples > 0);
|
||||
MOZ_ASSERT(aFormats.color_rbFormat);
|
||||
|
||||
*aColorMSRB = CreateRenderbuffer(aGL, aFormats.color_rbFormat, samples, aSize);
|
||||
}
|
||||
|
||||
if (aDepthRB &&
|
||||
aStencilRB &&
|
||||
aFormats.depthStencil)
|
||||
{
|
||||
*aDepthRB = CreateRenderbuffer(aGL, aFormats.depthStencil, samples, aSize);
|
||||
*aStencilRB = *aDepthRB;
|
||||
} else {
|
||||
if (aDepthRB) {
|
||||
MOZ_ASSERT(aFormats.depth);
|
||||
|
||||
*aDepthRB = CreateRenderbuffer(aGL, aFormats.depth, samples, aSize);
|
||||
}
|
||||
|
||||
if (aStencilRB) {
|
||||
MOZ_ASSERT(aFormats.stencil);
|
||||
|
||||
*aStencilRB = CreateRenderbuffer(aGL, aFormats.stencil, samples, aSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GLBlitHelper::GLBlitHelper(GLContext* gl)
|
||||
: mGL(gl)
|
||||
, mTexBlit_Buffer(0)
|
||||
@ -434,7 +325,7 @@ GLBlitHelper::BlitFramebufferToFramebuffer(GLuint srcFB, GLuint destFB,
|
||||
return;
|
||||
}
|
||||
|
||||
GLuint tex = CreateTextureForOffscreen(mGL, srcFormats, srcSize);
|
||||
GLuint tex = mGL->CreateTextureForOffscreen(srcFormats, srcSize);
|
||||
MOZ_ASSERT(tex);
|
||||
|
||||
BlitFramebufferToTexture(srcFB, tex, srcSize, srcSize);
|
||||
|
@ -18,49 +18,6 @@ namespace gl {
|
||||
|
||||
class GLContext;
|
||||
|
||||
/**
|
||||
* Helper function that creates a 2D texture aSize.width x aSize.height with
|
||||
* storage type specified by aFormats. Returns GL texture object id.
|
||||
*
|
||||
* See mozilla::gl::CreateTexture.
|
||||
*/
|
||||
GLuint CreateTextureForOffscreen(GLContext* aGL, const GLFormats& aFormats,
|
||||
const gfxIntSize& aSize);
|
||||
|
||||
/**
|
||||
* Helper function that creates a 2D texture aSize.width x aSize.height with
|
||||
* storage type aInternalFormat. Returns GL texture object id.
|
||||
*
|
||||
* Initialize textyre parameters to:
|
||||
* GL_TEXTURE_MIN_FILTER = GL_LINEAR
|
||||
* GL_TEXTURE_MAG_FILTER = GL_LINEAR
|
||||
* GL_TEXTURE_WRAP_S = GL_CLAMP_TO_EDGE
|
||||
* GL_TEXTURE_WRAP_T = GL_CLAMP_TO_EDGE
|
||||
*/
|
||||
GLuint CreateTexture(GLContext* aGL, GLenum aInternalFormat, GLenum aFormat,
|
||||
GLenum aType, const gfxIntSize& aSize);
|
||||
|
||||
/**
|
||||
* Helper function to create, potentially, multisample render buffers suitable
|
||||
* for offscreen rendering. Buffers of size aSize.width x aSize.height with
|
||||
* storage specified by aFormat. returns GL render buffer object id.
|
||||
*/
|
||||
GLuint CreateRenderbuffer(GLContext* aGL, GLenum aFormat, GLsizei aSamples,
|
||||
const gfxIntSize& aSize);
|
||||
|
||||
/**
|
||||
* Helper function to create, potentially, multisample render buffers suitable
|
||||
* for offscreen rendering. Buffers of size aSize.width x aSize.height with
|
||||
* storage specified by aFormats. GL render buffer object ids are returned via
|
||||
* aColorMSRB, aDepthRB, and aStencilRB
|
||||
*/
|
||||
void CreateRenderbuffersForOffscreen(GLContext* aGL, const GLFormats& aFormats,
|
||||
const gfxIntSize& aSize, bool aMultisample,
|
||||
GLuint* aColorMSRB, GLuint* aDepthRB,
|
||||
GLuint* aStencilRB);
|
||||
|
||||
|
||||
/** Buffer blitting helper */
|
||||
class GLBlitHelper MOZ_FINAL
|
||||
{
|
||||
// The GLContext is the sole owner of the GLBlitHelper.
|
||||
|
@ -1345,6 +1345,104 @@ GLContext::ChooseGLFormats(const SurfaceCaps& caps) const
|
||||
return formats;
|
||||
}
|
||||
|
||||
GLuint
|
||||
GLContext::CreateTextureForOffscreen(const GLFormats& formats, const gfxIntSize& size)
|
||||
{
|
||||
MOZ_ASSERT(formats.color_texInternalFormat);
|
||||
MOZ_ASSERT(formats.color_texFormat);
|
||||
MOZ_ASSERT(formats.color_texType);
|
||||
|
||||
return CreateTexture(formats.color_texInternalFormat,
|
||||
formats.color_texFormat,
|
||||
formats.color_texType,
|
||||
size);
|
||||
}
|
||||
|
||||
GLuint
|
||||
GLContext::CreateTexture(GLenum internalFormat, GLenum format, GLenum type, const gfxIntSize& size)
|
||||
{
|
||||
GLuint tex = 0;
|
||||
fGenTextures(1, &tex);
|
||||
ScopedBindTexture autoTex(this, tex);
|
||||
|
||||
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
|
||||
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
|
||||
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
|
||||
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
|
||||
|
||||
fTexImage2D(LOCAL_GL_TEXTURE_2D,
|
||||
0,
|
||||
internalFormat,
|
||||
size.width, size.height,
|
||||
0,
|
||||
format,
|
||||
type,
|
||||
nullptr);
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
static inline void
|
||||
RenderbufferStorageBySamples(GLContext* gl, GLsizei samples, GLenum internalFormat, const gfxIntSize& size)
|
||||
{
|
||||
if (samples) {
|
||||
gl->fRenderbufferStorageMultisample(LOCAL_GL_RENDERBUFFER,
|
||||
samples,
|
||||
internalFormat,
|
||||
size.width, size.height);
|
||||
} else {
|
||||
gl->fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
|
||||
internalFormat,
|
||||
size.width, size.height);
|
||||
}
|
||||
}
|
||||
|
||||
GLuint
|
||||
GLContext::CreateRenderbuffer(GLenum format, GLsizei samples, const gfxIntSize& size)
|
||||
{
|
||||
GLuint rb = 0;
|
||||
fGenRenderbuffers(1, &rb);
|
||||
ScopedBindRenderbuffer autoRB(this, rb);
|
||||
|
||||
RenderbufferStorageBySamples(this, samples, format, size);
|
||||
|
||||
return rb;
|
||||
}
|
||||
|
||||
void
|
||||
GLContext::CreateRenderbuffersForOffscreen(const GLFormats& formats, const gfxIntSize& size,
|
||||
bool multisample,
|
||||
GLuint* colorMSRB, GLuint* depthRB, GLuint* stencilRB)
|
||||
{
|
||||
GLsizei samples = multisample ? formats.samples : 0;
|
||||
if (colorMSRB) {
|
||||
MOZ_ASSERT(formats.samples > 0);
|
||||
MOZ_ASSERT(formats.color_rbFormat);
|
||||
|
||||
*colorMSRB = CreateRenderbuffer(formats.color_rbFormat, samples, size);
|
||||
}
|
||||
|
||||
if (depthRB &&
|
||||
stencilRB &&
|
||||
formats.depthStencil)
|
||||
{
|
||||
*depthRB = CreateRenderbuffer(formats.depthStencil, samples, size);
|
||||
*stencilRB = *depthRB;
|
||||
} else {
|
||||
if (depthRB) {
|
||||
MOZ_ASSERT(formats.depth);
|
||||
|
||||
*depthRB = CreateRenderbuffer(formats.depth, samples, size);
|
||||
}
|
||||
|
||||
if (stencilRB) {
|
||||
MOZ_ASSERT(formats.stencil);
|
||||
|
||||
*stencilRB = CreateRenderbuffer(formats.stencil, samples, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
GLContext::IsFramebufferComplete(GLuint fb, GLenum* pStatus)
|
||||
{
|
||||
|
@ -2822,8 +2822,25 @@ public:
|
||||
return *mPixelFormat;
|
||||
}
|
||||
|
||||
|
||||
GLuint CreateTextureForOffscreen(const GLFormats& formats,
|
||||
const gfxIntSize& size);
|
||||
GLuint CreateTexture(GLenum internalFormat,
|
||||
GLenum format, GLenum type,
|
||||
const gfxIntSize& size);
|
||||
GLuint CreateRenderbuffer(GLenum format,
|
||||
GLsizei samples,
|
||||
const gfxIntSize& size);
|
||||
bool IsFramebufferComplete(GLuint fb, GLenum* status = nullptr);
|
||||
|
||||
// Pass null to an RB arg to disable its creation.
|
||||
void CreateRenderbuffersForOffscreen(const GLFormats& formats,
|
||||
const gfxIntSize& size,
|
||||
bool multisample,
|
||||
GLuint* colorMSRB,
|
||||
GLuint* depthRB,
|
||||
GLuint* stencilRB);
|
||||
|
||||
// Does not check completeness.
|
||||
void AttachBuffersToFB(GLuint colorTex, GLuint colorRB,
|
||||
GLuint depthRB, GLuint stencilRB,
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <cstring>
|
||||
#include "gfxImageSurface.h"
|
||||
#include "GLContext.h"
|
||||
#include "GLBlitHelper.h"
|
||||
#include "SharedSurfaceGL.h"
|
||||
#include "SurfaceStream.h"
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
@ -548,8 +547,8 @@ DrawBuffer::Create(GLContext* const gl,
|
||||
pStencilRB = nullptr;
|
||||
}
|
||||
|
||||
CreateRenderbuffersForOffscreen(gl, formats, size, caps.antialias,
|
||||
pColorMSRB, pDepthRB, pStencilRB);
|
||||
gl->CreateRenderbuffersForOffscreen(formats, size, caps.antialias,
|
||||
pColorMSRB, pDepthRB, pStencilRB);
|
||||
|
||||
GLuint fb = 0;
|
||||
gl->fGenFramebuffers(1, &fb);
|
||||
@ -601,8 +600,8 @@ ReadBuffer::Create(GLContext* gl,
|
||||
GLuint* pDepthRB = caps.depth ? &depthRB : nullptr;
|
||||
GLuint* pStencilRB = caps.stencil ? &stencilRB : nullptr;
|
||||
|
||||
CreateRenderbuffersForOffscreen(gl, formats, surf->Size(), caps.antialias,
|
||||
nullptr, pDepthRB, pStencilRB);
|
||||
gl->CreateRenderbuffersForOffscreen(formats, surf->Size(), caps.antialias,
|
||||
nullptr, pDepthRB, pStencilRB);
|
||||
|
||||
GLuint colorTex = 0;
|
||||
GLuint colorRB = 0;
|
||||
|
@ -32,7 +32,7 @@ SharedSurface_EGLImage::Create(GLContext* prodGL,
|
||||
return nullptr;
|
||||
|
||||
MOZ_ALWAYS_TRUE(prodGL->MakeCurrent());
|
||||
GLuint prodTex = CreateTextureForOffscreen(prodGL, formats, size);
|
||||
GLuint prodTex = prodGL->CreateTextureForOffscreen(formats, size);
|
||||
if (!prodTex)
|
||||
return nullptr;
|
||||
|
||||
@ -130,7 +130,7 @@ CreateTexturePipe(GLLibraryEGL* const egl, GLContext* const gl,
|
||||
*out_tex = 0;
|
||||
*out_image = 0;
|
||||
|
||||
GLuint tex = CreateTextureForOffscreen(gl, formats, size);
|
||||
GLuint tex = gl->CreateTextureForOffscreen(formats, size);
|
||||
if (!tex)
|
||||
return false;
|
||||
|
||||
|
@ -247,10 +247,10 @@ SharedSurface_Basic::Create(GLContext* gl,
|
||||
bool hasAlpha)
|
||||
{
|
||||
gl->MakeCurrent();
|
||||
GLuint tex = CreateTexture(gl, formats.color_texInternalFormat,
|
||||
formats.color_texFormat,
|
||||
formats.color_texType,
|
||||
size);
|
||||
GLuint tex = gl->CreateTexture(formats.color_texInternalFormat,
|
||||
formats.color_texFormat,
|
||||
formats.color_texType,
|
||||
size);
|
||||
|
||||
gfxImageFormat format = gfxImageFormatRGB24;
|
||||
switch (formats.color_texInternalFormat) {
|
||||
@ -319,7 +319,7 @@ SharedSurface_GLTexture::Create(GLContext* prodGL,
|
||||
MOZ_ASSERT(!consGL || prodGL->SharesWith(consGL));
|
||||
|
||||
prodGL->MakeCurrent();
|
||||
GLuint tex = CreateTextureForOffscreen(prodGL, formats, size);
|
||||
GLuint tex = prodGL->CreateTextureForOffscreen(formats, size);
|
||||
|
||||
return new SharedSurface_GLTexture(prodGL, consGL, size, hasAlpha, tex);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user