Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Unified Diff: gpu/ipc/service/direct_composition_surface_win.cc

Issue 2852953003: Use real colorspace for DirectComposition overlays.
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/ipc/service/direct_composition_surface_win.cc
diff --git a/gpu/ipc/service/direct_composition_surface_win.cc b/gpu/ipc/service/direct_composition_surface_win.cc
index 13b9a03827f0dc2a9d3f3abe14bd63308f045b15..160e2233adac41e9352a80467c186b0ab9289395 100644
--- a/gpu/ipc/service/direct_composition_surface_win.cc
+++ b/gpu/ipc/service/direct_composition_surface_win.cc
@@ -554,8 +554,7 @@ void DCLayerTree::SwapChainPresenter::PresentToSwapChain(
CHECK(SUCCEEDED(hr));
}
- // TODO(jbauman): Use correct colorspace.
- gfx::ColorSpace src_color_space = gfx::ColorSpace::CreateREC709();
+ gfx::ColorSpace src_color_space = params.color_space;
base::win::ScopedComPtr<ID3D11VideoContext1> context1;
if (SUCCEEDED(video_context_.CopyTo(context1.GetAddressOf()))) {
context1->VideoProcessorSetStreamColorSpace1(
@@ -581,16 +580,46 @@ void DCLayerTree::SwapChainPresenter::PresentToSwapChain(
if (SUCCEEDED(swap_chain_.CopyTo(swap_chain3.GetAddressOf()))) {
DXGI_COLOR_SPACE_TYPE color_space =
gfx::ColorSpaceWin::GetDXGIColorSpace(output_color_space);
+ if (is_yuy2_swapchain_) {
+ // Swapchains with YUY2 textures can't have RGB color spaces.
+ switch (color_space) {
+ case DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709:
+ case DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709:
+ color_space = DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P709;
+ break;
+
+ case DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P709:
+ color_space = DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709;
+ break;
+
+ case DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P2020:
+ color_space = DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020;
+ break;
+
+ case DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020:
+ case DXGI_COLOR_SPACE_RGB_STUDIO_G2084_NONE_P2020:
+ color_space = DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_LEFT_P2020;
+ break;
+
+ case DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020:
+ color_space = DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020;
+ break;
+
+ default:
+ break;
+ }
+ }
HRESULT hr = swap_chain3->SetColorSpace1(color_space);
- CHECK(SUCCEEDED(hr));
- if (context1) {
- context1->VideoProcessorSetOutputColorSpace1(video_processor_.Get(),
- color_space);
- } else {
- D3D11_VIDEO_PROCESSOR_COLOR_SPACE d3d11_color_space =
- gfx::ColorSpaceWin::GetD3D11ColorSpace(output_color_space);
- video_context_->VideoProcessorSetOutputColorSpace(video_processor_.Get(),
- &d3d11_color_space);
+ if (SUCCEEDED(hr)) {
+ if (context1) {
+ context1->VideoProcessorSetOutputColorSpace1(video_processor_.Get(),
+ color_space);
+ } else {
+ D3D11_VIDEO_PROCESSOR_COLOR_SPACE d3d11_color_space =
+ gfx::ColorSpaceWin::GetD3D11ColorSpace(output_color_space);
+ video_context_->VideoProcessorSetOutputColorSpace(
+ video_processor_.Get(), &d3d11_color_space);
+ }
}
}
@@ -892,7 +921,7 @@ bool DCLayerTree::CommitAndClearPendingOverlays() {
false, gfx::Rect(), 0, gfx::Transform(),
std::vector<scoped_refptr<gl::GLImage>>(),
gfx::RectF(gfx::SizeF(surface_size)), gfx::Rect(surface_size), 0, 0, 1.0,
- 0));
+ 0, gfx::ColorSpace()));
// TODO(jbauman): Reuse swapchains that are switched between overlays and
// underlays.

Powered by Google App Engine
This is Rietveld 408576698