blob: d4db7823c2666a3f061b5258729ebd8ab3350025 [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
17#ifndef ANDROID_UI_LAYER_H
18#define ANDROID_UI_LAYER_H
19
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
24#include <SkXfermode.h>
25
26#include "Rect.h"
27
28namespace android {
29namespace uirenderer {
30
31/**
32 * Dimensions of a layer.
33 */
34struct LayerSize {
Romain Guy6c818932010-07-07 15:15:32 -070035 LayerSize(): width(0), height(0), id(0) { }
36 LayerSize(const uint32_t width, const uint32_t height): width(width), height(height), id(0) { }
37 LayerSize(const LayerSize& size): width(size.width), height(size.height), id(size.id) { }
Romain Guydda57022010-07-06 11:39:32 -070038
39 uint32_t width;
40 uint32_t height;
41
Romain Guy6c818932010-07-07 15:15:32 -070042 // Incremental id used by the layer cache to store multiple
43 // LayerSize with the same dimensions
44 uint32_t id;
45
Romain Guydda57022010-07-06 11:39:32 -070046 bool operator<(const LayerSize& rhs) const {
Romain Guy6c818932010-07-07 15:15:32 -070047 if (id != 0 && rhs.id != 0) {
48 return id < rhs.id;
49 }
Romain Guydda57022010-07-06 11:39:32 -070050 if (width == rhs.width) {
51 return height < rhs.height;
52 }
53 return width < rhs.width;
54 }
55
56 bool operator==(const LayerSize& rhs) const {
57 return width == rhs.width && height == rhs.height;
58 }
Romain Guyf7f93552010-07-08 19:17:03 -070059}; // struct LayerSize
Romain Guydda57022010-07-06 11:39:32 -070060
61/**
62 * A layer has dimensions and is backed by an OpenGL texture.
63 */
64struct Layer {
65 /**
66 * Coordinates of the layer corresponding to this snapshot.
67 * Only set when the flag kFlagIsLayer is set.
68 */
69 Rect layer;
70 /**
71 * Name of the texture used to render the layer.
72 * Only set when the flag kFlagIsLayer is set.
73 */
74 GLuint texture;
75 /**
76 * Name of the FBO used to render the layer.
77 * Only set when the flag kFlagIsLayer is set.
78 */
79 GLuint fbo;
80 /**
81 * Opacity of the layer.
82 * Only set when the flag kFlagIsLayer is set.
83 */
84 float alpha;
85 /**
86 * Blending mode of the layer.
87 * Only set when the flag kFlagIsLayer is set.
88 */
89 SkXfermode::Mode mode;
90 /**
91 * Indicates whether this layer should be blended.
92 */
93 bool blend;
94}; // struct Layer
95
96}; // namespace uirenderer
97}; // namespace android
98
99#endif // ANDROID_UI_LAYER_H