OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/ipc/service/direct_composition_surface_win.h" | 5 #include "gpu/ipc/service/direct_composition_surface_win.h" |
6 | 6 |
7 #include "base/optional.h" | 7 #include "base/optional.h" |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "gpu/ipc/service/gpu_channel_manager.h" | 9 #include "gpu/ipc/service/gpu_channel_manager.h" |
10 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" | 10 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
11 #include "gpu/ipc/service/switches.h" | 11 #include "gpu/ipc/service/switches.h" |
| 12 #include "ui/base/ui_base_switches.h" |
12 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
13 #include "ui/gl/egl_util.h" | 14 #include "ui/gl/egl_util.h" |
14 #include "ui/gl/gl_angle_util_win.h" | 15 #include "ui/gl/gl_angle_util_win.h" |
15 #include "ui/gl/gl_context.h" | 16 #include "ui/gl/gl_context.h" |
16 #include "ui/gl/gl_surface_egl.h" | 17 #include "ui/gl/gl_surface_egl.h" |
17 #include "ui/gl/scoped_make_current.h" | 18 #include "ui/gl/scoped_make_current.h" |
18 | 19 |
19 #ifndef EGL_ANGLE_flexible_surface_compatibility | 20 #ifndef EGL_ANGLE_flexible_surface_compatibility |
20 #define EGL_ANGLE_flexible_surface_compatibility 1 | 21 #define EGL_ANGLE_flexible_surface_compatibility 1 |
21 #define EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE 0x33A6 | 22 #define EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE 0x33A6 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 161 |
161 void DirectCompositionSurfaceWin::ReleaseCurrentSurface() { | 162 void DirectCompositionSurfaceWin::ReleaseCurrentSurface() { |
162 ReleaseDrawTexture(true); | 163 ReleaseDrawTexture(true); |
163 dcomp_surface_.Release(); | 164 dcomp_surface_.Release(); |
164 swap_chain_.Release(); | 165 swap_chain_.Release(); |
165 } | 166 } |
166 | 167 |
167 void DirectCompositionSurfaceWin::InitializeSurface() { | 168 void DirectCompositionSurfaceWin::InitializeSurface() { |
168 DCHECK(!dcomp_surface_); | 169 DCHECK(!dcomp_surface_); |
169 DCHECK(!swap_chain_); | 170 DCHECK(!swap_chain_); |
| 171 DXGI_FORMAT output_format = |
| 172 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHDR) |
| 173 ? DXGI_FORMAT_R16G16B16A16_FLOAT |
| 174 : DXGI_FORMAT_B8G8R8A8_UNORM; |
170 if (enable_dc_layers_) { | 175 if (enable_dc_layers_) { |
171 HRESULT hr = dcomp_device_->CreateSurface( | 176 HRESULT hr = dcomp_device_->CreateSurface( |
172 size_.width(), size_.height(), DXGI_FORMAT_B8G8R8A8_UNORM, | 177 size_.width(), size_.height(), output_format, |
173 DXGI_ALPHA_MODE_PREMULTIPLIED, dcomp_surface_.Receive()); | 178 DXGI_ALPHA_MODE_PREMULTIPLIED, dcomp_surface_.Receive()); |
174 has_been_rendered_to_ = false; | 179 has_been_rendered_to_ = false; |
175 CHECK(SUCCEEDED(hr)); | 180 CHECK(SUCCEEDED(hr)); |
176 } else { | 181 } else { |
177 base::win::ScopedComPtr<IDXGIDevice> dxgi_device; | 182 base::win::ScopedComPtr<IDXGIDevice> dxgi_device; |
178 d3d11_device_.QueryInterface(dxgi_device.Receive()); | 183 d3d11_device_.QueryInterface(dxgi_device.Receive()); |
179 base::win::ScopedComPtr<IDXGIAdapter> dxgi_adapter; | 184 base::win::ScopedComPtr<IDXGIAdapter> dxgi_adapter; |
180 dxgi_device->GetAdapter(dxgi_adapter.Receive()); | 185 dxgi_device->GetAdapter(dxgi_adapter.Receive()); |
181 base::win::ScopedComPtr<IDXGIFactory2> dxgi_factory; | 186 base::win::ScopedComPtr<IDXGIFactory2> dxgi_factory; |
182 dxgi_adapter->GetParent(IID_PPV_ARGS(dxgi_factory.Receive())); | 187 dxgi_adapter->GetParent(IID_PPV_ARGS(dxgi_factory.Receive())); |
183 | 188 |
184 DXGI_SWAP_CHAIN_DESC1 desc = {}; | 189 DXGI_SWAP_CHAIN_DESC1 desc = {}; |
185 desc.Width = size_.width(); | 190 desc.Width = size_.width(); |
186 desc.Height = size_.height(); | 191 desc.Height = size_.height(); |
187 desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; | 192 desc.Format = output_format; |
188 desc.Stereo = FALSE; | 193 desc.Stereo = FALSE; |
189 desc.SampleDesc.Count = 1; | 194 desc.SampleDesc.Count = 1; |
190 desc.BufferCount = 2; | 195 desc.BufferCount = 2; |
191 desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; | 196 desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; |
192 desc.Scaling = DXGI_SCALING_STRETCH; | 197 desc.Scaling = DXGI_SCALING_STRETCH; |
193 desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; | 198 desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; |
194 desc.AlphaMode = DXGI_ALPHA_MODE_PREMULTIPLIED; | 199 desc.AlphaMode = DXGI_ALPHA_MODE_PREMULTIPLIED; |
195 desc.Flags = 0; | 200 desc.Flags = 0; |
196 HRESULT hr = dxgi_factory->CreateSwapChainForComposition( | 201 HRESULT hr = dxgi_factory->CreateSwapChainForComposition( |
197 d3d11_device_.get(), &desc, nullptr, swap_chain_.Receive()); | 202 d3d11_device_.get(), &desc, nullptr, swap_chain_.Receive()); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 transform(transform), | 455 transform(transform), |
451 image(image), | 456 image(image), |
452 bounds_rect(bounds_rect), | 457 bounds_rect(bounds_rect), |
453 crop_rect(crop_rect) {} | 458 crop_rect(crop_rect) {} |
454 | 459 |
455 DirectCompositionSurfaceWin::Overlay::Overlay(const Overlay& overlay) = default; | 460 DirectCompositionSurfaceWin::Overlay::Overlay(const Overlay& overlay) = default; |
456 | 461 |
457 DirectCompositionSurfaceWin::Overlay::~Overlay() {} | 462 DirectCompositionSurfaceWin::Overlay::~Overlay() {} |
458 | 463 |
459 } // namespace gpu | 464 } // namespace gpu |
OLD | NEW |