1 /*
2 * Copyright (C) 2016 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 SIMPLE_H
18 #define SIMPLE_H
19
20 #include <stdint.h>
21 #include <sys/cdefs.h>
22 #include <sys/types.h>
23
24 #include <cutils/native_handle.h>
25
26 #include <hardware/hardware.h>
27
28 __BEGIN_DECLS
29
30 #define FORGROUND_COLOR "#133742"
31 #define ACTOR_COLOR "#424242"
32
33 /* Simple example */
34 typedef struct simple_t {
35 /**
36 * Common methods of the simple device.
37 */
38 struct hw_device_t common;
39
40 /* resolution of the framebuffer's display panel in pixel per inch*/
41 const float xdpi;
42 const float ydpi;
43
44 /* framebuffer's display panel refresh rate in frames per second */
45 const float fps;
46
47 int (*setSwapInterval)(struct simple_t* window,
48 int interval);
49
50 /*
51 * This hook is OPTIONAL.
52 */
53 int (*setUpdateRect)(struct simple_t* window,
54 int left, int top, int width, int height);
55
56 } simple_t;
57
58 /* Holds pixel coordinates */
59 typedef struct {
60 int px;
61 int py;
62
63 /*
64 * If non NULL it will be caused by SurfaceFlinger on dumpsys
65 */
66 void (*doDump)(int foo, char *buff, int buff_len);
67
68 } simple_location_t;
69
70 /** convenience API for coloring */
71
showColor(const struct hw_module_t * module,struct simple_t ** device)72 static inline int showColor(const struct hw_module_t* module,
73 struct simple_t** device) {
74 return module->methods->open(module,
75 FORGROUND_COLOR, (struct simple_t**)device);
76 }
77
hideColor(struct simple_t * device)78 static inline int hideColor(struct simple_t* device) {
79 return device->common.close(&device->common);
80 }
81
82 __END_DECLS
83
84 #endif // SIMPLE_H
85