gecko/gfx/gl/GLBlitHelper.h
Wes Kocher 8f849d9d65 Backed out 6 changesets (bug 877115) for mochitest-1 and reftest orange on this CLOSED TREE
Backed out changeset 65ad9d8860d6 (bug 877115)
Backed out changeset bf8095c168fb (bug 877115)
Backed out changeset 290ad5863615 (bug 877115)
Backed out changeset 4488ec28910e (bug 877115)
Backed out changeset 45f8859c6fd6 (bug 877115)
Backed out changeset 111cc426fa9e (bug 877115)
2013-12-16 16:33:07 -08:00

118 lines
4.4 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=8 sts=4 et sw=4 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 GLBLITHELPER_H_
#define GLBLITHELPER_H_
#include "GLContextTypes.h"
#include "GLConsts.h"
#include "nsSize.h"
#include "mozilla/Attributes.h"
struct nsIntSize;
namespace mozilla {
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.
GLContext* mGL;
GLuint mTexBlit_Buffer;
GLuint mTexBlit_VertShader;
GLuint mTex2DBlit_FragShader;
GLuint mTex2DRectBlit_FragShader;
GLuint mTex2DBlit_Program;
GLuint mTex2DRectBlit_Program;
void UseBlitProgram();
void SetBlitFramebufferForDestTexture(GLuint aTexture);
bool UseTexQuadProgram(GLenum target, const nsIntSize& srcSize);
bool InitTexQuadProgram(GLenum target = LOCAL_GL_TEXTURE_2D);
void DeleteTexBlitProgram();
public:
GLBlitHelper(GLContext* gl);
~GLBlitHelper();
// If you don't have |srcFormats| for the 2nd definition,
// then you'll need the framebuffer_blit extensions to use
// the first BlitFramebufferToFramebuffer.
void BlitFramebufferToFramebuffer(GLuint srcFB, GLuint destFB,
const nsIntSize& srcSize,
const nsIntSize& destSize);
void BlitFramebufferToFramebuffer(GLuint srcFB, GLuint destFB,
const nsIntSize& srcSize,
const nsIntSize& destSize,
const GLFormats& srcFormats);
void BlitTextureToFramebuffer(GLuint srcTex, GLuint destFB,
const nsIntSize& srcSize,
const nsIntSize& destSize,
GLenum srcTarget = LOCAL_GL_TEXTURE_2D);
void BlitFramebufferToTexture(GLuint srcFB, GLuint destTex,
const nsIntSize& srcSize,
const nsIntSize& destSize,
GLenum destTarget = LOCAL_GL_TEXTURE_2D);
void BlitTextureToTexture(GLuint srcTex, GLuint destTex,
const nsIntSize& srcSize,
const nsIntSize& destSize,
GLenum srcTarget = LOCAL_GL_TEXTURE_2D,
GLenum destTarget = LOCAL_GL_TEXTURE_2D);
};
}
}
#endif // GLBLITHELPER_H_