webrender_ffi.h (4686B)
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/. */ 6 7 #ifndef WR_h 8 #define WR_h 9 10 #include "mozilla/gfx/Types.h" 11 #include "nsTArray.h" 12 13 extern "C" { 14 15 // ---- 16 // Functions invoked from Rust code 17 // ---- 18 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 33 bool gecko_profiler_thread_is_being_profiled(); 34 35 // IMPORTANT: Keep this synchronized with enumerate_interners in 36 // gfx/wr/webrender_api 37 #define WEBRENDER_FOR_EACH_INTERNER(macro, comma_like_delim) \ 38 macro(clip) comma_like_delim macro(prim) \ 39 comma_like_delim macro(normal_border) \ 40 comma_like_delim macro(image_border) \ 41 comma_like_delim macro(image) \ 42 comma_like_delim macro(yuv_image) \ 43 comma_like_delim macro(line_decoration) \ 44 comma_like_delim macro(linear_grad) \ 45 comma_like_delim macro(radial_grad) \ 46 comma_like_delim macro(conic_grad) \ 47 comma_like_delim macro(picture) \ 48 comma_like_delim macro(text_run) \ 49 comma_like_delim macro(filterdata) \ 50 comma_like_delim macro(backdrop_capture) \ 51 comma_like_delim macro(backdrop_render) \ 52 comma_like_delim macro(polyon) \ 53 comma_like_delim macro(box_shadow) 54 55 // Prelude of types necessary before including webrender_ffi_generated.h 56 namespace mozilla { 57 namespace wr { 58 59 // Because this struct is macro-generated on the Rust side, cbindgen can't see 60 // it. Work around that by re-declaring it here. 61 #define DECLARE_MEMBER(id) uintptr_t id; 62 struct InternerSubReport { 63 WEBRENDER_FOR_EACH_INTERNER(DECLARE_MEMBER, ) 64 }; 65 66 #undef DECLARE_MEMBER 67 68 struct Transaction; 69 struct WrWindowId; 70 struct DocumentId; 71 struct WrPipelineInfo; 72 73 struct WrPipelineIdAndEpoch; 74 using WrPipelineIdEpochs = nsTArray<WrPipelineIdAndEpoch>; 75 76 } // namespace wr 77 } // namespace mozilla 78 79 void apz_register_updater(mozilla::wr::WrWindowId aWindowId); 80 void apz_pre_scene_swap(mozilla::wr::WrWindowId aWindowId); 81 void apz_post_scene_swap(mozilla::wr::WrWindowId aWindowId, 82 const mozilla::wr::WrPipelineInfo* aInfo); 83 void apz_run_updater(mozilla::wr::WrWindowId aWindowId); 84 void apz_deregister_updater(mozilla::wr::WrWindowId aWindowId); 85 86 void apz_register_sampler(mozilla::wr::WrWindowId aWindowId); 87 void apz_sample_transforms(mozilla::wr::WrWindowId aWindowId, 88 const uint64_t* aGeneratedFrameId, 89 mozilla::wr::Transaction* aTransaction); 90 void apz_deregister_sampler(mozilla::wr::WrWindowId aWindowId); 91 92 void omta_register_sampler(mozilla::wr::WrWindowId aWindowId); 93 void omta_sample(mozilla::wr::WrWindowId aWindowId, 94 mozilla::wr::Transaction* aTransaction); 95 void omta_deregister_sampler(mozilla::wr::WrWindowId aWindowId); 96 } // extern "C" 97 98 // Work-around Solaris define which conflcits with WR color constant, see 99 // bug 1773491. 100 #pragma push_macro("TRANSPARENT") 101 #undef TRANSPARENT 102 103 #include "webrender_ffi_generated.h" 104 105 #pragma pop_macro("TRANSPARENT") 106 107 template struct mozilla::wr::Point2D<int32_t, mozilla::wr::DevicePixel>; 108 template struct mozilla::wr::Point2D<int, mozilla::wr::WorldPixel>; 109 template struct mozilla::wr::Point2D<float, mozilla::wr::WorldPixel>; 110 template struct mozilla::wr::Box2D<int32_t, mozilla::wr::DevicePixel>; 111 template struct mozilla::wr::Box2D<int, mozilla::wr::LayoutPixel>; 112 113 namespace mozilla { 114 namespace wr { 115 116 // Cast a blob image key into a regular image for use in a display item. 117 inline ImageKey AsImageKey(BlobImageKey aKey) { return aKey._0; } 118 // Cast a snapshot image key into a regular image for use in a display item. 119 inline ImageKey AsImageKey(SnapshotImageKey aKey) { return aKey._0; } 120 121 } // namespace wr 122 } // namespace mozilla 123 124 #endif // WR_h