Renaming setting

This commit is contained in:
Thorsten Ball
2024-07-18 16:08:23 +02:00
parent c68c8928c2
commit aef9751e05
5 changed files with 20 additions and 20 deletions

View File

@@ -254,7 +254,7 @@ pub enum Decorations {
/// A type to describe which GPU to prefer.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Default)]
pub enum GPU {
pub enum Gpu {
/// The window is rendered using the integrated (lower-power) GPU
#[default]
Integrated,
@@ -692,7 +692,7 @@ pub struct WindowOptions {
/// Whether to prefer one GPU over another. macOS only
/// Note that this may be ignored.
pub gpu: Option<GPU>,
pub gpu: Option<Gpu>,
}
/// The variables that can be configured when creating a new window
@@ -725,7 +725,7 @@ pub(crate) struct WindowParams {
/// Whether to prefer one GPU over another. macOS only
/// Note that this may be ignored.
#[cfg_attr(target_os = "linux", allow(dead_code))]
pub gpu: Option<GPU>,
pub gpu: Option<Gpu>,
}
/// Represents the status of how a window should be opened.

View File

@@ -32,7 +32,7 @@ pub unsafe fn new_renderer(
native_view: *mut c_void,
bounds: crate::Size<f32>,
transparent: bool,
_gpu: Option<GPUPreference>,
_gpu: Option<Gpu>,
) -> Renderer {
use raw_window_handle as rwh;
struct RawWindow {

View File

@@ -1,8 +1,8 @@
use super::metal_atlas::MetalAtlas;
use crate::{
point, size, AtlasTextureId, AtlasTextureKind, AtlasTile, Bounds, ContentMask, DevicePixels,
Hsla, MonochromeSprite, Path, PathId, PathVertex, PolychromeSprite, PrimitiveBatch, Quad,
ScaledPixels, Scene, Shadow, Size, Surface, Underline, GPU,
Gpu, Hsla, MonochromeSprite, Path, PathId, PathVertex, PolychromeSprite, PrimitiveBatch, Quad,
ScaledPixels, Scene, Shadow, Size, Surface, Underline,
};
use anyhow::{anyhow, Result};
use block::ConcreteBlock;
@@ -38,7 +38,7 @@ pub unsafe fn new_renderer(
_native_view: *mut c_void,
_bounds: crate::Size<f32>,
_transparent: bool,
gpu: Option<GPU>,
gpu: Option<Gpu>,
) -> Renderer {
MetalRenderer::new(context, gpu)
}
@@ -109,9 +109,9 @@ pub(crate) struct MetalRenderer {
}
impl MetalRenderer {
pub fn new(instance_buffer_pool: Arc<Mutex<InstanceBufferPool>>, gpu: Option<GPU>) -> Self {
pub fn new(instance_buffer_pool: Arc<Mutex<InstanceBufferPool>>, gpu: Option<Gpu>) -> Self {
let device = match gpu {
Some(GPU::Discrete) => metal::Device::system_default(),
Some(Gpu::Discrete) => metal::Device::system_default(),
_ => {
// By default, prefer lowpower integrated GPUs on Intel Mac. On Apple
// Silicon, there is only ever one GPU, so this is equivalent to

View File

@@ -12,7 +12,7 @@ use breadcrumbs::Breadcrumbs;
use client::ZED_URL_SCHEME;
use collections::VecDeque;
use editor::{scroll::Autoscroll, Editor, MultiBuffer};
use gpu::GPUSettings;
use gpu::GpuSettings;
use gpui::{
actions, point, px, AppContext, AsyncAppContext, Context, FocusableView, MenuItem, PromptLevel,
ReadGlobal, TitlebarOptions, View, ViewContext, VisualContext, WindowKind, WindowOptions,
@@ -80,7 +80,7 @@ pub fn init(cx: &mut AppContext) {
cx.on_action(|_: &ShowAll, cx| cx.unhide_other_apps());
cx.on_action(quit);
GPUSettings::register(cx);
GpuSettings::register(cx);
if ReleaseChannel::global(cx) == ReleaseChannel::Dev {
cx.on_action(test_panic);
}
@@ -118,7 +118,7 @@ pub fn build_window_options(display_uuid: Option<Uuid>, cx: &mut AppContext) ->
width: px(360.0),
height: px(240.0),
}),
gpu: GPUSettings::get_global(cx).gpu.map(Into::into),
gpu: GpuSettings::get_global(cx).gpu.map(Into::into),
}
}

View File

@@ -4,32 +4,32 @@ use settings::{Settings, SettingsSources};
#[derive(Copy, Clone, Debug, Default, Serialize, PartialEq, Eq, Deserialize, JsonSchema)]
#[serde(rename_all = "lowercase")]
pub enum GPU {
pub enum Gpu {
Discrete,
#[default]
Integrated,
}
impl Into<gpui::GPU> for GPU {
fn into(self) -> gpui::GPU {
impl Into<gpui::Gpu> for Gpu {
fn into(self) -> gpui::Gpu {
match self {
GPU::Discrete => gpui::GPU::Discrete,
GPU::Integrated => gpui::GPU::Integrated,
Gpu::Discrete => gpui::Gpu::Discrete,
Gpu::Integrated => gpui::Gpu::Integrated,
}
}
}
/// Settings related to the machine's GPU and how Zed uses it.
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq, Default)]
pub struct GPUSettings {
pub struct GpuSettings {
/// Which GPU to prefer: discrete or integrated.
/// Integrated are often lower-power and thus more battery-efficient.
///
/// Default: 0.2
pub gpu: Option<GPU>,
pub gpu: Option<Gpu>,
}
impl Settings for GPUSettings {
impl Settings for GpuSettings {
const KEY: Option<&'static str> = None;
type FileContent = Option<Self>;