blob: 70d64ca4b91405fda8a1d024e88c8b94b238c989 [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
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 {
33 LayerSize(): width(0), height(0) { }
34 LayerSize(const uint32_t width, const uint32_t height): width(width), height(height) { }
35 LayerSize(const LayerSize& size): width(size.width), height(size.height) { }
36
37 uint32_t width;
38 uint32_t height;
39
40 bool operator<(const LayerSize& rhs) const {
41 if (width == rhs.width) {
42 return height < rhs.height;
43 }
44 return width < rhs.width;
45 }
46
47 bool operator==(const LayerSize& rhs) const {
48 return width == rhs.width && height == rhs.height;
49 }
50};
51
52/**
53 * A layer has dimensions and is backed by an OpenGL texture.
54 */
55struct Layer {
56 /**
57 * Coordinates of the layer corresponding to this snapshot.
58 * Only set when the flag kFlagIsLayer is set.
59 */
60 Rect layer;
61 /**
62 * Name of the texture used to render the layer.
63 * Only set when the flag kFlagIsLayer is set.
64 */
65 GLuint texture;
66 /**
67 * Name of the FBO used to render the layer.
68 * Only set when the flag kFlagIsLayer is set.
69 */
70 GLuint fbo;
71 /**
72 * Opacity of the layer.
73 * Only set when the flag kFlagIsLayer is set.
74 */
75 float alpha;
76 /**
77 * Blending mode of the layer.
78 * Only set when the flag kFlagIsLayer is set.
79 */
80 SkXfermode::Mode mode;
81 /**
82 * Indicates whether this layer should be blended.
83 */
84 bool blend;
85}; // struct Layer
86
87}; // namespace uirenderer
88}; // namespace android
89
90#endif // ANDROID_UI_LAYER_H