Bug 1706561 Part 5: Intern polygon data for image masks, and retrieve for hit tests...
[gecko.git] / gfx / webrender_bindings / webrender_ffi.h
blob0653e0115a8be4a768c85af9b833c4f3ffdd08c3
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef WR_h
8 #define WR_h
10 #include "mozilla/gfx/Types.h"
11 #include "nsTArray.h"
13 extern "C" {
15 // ----
16 // Functions invoked from Rust code
17 // ----
19 bool is_in_compositor_thread();
20 bool is_in_main_thread();
21 bool is_in_render_thread();
22 bool is_glcontext_gles(void* glcontext_ptr);
23 bool is_glcontext_angle(void* glcontext_ptr);
24 bool gfx_use_wrench();
25 const char* gfx_wr_resource_path_override();
26 bool gfx_wr_use_optimized_shaders();
27 void gfx_critical_note(const char* msg);
28 void gfx_critical_error(const char* msg);
29 void gecko_printf_stderr_output(const char* msg);
30 void* get_proc_address_from_glcontext(void* glcontext_ptr,
31 const char* procname);
32 void gecko_profiler_register_thread(const char* threadname);
33 void gecko_profiler_unregister_thread();
35 void gecko_profiler_start_marker(const char* name);
36 void gecko_profiler_end_marker(const char* name);
37 void gecko_profiler_event_marker(const char* name);
38 void gecko_profiler_add_text_marker(const char* name, const char* text_ptr,
39 size_t text_len, uint64_t microseconds);
40 bool gecko_profiler_thread_is_being_profiled();
42 // IMPORTANT: Keep this synchronized with enumerate_interners in
43 // gfx/wr/webrender_api
44 #define WEBRENDER_FOR_EACH_INTERNER(macro) \
45 macro(clip); \
46 macro(prim); \
47 macro(normal_border); \
48 macro(image_border); \
49 macro(image); \
50 macro(yuv_image); \
51 macro(line_decoration); \
52 macro(linear_grad); \
53 macro(radial_grad); \
54 macro(conic_grad); \
55 macro(picture); \
56 macro(text_run); \
57 macro(filterdata); \
58 macro(backdrop); \
59 macro(polyon);
61 // Prelude of types necessary before including webrender_ffi_generated.h
62 namespace mozilla {
63 namespace wr {
65 // Because this struct is macro-generated on the Rust side, cbindgen can't see
66 // it. Work around that by re-declaring it here.
67 #define DECLARE_MEMBER(id) uintptr_t id;
68 struct InternerSubReport {
69 WEBRENDER_FOR_EACH_INTERNER(DECLARE_MEMBER)
72 #undef DECLARE_MEMBER
74 struct Transaction;
75 struct WrWindowId;
76 struct DocumentId;
77 struct WrPipelineInfo;
79 struct WrPipelineIdAndEpoch;
80 using WrPipelineIdEpochs = nsTArray<WrPipelineIdAndEpoch>;
82 const uint64_t ROOT_CLIP_CHAIN = ~0;
84 } // namespace wr
85 } // namespace mozilla
87 void apz_register_updater(mozilla::wr::WrWindowId aWindowId);
88 void apz_pre_scene_swap(mozilla::wr::WrWindowId aWindowId);
89 void apz_post_scene_swap(mozilla::wr::WrWindowId aWindowId,
90 const mozilla::wr::WrPipelineInfo* aInfo);
91 void apz_run_updater(mozilla::wr::WrWindowId aWindowId);
92 void apz_deregister_updater(mozilla::wr::WrWindowId aWindowId);
94 void apz_register_sampler(mozilla::wr::WrWindowId aWindowId);
95 void apz_sample_transforms(mozilla::wr::WrWindowId aWindowId,
96 const uint64_t* aGeneratedFrameId,
97 mozilla::wr::Transaction* aTransaction);
98 void apz_deregister_sampler(mozilla::wr::WrWindowId aWindowId);
100 void omta_register_sampler(mozilla::wr::WrWindowId aWindowId);
101 void omta_sample(mozilla::wr::WrWindowId aWindowId,
102 mozilla::wr::Transaction* aTransaction);
103 void omta_deregister_sampler(mozilla::wr::WrWindowId aWindowId);
104 } // extern "C"
106 // Work-around wingdi.h define which conflcits with WR color constant
107 #pragma push_macro("TRANSPARENT")
108 #undef TRANSPARENT
110 #include "webrender_ffi_generated.h"
112 #pragma pop_macro("TRANSPARENT")
114 // More functions invoked from Rust code. These are down here because they
115 // refer to data structures from webrender_ffi_generated.h
116 extern "C" {
117 void record_telemetry_time(mozilla::wr::TelemetryProbe aProbe,
118 uint64_t aTimeNs);
121 namespace mozilla {
122 namespace wr {
124 // Cast a blob image key into a regular image for use in
125 // a display item.
126 inline ImageKey AsImageKey(BlobImageKey aKey) { return aKey._0; }
128 } // namespace wr
129 } // namespace mozilla
131 #endif // WR_h