| Jamie Gennis | 9c183f2 | 2012-12-03 16:44:16 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2012 The Android Open Source Project | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
|  | 17 | #include <stdint.h> | 
|  | 18 |  | 
|  | 19 | #include <EGL/egl.h> | 
|  | 20 | #include <GLES2/gl2.h> | 
|  | 21 |  | 
|  | 22 | #include <gui/GLConsumer.h> | 
|  | 23 |  | 
|  | 24 | namespace android { | 
|  | 25 |  | 
|  | 26 | #define NELEMS(x) ((int) (sizeof(x) / sizeof((x)[0]))) | 
|  | 27 |  | 
|  | 28 | enum { MAX_NUM_LAYERS = 16 }; | 
|  | 29 | enum { MAX_TEST_RUNS = 16 }; | 
|  | 30 |  | 
|  | 31 | class Composer; | 
|  | 32 | class Renderer; | 
|  | 33 | class GLHelper; | 
|  | 34 |  | 
|  | 35 | struct LayerDesc { | 
|  | 36 | uint32_t flags; | 
|  | 37 | Renderer* (*rendererFactory)(); | 
|  | 38 | Composer* (*composerFactory)(); | 
|  | 39 | int32_t x; | 
|  | 40 | int32_t y; | 
|  | 41 | uint32_t width; | 
|  | 42 | uint32_t height; | 
|  | 43 | }; | 
|  | 44 |  | 
|  | 45 | void resetColorGenerator(); | 
|  | 46 |  | 
|  | 47 | class Composer { | 
|  | 48 | public: | 
|  | 49 | virtual ~Composer() {} | 
|  | 50 | virtual bool setUp(const LayerDesc& desc, GLHelper* helper) = 0; | 
|  | 51 | virtual void tearDown() = 0; | 
|  | 52 | virtual bool compose(GLuint texName, const sp<GLConsumer>& glc) = 0; | 
|  | 53 | }; | 
|  | 54 |  | 
|  | 55 | Composer* nocomp(); | 
|  | 56 | Composer* opaque(); | 
|  | 57 | Composer* opaqueShrink(); | 
|  | 58 | Composer* blend(); | 
|  | 59 | Composer* blendShrink(); | 
|  | 60 |  | 
|  | 61 | class Renderer { | 
|  | 62 | public: | 
|  | 63 | virtual ~Renderer() {} | 
|  | 64 | virtual bool setUp(GLHelper* helper) = 0; | 
|  | 65 | virtual void tearDown() = 0; | 
|  | 66 | virtual bool render(EGLSurface surface) = 0; | 
|  | 67 | }; | 
|  | 68 |  | 
|  | 69 | Renderer* staticGradient(); | 
|  | 70 |  | 
|  | 71 | } // namespace android |