blob: 7d54d3b3255df09b981d28cc9b2e667d085bb8ca [file] [log] [blame]
Romain Guydda57022010-07-06 11:39:32 -07001/*
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
Romain Guy5b3b3522010-10-27 18:57:51 -070017#ifndef ANDROID_HWUI_LAYER_H
18#define ANDROID_HWUI_LAYER_H
Romain Guydda57022010-07-06 11:39:32 -070019
Romain Guyf7f93552010-07-08 19:17:03 -070020#include <sys/types.h>
21
Romain Guydda57022010-07-06 11:39:32 -070022#include <GLES2/gl2.h>
23
Romain Guy5b3b3522010-10-27 18:57:51 -070024#include <ui/Region.h>
25
Romain Guydda57022010-07-06 11:39:32 -070026#include <SkXfermode.h>
27
28#include "Rect.h"
Romain Guy171c5922011-01-06 10:04:23 -080029#include "SkiaColorFilter.h"
Romain Guydda57022010-07-06 11:39:32 -070030
31namespace android {
32namespace uirenderer {
33
Romain Guy8550c4c2010-10-08 15:49:53 -070034///////////////////////////////////////////////////////////////////////////////
35// Layers
36///////////////////////////////////////////////////////////////////////////////
Romain Guydda57022010-07-06 11:39:32 -070037
38/**
Romain Guyeb993562010-10-05 18:14:38 -070039 * A layer has dimensions and is backed by an OpenGL texture or FBO.
Romain Guydda57022010-07-06 11:39:32 -070040 */
41struct Layer {
Romain Guy8550c4c2010-10-08 15:49:53 -070042 Layer(const uint32_t layerWidth, const uint32_t layerHeight):
43 width(layerWidth), height(layerHeight) {
44 }
45
Romain Guydda57022010-07-06 11:39:32 -070046 /**
Romain Guy8550c4c2010-10-08 15:49:53 -070047 * Bounds of the layer.
Romain Guydda57022010-07-06 11:39:32 -070048 */
49 Rect layer;
50 /**
Romain Guy8550c4c2010-10-08 15:49:53 -070051 * Texture coordinates of the layer.
Romain Guydda57022010-07-06 11:39:32 -070052 */
Romain Guy8550c4c2010-10-08 15:49:53 -070053 Rect texCoords;
54
Romain Guydda57022010-07-06 11:39:32 -070055 /**
Romain Guyeb993562010-10-05 18:14:38 -070056 * Name of the FBO used to render the layer. If the name is 0
57 * this layer is not backed by an FBO, but a simple texture.
58 */
59 GLuint fbo;
Romain Guy8550c4c2010-10-08 15:49:53 -070060
Romain Guyeb993562010-10-05 18:14:38 -070061 /**
Romain Guydda57022010-07-06 11:39:32 -070062 * Opacity of the layer.
Romain Guydda57022010-07-06 11:39:32 -070063 */
Romain Guyf607bdc2010-09-10 19:20:06 -070064 int alpha;
Romain Guydda57022010-07-06 11:39:32 -070065 /**
66 * Blending mode of the layer.
Romain Guydda57022010-07-06 11:39:32 -070067 */
68 SkXfermode::Mode mode;
69 /**
70 * Indicates whether this layer should be blended.
71 */
72 bool blend;
Romain Guy8550c4c2010-10-08 15:49:53 -070073
Romain Guy38c85b92010-09-22 22:48:20 -070074 /**
Romain Guy0bb56672010-10-01 00:25:02 -070075 * Indicates whether this layer has been used already.
Romain Guy38c85b92010-09-22 22:48:20 -070076 */
77 bool empty;
Romain Guy8550c4c2010-10-08 15:49:53 -070078
79 /**
80 * Name of the texture used to render the layer.
81 */
82 GLuint texture;
83 /**
84 * Width of the layer texture.
85 */
86 uint32_t width;
87 /**
88 * Height of the layer texture.
89 */
90 uint32_t height;
Romain Guy5b3b3522010-10-27 18:57:51 -070091
92 /**
93 * Dirty region indicating what parts of the layer
94 * have been drawn.
95 */
96 Region region;
Romain Guy171c5922011-01-06 10:04:23 -080097
98 /**
99 * Color filter used to draw this layer. Optional.
100 */
101 SkiaColorFilter* colorFilter;
Romain Guydda57022010-07-06 11:39:32 -0700102}; // struct Layer
103
104}; // namespace uirenderer
105}; // namespace android
106
Romain Guy5b3b3522010-10-27 18:57:51 -0700107#endif // ANDROID_HWUI_LAYER_H