blob: 1888aee1929ed35dead5997a580a94cd131a7cb6 [file] [log] [blame]
Mathias Agopian1473f462009-04-10 14:24:30 -07001/*
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);
31bool drawTrangleFanWithCopybit_impl(ogles_context_t* c, GLint first,
32 GLsizei count);
33
34inline bool copybitQuickCheckContext(ogles_context_t* c) {
35 return c->copybits.drawSurfaceFd >= 0
36 && c->rasterizer.state.enabled_tmu == 1
37 && c->textures.tmu[0].texture->copybits_fd >= 0;
38}
39
40/*
41 * Tries to draw a drawTexiOES using copybit hardware.
42 * Returns true if successful.
43 */
44inline bool drawTexiOESWithCopybit(GLint x, GLint y, GLint z,
45 GLint w, GLint h, ogles_context_t* c) {
46 if (!copybitQuickCheckContext(c)) {
47 return false;
48 }
49
50 return drawTexiOESWithCopybit_impl(x, y, z, w, h, c);
51}
52
53/*
54 * Tries to draw a triangle fan using copybit hardware.
55 * Returns true if successful.
56 */
57inline bool drawTrangleFanWithCopybit(ogles_context_t* c, GLint first,
58 GLsizei count) {
59 /*
60 * We are looking for the glDrawArrays call made by SurfaceFlinger.
61 */
62
63 if (!(copybitQuickCheckContext(c) && first == 0 && count == 4)) {
64 return false;
65 }
66
67 return drawTrangleFanWithCopybit_impl(c, first, count);
68}
69
70
71#endif // LIBAGL_USE_GRALLOC_COPYBITS
72
73} // namespace android
74
75#endif // ANDROID_OPENGLES_COPYBIT_H