Skip to content

Commit a39408d

Browse files
committed
display_gl_get_property: reformat
- reindent - DISPLAY_PROPERTY_CODECS - early return if low size - return in the individual switch cases immediately than later
1 parent 0074f52 commit a39408d

File tree

1 file changed

+43
-36
lines changed

1 file changed

+43
-36
lines changed

src/video_display/gl.cpp

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,50 +1896,57 @@ display_gl_get_property(void *state, int property, void *val, size_t *len)
18961896
int rgb_shift[] = {0, 8, 16};
18971897

18981898
switch (property) {
1899-
case DISPLAY_PROPERTY_CODECS:
1900-
if (sizeof gl_supp_codecs <= *len) {
1901-
auto filter_codecs = [s](codec_t c) {
1902-
if (get_bits_per_component(c) > 8 && commandline_params.find(GL_DISABLE_10B_OPT_PARAM_NAME) != commandline_params.end()) { // option to disable 10-bit processing
1903-
return false;
1904-
}
1905-
if (glsl_programs.find(c) != glsl_programs.end() && s->PHandles.find(c) == s->PHandles.end()) { // GLSL shader needed but compilation failed
1906-
return false;
1907-
}
1908-
if (c == HW_VDPAU && !s->vdp_interop) {
1909-
return false;
1910-
}
1911-
return true;
1912-
};
1913-
copy_if(gl_supp_codecs.begin(), gl_supp_codecs.end(), (codec_t *) val, filter_codecs);
1914-
} else {
1899+
case DISPLAY_PROPERTY_CODECS: {
1900+
if (sizeof gl_supp_codecs > *len) {
1901+
return false;
1902+
}
1903+
auto filter_codecs = [s](codec_t c) {
1904+
if (get_bits_per_component(c) > DEPTH8 &&
1905+
commandline_params.find(
1906+
GL_DISABLE_10B_OPT_PARAM_NAME) !=
1907+
commandline_params.end()) { // option to disable
1908+
// 10-bit processing
19151909
return false;
19161910
}
1917-
1918-
*len = sizeof gl_supp_codecs;
1919-
break;
1920-
case DISPLAY_PROPERTY_RGB_SHIFT:
1921-
if(sizeof(rgb_shift) > *len) {
1911+
if (glsl_programs.find(c) != glsl_programs.end() &&
1912+
s->PHandles.find(c) ==
1913+
s->PHandles.end()) { // GLSL shader needed but
1914+
// compilation failed
19221915
return false;
19231916
}
1924-
memcpy(val, rgb_shift, sizeof(rgb_shift));
1925-
*len = sizeof(rgb_shift);
1926-
break;
1927-
case DISPLAY_PROPERTY_BUF_PITCH:
1928-
*(int *) val = PITCH_DEFAULT;
1929-
*len = sizeof(int);
1930-
break;
1931-
case DISPLAY_PROPERTY_SUPPORTED_IL_MODES:
1932-
if(sizeof(supported_il_modes) <= *len) {
1933-
memcpy(val, supported_il_modes, sizeof(supported_il_modes));
1934-
} else {
1917+
if (c == HW_VDPAU && !s->vdp_interop) {
19351918
return false;
19361919
}
1937-
*len = sizeof(supported_il_modes);
1938-
break;
1939-
default:
1920+
return true;
1921+
};
1922+
copy_if(gl_supp_codecs.begin(), gl_supp_codecs.end(),
1923+
(codec_t *) val, filter_codecs);
1924+
*len = sizeof gl_supp_codecs;
1925+
return true;
1926+
}
1927+
case DISPLAY_PROPERTY_RGB_SHIFT:
1928+
if (sizeof(rgb_shift) > *len) {
1929+
return false;
1930+
}
1931+
memcpy(val, rgb_shift, sizeof(rgb_shift));
1932+
*len = sizeof(rgb_shift);
1933+
return true;
1934+
case DISPLAY_PROPERTY_BUF_PITCH:
1935+
*(int *) val = PITCH_DEFAULT;
1936+
*len = sizeof(int);
1937+
return true;
1938+
case DISPLAY_PROPERTY_SUPPORTED_IL_MODES:
1939+
if (sizeof(supported_il_modes) <= *len) {
1940+
memcpy(val, supported_il_modes,
1941+
sizeof(supported_il_modes));
1942+
} else {
19401943
return false;
1944+
}
1945+
*len = sizeof(supported_il_modes);
1946+
return true;
1947+
default:
1948+
return false;
19411949
}
1942-
return true;
19431950
}
19441951

19451952
static void display_gl_done(void *state)

0 commit comments

Comments
 (0)