Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | #ifndef ANDROID_HWUI_LAYER_RENDERER_H |
| 18 | #define ANDROID_HWUI_LAYER_RENDERER_H |
| 19 | |
| 20 | #include "OpenGLRenderer.h" |
Romain Guy | ada830f | 2011-01-13 12:13:20 -0800 | [diff] [blame] | 21 | #include "Layer.h" |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 22 | |
Romain Guy | 77a8116 | 2011-06-14 16:45:55 -0700 | [diff] [blame] | 23 | #include <SkBitmap.h> |
| 24 | |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 25 | namespace android { |
| 26 | namespace uirenderer { |
| 27 | |
| 28 | /////////////////////////////////////////////////////////////////////////////// |
Romain Guy | 1fc883b | 2011-01-12 14:30:59 -0800 | [diff] [blame] | 29 | // Defines |
| 30 | /////////////////////////////////////////////////////////////////////////////// |
| 31 | |
| 32 | // Debug |
| 33 | #if DEBUG_LAYER_RENDERER |
| 34 | #define LAYER_RENDERER_LOGD(...) LOGD(__VA_ARGS__) |
| 35 | #else |
| 36 | #define LAYER_RENDERER_LOGD(...) |
| 37 | #endif |
| 38 | |
| 39 | /////////////////////////////////////////////////////////////////////////////// |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 40 | // Renderer |
| 41 | /////////////////////////////////////////////////////////////////////////////// |
| 42 | |
| 43 | class LayerRenderer: public OpenGLRenderer { |
| 44 | public: |
Romain Guy | ada830f | 2011-01-13 12:13:20 -0800 | [diff] [blame] | 45 | LayerRenderer(Layer* layer): mLayer(layer) { |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | ~LayerRenderer() { |
| 49 | } |
| 50 | |
Romain Guy | 7d7b549 | 2011-01-24 16:33:45 -0800 | [diff] [blame] | 51 | void prepareDirty(float left, float top, float right, float bottom, bool opaque); |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 52 | void finish(); |
| 53 | |
Romain Guy | f219da5 | 2011-01-16 12:54:25 -0800 | [diff] [blame] | 54 | bool hasLayer(); |
| 55 | Region* getRegion(); |
Romain Guy | 42f3a4b | 2011-01-19 13:42:26 -0800 | [diff] [blame] | 56 | GLint getTargetFbo(); |
Romain Guy | f219da5 | 2011-01-16 12:54:25 -0800 | [diff] [blame] | 57 | |
Romain Guy | a948927 | 2011-06-22 20:58:11 -0700 | [diff] [blame] | 58 | static Layer* createTextureLayer(bool isOpaque); |
Romain Guy | ada830f | 2011-01-13 12:13:20 -0800 | [diff] [blame] | 59 | static Layer* createLayer(uint32_t width, uint32_t height, bool isOpaque = false); |
| 60 | static bool resizeLayer(Layer* layer, uint32_t width, uint32_t height); |
Romain Guy | aa6c24c | 2011-04-28 18:40:04 -0700 | [diff] [blame] | 61 | static void updateTextureLayer(Layer* layer, uint32_t width, uint32_t height, |
Romain Guy | a948927 | 2011-06-22 20:58:11 -0700 | [diff] [blame] | 62 | bool isOpaque, GLenum renderTarget, float* transform); |
Romain Guy | ada830f | 2011-01-13 12:13:20 -0800 | [diff] [blame] | 63 | static void destroyLayer(Layer* layer); |
| 64 | static void destroyLayerDeferred(Layer* layer); |
Romain Guy | 77a8116 | 2011-06-14 16:45:55 -0700 | [diff] [blame] | 65 | static bool copyLayer(Layer* layer, SkBitmap* bitmap); |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 66 | |
| 67 | private: |
Romain Guy | f219da5 | 2011-01-16 12:54:25 -0800 | [diff] [blame] | 68 | void generateMesh(); |
| 69 | |
Romain Guy | ada830f | 2011-01-13 12:13:20 -0800 | [diff] [blame] | 70 | Layer* mLayer; |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 71 | }; // class LayerRenderer |
| 72 | |
| 73 | }; // namespace uirenderer |
| 74 | }; // namespace android |
| 75 | |
| 76 | #endif // ANDROID_HWUI_LAYER_RENDERER_H |