tizen beta release
[profile/ivi/webkit-efl.git] / Source / WebKit / efl / ewk / ewk_tiled_backing_store.h
1 /*
2     Copyright (C) 2009-2010 Samsung Electronics
3     Copyright (C) 2009-2010 ProFUSION embedded systems
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Library General Public
7     License as published by the Free Software Foundation; either
8     version 2 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Library General Public License for more details.
14
15     You should have received a copy of the GNU Library General Public License
16     along with this library; see the file COPYING.LIB.  If not, write to
17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18     Boston, MA 02110-1301, USA.
19 */
20
21 #ifndef ewk_tiled_backing_store_h
22 #define ewk_tiled_backing_store_h
23
24 #include "EWebKit.h"
25
26 /* Enable accounting of render time in tile statistics */
27 // #define TILE_STATS_ACCOUNT_RENDER_TIME
28
29
30 /* If define ewk will do more accounting to check for memory leaks
31  * try "kill -USR1 $PID" to get instantaneous debug
32  * try "kill -USR2 $PID" to get instantaneous debug and force flush of cache
33  */
34 #undef DEBUG_MEM_LEAKS
35
36 #if ENABLE(TIZEN_DEFAULT_TILE_SIZE)
37 #define DEFAULT_TILE_W (320)
38 #define DEFAULT_TILE_H (320)
39 #else
40 #define DEFAULT_TILE_W (256)
41 #define DEFAULT_TILE_H (256)
42 #endif
43
44 #define ZOOM_STEP_MIN (0.01)
45
46 #define TILE_SIZE_AT_ZOOM(SIZE, ZOOM) ((int)roundf((SIZE) * (ZOOM)))
47 #define TILE_ZOOM_AT_SIZE(SIZE, ORIG_TILE) ((float)(SIZE) / (float)(ORIG_TILE))
48 #define ROUNDED_ZOOM(SIZE, ZOOM) ((float)(SIZE) / (float)(((int)roundf((SIZE) / (ZOOM)))))
49
50 #include <Evas.h>
51 #include <cairo.h>
52
53 typedef struct _Ewk_Tile                     Ewk_Tile;
54 typedef struct _Ewk_Tile_Stats               Ewk_Tile_Stats;
55 typedef struct _Ewk_Tile_Matrix              Ewk_Tile_Matrix;
56
57 struct _Ewk_Tile_Stats {
58     double last_used;        /**< time of last use */
59 #ifdef TILE_STATS_ACCOUNT_RENDER_TIME
60     double render_time;      /**< amount of time this tile took to render */
61 #endif
62     unsigned int area;       /**< cache for (w * h) */
63     unsigned int misses;     /**< number of times it became dirty but not
64                               * repainted at all since it was not visible.
65                               */
66     Eina_Bool full_update : 1; /**< tile requires full size update */
67 };
68
69 struct _Ewk_Tile {
70 #if ENABLE(TIZEN_TILE_REUSE_ALREADY_CREATED)
71     Eina_Inlist cache;        /**< cache of unused tiles entries */
72 #endif
73     Eina_Tiler* updates;    /**< updated/dirty areas */
74     Ewk_Tile_Stats stats;       /**< tile usage statistics */
75     unsigned long col, row; /**< tile tile position */
76     Evas_Coord x, y;        /**< tile coordinate position */
77 #if ENABLE(TIZEN_TILE_REUSE_ALREADY_CREATED)
78     Ewk_Tile_Matrix* matrix; /**< the matrix that contains this tile */
79
80     struct {
81         void (*cb)(void* data, Ewk_Tile* t);
82         void* data;
83     } tile_free;
84 #endif
85 #if !ENABLE(TIZEN_CAIRO_USAGE_ON_DEMAND)
86     /* TODO: does it worth to keep those or create on demand? */
87     cairo_surface_t* surface;
88     cairo_t* cairo;
89
90 #endif
91     /** Never ever change those after tile is created (respect const!) */
92     const Evas_Coord width, height;        /**< tile size (see TILE_SIZE_AT_ZOOM()) */
93     const Evas_Colorspace cspace; /**< colorspace */
94     const float zoom;             /**< zoom level contents were rendered at */
95     const size_t bytes;           /**< bytes used in pixels. keep
96                                    * before pixels to guarantee
97                                    * alignement!
98                                    */
99 #if ENABLE(TIZEN_CAIRO_SCALE_PATCH)
100     const Eina_Bool scaled;       /**< contents is being scaled or not when
101                                    * when doing zoom
102                                    */
103 #endif
104     int visible;                  /**< visibility counter of this tile */
105     Evas_Object* image;           /**< Evas Image, the tile to be rendered */
106     uint8_t* pixels;
107 #if ENABLE(TIZEN_TILE_REUSE_ALREADY_CREATED)
108     Eina_Bool empty;              /**< is there something on the image? */
109 #endif
110 #if ENABLE(TIZEN_TILE_ADD_PAINTED_STATE)
111     Eina_Bool painted:1;          /**< painted */
112 #endif
113 };
114
115 #include "ewk_tiled_matrix.h"
116 #include "ewk_tiled_model.h"
117
118 /* view */
119 Evas_Object* ewk_tiled_backing_store_add(Evas* e);
120
121 void ewk_tiled_backing_store_render_cb_set(Evas_Object *o, Eina_Bool (*cb)(void* data, Ewk_Tile* t, const Eina_Rectangle* area), const void* data);
122
123 Eina_Bool ewk_tiled_backing_store_scroll_full_offset_set(Evas_Object* o, Evas_Coord x, Evas_Coord y);
124 Eina_Bool ewk_tiled_backing_store_scroll_full_offset_add(Evas_Object* o, Evas_Coord dx, Evas_Coord dy);
125 Eina_Bool ewk_tiled_backing_store_scroll_inner_offset_add(Evas_Object* o, Evas_Coord dx, Evas_Coord dy, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
126
127 Eina_Bool ewk_tiled_backing_store_zoom_set(Evas_Object* o, float* zoom, Evas_Coord cx, Evas_Coord cy, Evas_Coord* offx, Evas_Coord* offy);
128 void ewk_tiled_backing_store_fix_offsets(Evas_Object* o, Evas_Coord w, Evas_Coord h);
129 void ewk_tiled_backing_store_bg_color_set(Evas_Object* o, Eina_Bool has_alpha);
130 Eina_Bool ewk_tiled_backing_store_update(Evas_Object* o, const Eina_Rectangle* update);
131 void ewk_tiled_backing_store_updates_process_pre_set(Evas_Object* o, void*(*cb)(void* data, Evas_Object *o), const void* data);
132 void ewk_tiled_backing_store_updates_process_post_set(Evas_Object* o, void*(*cb)(void* data, void* pre_data, Evas_Object *o), const void* data);
133 void ewk_tiled_backing_store_updates_process(Evas_Object* o);
134 void ewk_tiled_backing_store_updates_clear(Evas_Object* o);
135 void ewk_tiled_backing_store_contents_resize(Evas_Object* o, Evas_Coord width, Evas_Coord height);
136 void ewk_tiled_backing_store_disabled_update_set(Evas_Object* o, Eina_Bool value);
137 #if ENABLE(TIZEN_FIX_RSS_IMAGE_DISPLAY)
138 Eina_Bool ewk_tiled_backing_store_disabled_update_get(Evas_Object* o);
139 #endif
140 void ewk_tiled_backing_store_flush(Evas_Object* o);
141 void ewk_tiled_backing_store_enable_scale_set(Evas_Object* o, Eina_Bool value);
142
143 Ewk_Tile_Unused_Cache* ewk_tiled_backing_store_tile_unused_cache_get(const Evas_Object* o);
144 void ewk_tiled_backing_store_tile_unused_cache_set(Evas_Object* o, Ewk_Tile_Unused_Cache* tuc);
145
146 Eina_Bool ewk_tiled_backing_store_pre_render_region(Evas_Object* o, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, float zoom);
147 Eina_Bool ewk_tiled_backing_store_pre_render_relative_radius(Evas_Object* o, unsigned int n, float zoom);
148 Eina_Bool ewk_tiled_backing_store_pre_render_spiral_queue(Evas_Object* o, Eina_Rectangle* view_rect, Eina_Rectangle* render_rect, int max_memory, float zoom);
149 void ewk_tiled_backing_store_pre_render_cancel(Evas_Object* o);
150
151 Eina_Bool ewk_tiled_backing_store_disable_render(Evas_Object *o);
152 Eina_Bool ewk_tiled_backing_store_enable_render(Evas_Object *o);
153 Eina_Bool ewk_tiled_backing_store_active_set(Evas_Object *o, Eina_Bool value);
154 #if ENABLE(TIZEN_FIX_RSS_IMAGE_DISPLAY)
155 void ewk_tiled_backing_store_zoom_changed_set(Evas_Object* o, Eina_Bool value);
156 Eina_Bool ewk_tiled_backing_store_zoom_changed_get(Evas_Object* o);
157 #endif
158
159 #if ENABLE(TIZEN_SELECTIVE_RENDERING)
160 Eina_Bool ewk_tiled_backing_store_selective_rendering_set(Evas_Object* o, Eina_Bool value);
161 Eina_Bool ewk_tiled_backing_store_selective_rendering_is_enabled(Evas_Object* o);
162 #endif
163
164 #if ENABLE(TIZEN_TILE_SIZE_SET)
165 void ewk_tiled_backing_store_tile_size_get(const Evas_Object *o, Evas_Coord *tw, Evas_Coord *th);
166 Eina_Bool ewk_tiled_backing_store_tile_size_set(Evas_Object *o, Evas_Coord tw, Evas_Coord th);
167 #endif
168
169 #endif // ewk_tiled_backing_store_h