1f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland/*
2f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland * Copyright (C) 2016 The Android Open Source Project
3f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland *
4f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland * Licensed under the Apache License, Version 2.0 (the "License");
5f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland * you may not use this file except in compliance with the License.
6f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland * You may obtain a copy of the License at
7f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland *
8f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland *      http://www.apache.org/licenses/LICENSE-2.0
9f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland *
10f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland * Unless required by applicable law or agreed to in writing, software
11f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland * distributed under the License is distributed on an "AS IS" BASIS,
12f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland * See the License for the specific language governing permissions and
14f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland * limitations under the License.
15f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland */
16f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
17f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland#ifndef SIMPLE_H
18f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland#define SIMPLE_H
19f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
20f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland#include <stdint.h>
21f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland#include <sys/cdefs.h>
22f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland#include <sys/types.h>
23f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
24f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland#include <cutils/native_handle.h>
25f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
26f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland#include <hardware/hardware.h>
27f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
28f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland__BEGIN_DECLS
29f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
30f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland#define FORGROUND_COLOR "#133742"
31f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland#define ACTOR_COLOR "#424242"
32f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
33f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland/* Simple example */
34f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Morelandtypedef struct simple_t {
35f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    /**
36f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland     * Common methods of the simple device.
37f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland     */
38f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    struct hw_device_t common;
39f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
40f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    /* resolution of the framebuffer's display panel in pixel per inch*/
41f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    const float     xdpi;
42f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    const float     ydpi;
43f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
44f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    /* framebuffer's display panel refresh rate in frames per second */
45f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    const float     fps;
46f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
47f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    int (*setSwapInterval)(struct simple_t* window,
48f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland            int interval);
49f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
50f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    /*
51f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland     * This hook is OPTIONAL.
52f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland     */
53f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    int (*setUpdateRect)(struct simple_t* window,
54f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland            int left, int top, int width, int height);
55f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
56f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland} simple_t;
57f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
58f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland/* Holds pixel coordinates */
59f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Morelandtypedef struct {
60f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    int px;
61f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    int py;
62f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
63f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    /*
64f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland     * If non NULL it will be caused by SurfaceFlinger on dumpsys
65f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland     */
667d4d45bb0f12c1a50a1084e9b0844d9de7a65548Steven Moreland    void (*doDump)(int foo, char *buff, int buff_len);
67f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
68f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland} simple_location_t;
69f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
70f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland/** convenience API for coloring */
71f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
72f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Morelandstatic inline int showColor(const struct hw_module_t* module,
73f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland        struct simple_t** device) {
74f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    return module->methods->open(module,
75f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland            FORGROUND_COLOR, (struct simple_t**)device);
76f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland}
77f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
78f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Morelandstatic inline int hideColor(struct simple_t* device) {
79f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland    return device->common.close(&device->common);
80f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland}
81f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
82f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland__END_DECLS
83f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland
84f1a35f7d73f38e0d30d7a4343e33c3f4777cf87eSteven Moreland#endif  // SIMPLE_H
85