| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | ** | 
|  | 3 | ** Copyright 2009, The Android Open Source Project | 
|  | 4 | ** | 
|  | 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 6 | ** you may not use this file except in compliance with the License. | 
|  | 7 | ** You may obtain a copy of the License at | 
|  | 8 | ** | 
|  | 9 | **     http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 10 | ** | 
|  | 11 | ** Unless required by applicable law or agreed to in writing, software | 
|  | 12 | ** distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 14 | ** See the License for the specific language governing permissions and | 
|  | 15 | ** limitations under the License. | 
|  | 16 | */ | 
|  | 17 |  | 
|  | 18 | #ifndef ANDROID_OPENGLES_COPYBIT_H | 
|  | 19 | #define ANDROID_OPENGLES_COPYBIT_H | 
|  | 20 |  | 
|  | 21 | #include <stdlib.h> | 
|  | 22 |  | 
|  | 23 | #include <GLES/gl.h> | 
|  | 24 |  | 
|  | 25 | #include "TextureObjectManager.h" | 
|  | 26 | namespace android { | 
|  | 27 | #ifdef LIBAGL_USE_GRALLOC_COPYBITS | 
|  | 28 |  | 
|  | 29 | bool drawTexiOESWithCopybit_impl(GLint x, GLint y, GLint z, | 
|  | 30 | GLint w, GLint h, ogles_context_t* c); | 
| Mathias Agopian | 6d2cad2 | 2009-06-17 21:18:56 -0700 | [diff] [blame] | 31 |  | 
|  | 32 | bool drawTriangleFanWithCopybit_impl(ogles_context_t* c, GLint first, | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 33 | GLsizei count); | 
|  | 34 |  | 
|  | 35 | inline bool copybitQuickCheckContext(ogles_context_t* c) { | 
| Mathias Agopian | 0a3139a | 2009-06-10 16:01:54 -0700 | [diff] [blame] | 36 | return  c->copybits.drawSurfaceBuffer != 0 | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 37 | && c->rasterizer.state.enabled_tmu == 1 | 
| Mathias Agopian | 0a3139a | 2009-06-10 16:01:54 -0700 | [diff] [blame] | 38 | && c->textures.tmu[0].texture->try_copybit; | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 39 | } | 
|  | 40 |  | 
|  | 41 | /* | 
|  | 42 | * Tries to draw a drawTexiOES using copybit hardware. | 
|  | 43 | * Returns true if successful. | 
|  | 44 | */ | 
|  | 45 | inline bool drawTexiOESWithCopybit(GLint x, GLint y, GLint z, | 
|  | 46 | GLint w, GLint h, ogles_context_t* c) { | 
|  | 47 | if (!copybitQuickCheckContext(c)) { | 
|  | 48 | return false; | 
|  | 49 | } | 
|  | 50 |  | 
|  | 51 | return drawTexiOESWithCopybit_impl(x, y, z, w, h, c); | 
|  | 52 | } | 
|  | 53 |  | 
|  | 54 | /* | 
|  | 55 | * Tries to draw a triangle fan using copybit hardware. | 
|  | 56 | * Returns true if successful. | 
|  | 57 | */ | 
| Mathias Agopian | 6d2cad2 | 2009-06-17 21:18:56 -0700 | [diff] [blame] | 58 | inline bool drawTriangleFanWithCopybit(ogles_context_t* c, GLint first, | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 59 | GLsizei count) { | 
|  | 60 | /* | 
|  | 61 | * We are looking for the glDrawArrays call made by SurfaceFlinger. | 
|  | 62 | */ | 
|  | 63 |  | 
| Mathias Agopian | 6d2cad2 | 2009-06-17 21:18:56 -0700 | [diff] [blame] | 64 | if ((count!=4) || first || !copybitQuickCheckContext(c)) | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 65 | return false; | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 66 |  | 
| Mathias Agopian | 6d2cad2 | 2009-06-17 21:18:56 -0700 | [diff] [blame] | 67 | return drawTriangleFanWithCopybit_impl(c, first, count); | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 68 | } | 
|  | 69 |  | 
|  | 70 |  | 
|  | 71 | #endif // LIBAGL_USE_GRALLOC_COPYBITS | 
|  | 72 |  | 
|  | 73 | } // namespace android | 
|  | 74 |  | 
|  | 75 | #endif // ANDROID_OPENGLES_COPYBIT_H |