• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2011 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sublicense, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial
14  * portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24  */
25 
26 #include <stdint.h>
27 #include <inttypes.h>
28 
29 #include "config.h"
30 
31 #include <libweston/libweston.h>
32 #include "shared/timespec-util.h"
33 
34 WL_EXPORT void
weston_view_geometry_dirty(struct weston_view * view)35 weston_view_geometry_dirty(struct weston_view *view)
36 {
37 }
38 
39 WL_EXPORT int
weston_log(const char * fmt,...)40 weston_log(const char *fmt, ...)
41 {
42 	return 0;
43 }
44 
45 WL_EXPORT void
weston_view_schedule_repaint(struct weston_view * view)46 weston_view_schedule_repaint(struct weston_view *view)
47 {
48 }
49 
50 WL_EXPORT void
weston_compositor_schedule_repaint(struct weston_compositor * compositor)51 weston_compositor_schedule_repaint(struct weston_compositor *compositor)
52 {
53 }
54 
55 int
main(int argc,char * argv[])56 main(int argc, char *argv[])
57 {
58 	const double k = 300.0;
59 	const double current = 0.5;
60 	const double target = 1.0;
61 	const double friction = 1400;
62 
63 	struct weston_spring spring;
64 	struct timespec time = { 0 };
65 
66 	weston_spring_init(&spring, k, current, target);
67 	spring.friction = friction;
68 	spring.previous = 0.48;
69 	spring.timestamp = (struct timespec) { 0 };
70 
71 	while (!weston_spring_done(&spring)) {
72 		printf("\t%" PRId64 "\t%f\n",
73 		       timespec_to_msec(&time), spring.current);
74 		weston_spring_update(&spring, &time);
75 		timespec_add_msec(&time, &time, 16);
76 	}
77 
78 	return 0;
79 }
80