Layer.h revision 171c592f0b7066acf279863c8a52ddabea49d3db
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_HWUI_LAYER_H
18#define ANDROID_HWUI_LAYER_H
19
20#include <sys/types.h>
21
22#include <GLES2/gl2.h>
23
24#include <ui/Region.h>
25
26#include <SkXfermode.h>
27
28#include "Rect.h"
29#include "SkiaColorFilter.h"
30
31namespace android {
32namespace uirenderer {
33
34///////////////////////////////////////////////////////////////////////////////
35// Layers
36///////////////////////////////////////////////////////////////////////////////
37
38/**
39 * A layer has dimensions and is backed by an OpenGL texture or FBO.
40 */
41struct Layer {
42    Layer(const uint32_t layerWidth, const uint32_t layerHeight):
43            width(layerWidth), height(layerHeight) {
44    }
45
46    /**
47     * Bounds of the layer.
48     */
49    Rect layer;
50    /**
51     * Texture coordinates of the layer.
52     */
53    Rect texCoords;
54
55    /**
56     * 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;
60
61    /**
62     * Opacity of the layer.
63     */
64    int alpha;
65    /**
66     * Blending mode of the layer.
67     */
68    SkXfermode::Mode mode;
69    /**
70     * Indicates whether this layer should be blended.
71     */
72    bool blend;
73
74    /**
75     * Indicates whether this layer has been used already.
76     */
77    bool empty;
78
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;
91
92    /**
93     * Dirty region indicating what parts of the layer
94     * have been drawn.
95     */
96    Region region;
97
98    /**
99     * Color filter used to draw this layer. Optional.
100     */
101    SkiaColorFilter* colorFilter;
102}; // struct Layer
103
104}; // namespace uirenderer
105}; // namespace android
106
107#endif // ANDROID_HWUI_LAYER_H
108