1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use crate::{gpu::DriverBugWorkarounds, prelude::*};
use skia_bindings::{self as sb, GrContextOptions};
use std::os::raw;

pub use skia_bindings::GrContextOptions_Enable as Enable;
variant_name!(Enable::Yes);
pub use skia_bindings::GrContextOptions_ShaderCacheStrategy as ShaderCacheStrategy;
variant_name!(ShaderCacheStrategy::BackendSource);

#[repr(C)]
#[derive(Debug)]
pub struct ContextOptions {
    pub suppress_prints: bool,
    pub skip_gl_error_checks: Enable,
    pub max_texture_size_override: raw::c_int,
    pub buffer_map_threshold: raw::c_int,
    executor: *mut sb::SkExecutor,
    pub do_manual_mipmapping: bool,
    pub disable_coverage_counting_paths: bool,
    pub disable_distance_field_paths: bool,
    pub allow_path_mask_caching: bool,
    pub disable_gpu_yuv_conversion: bool,
    pub glyph_cache_texture_maximum_bytes: usize,
    pub min_distance_field_font_size: f32,
    pub glyphs_as_paths_font_size: f32,
    pub allow_multiple_glyph_cache_textures: Enable,
    pub avoid_stencil_buffers: bool,
    pub use_draw_instead_of_clear: Enable,
    pub reduce_ops_task_splitting: Enable,
    pub prefer_external_images_over_es3: bool,
    pub disable_driver_correctness_workarounds: bool,
    pub runtime_program_cache_size: raw::c_int,
    persistent_cache: *mut sb::GrContextOptions_PersistentCache,
    pub shader_cache_strategy: ShaderCacheStrategy,
    shader_error_handler: *mut sb::GrContextOptions_ShaderErrorHandler,
    pub internal_multisample_count: raw::c_int,
    pub max_cached_vulkan_secondary_command_buffers: raw::c_int,
    pub suppress_mipmap_support: bool,
    pub enable_experimental_hardware_tessellation: bool,
    pub reduced_shader_variations: bool,
    pub allow_msaa_on_new_intel: bool,
    pub always_use_text_storage_when_available: bool,
    context_delete_context: sb::GrDirectContextDestroyedContext,
    context_delete_proc: sb::GrDirectContextDestroyedProc,
    pub driver_bug_workarounds: DriverBugWorkarounds,
}
unsafe_send_sync!(ContextOptions);

impl Default for ContextOptions {
    fn default() -> Self {
        Self::construct(|ptr| unsafe { sb::C_GrContextOptions_Construct(ptr) })
    }
}

impl ContextOptions {
    pub fn new() -> Self {
        Self::default()
    }
}

native_transmutable!(GrContextOptions, ContextOptions, context_options_layout);

// TODO: PersistentCache, ShaderErrorHandler