|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* vim: set ts=8 sts=4 et sw=4 tw=80: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef GLBLITTEXTUREIMAGEHELPER_H_ |
|
8 #define GLBLITTEXTUREIMAGEHELPER_H_ |
|
9 |
|
10 #include "mozilla/Attributes.h" |
|
11 #include "GLContextTypes.h" |
|
12 #include "GLConsts.h" |
|
13 |
|
14 struct nsIntRect; |
|
15 |
|
16 namespace mozilla { |
|
17 namespace gl { |
|
18 |
|
19 class GLContext; |
|
20 class TextureImage; |
|
21 |
|
22 class GLBlitTextureImageHelper MOZ_FINAL |
|
23 { |
|
24 // The GLContext is the sole owner of the GLBlitTextureImageHelper. |
|
25 GLContext* mGL; |
|
26 |
|
27 // lazy-initialized things |
|
28 GLuint mBlitProgram, mBlitFramebuffer; |
|
29 void UseBlitProgram(); |
|
30 void SetBlitFramebufferForDestTexture(GLuint aTexture); |
|
31 |
|
32 public: |
|
33 |
|
34 GLBlitTextureImageHelper(GLContext *gl); |
|
35 ~GLBlitTextureImageHelper(); |
|
36 |
|
37 /** |
|
38 * Copy a rectangle from one TextureImage into another. The |
|
39 * source and destination are given in integer coordinates, and |
|
40 * will be converted to texture coordinates. |
|
41 * |
|
42 * For the source texture, the wrap modes DO apply -- it's valid |
|
43 * to use REPEAT or PAD and expect appropriate behaviour if the source |
|
44 * rectangle extends beyond its bounds. |
|
45 * |
|
46 * For the destination texture, the wrap modes DO NOT apply -- the |
|
47 * destination will be clipped by the bounds of the texture. |
|
48 * |
|
49 * Note: calling this function will cause the following OpenGL state |
|
50 * to be changed: |
|
51 * |
|
52 * - current program |
|
53 * - framebuffer binding |
|
54 * - viewport |
|
55 * - blend state (will be enabled at end) |
|
56 * - scissor state (will be enabled at end) |
|
57 * - vertex attrib 0 and 1 (pointer and enable state [enable state will be disabled at exit]) |
|
58 * - array buffer binding (will be 0) |
|
59 * - active texture (will be 0) |
|
60 * - texture 0 binding |
|
61 */ |
|
62 void BlitTextureImage(TextureImage *aSrc, const nsIntRect& aSrcRect, |
|
63 TextureImage *aDst, const nsIntRect& aDstRect); |
|
64 }; |
|
65 |
|
66 } |
|
67 } |
|
68 |
|
69 #endif // GLBLITTEXTUREIMAGEHELPER_H_ |