Skip to content

Commit

Permalink
Added Automatic Color Buffer Accuracy selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Apr 27, 2024
1 parent d1e4902 commit 2cc2b36
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
4 changes: 1 addition & 3 deletions mrv2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ if(FLTK_BUILD_SHARED_LIBS)
set(FLTK_LIBRARIES fltk::fltk-shared )
set(FLTK_gl_LIBRARY )
else()
# fltk::images must *NOT* be shared or jpeg library enters in conflict
# with tlRender's libjpeg-turbo.
set(FLTK_LIBRARIES fltk::fltk-shared fltk::images )
set(FLTK_LIBRARIES fltk::fltk-shared fltk::images-shared )
set(FLTK_gl_LIBRARY fltk::gl-shared)
endif()
else()
Expand Down
5 changes: 3 additions & 2 deletions mrv2/lib/mrvFl/mrvPreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ namespace mrv
opengl.get("vsync", tmp, 1);
uiPrefs->uiPrefsOpenGLVsync->value(tmp);

opengl.get("color_accuracy", tmp, 1);
opengl.get("color_buffers_accuracy", tmp, 0);
uiPrefs->uiPrefsColorAccuracy->value(tmp);

opengl.get("blit_viewports", tmp, 1);
Expand Down Expand Up @@ -1413,7 +1413,8 @@ namespace mrv
Fl_Preferences opengl(base, "opengl");
opengl.set("vsync", (int)uiPrefs->uiPrefsOpenGLVsync->value());
opengl.set(
"color_accuracy", (int)uiPrefs->uiPrefsColorAccuracy->value());
"color_buffers_accuracy",
(int)uiPrefs->uiPrefsColorAccuracy->value());
opengl.set(
"blit_viewports", (int)uiPrefs->uiPrefsBlitViewports->value());
opengl.set("blit_timeline", (int)uiPrefs->uiPrefsBlitTimeline->value());
Expand Down
30 changes: 28 additions & 2 deletions mrv2/lib/mrvGL/mrvGLViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,35 @@ namespace mrv
{
if (renderSize.isValid())
{
bool isFloatImage = p.ocioOptions.enabled;
int accuracy = p.ui->uiPrefs->uiPrefsColorAccuracy->value();
if (accuracy == 0)
isFloatImage = true;

if (accuracy == 2 && !p.videoData[0].layers.empty() &&
p.videoData[0].layers[0].image->isValid())
{
const auto& pixelType =
p.videoData[0].layers[0].image->getPixelType();
switch (pixelType)
{
case image::PixelType::RGBA_F32:
case image::PixelType::RGB_F32:
case image::PixelType::RGBA_F16:
case image::PixelType::RGB_F16:
case image::PixelType::L_F32:
case image::PixelType::LA_F32:
case image::PixelType::L_F16:
case image::PixelType::LA_F16:
isFloatImage = true;
break;
default:
break;
}
}

image::PixelType colorBufferType = image::PixelType::RGBA_U8;
if ((p.ui->uiPrefs->uiPrefsColorAccuracy->value() == 0) ||
p.ocioOptions.enabled == true)
if (isFloatImage)
colorBufferType = image::PixelType::RGBA_F32;

if (gl.colorBufferType != colorBufferType)
Expand Down
8 changes: 6 additions & 2 deletions mrv2/lib/mrvWidgets/mrvPreferencesUI.fl
Original file line number Diff line number Diff line change
Expand Up @@ -1374,13 +1374,17 @@ v->uiOCIO_Look->do_callback();}
}
Fl_Choice uiPrefsColorAccuracy {
label {Color Buffers' Accuracy} open selected
tooltip {Color Buffers can be accurate or fast. Accurate preserves all float information, while Fast works in 8-bits.} xywh {473 163 255 25} down_box BORDER_BOX align 132 textcolor 32
tooltip {Color Buffers can be Accurate, Fast or Automatic. Accurate preserves all float information, while Fast works in 8-bits. Automatic selects the accuracy baed on image depth and OCIO use.} xywh {473 163 255 25} down_box BORDER_BOX align 132 textcolor 32
class {mrv::Choice}
} {
MenuItem {} {
label Accurate
label Automatic
xywh {50 50 100 20}
}
MenuItem {} {
label Accurate
xywh {60 60 100 20}
}
MenuItem {} {
label Fast
xywh {50 50 100 20}
Expand Down

0 comments on commit 2cc2b36

Please sign in to comment.