blob: b8b5afda2656be9f963a18298b0fa1701079f3a0 [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);
Mathias Agopian03a1b012009-06-17 21:18:56 -070031
32bool drawTriangleFanWithCopybit_impl(ogles_context_t* c, GLint first,
Mathias Agopian1473f462009-04-10 14:24:30 -070033 GLsizei count);
34
35inline bool copybitQuickCheckContext(ogles_context_t* c) {
Mathias Agopian350d6512009-06-10 16:01:54 -070036 return c->copybits.drawSurfaceBuffer != 0
Mathias Agopian1473f462009-04-10 14:24:30 -070037 && c->rasterizer.state.enabled_tmu == 1
Mathias Agopian350d6512009-06-10 16:01:54 -070038 && c->textures.tmu[0].texture->try_copybit;
Mathias Agopian1473f462009-04-10 14:24:30 -070039}
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 */
Mathias Agopian03a1b012009-06-17 21:18:56 -070058inline bool drawTriangleFanWithCopybit(ogles_context_t* c, GLint first,
Mathias Agopian1473f462009-04-10 14:24:30 -070059 GLsizei count) {
60 /*
61 * We are looking for the glDrawArrays call made by SurfaceFlinger.
62 */
63
Mathias Agopian03a1b012009-06-17 21:18:56 -070064 if ((count!=4) || first || !copybitQuickCheckContext(c))
Mathias Agopian1473f462009-04-10 14:24:30 -070065 return false;
Mathias Agopian1473f462009-04-10 14:24:30 -070066
Mathias Agopian03a1b012009-06-17 21:18:56 -070067 return drawTriangleFanWithCopybit_impl(c, first, count);
Mathias Agopian1473f462009-04-10 14:24:30 -070068}
69
70
71#endif // LIBAGL_USE_GRALLOC_COPYBITS
72
73} // namespace android
74
75#endif // ANDROID_OPENGLES_COPYBIT_H