Romain Guy | dda57020 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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_UI_LAYER_H |
| 18 | #define ANDROID_UI_LAYER_H |
| 19 | |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 20 | #include <sys/types.h> |
| 21 | |
Romain Guy | dda57020 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 22 | #include <GLES2/gl2.h> |
| 23 | |
| 24 | #include <SkXfermode.h> |
| 25 | |
| 26 | #include "Rect.h" |
| 27 | |
| 28 | namespace android { |
| 29 | namespace uirenderer { |
| 30 | |
| 31 | /** |
| 32 | * Dimensions of a layer. |
| 33 | */ |
| 34 | struct LayerSize { |
Romain Guy | eb99356 | 2010-10-05 18:14:38 -0700 | [diff] [blame] | 35 | LayerSize(): width(0), height(0) { } |
| 36 | LayerSize(const uint32_t width, const uint32_t height): width(width), height(height) { } |
| 37 | LayerSize(const LayerSize& size): width(size.width), height(size.height) { } |
Romain Guy | dda57020 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 38 | |
| 39 | uint32_t width; |
| 40 | uint32_t height; |
| 41 | |
| 42 | bool operator<(const LayerSize& rhs) const { |
Romain Guy | dda57020 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 43 | if (width == rhs.width) { |
| 44 | return height < rhs.height; |
| 45 | } |
| 46 | return width < rhs.width; |
| 47 | } |
| 48 | |
| 49 | bool operator==(const LayerSize& rhs) const { |
Romain Guy | eb99356 | 2010-10-05 18:14:38 -0700 | [diff] [blame] | 50 | return width == rhs.width && height == rhs.height; |
Romain Guy | dda57020 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 51 | } |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 52 | }; // struct LayerSize |
Romain Guy | dda57020 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 53 | |
| 54 | /** |
Romain Guy | eb99356 | 2010-10-05 18:14:38 -0700 | [diff] [blame] | 55 | * A layer has dimensions and is backed by an OpenGL texture or FBO. |
Romain Guy | dda57020 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 56 | */ |
| 57 | struct Layer { |
| 58 | /** |
Romain Guy | f607bdc | 2010-09-10 19:20:06 -0700 | [diff] [blame] | 59 | * Coordinates of the layer. |
Romain Guy | dda57020 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 60 | */ |
| 61 | Rect layer; |
| 62 | /** |
| 63 | * Name of the texture used to render the layer. |
Romain Guy | dda57020 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 64 | */ |
| 65 | GLuint texture; |
| 66 | /** |
Romain Guy | eb99356 | 2010-10-05 18:14:38 -0700 | [diff] [blame] | 67 | * Name of the FBO used to render the layer. If the name is 0 |
| 68 | * this layer is not backed by an FBO, but a simple texture. |
| 69 | */ |
| 70 | GLuint fbo; |
| 71 | /** |
Romain Guy | dda57020 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 72 | * Opacity of the layer. |
Romain Guy | dda57020 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 73 | */ |
Romain Guy | f607bdc | 2010-09-10 19:20:06 -0700 | [diff] [blame] | 74 | int alpha; |
Romain Guy | dda57020 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 75 | /** |
| 76 | * Blending mode of the layer. |
Romain Guy | dda57020 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 77 | */ |
| 78 | SkXfermode::Mode mode; |
| 79 | /** |
| 80 | * Indicates whether this layer should be blended. |
| 81 | */ |
| 82 | bool blend; |
Romain Guy | 38c85b9 | 2010-09-22 22:48:20 -0700 | [diff] [blame] | 83 | /** |
Romain Guy | 0bb5667 | 2010-10-01 00:25:02 -0700 | [diff] [blame] | 84 | * Indicates whether this layer has been used already. |
Romain Guy | 38c85b9 | 2010-09-22 22:48:20 -0700 | [diff] [blame] | 85 | */ |
| 86 | bool empty; |
Romain Guy | dda57020 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 87 | }; // struct Layer |
| 88 | |
| 89 | }; // namespace uirenderer |
| 90 | }; // namespace android |
| 91 | |
| 92 | #endif // ANDROID_UI_LAYER_H |