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

Side by Side Diff: gpu/ipc/service/direct_composition_surface_win.h

Issue 2926763002: Split DirectCompositionSurfaceWin into two parts. (Closed)
Patch Set: add disallow copy and assign Created 3 years, 6 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 unified diff | Download patch
OLDNEW
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 #ifndef GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_ 5 #ifndef GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_
6 #define GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_ 6 #define GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_
7 7
8 #include <d3d11.h> 8 #include <d3d11.h>
9 #include <dcomp.h> 9 #include <dcomp.h>
10 #include <windows.h> 10 #include <windows.h>
11 11
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/win/scoped_comptr.h" 13 #include "base/win/scoped_comptr.h"
14 #include "gpu/config/gpu_driver_bug_workarounds.h" 14 #include "gpu/config/gpu_driver_bug_workarounds.h"
15 #include "gpu/gpu_export.h" 15 #include "gpu/gpu_export.h"
16 #include "gpu/ipc/service/child_window_win.h" 16 #include "gpu/ipc/service/child_window_win.h"
17 #include "gpu/ipc/service/image_transport_surface_delegate.h" 17 #include "gpu/ipc/service/image_transport_surface_delegate.h"
18 #include "ui/gl/gl_image.h" 18 #include "ui/gl/gl_image.h"
19 #include "ui/gl/gl_surface_egl.h" 19 #include "ui/gl/gl_surface_egl.h"
20 20
21 namespace gpu { 21 namespace gpu {
22 22
23 class DCLayerTree; 23 class DCLayerTree;
24 class DirectCompositionChildSurfaceWin;
24 25
25 class GPU_EXPORT DirectCompositionSurfaceWin : public gl::GLSurfaceEGL { 26 class GPU_EXPORT DirectCompositionSurfaceWin : public gl::GLSurfaceEGL {
26 public: 27 public:
27 DirectCompositionSurfaceWin( 28 DirectCompositionSurfaceWin(
28 std::unique_ptr<gfx::VSyncProvider> vsync_provider, 29 std::unique_ptr<gfx::VSyncProvider> vsync_provider,
29 base::WeakPtr<ImageTransportSurfaceDelegate> delegate, 30 base::WeakPtr<ImageTransportSurfaceDelegate> delegate,
30 HWND parent_window); 31 HWND parent_window);
31 32
32 // Returns true if there's an output on the current adapter that can 33 // Returns true if there's an output on the current adapter that can
33 // use overlays. 34 // use overlays.
(...skipping 23 matching lines...) Expand all
57 gfx::Vector2d GetDrawOffset() const override; 58 gfx::Vector2d GetDrawOffset() const override;
58 void WaitForSnapshotRendering() override; 59 void WaitForSnapshotRendering() override;
59 60
60 // This schedules an overlay plane to be displayed on the next SwapBuffers 61 // This schedules an overlay plane to be displayed on the next SwapBuffers
61 // or PostSubBuffer call. Overlay planes must be scheduled before every swap 62 // or PostSubBuffer call. Overlay planes must be scheduled before every swap
62 // to remain in the layer tree. This surface's backbuffer doesn't have to be 63 // to remain in the layer tree. This surface's backbuffer doesn't have to be
63 // scheduled with ScheduleDCLayer, as it's automatically placed in the layer 64 // scheduled with ScheduleDCLayer, as it's automatically placed in the layer
64 // tree at z-order 0. 65 // tree at z-order 0.
65 bool ScheduleDCLayer(const ui::DCRendererLayerParams& params) override; 66 bool ScheduleDCLayer(const ui::DCRendererLayerParams& params) override;
66 67
67 const base::win::ScopedComPtr<IDCompositionSurface>& dcomp_surface() const { 68 const base::win::ScopedComPtr<IDCompositionSurface> dcomp_surface() const;
68 return dcomp_surface_; 69 const base::win::ScopedComPtr<IDXGISwapChain1> swap_chain() const;
69 }
70 70
71 scoped_refptr<base::TaskRunner> GetWindowTaskRunnerForTesting(); 71 scoped_refptr<base::TaskRunner> GetWindowTaskRunnerForTesting();
72 const base::win::ScopedComPtr<IDXGISwapChain1>& swap_chain() const {
73 return swap_chain_;
74 }
75 72
76 base::win::ScopedComPtr<IDXGISwapChain1> GetLayerSwapChainForTesting( 73 base::win::ScopedComPtr<IDXGISwapChain1> GetLayerSwapChainForTesting(
77 size_t index) const; 74 size_t index) const;
78 75
79 const GpuDriverBugWorkarounds& workarounds() const { return workarounds_; } 76 const GpuDriverBugWorkarounds& workarounds() const { return workarounds_; }
80 77
81 protected: 78 protected:
82 ~DirectCompositionSurfaceWin() override; 79 ~DirectCompositionSurfaceWin() override;
83 80
84 private: 81 private:
85 void ReleaseCurrentSurface(); 82 bool RecreateRootSurface();
86 void InitializeSurface();
87 // Release the texture that's currently being drawn to. If will_discard is
88 // true then the surface should be discarded without swapping any contents
89 // to it.
90 void ReleaseDrawTexture(bool will_discard);
91 83
92 ChildWindowWin child_window_; 84 ChildWindowWin child_window_;
93 85
94 GpuDriverBugWorkarounds workarounds_; 86 GpuDriverBugWorkarounds workarounds_;
95 87
96 HWND window_ = nullptr; 88 HWND window_ = nullptr;
97 // This is a placeholder surface used when not rendering to the 89 // This is a placeholder surface used when not rendering to the
98 // DirectComposition surface. 90 // DirectComposition surface.
99 EGLSurface default_surface_ = 0; 91 EGLSurface default_surface_ = 0;
100 92
101 // This is the real surface representing the backbuffer. It may be null
102 // outside of a BeginDraw/EndDraw pair.
103 EGLSurface real_surface_ = 0;
104 gfx::Size size_ = gfx::Size(1, 1); 93 gfx::Size size_ = gfx::Size(1, 1);
105 bool first_swap_ = true;
106 bool enable_dc_layers_ = false; 94 bool enable_dc_layers_ = false;
107 bool has_alpha_ = true; 95 bool has_alpha_ = true;
108 std::unique_ptr<gfx::VSyncProvider> vsync_provider_; 96 std::unique_ptr<gfx::VSyncProvider> vsync_provider_;
109 gfx::Rect swap_rect_; 97 scoped_refptr<DirectCompositionChildSurfaceWin> root_surface_;
110 std::unique_ptr<DCLayerTree> layer_tree_; 98 std::unique_ptr<DCLayerTree> layer_tree_;
111 gfx::Vector2d draw_offset_;
112 99
113 base::win::ScopedComPtr<ID3D11Device> d3d11_device_; 100 base::win::ScopedComPtr<ID3D11Device> d3d11_device_;
114 base::win::ScopedComPtr<IDCompositionDevice2> dcomp_device_; 101 base::win::ScopedComPtr<IDCompositionDevice2> dcomp_device_;
115 base::win::ScopedComPtr<IDCompositionSurface> dcomp_surface_;
116 base::win::ScopedComPtr<IDXGISwapChain1> swap_chain_;
117 base::win::ScopedComPtr<ID3D11Texture2D> draw_texture_;
118
119 // Keep track of whether the texture has been rendered to, as the first draw
120 // to it must overwrite the entire thing.
121 bool has_been_rendered_to_ = false;
122 102
123 DISALLOW_COPY_AND_ASSIGN(DirectCompositionSurfaceWin); 103 DISALLOW_COPY_AND_ASSIGN(DirectCompositionSurfaceWin);
124 }; 104 };
125 105
126 } // namespace gpu 106 } // namespace gpu
127 107
128 #endif // GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_ 108 #endif // GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_
OLDNEW
« no previous file with comments | « gpu/ipc/service/direct_composition_child_surface_win.cc ('k') | gpu/ipc/service/direct_composition_surface_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698