michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* vim: set ts=8 sts=4 et sw=4 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GLBLITTEXTUREIMAGEHELPER_H_ michael@0: #define GLBLITTEXTUREIMAGEHELPER_H_ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "GLContextTypes.h" michael@0: #include "GLConsts.h" michael@0: michael@0: struct nsIntRect; michael@0: michael@0: namespace mozilla { michael@0: namespace gl { michael@0: michael@0: class GLContext; michael@0: class TextureImage; michael@0: michael@0: class GLBlitTextureImageHelper MOZ_FINAL michael@0: { michael@0: // The GLContext is the sole owner of the GLBlitTextureImageHelper. michael@0: GLContext* mGL; michael@0: michael@0: // lazy-initialized things michael@0: GLuint mBlitProgram, mBlitFramebuffer; michael@0: void UseBlitProgram(); michael@0: void SetBlitFramebufferForDestTexture(GLuint aTexture); michael@0: michael@0: public: michael@0: michael@0: GLBlitTextureImageHelper(GLContext *gl); michael@0: ~GLBlitTextureImageHelper(); michael@0: michael@0: /** michael@0: * Copy a rectangle from one TextureImage into another. The michael@0: * source and destination are given in integer coordinates, and michael@0: * will be converted to texture coordinates. michael@0: * michael@0: * For the source texture, the wrap modes DO apply -- it's valid michael@0: * to use REPEAT or PAD and expect appropriate behaviour if the source michael@0: * rectangle extends beyond its bounds. michael@0: * michael@0: * For the destination texture, the wrap modes DO NOT apply -- the michael@0: * destination will be clipped by the bounds of the texture. michael@0: * michael@0: * Note: calling this function will cause the following OpenGL state michael@0: * to be changed: michael@0: * michael@0: * - current program michael@0: * - framebuffer binding michael@0: * - viewport michael@0: * - blend state (will be enabled at end) michael@0: * - scissor state (will be enabled at end) michael@0: * - vertex attrib 0 and 1 (pointer and enable state [enable state will be disabled at exit]) michael@0: * - array buffer binding (will be 0) michael@0: * - active texture (will be 0) michael@0: * - texture 0 binding michael@0: */ michael@0: void BlitTextureImage(TextureImage *aSrc, const nsIntRect& aSrcRect, michael@0: TextureImage *aDst, const nsIntRect& aDstRect); michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif // GLBLITTEXTUREIMAGEHELPER_H_