blob: b8b5afda2656be9f963a18298b0fa1701079f3a0 [file] [log] [blame]
Jean-Baptiste Querucc8c35c2009-11-12 18:45:53 -08001/*
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"
26namespace android {
27#ifdef LIBAGL_USE_GRALLOC_COPYBITS
28
29bool drawTexiOESWithCopybit_impl(GLint x, GLint y, GLint z,
30 GLint w, GLint h, ogles_context_t* c);
31
32bool drawTriangleFanWithCopybit_impl(ogles_context_t* c, GLint first,
33 GLsizei count);
34
35inline bool copybitQuickCheckContext(ogles_context_t* c) {
36 return c->copybits.drawSurfaceBuffer != 0
37 && c->rasterizer.state.enabled_tmu == 1
38 && c->textures.tmu[0].texture->try_copybit;
39}
40
41/*
42 * Tries to draw a drawTexiOES using copybit hardware.
43 * Returns true if successful.
44 */
45inline 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 */
58inline bool drawTriangleFanWithCopybit(ogles_context_t* c, GLint first,
59 GLsizei count) {
60 /*
61 * We are looking for the glDrawArrays call made by SurfaceFlinger.
62 */
63
64 if ((count!=4) || first || !copybitQuickCheckContext(c))
65 return false;
66
67 return drawTriangleFanWithCopybit_impl(c, first, count);
68}
69
70
71#endif // LIBAGL_USE_GRALLOC_COPYBITS
72
73} // namespace android
74
75#endif // ANDROID_OPENGLES_COPYBIT_H