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 <d3d11_1.h> | 7 #include <d3d11_1.h> |
8 #include <dcomptypes.h> | 8 #include <dcomptypes.h> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 return true; | 637 return true; |
638 } | 638 } |
639 | 639 |
640 bool DCLayerTree::ScheduleDCLayer(const ui::DCRendererLayerParams& params) { | 640 bool DCLayerTree::ScheduleDCLayer(const ui::DCRendererLayerParams& params) { |
641 pending_overlays_.push_back( | 641 pending_overlays_.push_back( |
642 base::MakeUnique<ui::DCRendererLayerParams>(params)); | 642 base::MakeUnique<ui::DCRendererLayerParams>(params)); |
643 return true; | 643 return true; |
644 } | 644 } |
645 | 645 |
646 DirectCompositionSurfaceWin::DirectCompositionSurfaceWin( | 646 DirectCompositionSurfaceWin::DirectCompositionSurfaceWin( |
| 647 std::unique_ptr<gfx::VSyncProvider> vsync_provider, |
647 base::WeakPtr<ImageTransportSurfaceDelegate> delegate, | 648 base::WeakPtr<ImageTransportSurfaceDelegate> delegate, |
648 HWND parent_window) | 649 HWND parent_window) |
649 : gl::GLSurfaceEGL(), child_window_(delegate, parent_window) {} | 650 : gl::GLSurfaceEGL(), |
| 651 child_window_(delegate, parent_window), |
| 652 vsync_provider_(std::move(vsync_provider)) {} |
650 | 653 |
651 DirectCompositionSurfaceWin::~DirectCompositionSurfaceWin() { | 654 DirectCompositionSurfaceWin::~DirectCompositionSurfaceWin() { |
652 Destroy(); | 655 Destroy(); |
653 } | 656 } |
654 | 657 |
655 // static | 658 // static |
656 bool DirectCompositionSurfaceWin::AreOverlaysSupported() { | 659 bool DirectCompositionSurfaceWin::AreOverlaysSupported() { |
657 if (!base::FeatureList::IsEnabled(switches::kDirectCompositionOverlays)) | 660 if (!base::FeatureList::IsEnabled(switches::kDirectCompositionOverlays)) |
658 return false; | 661 return false; |
659 | 662 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 | 700 |
698 bool DirectCompositionSurfaceWin::InitializeNativeWindow() { | 701 bool DirectCompositionSurfaceWin::InitializeNativeWindow() { |
699 if (window_) | 702 if (window_) |
700 return true; | 703 return true; |
701 | 704 |
702 bool result = child_window_.Initialize(); | 705 bool result = child_window_.Initialize(); |
703 window_ = child_window_.window(); | 706 window_ = child_window_.window(); |
704 return result; | 707 return result; |
705 } | 708 } |
706 | 709 |
707 bool DirectCompositionSurfaceWin::Initialize( | |
708 std::unique_ptr<gfx::VSyncProvider> vsync_provider) { | |
709 vsync_provider_ = std::move(vsync_provider); | |
710 return Initialize(gl::GLSurfaceFormat()); | |
711 } | |
712 | |
713 bool DirectCompositionSurfaceWin::Initialize(gl::GLSurfaceFormat format) { | 710 bool DirectCompositionSurfaceWin::Initialize(gl::GLSurfaceFormat format) { |
714 d3d11_device_ = gl::QueryD3D11DeviceObjectFromANGLE(); | 711 d3d11_device_ = gl::QueryD3D11DeviceObjectFromANGLE(); |
715 dcomp_device_ = gl::QueryDirectCompositionDevice(d3d11_device_); | 712 dcomp_device_ = gl::QueryDirectCompositionDevice(d3d11_device_); |
716 if (!dcomp_device_) | 713 if (!dcomp_device_) |
717 return false; | 714 return false; |
718 | 715 |
719 EGLDisplay display = GetDisplay(); | 716 EGLDisplay display = GetDisplay(); |
720 if (!window_) { | 717 if (!window_) { |
721 if (!InitializeNativeWindow()) { | 718 if (!InitializeNativeWindow()) { |
722 DLOG(ERROR) << "Failed to initialize native window"; | 719 DLOG(ERROR) << "Failed to initialize native window"; |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { | 1016 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { |
1020 return child_window_.GetTaskRunnerForTesting(); | 1017 return child_window_.GetTaskRunnerForTesting(); |
1021 } | 1018 } |
1022 | 1019 |
1023 base::win::ScopedComPtr<IDXGISwapChain1> | 1020 base::win::ScopedComPtr<IDXGISwapChain1> |
1024 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { | 1021 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { |
1025 return layer_tree_->GetLayerSwapChainForTesting(index); | 1022 return layer_tree_->GetLayerSwapChainForTesting(index); |
1026 } | 1023 } |
1027 | 1024 |
1028 } // namespace gpu | 1025 } // namespace gpu |
OLD | NEW |