blob: 586a05e77e253ff576027bf7bd4f91ce8e392feb [file] [log] [blame]
Romain Guydda570202010-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
17#ifndef ANDROID_UI_LAYER_H
18#define ANDROID_UI_LAYER_H
19
20#include <GLES2/gl2.h>
21
22#include <SkXfermode.h>
23
24#include "Rect.h"
25
26namespace android {
27namespace uirenderer {
28
29/**
30 * Dimensions of a layer.
31 */
32struct LayerSize {
Romain Guy6c818932010-07-07 15:15:32 -070033 LayerSize(): width(0), height(0), id(0) { }
34 LayerSize(const uint32_t width, const uint32_t height): width(width), height(height), id(0) { }
35 LayerSize(const LayerSize& size): width(size.width), height(size.height), id(size.id) { }
Romain Guydda570202010-07-06 11:39:32 -070036
37 uint32_t width;
38 uint32_t height;
39
Romain Guy6c818932010-07-07 15:15:32 -070040 // Incremental id used by the layer cache to store multiple
41 // LayerSize with the same dimensions
42 uint32_t id;
43
Romain Guydda570202010-07-06 11:39:32 -070044 bool operator<(const LayerSize& rhs) const {
Romain Guy6c818932010-07-07 15:15:32 -070045 if (id != 0 && rhs.id != 0) {
46 return id < rhs.id;
47 }
Romain Guydda570202010-07-06 11:39:32 -070048 if (width == rhs.width) {
49 return height < rhs.height;
50 }
51 return width < rhs.width;
52 }
53
54 bool operator==(const LayerSize& rhs) const {
55 return width == rhs.width && height == rhs.height;
56 }
57};
58
59/**
60 * A layer has dimensions and is backed by an OpenGL texture.
61 */
62struct Layer {
63 /**
64 * Coordinates of the layer corresponding to this snapshot.
65 * Only set when the flag kFlagIsLayer is set.
66 */
67 Rect layer;
68 /**
69 * Name of the texture used to render the layer.
70 * Only set when the flag kFlagIsLayer is set.
71 */
72 GLuint texture;
73 /**
74 * Name of the FBO used to render the layer.
75 * Only set when the flag kFlagIsLayer is set.
76 */
77 GLuint fbo;
78 /**
79 * Opacity of the layer.
80 * Only set when the flag kFlagIsLayer is set.
81 */
82 float alpha;
83 /**
84 * Blending mode of the layer.
85 * Only set when the flag kFlagIsLayer is set.
86 */
87 SkXfermode::Mode mode;
88 /**
89 * Indicates whether this layer should be blended.
90 */
91 bool blend;
92}; // struct Layer
93
94}; // namespace uirenderer
95}; // namespace android
96
97#endif // ANDROID_UI_LAYER_H