blob: b3bd5fd428c960b3189c3fa52467cfc558263d40 [file] [log] [blame]
Chris Craik0519c812015-02-11 13:17:06 -08001/*
2 * Copyright (C) 2015 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#ifndef FLOATCOLOR_H
17#define FLOATCOLOR_H
18
19#include "utils/Macros.h"
20
Chris Craik922d3a72015-02-13 17:47:21 -080021#include <stdint.h>
22
Chris Craik0519c812015-02-11 13:17:06 -080023namespace android {
24namespace uirenderer {
25
26struct FloatColor {
Chris Craik922d3a72015-02-13 17:47:21 -080027 void set(uint32_t color) {
28 a = ((color >> 24) & 0xff) / 255.0f;
29 r = a * ((color >> 16) & 0xff) / 255.0f;
30 g = a * ((color >> 8) & 0xff) / 255.0f;
31 b = a * ((color ) & 0xff) / 255.0f;
32 }
33
Chris Craik0519c812015-02-11 13:17:06 -080034 float r;
35 float g;
36 float b;
37 float a;
38};
39
40REQUIRE_COMPATIBLE_LAYOUT(FloatColor);
41
42} /* namespace uirenderer */
43} /* namespace android */
44
45#endif /* FLOATCOLOR_H */